├── Base
├── Attributes
│ ├── BitmapOptionsAttribute.cs
│ ├── ComboBoxOptionsAttribute.cs
│ ├── ControlAttributionAttribute.cs
│ ├── ControlOptionsAttribute.cs
│ ├── ControlTagAttribute.cs
│ ├── DependentOnAttribute.cs
│ ├── HelpAttribute.cs
│ ├── IgnoreBindingAttribute.cs
│ ├── MessageAttribute.cs
│ ├── NumberBoxOptionsAttribute.cs
│ ├── OptionBoxAttribute.cs
│ ├── OptionBoxOptionsAttribute.cs
│ ├── PageOptionsAttribute.cs
│ ├── SelectionBoxAttribute.cs
│ ├── SelectionBoxOptionsAttribute.cs
│ ├── TabAttribute.cs
│ └── TextBoxOptionsAttribute.cs
├── Base.csproj
├── Base.nuspec
├── Base
│ ├── ClosingArg.cs
│ ├── DependencyHandler.cs
│ ├── IPageSpec.cs
│ ├── IPropertyManagerPageEx.cs
│ ├── IPropertyManagerPageHandlerEx.cs
│ ├── ISelectionCustomFilter.cs
│ ├── PropertyManagerPageClosedDelegate.cs
│ └── PropertyManagerPageClosingDelegate.cs
├── Constructors
│ ├── PropertyManagerPageBitmapConstructor.cs
│ ├── PropertyManagerPageButtonConstructor.cs
│ ├── PropertyManagerPageCheckBoxConstructor.cs
│ ├── PropertyManagerPageComboBoxConstructor.cs
│ ├── PropertyManagerPageConstructor.cs
│ ├── PropertyManagerPageControlConstructor.cs
│ ├── PropertyManagerPageGroupConstructor.cs
│ ├── PropertyManagerPageNumberBoxConstructor.cs
│ ├── PropertyManagerPageOptionBoxConstructor.cs
│ ├── PropertyManagerPageSelectionBoxConstructor.cs
│ ├── PropertyManagerPageTabConstructor.cs
│ └── PropertyManagerPageTextBoxConstructor.cs
├── Controls
│ ├── PropertyManagerPageBitmapEx.cs
│ ├── PropertyManagerPageButtonEx.cs
│ ├── PropertyManagerPageCheckBoxEx.cs
│ ├── PropertyManagerPageComboBoxEx.cs
│ ├── PropertyManagerPageControlEx.cs
│ ├── PropertyManagerPageElementEx.cs
│ ├── PropertyManagerPageGroupBaseEx.cs
│ ├── PropertyManagerPageGroupEx.cs
│ ├── PropertyManagerPageNumberBoxEx.cs
│ ├── PropertyManagerPageOptionBoxEx.cs
│ ├── PropertyManagerPagePageEx.cs
│ ├── PropertyManagerPageSelectionBoxEx.cs
│ ├── PropertyManagerPageTabEx.cs
│ └── PropertyManagerPageTextBoxEx.cs
├── Data
│ ├── ControlIcon.cs
│ ├── PageSpec.cs
│ ├── TabIcon.cs
│ └── TitleIcon.cs
├── Helper.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── PropertyManagerPageBuilder.cs
├── PropertyManagerPageEx.cs
├── PropertyManagerPageHandlerEx.cs
├── Resources
│ └── DefaultBitmap.png
├── packages.config
└── readme.txt
├── HelpDoc
├── Common.tokens
├── Content
│ ├── VersionHistory
│ │ ├── VersionHistory.aml
│ │ ├── v0.1.0.aml
│ │ ├── v0.2.0.aml
│ │ ├── v0.4.0.aml
│ │ ├── v0.4.5.aml
│ │ ├── v0.5.0.aml
│ │ ├── v0.6.0.aml
│ │ ├── v0.7.0.aml
│ │ ├── v0.7.1.aml
│ │ └── v0.7.2.aml
│ └── Welcome.aml
├── ContentLayout.content
├── HelpDoc.shfbproj
└── icons
│ ├── Help.png
│ └── favicon.ico
├── LICENSE
├── README.md
├── Samples
└── AddIn
│ ├── AddIn.csproj
│ ├── DataModel.cs
│ ├── Icons
│ ├── IconLarge.bmp
│ └── IconSmall.bmp
│ ├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ └── Resources.resx
│ ├── PropertyPageEventsHandler.cs
│ ├── Resources
│ ├── button-icon.png
│ └── shield-icon.png
│ ├── SwAddin.cs
│ ├── TabDataModel.cs
│ ├── packages.config
│ └── thirdpty
│ └── SolidWorksTools.dll
├── favicon.ico
├── swex-pmpage-docs.sln
└── swex-pmpage.sln
/Base/Attributes/BitmapOptionsAttribute.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using SolidWorks.Interop.swconst;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Drawing;
12 | using System.Linq;
13 | using System.Text;
14 | using Xarial.VPages.Framework.Base;
15 |
16 | namespace CodeStack.SwEx.PMPage.Attributes
17 | {
18 | ///
19 | /// Additional options for bitmap control
20 | ///
21 | /// Applied to property of type
22 | public class BitmapOptionsAttribute : Attribute, IAttribute
23 | {
24 | internal Size Size { get; private set; }
25 |
26 | ///
27 | /// Constructor for bitmap options
28 | ///
29 | /// Width of the bitmap
30 | /// Height of the bitmap
31 | public BitmapOptionsAttribute(int width, int height)
32 | {
33 | Size = new Size(width, height);
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Base/Attributes/ComboBoxOptionsAttribute.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using SolidWorks.Interop.swconst;
9 | using System;
10 | using Xarial.VPages.Framework.Base;
11 |
12 | namespace CodeStack.SwEx.PMPage.Attributes
13 | {
14 | ///
15 | /// Provides additional options for the drop-down list box
16 | ///
17 | /// Must be applied to the property of
18 | public class ComboBoxOptionsAttribute : Attribute, IAttribute
19 | {
20 | internal swPropMgrPageComboBoxStyle_e Style { get; private set; }
21 |
22 | ///
23 | /// Constructor for specifying style of combo box
24 | ///
25 | /// Specific style applied for combo box control.
26 | /// Refer swPropMgrPageComboBoxStyle_e Enumeration for more information.
27 | /// Use 0 for default style
28 | public ComboBoxOptionsAttribute(swPropMgrPageComboBoxStyle_e style = 0)
29 | {
30 | Style = style;
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Base/Attributes/ControlAttributionAttribute.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using CodeStack.SwEx.Common.Reflection;
9 | using CodeStack.SwEx.PMPage.Data;
10 | using SolidWorks.Interop.swconst;
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Drawing;
14 | using System.Linq;
15 | using System.Text;
16 | using Xarial.VPages.Framework.Base;
17 |
18 | namespace CodeStack.SwEx.PMPage.Attributes
19 | {
20 | ///
21 | /// Provides additional attribution options (i.e. icons, labels, tooltips etc.) for all controls
22 | ///
23 | /// Can be applied to any property which is bound to the property manager page control
24 | public class ControlAttributionAttribute : Attribute, IAttribute
25 | {
26 | internal swControlBitmapLabelType_e StandardIcon { get; private set; } = 0;
27 |
28 | internal ControlIcon Icon { get; private set; }
29 |
30 | /// Constructor allowing specify the standard icon
31 | /// Control label as defined in swControlBitmapLabelType_e Enumeration
32 | public ControlAttributionAttribute(swControlBitmapLabelType_e standardIcon)
33 | {
34 | StandardIcon = standardIcon;
35 | }
36 |
37 | ///
38 | /// Constructor allowing to specify custom icon from the resources
39 | ///
40 | /// resType
41 | /// Image resource name referencing the icon
42 | public ControlAttributionAttribute(Type resType, string iconResName)
43 | {
44 | Icon = new ControlIcon(ResourceHelper.GetResource(resType, iconResName));
45 | }
46 |
47 | ///
48 | /// Image resource name referencing the icon mask
49 | public ControlAttributionAttribute(Type resType, string iconResName, string maskResName)
50 | {
51 | Icon = new ControlIcon(
52 | ResourceHelper.GetResource(resType, iconResName),
53 | ResourceHelper.GetResource(resType, maskResName));
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/Base/Attributes/ControlOptionsAttribute.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using SolidWorks.Interop.swconst;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Drawing;
12 | using System.Linq;
13 | using System.Text;
14 | using Xarial.VPages.Framework.Base;
15 |
16 | namespace CodeStack.SwEx.PMPage.Attributes
17 | {
18 | ///
19 | /// Generic options for all controls
20 | ///
21 | public class ControlOptionsAttribute : Attribute, IAttribute
22 | {
23 | internal swAddControlOptions_e Options { get; private set; }
24 | internal swPropertyManagerPageControlLeftAlign_e Align { get; private set; }
25 | internal KnownColor BackgroundColor { get; private set; }
26 | internal KnownColor TextColor { get; private set; }
27 | internal short Left { get; private set; }
28 | internal short Top { get; private set; }
29 | internal short Width { get; private set; }
30 | internal short Height { get; private set; }
31 | internal swPropMgrPageControlOnResizeOptions_e ResizeOptions { get; private set; }
32 |
33 | ///
34 | /// Constructor allowing to specify control common parameters
35 | ///
36 | /// Generic control options as defined in swAddControlOptions_e Enumeration
37 | /// Control alignment options as defined in swPropertyManagerPageControlLeftAlign_e Enumeration
38 | /// Background color of control. Use 0 for default color
39 | /// Color of the text on the control. Use 0 for default color
40 | /// Left alignment of the control. Use -1 for default alignment
41 | /// Top alignment of the control. Use -1 to align the control under the previous control
42 | /// Width of the control. Use -1 for auto width
43 | /// Height of the control in property manager page dialog box units. Use -1 for the auto height
44 | /// Options to resize as defined in swPropMgrPageControlOnResizeOptions_e Enumeration
45 | public ControlOptionsAttribute(
46 | swAddControlOptions_e opts = swAddControlOptions_e.swControlOptions_Enabled | swAddControlOptions_e.swControlOptions_Visible,
47 | swPropertyManagerPageControlLeftAlign_e align = swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge,
48 | KnownColor backgroundColor = 0, KnownColor textColor = 0, short left = -1, short top = -1, short width = -1, short height = -1,
49 | swPropMgrPageControlOnResizeOptions_e resizeOptions = 0)
50 | {
51 | Options = opts;
52 | Align = align;
53 | BackgroundColor = backgroundColor;
54 | TextColor = textColor;
55 | Left = left;
56 | Top = top;
57 | Width = width;
58 | Height = height;
59 | ResizeOptions = resizeOptions;
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Base/Attributes/ControlTagAttribute.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using System;
9 | using System.Collections.Generic;
10 | using System.Linq;
11 | using System.Text;
12 |
13 | namespace CodeStack.SwEx.PMPage.Attributes
14 | {
15 | ///
16 | /// Adds the tag associated with control created for the specified model property
17 | ///
18 | /// This attribute is used together with to mark the dependencies
19 | public class ControlTagAttribute : Xarial.VPages.Framework.Attributes.ControlTagAttribute
20 | {
21 | /// Tag which should be associated with the control created for this property.
22 | /// It is recommended to use enumerator or string as a tag
23 | public ControlTagAttribute(object tag) : base(tag)
24 | {
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Base/Attributes/DependentOnAttribute.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using CodeStack.SwEx.PMPage.Base;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 |
14 | namespace CodeStack.SwEx.PMPage.Attributes
15 | {
16 | ///
17 | /// Allows to enable dependency of the control from another controls
18 | ///
19 | public class DependentOnAttribute : Xarial.VPages.Framework.Attributes.DependentOnAttribute
20 | {
21 | /// Assigns the dependency based on a handler for the specified dependencies
22 | /// Dependency handler of type
23 | /// List of tags of dependent controls. Use to tag the controls
24 | public DependentOnAttribute(Type dependencyHandler, params object[] dependencies)
25 | : base(dependencyHandler, dependencies)
26 | {
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/Base/Attributes/HelpAttribute.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using System;
9 | using System.Collections.Generic;
10 | using System.Linq;
11 | using System.Text;
12 | using Xarial.VPages.Framework.Base;
13 |
14 | namespace CodeStack.SwEx.PMPage.Attributes
15 | {
16 | ///
17 | /// Provides the additional help links for the page
18 | ///
19 | /// Applied to the model class
20 | public class HelpAttribute : Attribute, IAttribute
21 | {
22 | internal string HelpLink { get; private set; }
23 | internal string WhatsNewLink { get; private set; }
24 |
25 | ///
26 | /// Constructor for specifying links to help resources
27 | ///
28 | /// Link to help documentation
29 | /// Link to what's new page
30 | public HelpAttribute(string helpLink, string whatsNewLink = "")
31 | {
32 | HelpLink = helpLink;
33 | WhatsNewLink = whatsNewLink;
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Base/Attributes/IgnoreBindingAttribute.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using System;
9 | using System.Collections.Generic;
10 | using System.Linq;
11 | using System.Text;
12 |
13 | namespace CodeStack.SwEx.PMPage.Attributes
14 | {
15 | ///
16 | /// Indicates that current property should be ignored for binding
17 | /// and control should not be created
18 | ///
19 | public class IgnoreBindingAttribute : Xarial.VPages.Framework.Attributes.IgnoreBindingAttribute
20 | {
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Base/Attributes/MessageAttribute.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using SolidWorks.Interop.swconst;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 | using Xarial.VPages.Framework.Base;
14 |
15 | namespace CodeStack.SwEx.PMPage.Attributes
16 | {
17 | ///
18 | /// Attributes allows to specify the message to be displayed in the property manager page
19 | ///
20 | [AttributeUsage(AttributeTargets.Class)]
21 | public class MessageAttribute : Attribute, IAttribute
22 | {
23 | internal string Text { get; private set; }
24 | internal swPropertyManagerPageMessageVisibility Visibility { get; private set; }
25 | internal swPropertyManagerPageMessageExpanded Expanded { get; private set; }
26 | internal string Caption { get; private set; }
27 |
28 | ///
29 | /// Constructor to specify message and its parameters
30 | ///
31 | /// Text to be displayed in the message
32 | /// Message box caption
33 | /// Visibility option as defined in swPropertyManagerPageMessageVisibility Enumeration
34 | /// Expansion state as defined in swPropertyManagerPageMessageExpanded Enumeration
35 | public MessageAttribute(string text, string caption,
36 | swPropertyManagerPageMessageVisibility visibility = swPropertyManagerPageMessageVisibility.swMessageBoxVisible,
37 | swPropertyManagerPageMessageExpanded expanded = swPropertyManagerPageMessageExpanded.swMessageBoxExpand)
38 | {
39 | Text = text;
40 | Caption = caption;
41 | Visibility = visibility;
42 | Expanded = expanded;
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/Base/Attributes/NumberBoxOptionsAttribute.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using SolidWorks.Interop.swconst;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 | using Xarial.VPages.Framework.Base;
14 |
15 | namespace CodeStack.SwEx.PMPage.Attributes
16 | {
17 | ///
18 | /// Provides additional options for number box control
19 | ///
20 | /// Applied to all numeric properties (i.e. , )
21 | public class NumberBoxOptionsAttribute : Attribute, IAttribute
22 | {
23 | internal swPropMgrPageNumberBoxStyle_e Style { get; private set; }
24 | internal swNumberboxUnitType_e Units { get; private set; } = 0;
25 | internal double Minimum { get; private set; }
26 | internal double Maximum { get; private set; }
27 | internal double Increment { get; private set; }
28 | internal double FastIncrement { get; private set; }
29 | internal double SlowIncrement { get; private set; }
30 | internal bool Inclusive { get; private set; }
31 |
32 | ///
33 | /// Constructor for specifying number box options
34 | ///
35 | /// Number box style as defined in swPropMgrPageNumberBoxStyle_e Enumeration0 for default style
36 | public NumberBoxOptionsAttribute(swPropMgrPageNumberBoxStyle_e style = 0)
37 | : this(0, 0, 100, 5, true, 10, 1, style)
38 | {
39 | }
40 |
41 |
42 | ///
43 | /// Number box units as defined in swNumberboxUnitType_e Enumeration
44 | /// 0 for not using units. If units are specified corresponding current user unit system
45 | /// will be used and the corresponding units marks will be displayed in the number box.
46 | /// Regardless of the current unit system the value will be stored in system units (MKS)
47 | ///
48 | /// Minimum allowed value for the number box
49 | /// Maximum allowed value for the number box
50 | /// Default increment when up or down increment button is clicked
51 | /// True sets the minimum-maximum as inclusive, false sets it as exclusive
52 | /// Fast increment for mouse wheel or scroll
53 | /// Slow increment for mouse wheel or scroll
54 | public NumberBoxOptionsAttribute(swNumberboxUnitType_e units,
55 | double minimum, double maximum, double increment, bool inclusive,
56 | double fastIncrement, double slowIncrement,
57 | swPropMgrPageNumberBoxStyle_e style = 0)
58 | {
59 | Units = units;
60 | Minimum = minimum;
61 | Maximum = maximum;
62 | Increment = increment;
63 | Inclusive = inclusive;
64 | FastIncrement = fastIncrement;
65 | SlowIncrement = slowIncrement;
66 | Style = style;
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/Base/Attributes/OptionBoxAttribute.cs:
--------------------------------------------------------------------------------
1 | using CodeStack.SwEx.PMPage.Constructors;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using Xarial.VPages.Framework.Attributes;
7 |
8 | namespace CodeStack.SwEx.PMPage.Attributes
9 | {
10 | ///
11 | /// Attribute indicates that current property should be rendered as option box
12 | ///
13 | /// This attribute is only applicable for enum types
14 | public class OptionBoxAttribute : SpecificConstructorAttribute
15 | {
16 | ///
17 | /// Sets the current property as option box
18 | ///
19 | public OptionBoxAttribute() : base(typeof(IPropertyManagerPageOptionBoxConstructor))
20 | {
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Base/Attributes/OptionBoxOptionsAttribute.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using SolidWorks.Interop.swconst;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Drawing;
12 | using System.Linq;
13 | using System.Text;
14 | using Xarial.VPages.Framework.Base;
15 |
16 | namespace CodeStack.SwEx.PMPage.Attributes
17 | {
18 | ///
19 | /// Additional options for option box control
20 | ///
21 | public class OptionBoxOptionsAttribute : Attribute, IAttribute
22 | {
23 | internal swPropMgrPageOptionStyle_e Style { get; private set; }
24 |
25 | ///
26 | /// Assigns additional options (such as style) for this option box control
27 | ///
28 | ///
29 | public OptionBoxOptionsAttribute(
30 | swPropMgrPageOptionStyle_e style = 0)
31 | {
32 | Style = style;
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Base/Attributes/PageOptionsAttribute.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using CodeStack.SwEx.Common.Reflection;
9 | using CodeStack.SwEx.PMPage.Data;
10 | using SolidWorks.Interop.swconst;
11 | using System;
12 | using System.Collections.Generic;
13 | using System.Drawing;
14 | using System.Linq;
15 | using System.Text;
16 | using Xarial.VPages.Framework.Base;
17 |
18 | namespace CodeStack.SwEx.PMPage.Attributes
19 | {
20 | ///
21 | /// Property manager page options
22 | ///
23 | /// Applied to the main class of the data model
24 | public class PageOptionsAttribute : Attribute, IAttribute
25 | {
26 | internal swPropertyManagerPageOptions_e Options { get; private set; }
27 |
28 | internal TitleIcon Icon { get; private set; }
29 |
30 | /// Constructor for specifying property manager page options
31 | /// property page options as defined in swPropertyManagerPageOptions_e Enumeration
32 | public PageOptionsAttribute(swPropertyManagerPageOptions_e opts)
33 | {
34 | Options = opts;
35 | }
36 |
37 | ///
38 | /// resType
39 | /// Name of image resource for property manager page icon
40 | public PageOptionsAttribute(Type resType, string iconResName,
41 | swPropertyManagerPageOptions_e opts = swPropertyManagerPageOptions_e.swPropertyManagerOptions_OkayButton | swPropertyManagerPageOptions_e.swPropertyManagerOptions_CancelButton)
42 | : this(new TitleIcon(ResourceHelper.GetResource(resType, iconResName)), opts)
43 | {
44 | }
45 |
46 | internal PageOptionsAttribute(TitleIcon icon, swPropertyManagerPageOptions_e opts) : this(opts)
47 | {
48 | Icon = icon;
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/Base/Attributes/SelectionBoxAttribute.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using CodeStack.SwEx.PMPage.Constructors;
9 | using SolidWorks.Interop.swconst;
10 | using SolidWorks.Interop.sldworks;
11 | using Xarial.VPages.Framework.Attributes;
12 | using System.Collections.Generic;
13 | using System;
14 | using CodeStack.SwEx.PMPage.Base;
15 |
16 | namespace CodeStack.SwEx.PMPage.Attributes
17 | {
18 | ///
19 | /// Sets the current control to be a selection box
20 | ///
21 | /// This attribute is applicable for properties of type or
22 | /// specific SOLIDWORKS type (e.g. , , etc.
23 | /// In this case the selection box will allow single entity selection only.
24 | /// are also supported. In this case multiple entities can be selected
25 | public class SelectionBoxAttribute : SpecificConstructorAttribute
26 | {
27 | internal swSelectType_e[] Filters { get; private set;}
28 | internal int SelectionMark { get; private set; }
29 | internal Type CustomFilter { get; private set; }
30 |
31 | ///
32 | /// Constructor for selection box options
33 | ///
34 | /// Filters allowed for selection into this selection box
35 | public SelectionBoxAttribute(params swSelectType_e[] filters)
36 | : this(-1, filters)
37 | {
38 | }
39 |
40 | ///
41 | /// Selection mark. If multiple selections box are used - use different selection marks for each of them
42 | /// to differentiate the selections
43 | public SelectionBoxAttribute(int mark, params swSelectType_e[] filters)
44 | : this(mark, null, filters)
45 | {
46 | }
47 |
48 | ///
49 | public SelectionBoxAttribute(Type customFilter, params swSelectType_e[] filters)
50 | : this(-1, customFilter, filters)
51 | {
52 | }
53 |
54 | ///
55 | /// Type of custom filter of for custom logic for filtering selection objects
56 | ///
57 | public SelectionBoxAttribute(int mark, Type customFilter, params swSelectType_e[] filters)
58 | : base(typeof(IPropertyManagerPageSelectionBoxConstructor))
59 | {
60 | Filters = filters;
61 | SelectionMark = mark;
62 |
63 | if (customFilter != null)
64 | {
65 | if (!typeof(ISelectionCustomFilter).IsAssignableFrom(customFilter))
66 | {
67 | throw new InvalidCastException($"{customFilter.FullName} doesn't implement {typeof(ISelectionCustomFilter).FullName}");
68 | }
69 |
70 | CustomFilter = customFilter;
71 | }
72 | }
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/Base/Attributes/SelectionBoxOptionsAttribute.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using SolidWorks.Interop.swconst;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Drawing;
12 | using System.Linq;
13 | using System.Text;
14 | using Xarial.VPages.Framework.Base;
15 |
16 | namespace CodeStack.SwEx.PMPage.Attributes
17 | {
18 | ///
19 | /// Additional options for selection box control
20 | ///
21 | public class SelectionBoxOptionsAttribute : Attribute, IAttribute
22 | {
23 | internal swPropMgrPageSelectionBoxStyle_e Style { get; private set; }
24 | internal KnownColor SelectionColor { get; private set; }
25 |
26 | ///
27 | /// Constructor for selection box options
28 | ///
29 | /// Selection box style as defined in swPropMgrPageSelectionBoxStyle_e Enumeration
30 | /// Color of the selections in this selection box
31 | public SelectionBoxOptionsAttribute(
32 | swPropMgrPageSelectionBoxStyle_e style = 0,
33 | KnownColor selColor = 0)
34 | {
35 | Style = style;
36 | SelectionColor = selColor;
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Base/Attributes/TabAttribute.cs:
--------------------------------------------------------------------------------
1 | using CodeStack.SwEx.PMPage.Constructors;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using Xarial.VPages.Framework.Attributes;
7 |
8 | namespace CodeStack.SwEx.PMPage.Attributes
9 | {
10 | ///
11 | /// Attribute indicates that current property or class should be rendered as tab box
12 | ///
13 | /// This attribute is only applicable for complex types which contain nested properties
14 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property)]
15 | public class TabAttribute : SpecificConstructorAttribute
16 | {
17 | ///
18 | /// Sets the current property as tab container
19 | ///
20 | public TabAttribute() : base(typeof(IPropertyManagerPageTabConstructor))
21 | {
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Base/Attributes/TextBoxOptionsAttribute.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using SolidWorks.Interop.swconst;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 | using Xarial.VPages.Framework.Base;
14 |
15 | namespace CodeStack.SwEx.PMPage.Attributes
16 | {
17 | ///
18 | /// Additional options for text box control
19 | ///
20 | /// Applied to property of type
21 | public class TextBoxOptionsAttribute : Attribute, IAttribute
22 | {
23 | internal swPropMgrPageTextBoxStyle_e Style { get; private set; }
24 |
25 | ///
26 | /// Constructor for text box options
27 | ///
28 | /// Text box control style as defined in swPropMgrPageTextBoxStyle_e Enumeration
29 | public TextBoxOptionsAttribute(swPropMgrPageTextBoxStyle_e style = 0)
30 | {
31 | Style = style;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Base/Base.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | CodeStack.SwEx.PMPage
5 | 0.7.2.0
6 | Framework for developing property manager pages in SOLIDWORKS
7 | CodeStack
8 | CodeStack
9 | https://github.com/codestackdev/vpages-sw/blob/master/LICENSE
10 | https://www.codestack.net/labs/solidworks/swex/pmpage
11 | https://www.codestack.net/labs/solidworks/swex/pmpage/logo.png
12 | false
13 | Data driven SOLIDWORKS property manager pages based on vPages framework
14 |
15 | Copyright © CodeStack 2019
16 | Pages PMP SOLIDWORKS Property Manager Page
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Base/Base/ClosingArg.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using System;
9 | using System.Collections.Generic;
10 | using System.Linq;
11 | using System.Text;
12 |
13 | namespace CodeStack.SwEx.PMPage.Base
14 | {
15 | ///
16 | /// Represents the parameter of notification
17 | ///
18 | /// If parameter is set to true and
19 | /// and are not empty. Framework will display the error popup box
20 | /// next to the property manager page
21 | public class ClosingArg
22 | {
23 | ///
24 | /// True to cancel the closing of property manager page
25 | ///
26 | public bool Cancel { get; set; }
27 |
28 | ///
29 | /// Title of the error to be displayed to the user or empty string if no error to be displayed
30 | ///
31 | public string ErrorTitle { get; set; }
32 |
33 | ///
34 | /// Message of the error to be displayed to the user or empty string if no error to be displayed
35 | ///
36 | public string ErrorMessage { get; set; }
37 |
38 | internal ClosingArg()
39 | {
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Base/Base/DependencyHandler.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using CodeStack.SwEx.PMPage.Attributes;
9 | using CodeStack.SwEx.PMPage.Controls;
10 | using System;
11 | using System.Collections.Generic;
12 | using System.ComponentModel;
13 | using System.Linq;
14 | using System.Text;
15 | using Xarial.VPages.Framework.Base;
16 |
17 | namespace CodeStack.SwEx.PMPage.Base
18 | {
19 | ///
20 | /// Handler for the control dependencies marked with
21 | ///
22 | /// This handler should be used if it is required to change the state of controls
23 | /// depending on the states/values of other controls.
24 | /// For example one control should be disabled if check box is checked
25 | public abstract class DependencyHandler : IDependencyHandler
26 | {
27 | [Browsable(false)]
28 | [EditorBrowsable(EditorBrowsableState.Never)]
29 | public void UpdateState(IBinding binding, IBinding[] dependencies)
30 | {
31 | if (binding.Control is IPropertyManagerPageElementEx)
32 | {
33 | var ctrl = binding.Control as IPropertyManagerPageElementEx;
34 |
35 | var deps = dependencies.Select(d =>
36 | {
37 | if (d.Control is IPropertyManagerPageElementEx)
38 | {
39 | return d.Control as IPropertyManagerPageElementEx;
40 | }
41 | else
42 | {
43 | ThrowInvalidControlException();
44 | return null;
45 | }
46 | }).ToArray();
47 |
48 | UpdateControlState(ctrl, deps);
49 | }
50 | else
51 | {
52 | ThrowInvalidControlException();
53 | return;
54 | }
55 | }
56 |
57 | [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
58 | [Obsolete("This method has been deprecated and replaced with UpdateControlState(IPropertyManagerPageElementEx, IPropertyManagerPageElementEx[])")]
59 | protected virtual void UpdateControlState(IPropertyManagerPageControlEx control,
60 | IPropertyManagerPageControlEx[] parents)
61 | {
62 | }
63 |
64 | ///
65 | /// Called when the control state needs to be updated (i.e. one of the parent dependency controls has changed its value)
66 | ///
67 | /// This is a source control decorated with
68 | /// Dependency controls. These are the controls passed as the parameter to
69 | protected virtual void UpdateControlState(IPropertyManagerPageElementEx control,
70 | IPropertyManagerPageElementEx[] parents)
71 | {
72 | //TODO: remove the obsolete method
73 | #pragma warning disable CS0618
74 | UpdateControlState((IPropertyManagerPageControlEx)control, parents.Cast().ToArray());
75 | #pragma warning restore
76 | }
77 |
78 | private void ThrowInvalidControlException()
79 | {
80 | throw new InvalidCastException(
81 | $"Bound control is not of type {typeof(IPropertyManagerPageElementEx)}");
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/Base/Base/IPageSpec.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using CodeStack.SwEx.PMPage.Data;
9 | using SolidWorks.Interop.swconst;
10 | using System;
11 | using System.Collections.Generic;
12 | using System.ComponentModel;
13 | using System.Drawing;
14 | using System.Linq;
15 | using System.Text;
16 |
17 | namespace CodeStack.SwEx.PMPage.Base
18 | {
19 | [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
20 | public interface IPageSpec
21 | {
22 | string Title { get; }
23 | Image Icon { get; }
24 | swPropertyManagerPageOptions_e Options { get; }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Base/Base/IPropertyManagerPageEx.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using CodeStack.SwEx.PMPage.Attributes;
9 | using CodeStack.SwEx.PMPage.Controls;
10 | using System;
11 | using System.Collections.Generic;
12 | using System.ComponentModel;
13 | using System.Linq;
14 | using System.Text;
15 | using Xarial.VPages.Framework.Base;
16 |
17 | namespace CodeStack.SwEx.PMPage.Base
18 | {
19 | ///
20 | /// Represents the wrapper for the property manager page which builds the user interface
21 | /// based on the provided data model
22 | ///
23 | /// Handler of the property manager page which provides an access to additional properties and events related to user interface.
24 | /// Must be com visible
25 | /// Type used both as the design layout and data model
26 | /// The pointer to this page must be stored on a class level to avoid garbage collection
27 | [Browsable(false)]
28 | [EditorBrowsable(EditorBrowsableState.Never)]
29 | public interface IPropertyManagerPageEx
30 | where THandler : PropertyManagerPageHandlerEx, new()
31 | {
32 | ///
33 | /// Pointer to the current instance of the model
34 | ///
35 | TModel Model { get; }
36 |
37 | ///
38 | /// Pointer to the handler
39 | ///
40 | THandler Handler { get; }
41 |
42 | ///
43 | /// List of all controls created in the property manager page
44 | ///
45 | /// Tag data model fields with
46 | /// and use property to find the corresponding controls created for the data fields
47 | IEnumerable Controls { get; }
48 |
49 | ///
50 | /// Display property manager page modeless
51 | ///
52 | /// Data model to create property manager page for
53 | /// Control is returned immediately after calling the method.
54 | /// Use event to receive a notification when this property manager page is closed
55 | void Show(TModel model);
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Base/Base/IPropertyManagerPageHandlerEx.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using SolidWorks.Interop.swconst;
9 | using SolidWorks.Interop.swpublished;
10 | using System;
11 | using System.Collections.Generic;
12 | using System.ComponentModel;
13 | using System.Linq;
14 | using System.Text;
15 |
16 | namespace CodeStack.SwEx.PMPage.Base
17 | {
18 | ///
19 | /// Provides additional user interface related handlers and options
20 | ///
21 | [Browsable(false)]
22 | [EditorBrowsable(EditorBrowsableState.Never)]
23 | public interface IPropertyManagerPageHandlerEx
24 | {
25 | ///
26 | /// Fired when the data is changed (i.e. text box changed, combobox selection changed etc.)
27 | ///
28 | event Action DataChanged;
29 |
30 | ///
31 | /// Fired when property page is about to be closed. Use the argument to provide additional instructions
32 | ///
33 | event PropertyManagerPageClosingDelegate Closing;
34 |
35 | ///
36 | /// Fired when property manager page is closed
37 | ///
38 | event PropertyManagerPageClosedDelegate Closed;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Base/Base/ISelectionCustomFilter.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using CodeStack.SwEx.PMPage.Attributes;
9 | using CodeStack.SwEx.PMPage.Controls;
10 | using SolidWorks.Interop.swconst;
11 | using System;
12 | using System.Collections.Generic;
13 | using System.ComponentModel;
14 | using System.Linq;
15 | using System.Text;
16 |
17 | namespace CodeStack.SwEx.PMPage.Base
18 | {
19 | [Browsable(false)]
20 | [EditorBrowsable(EditorBrowsableState.Never)]
21 | internal interface ISelectionCustomFilter
22 | {
23 | [Browsable(false)]
24 | [EditorBrowsable(EditorBrowsableState.Never)]
25 | bool Filter(IPropertyManagerPageControlEx selBox, object selection, swSelectType_e selType, ref string itemText);
26 | }
27 |
28 | ///
29 | /// Custom filter to be used in which allows providing a
30 | /// custom logic to filter the selections in the selection box
31 | ///
32 | /// Type of selection or
33 | /// Use this method if object needs to be filtered by additional parameters (not just by type).
34 | /// For example only planar faces can be selected or only part components can be selected in the assembly
35 | public class SelectionCustomFilter : ISelectionCustomFilter
36 | {
37 | [Browsable(false)]
38 | [EditorBrowsable(EditorBrowsableState.Never)]
39 | bool ISelectionCustomFilter.Filter(IPropertyManagerPageControlEx selBox, object selection,
40 | swSelectType_e selType, ref string itemText)
41 | {
42 | if (selection is TSelection)
43 | {
44 | return Filter(selBox, (TSelection)selection, selType, ref itemText);
45 | }
46 | else
47 | {
48 | throw new InvalidCastException($"Selection type of {selBox.Id} doesn't match the '{typeof(TSelection)}' type");
49 | }
50 | }
51 |
52 | /// />
53 | /// Pointer to the selection box control
54 | /// Type of the selecting object as defined in swSelectType_e Enumeration
55 | /// Text to be displayed in the selection box
56 | protected virtual bool Filter(IPropertyManagerPageControlEx selBox, TSelection selection,
57 | swSelectType_e selType, ref string itemText)
58 | {
59 | return Filter(selection);
60 | }
61 |
62 | ///
63 | /// Filters if selection should be added to the selection box
64 | ///
65 | /// Pointer to SOLIDWORKS object which is about to be selected
66 | /// True to add the selection to selection box, false to ignore the selection
67 | protected virtual bool Filter(TSelection selection)
68 | {
69 | return true;
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/Base/Base/PropertyManagerPageClosedDelegate.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using SolidWorks.Interop.swconst;
9 |
10 | namespace CodeStack.SwEx.PMPage.Base
11 | {
12 | ///
13 | /// Delegate for handling the parameters of property manager page closed event
14 | ///
15 | /// Reason of closing as defined in swPropertyManagerPageCloseReasons_e Enumeration
16 | public delegate void PropertyManagerPageClosedDelegate(swPropertyManagerPageCloseReasons_e reason);
17 | }
18 |
--------------------------------------------------------------------------------
/Base/Base/PropertyManagerPageClosingDelegate.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using SolidWorks.Interop.swconst;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 |
14 | namespace CodeStack.SwEx.PMPage.Base
15 | {
16 | ///
17 | /// Delegate for handling the parameters of property manager page closing event
18 | ///
19 | /// Reason of closing as defined in swPropertyManagerPageCloseReasons_e Enumeration
20 | /// Closing argument. Use this argument to cancel closing if needed
21 | public delegate void PropertyManagerPageClosingDelegate(swPropertyManagerPageCloseReasons_e reason, ClosingArg arg);
22 | }
23 |
--------------------------------------------------------------------------------
/Base/Constructors/PropertyManagerPageBitmapConstructor.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using CodeStack.SwEx.PMPage.Controls;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 | using Xarial.VPages.Framework.Attributes;
14 | using Xarial.VPages.Framework.Constructors;
15 | using Xarial.VPages.Framework.Base;
16 | using SolidWorks.Interop.swconst;
17 | using CodeStack.SwEx.PMPage.Attributes;
18 | using System.Drawing;
19 | using SolidWorks.Interop.sldworks;
20 | using CodeStack.SwEx.Common.Icons;
21 |
22 | namespace CodeStack.SwEx.PMPage.Constructors
23 | {
24 | [DefaultType(typeof(Image))]
25 | internal class PropertyManagerPageBitmapConstructor
26 | : PropertyManagerPageControlConstructor
27 | where THandler : PropertyManagerPageHandlerEx, new()
28 | {
29 | private readonly IconsConverter m_IconsConv;
30 |
31 | public PropertyManagerPageBitmapConstructor(ISldWorks app, IconsConverter iconsConv)
32 | : base(app, swPropertyManagerPageControlType_e.swControlType_Bitmap, iconsConv)
33 | {
34 | m_IconsConv = iconsConv;
35 | }
36 |
37 | protected override PropertyManagerPageBitmapEx CreateControl(
38 | IPropertyManagerPageBitmap swCtrl, IAttributeSet atts, THandler handler, short height)
39 | {
40 | Size? size = null;
41 |
42 | if (atts.Has())
43 | {
44 | var opts = atts.Get();
45 | size = opts.Size;
46 | }
47 |
48 | return new PropertyManagerPageBitmapEx(m_IconsConv, atts.Id, atts.Tag, size, swCtrl, handler);
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/Base/Constructors/PropertyManagerPageButtonConstructor.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using CodeStack.SwEx.PMPage.Controls;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 | using Xarial.VPages.Framework.Attributes;
14 | using Xarial.VPages.Framework.Constructors;
15 | using Xarial.VPages.Framework.Base;
16 | using SolidWorks.Interop.swconst;
17 | using CodeStack.SwEx.PMPage.Attributes;
18 | using System.Drawing;
19 | using SolidWorks.Interop.sldworks;
20 | using CodeStack.SwEx.Common.Icons;
21 |
22 | namespace CodeStack.SwEx.PMPage.Constructors
23 | {
24 | [DefaultType(typeof(Action))]
25 | internal class PropertyManagerPageButtonConstructor
26 | : PropertyManagerPageControlConstructor
27 | where THandler : PropertyManagerPageHandlerEx, new()
28 | {
29 | public PropertyManagerPageButtonConstructor(ISldWorks app, IconsConverter iconsConv)
30 | : base(app, swPropertyManagerPageControlType_e.swControlType_Button, iconsConv)
31 | {
32 | }
33 |
34 | protected override PropertyManagerPageButtonEx CreateControl(
35 | IPropertyManagerPageButton swCtrl, IAttributeSet atts, THandler handler, short height)
36 | {
37 | swCtrl.Caption = atts.Name;
38 |
39 | return new PropertyManagerPageButtonEx(atts.Id, atts.Tag, swCtrl, handler);
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Base/Constructors/PropertyManagerPageCheckBoxConstructor.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using CodeStack.SwEx.PMPage.Controls;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 | using Xarial.VPages.Framework.Attributes;
14 | using Xarial.VPages.Framework.Constructors;
15 | using Xarial.VPages.Framework.Base;
16 | using SolidWorks.Interop.swconst;
17 | using CodeStack.SwEx.PMPage.Attributes;
18 | using System.Drawing;
19 | using SolidWorks.Interop.sldworks;
20 | using CodeStack.SwEx.Common.Icons;
21 |
22 | namespace CodeStack.SwEx.PMPage.Constructors
23 | {
24 | [DefaultType(typeof(bool))]
25 | internal class PropertyManagerPageCheckBoxConstructor
26 | : PropertyManagerPageControlConstructor
27 | where THandler : PropertyManagerPageHandlerEx, new()
28 | {
29 | public PropertyManagerPageCheckBoxConstructor(ISldWorks app, IconsConverter iconsConv)
30 | : base(app, swPropertyManagerPageControlType_e.swControlType_Checkbox, iconsConv)
31 | {
32 | }
33 |
34 | protected override PropertyManagerPageCheckBoxEx CreateControl(
35 | IPropertyManagerPageCheckbox swCtrl, IAttributeSet atts, THandler handler, short height)
36 | {
37 | swCtrl.Caption = atts.Name;
38 |
39 | return new PropertyManagerPageCheckBoxEx(atts.Id, atts.Tag, swCtrl, handler);
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Base/Constructors/PropertyManagerPageComboBoxConstructor.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using CodeStack.SwEx.PMPage.Controls;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 | using Xarial.VPages.Framework.Constructors;
14 | using Xarial.VPages.Framework.Base;
15 | using SolidWorks.Interop.swconst;
16 | using Xarial.VPages.Framework.Attributes;
17 | using Xarial.VPages.Framework.Core;
18 | using SolidWorks.Interop.sldworks;
19 | using CodeStack.SwEx.PMPage.Attributes;
20 | using CodeStack.SwEx.Common.Icons;
21 | using CodeStack.SwEx.Common.Reflection;
22 | using System.ComponentModel;
23 |
24 | namespace CodeStack.SwEx.PMPage.Constructors
25 | {
26 | [DefaultType(typeof(SpecialTypes.EnumType))]
27 | internal class PropertyManagerPageComboBoxConstructor
28 | : PropertyManagerPageControlConstructor
29 | where THandler : PropertyManagerPageHandlerEx, new()
30 | {
31 | public PropertyManagerPageComboBoxConstructor(ISldWorks app, IconsConverter iconsConv)
32 | : base(app, swPropertyManagerPageControlType_e.swControlType_Combobox, iconsConv)
33 | {
34 | }
35 |
36 | protected override PropertyManagerPageComboBoxEx CreateControl(
37 | IPropertyManagerPageCombobox swCtrl, IAttributeSet atts, THandler handler, short height)
38 | {
39 | var items = Helper.GetEnumFields(atts.BoundType);
40 |
41 | swCtrl.AddItems(items.Values.ToArray());
42 |
43 | if (height != -1)
44 | {
45 | swCtrl.Height = height;
46 | }
47 |
48 | if (atts.Has())
49 | {
50 | var style = atts.Get();
51 |
52 | if (style.Style != 0)
53 | {
54 | swCtrl.Style = (int)style.Style;
55 | }
56 | }
57 |
58 | return new PropertyManagerPageComboBoxEx(atts.Id, atts.Tag, swCtrl, items.Keys.ToList().AsReadOnly(), handler);
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/Base/Constructors/PropertyManagerPageConstructor.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using CodeStack.SwEx.PMPage.Controls;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 | using Xarial.VPages.Framework.Constructors;
14 | using Xarial.VPages.Framework.Base;
15 | using SolidWorks.Interop.sldworks;
16 | using SolidWorks.Interop.swconst;
17 | using CodeStack.SwEx.PMPage.Attributes;
18 | using CodeStack.SwEx.Common.Icons;
19 | using CodeStack.SwEx.PMPage.Data;
20 | using System.Drawing;
21 | using CodeStack.SwEx.Common.Attributes;
22 |
23 | namespace CodeStack.SwEx.PMPage.Constructors
24 | {
25 | internal class PropertyManagerPageConstructor : PageConstructor>
26 | where THandler : PropertyManagerPageHandlerEx, new()
27 | {
28 | private readonly ISldWorks m_App;
29 | private readonly IconsConverter m_IconsConv;
30 | private readonly THandler m_Handler;
31 |
32 | internal PropertyManagerPageConstructor(ISldWorks app, IconsConverter iconsConv, THandler handler)
33 | {
34 | m_App = app;
35 | m_IconsConv = iconsConv;
36 |
37 | m_Handler = handler;
38 | handler.Init(m_App);
39 | }
40 |
41 | protected override PropertyManagerPagePageEx Create(IAttributeSet atts)
42 | {
43 | int err = -1;
44 |
45 | swPropertyManagerPageOptions_e opts;
46 |
47 | TitleIcon titleIcon = null;
48 |
49 | IconAttribute commIconAtt;
50 | if (atts.BoundType.TryGetAttribute(out commIconAtt))
51 | {
52 | if (commIconAtt.Icon != null)
53 | {
54 | titleIcon = new TitleIcon(commIconAtt.Icon);
55 | }
56 | }
57 |
58 | if (atts.Has())
59 | {
60 | var optsAtt = atts.Get();
61 |
62 | opts = optsAtt.Options;
63 |
64 | if (optsAtt.Icon != null)
65 | {
66 | titleIcon = optsAtt.Icon;
67 | }
68 | }
69 | else
70 | {
71 | opts = swPropertyManagerPageOptions_e.swPropertyManagerOptions_OkayButton;
72 | }
73 |
74 | var helpLink = "";
75 | var whatsNewLink = "";
76 |
77 | if (atts.Has())
78 | {
79 | var helpAtt = atts.Get();
80 |
81 | if (!string.IsNullOrEmpty(helpAtt.WhatsNewLink))
82 | {
83 | if (!opts.HasFlag(swPropertyManagerPageOptions_e.swPropertyManagerOptions_WhatsNew))
84 | {
85 | opts |= swPropertyManagerPageOptions_e.swPropertyManagerOptions_WhatsNew;
86 | }
87 | }
88 |
89 | helpLink = helpAtt.HelpLink;
90 | whatsNewLink = helpAtt.WhatsNewLink;
91 | }
92 |
93 | var page = m_App.CreatePropertyManagerPage(atts.Name,
94 | (int)opts,
95 | m_Handler, ref err) as IPropertyManagerPage2;
96 |
97 | if (titleIcon != null)
98 | {
99 | var iconPath = m_IconsConv.ConvertIcon(titleIcon, false).First();
100 | page.SetTitleBitmap2(iconPath);
101 | }
102 |
103 | if (atts.Has())
104 | {
105 | var msgAtt = atts.Get();
106 | page.SetMessage3(msgAtt.Text, (int)msgAtt.Visibility,
107 | (int)msgAtt.Expanded, msgAtt.Caption);
108 | }
109 | else if (!string.IsNullOrEmpty(atts.Description))
110 | {
111 | page.SetMessage3(atts.Description, (int)swPropertyManagerPageMessageVisibility.swMessageBoxVisible,
112 | (int)swPropertyManagerPageMessageExpanded.swMessageBoxExpand, "");
113 | }
114 |
115 | return new PropertyManagerPagePageEx(page, m_Handler, m_App, helpLink, whatsNewLink);
116 | }
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/Base/Constructors/PropertyManagerPageGroupConstructor.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using CodeStack.SwEx.PMPage.Controls;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 | using Xarial.VPages.Framework.Constructors;
14 | using Xarial.VPages.Framework.Base;
15 | using SolidWorks.Interop.swconst;
16 | using Xarial.VPages.Framework.Attributes;
17 | using Xarial.VPages.Framework.Core;
18 |
19 | namespace CodeStack.SwEx.PMPage.Constructors
20 | {
21 | [DefaultType(typeof(SpecialTypes.ComplexType))]
22 | internal class PropertyManagerPageGroupConstructor
23 | : GroupConstructor, PropertyManagerPagePageEx>,
24 | IPropertyManagerPageElementConstructor
25 | where THandler : PropertyManagerPageHandlerEx, new()
26 | {
27 | public Type ControlType
28 | {
29 | get
30 | {
31 | return typeof(PropertyManagerPageGroupEx);
32 | }
33 | }
34 |
35 | public void PostProcessControls(IEnumerable ctrls)
36 | {
37 | //TODO: not used
38 | }
39 |
40 | protected override PropertyManagerPageGroupBaseEx Create(
41 | PropertyManagerPageGroupBaseEx group, IAttributeSet atts)
42 | {
43 | if (group is PropertyManagerPageTabEx)
44 | {
45 | var grp = (group as PropertyManagerPageTabEx).Tab.AddGroupBox(atts.Id, atts.Name,
46 | (int)(swAddGroupBoxOptions_e.swGroupBoxOptions_Expanded
47 | | swAddGroupBoxOptions_e.swGroupBoxOptions_Visible)) as SolidWorks.Interop.sldworks.IPropertyManagerPageGroup;
48 |
49 | return new PropertyManagerPageGroupEx(atts.Id, atts.Tag,
50 | group.Handler, grp, group.App, group.ParentPage);
51 | }
52 | //NOTE: nested groups are not supported in SOLIDWORKS, creating the group in page instead
53 | else if (group is PropertyManagerPageGroupEx)
54 | {
55 | return Create(group.ParentPage, atts);
56 | }
57 | else
58 | {
59 | throw new NullReferenceException("Not supported group type");
60 | }
61 | }
62 |
63 | protected override PropertyManagerPageGroupBaseEx Create(PropertyManagerPagePageEx page, IAttributeSet atts)
64 | {
65 | var grp = page.Page.AddGroupBox(atts.Id, atts.Name,
66 | (int)(swAddGroupBoxOptions_e.swGroupBoxOptions_Expanded
67 | | swAddGroupBoxOptions_e.swGroupBoxOptions_Visible)) as SolidWorks.Interop.sldworks.IPropertyManagerPageGroup;
68 |
69 | return new PropertyManagerPageGroupEx(atts.Id, atts.Tag,
70 | page.Handler, grp, page.App, page);
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/Base/Constructors/PropertyManagerPageNumberBoxConstructor.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using CodeStack.SwEx.PMPage.Controls;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 | using Xarial.VPages.Framework.Attributes;
14 | using Xarial.VPages.Framework.Constructors;
15 | using Xarial.VPages.Framework.Base;
16 | using SolidWorks.Interop.swconst;
17 | using CodeStack.SwEx.PMPage.Attributes;
18 | using System.Drawing;
19 | using SolidWorks.Interop.sldworks;
20 | using CodeStack.SwEx.Common.Icons;
21 |
22 | namespace CodeStack.SwEx.PMPage.Constructors
23 | {
24 | [DefaultType(typeof(int))]
25 | [DefaultType(typeof(double))]
26 | internal class PropertyManagerPageNumberBoxConstructor
27 | : PropertyManagerPageControlConstructor
28 | where THandler : PropertyManagerPageHandlerEx, new()
29 | {
30 | public PropertyManagerPageNumberBoxConstructor(ISldWorks app, IconsConverter iconsConv)
31 | : base(app, swPropertyManagerPageControlType_e.swControlType_Numberbox, iconsConv)
32 | {
33 | }
34 |
35 | protected override PropertyManagerPageNumberBoxEx CreateControl(
36 | IPropertyManagerPageNumberbox swCtrl, IAttributeSet atts, THandler handler, short height)
37 | {
38 | if (height != -1)
39 | {
40 | swCtrl.Height = height;
41 | }
42 |
43 | if (atts.Has())
44 | {
45 | var style = atts.Get();
46 |
47 | if (style.Style != 0)
48 | {
49 | swCtrl.Style = (int)style.Style;
50 | }
51 |
52 | if (style.Units != 0)
53 | {
54 | swCtrl.SetRange2((int)style.Units, style.Minimum, style.Maximum,
55 | style.Inclusive, style.Increment, style.FastIncrement, style.SlowIncrement);
56 | }
57 | }
58 |
59 | return new PropertyManagerPageNumberBoxEx(atts.Id, atts.Tag, swCtrl, handler);
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/Base/Constructors/PropertyManagerPageOptionBoxConstructor.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using CodeStack.SwEx.PMPage.Controls;
9 | using System;
10 | using System.Linq;
11 | using Xarial.VPages.Framework.Base;
12 | using SolidWorks.Interop.swconst;
13 | using CodeStack.SwEx.Common.Icons;
14 | using CodeStack.SwEx.Common.Reflection;
15 | using System.ComponentModel;
16 | using SolidWorks.Interop.sldworks;
17 | using CodeStack.SwEx.PMPage.Attributes;
18 | using CodeStack.SwEx.Common.Enums;
19 |
20 | namespace CodeStack.SwEx.PMPage.Constructors
21 | {
22 | internal interface IPropertyManagerPageOptionBoxConstructor
23 | {
24 | }
25 |
26 | internal class PropertyManagerPageOptionBoxConstructor
27 | : PropertyManagerPageControlConstructor,
28 | IPropertyManagerPageOptionBoxConstructor
29 | where THandler : PropertyManagerPageHandlerEx, new()
30 | {
31 | private delegate IPropertyManagerPageOption ControlCreatorDelegate(int id, short controlType, string caption, short leftAlign, int options, string tip);
32 |
33 | public PropertyManagerPageOptionBoxConstructor(ISldWorks app, IconsConverter iconsConv)
34 | : base(app, swPropertyManagerPageControlType_e.swControlType_Option, iconsConv)
35 | {
36 | }
37 |
38 | protected override PropertyManagerPageOptionBoxEx Create(PropertyManagerPagePageEx page, IAttributeSet atts, ref int idRange)
39 | {
40 | idRange = Helper.GetEnumFields(atts.BoundType).Count;
41 | return base.Create(page, atts);
42 | }
43 |
44 | protected override PropertyManagerPageOptionBoxEx Create(PropertyManagerPageGroupBaseEx group, IAttributeSet atts, ref int idRange)
45 | {
46 | idRange = Helper.GetEnumFields(atts.BoundType).Count;
47 | return base.Create(group, atts);
48 | }
49 |
50 | protected override PropertyManagerPageOptionBoxEx CreateControl(
51 | PropertyManagerPageOptionBox swCtrl, IAttributeSet atts, THandler handler, short height)
52 | {
53 | var options = Helper.GetEnumFields(atts.BoundType);
54 |
55 | if (atts.Has())
56 | {
57 | var style = atts.Get();
58 |
59 | if (style.Style != 0)
60 | {
61 | swCtrl.Style = (int)style.Style;
62 | }
63 | }
64 |
65 | return new PropertyManagerPageOptionBoxEx(atts.Id, atts.Tag, swCtrl, options.Keys.ToList().AsReadOnly(), handler);
66 | }
67 |
68 | protected override PropertyManagerPageOptionBox CreateSwControlInPage(IPropertyManagerPage2 page,
69 | ControlOptionsAttribute opts, IAttributeSet atts)
70 | {
71 | return CreateOptionBoxControl(opts, atts,
72 | (int id, short controlType, string caption, short leftAlign, int options, string tip) =>
73 | {
74 | if (m_App.IsVersionNewerOrEqual(SwVersion_e.Sw2014, 1))
75 | {
76 | return page.AddControl2(id, controlType, caption, leftAlign, options, tip) as IPropertyManagerPageOption;
77 | }
78 | else
79 | {
80 | return page.AddControl(id, controlType, caption, leftAlign, options, tip) as IPropertyManagerPageOption;
81 | }
82 | });
83 | }
84 |
85 | protected override PropertyManagerPageOptionBox CreateSwControlInGroup(IPropertyManagerPageGroup group,
86 | ControlOptionsAttribute opts, IAttributeSet atts)
87 | {
88 | return CreateOptionBoxControl(opts, atts,
89 | (int id, short controlType, string caption, short leftAlign, int options, string tip) =>
90 | {
91 | if (m_App.IsVersionNewerOrEqual(SwVersion_e.Sw2014, 1))
92 | {
93 | return group.AddControl2(id, controlType, caption, leftAlign, options, tip) as IPropertyManagerPageOption;
94 | }
95 | else
96 | {
97 | return group.AddControl(id, controlType, caption, leftAlign, options, tip) as IPropertyManagerPageOption;
98 | }
99 | });
100 | }
101 |
102 | protected override PropertyManagerPageOptionBox CreateSwControlInTab(IPropertyManagerPageTab tab, ControlOptionsAttribute opts, IAttributeSet atts)
103 | {
104 | return CreateOptionBoxControl(opts, atts,
105 | (int id, short controlType, string caption, short leftAlign, int options, string tip) =>
106 | {
107 | if (m_App.IsVersionNewerOrEqual(SwVersion_e.Sw2014, 1))
108 | {
109 | return tab.AddControl2(id, controlType, caption, leftAlign, options, tip) as IPropertyManagerPageOption;
110 | }
111 | else
112 | {
113 | return tab.AddControl(id, controlType, caption, leftAlign, options, tip) as IPropertyManagerPageOption;
114 | }
115 | });
116 | }
117 |
118 | private PropertyManagerPageOptionBox CreateOptionBoxControl(ControlOptionsAttribute opts, IAttributeSet atts,
119 | ControlCreatorDelegate creator)
120 | {
121 | var options = Helper.GetEnumFields(atts.BoundType);
122 |
123 | var ctrls = new IPropertyManagerPageOption[options.Count];
124 |
125 | for (int i = 0; i < options.Count; i++)
126 | {
127 | var name = options.ElementAt(i).Value;
128 | ctrls[i] = creator.Invoke(atts.Id + i, (short)swPropertyManagerPageControlType_e.swControlType_Option, name,
129 | (short)opts.Align, (short)opts.Options, atts.Description);
130 | }
131 |
132 | return new PropertyManagerPageOptionBox(ctrls);
133 | }
134 | }
135 | }
136 |
--------------------------------------------------------------------------------
/Base/Constructors/PropertyManagerPageSelectionBoxConstructor.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using CodeStack.SwEx.PMPage.Controls;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 | using Xarial.VPages.Framework.Attributes;
14 | using Xarial.VPages.Framework.Constructors;
15 | using Xarial.VPages.Framework.Base;
16 | using SolidWorks.Interop.swconst;
17 | using CodeStack.SwEx.PMPage.Attributes;
18 | using System.Drawing;
19 | using SolidWorks.Interop.sldworks;
20 | using System.Collections;
21 | using CodeStack.SwEx.PMPage.Base;
22 | using CodeStack.SwEx.Common.Icons;
23 | using CodeStack.SwEx.Common.Diagnostics;
24 |
25 | namespace CodeStack.SwEx.PMPage.Constructors
26 | {
27 | internal interface IPropertyManagerPageSelectionBoxConstructor
28 | {
29 | }
30 |
31 | internal class PropertyManagerPageSelectionBoxConstructor
32 | : PropertyManagerPageControlConstructor,
33 | IPropertyManagerPageSelectionBoxConstructor
34 | where THandler : PropertyManagerPageHandlerEx, new()
35 | {
36 | private readonly ILogger m_Logger;
37 |
38 | public PropertyManagerPageSelectionBoxConstructor(ISldWorks app, IconsConverter iconsConv, ILogger logger)
39 | : base(app, swPropertyManagerPageControlType_e.swControlType_Selectionbox, iconsConv)
40 | {
41 | m_Logger = logger;
42 | }
43 |
44 | protected override PropertyManagerPageSelectionBoxEx CreateControl(
45 | IPropertyManagerPageSelectionbox swCtrl, IAttributeSet atts, THandler handler, short height)
46 | {
47 | var selAtt = atts.Get();
48 | swCtrl.SetSelectionFilters(selAtt.Filters);
49 | swCtrl.Mark = selAtt.SelectionMark;
50 |
51 | swCtrl.SingleEntityOnly = !(typeof(IList).IsAssignableFrom(atts.BoundType));
52 |
53 | ISelectionCustomFilter customFilter = null;
54 |
55 | if (selAtt.CustomFilter != null)
56 | {
57 | customFilter = Activator.CreateInstance(selAtt.CustomFilter) as ISelectionCustomFilter;
58 |
59 | if (customFilter == null)
60 | {
61 | throw new InvalidCastException(
62 | $"Specified custom filter of type {selAtt.CustomFilter.FullName} cannot be cast to {typeof(ISelectionCustomFilter).FullName}");
63 | }
64 | }
65 |
66 | if (height == -1)
67 | {
68 | height = 20;
69 | }
70 |
71 | swCtrl.Height = height;
72 |
73 | if (atts.Has())
74 | {
75 | var style = atts.Get();
76 |
77 | if (style.Style != 0)
78 | {
79 | swCtrl.Style = (int)style.Style;
80 | }
81 |
82 | if (style.SelectionColor != 0)
83 | {
84 | swCtrl.SetSelectionColor(true, ConvertColor(style.SelectionColor));
85 | }
86 | }
87 |
88 | return new PropertyManagerPageSelectionBoxEx(m_App, atts.Id, atts.Tag,
89 | swCtrl, handler, atts.BoundType, customFilter);
90 | }
91 |
92 | public override void PostProcessControls(IEnumerable ctrls)
93 | {
94 | var selBoxes = ctrls.OfType().ToArray();
95 |
96 | var autoAssignSelMarksCtrls = selBoxes
97 | .Where(s => s.SelectionBox.Mark == -1).ToList();
98 |
99 | var assignedMarks = ctrls.OfType()
100 | .Except(autoAssignSelMarksCtrls).Select(c => c.SelectionBox.Mark).ToList();
101 |
102 | ValidateMarks(assignedMarks);
103 |
104 | if (selBoxes.Length == 1)
105 | {
106 | autoAssignSelMarksCtrls[0].SelectionBox.Mark = 0;
107 | }
108 | else
109 | {
110 | int index = 0;
111 |
112 | autoAssignSelMarksCtrls.ForEach(c =>
113 | {
114 | int mark;
115 | do
116 | {
117 | mark = (int)Math.Pow(2, index);
118 | index++;
119 | } while (assignedMarks.Contains(mark));
120 |
121 | c.SelectionBox.Mark = mark;
122 | });
123 | }
124 |
125 | m_Logger.Log($"Assigned selection box marks: {string.Join(", ", selBoxes.Select(s => s.SelectionBox.Mark).ToArray())}");
126 | }
127 |
128 | private void ValidateMarks(List assignedMarks)
129 | {
130 | if (assignedMarks.Count > 1)
131 | {
132 | var dups = assignedMarks.GroupBy(m => m).Where(g => g.Count() > 1).Select(g => g.Key);
133 |
134 | if (dups.Any())
135 | {
136 | m_Logger.Log($"Potential issue for selection boxes as there are duplicate selection marks: {string.Join(", ", dups.ToArray())}");
137 | }
138 |
139 | var joinedMarks = assignedMarks.Where(m => m != 0 && !IsPowerOfTwo(m));
140 |
141 | if (joinedMarks.Any())
142 | {
143 | m_Logger.Log($"Potential issue for selection boxes as not all marks are power of 2: {string.Join(", ", joinedMarks.ToArray())}");
144 | }
145 |
146 | if (assignedMarks.Any(m => m == 0))
147 | {
148 | m_Logger.Log($"Potential issue for selection boxes as some of the marks is 0 which means that all selections allowed");
149 | }
150 | }
151 | }
152 |
153 | private bool IsPowerOfTwo(int mark)
154 | {
155 | return (mark != 0) && ((mark & (mark - 1)) == 0);
156 | }
157 | }
158 | }
159 |
--------------------------------------------------------------------------------
/Base/Constructors/PropertyManagerPageTabConstructor.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using CodeStack.SwEx.PMPage.Controls;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 | using Xarial.VPages.Framework.Constructors;
14 | using Xarial.VPages.Framework.Base;
15 | using SolidWorks.Interop.swconst;
16 | using Xarial.VPages.Framework.Attributes;
17 | using Xarial.VPages.Framework.Core;
18 | using CodeStack.SwEx.Common.Reflection;
19 | using CodeStack.SwEx.Common.Attributes;
20 | using CodeStack.SwEx.PMPage.Data;
21 | using CodeStack.SwEx.Common.Icons;
22 | using System.Drawing;
23 | using System.Drawing.Imaging;
24 |
25 | namespace CodeStack.SwEx.PMPage.Constructors
26 | {
27 | internal interface IPropertyManagerPageTabConstructor
28 | {
29 | }
30 |
31 | internal class PropertyManagerPageTabConstructor
32 | : GroupConstructor, PropertyManagerPagePageEx>,
33 | IPropertyManagerPageElementConstructor,
34 | IPropertyManagerPageTabConstructor
35 | where THandler : PropertyManagerPageHandlerEx, new()
36 | {
37 | public Type ControlType
38 | {
39 | get
40 | {
41 | return typeof(PropertyManagerPageGroupBaseEx);
42 | }
43 | }
44 |
45 | private readonly IconsConverter m_IconsConv;
46 |
47 | public PropertyManagerPageTabConstructor(IconsConverter iconsConv)
48 | {
49 | m_IconsConv = iconsConv;
50 | }
51 |
52 | public void PostProcessControls(IEnumerable ctrls)
53 | {
54 | //TODO: not used
55 | }
56 |
57 | protected override PropertyManagerPageGroupBaseEx Create(PropertyManagerPageGroupBaseEx group, IAttributeSet atts)
58 | {
59 | //NOTE: nested tabs are not supported in SOLIDWORKS, creating the group in page instead
60 | return Create(group.ParentPage, atts);
61 | }
62 |
63 | protected override PropertyManagerPageGroupBaseEx Create(PropertyManagerPagePageEx page, IAttributeSet atts)
64 | {
65 | const int OPTIONS_NOT_USED = 0;
66 |
67 | var icon = atts.BoundMemberInfo?.TryGetAttribute()?.Icon;
68 |
69 | if (icon == null)
70 | {
71 | icon = atts.BoundType?.TryGetAttribute()?.Icon;
72 | }
73 |
74 | string iconPath = "";
75 |
76 | if (icon != null)
77 | {
78 | iconPath = m_IconsConv.ConvertIcon(new TabIcon(icon), true).First();
79 |
80 | //NOTE: tab icon must be in 256 color bitmap, otherwise it is not displayed
81 | TryConvertIconTo8bit(iconPath);
82 | }
83 |
84 | var tab = page.Page.AddTab(atts.Id, atts.Name,
85 | iconPath, OPTIONS_NOT_USED) as SolidWorks.Interop.sldworks.IPropertyManagerPageTab;
86 |
87 | return new PropertyManagerPageTabEx(atts.Id, atts.Tag,
88 | page.Handler, tab, page.App, page);
89 | }
90 |
91 | private void TryConvertIconTo8bit(string path)
92 | {
93 | try
94 | {
95 | using (var img = Image.FromFile(path))
96 | {
97 | using (var srcBmp = new Bitmap(img))
98 | {
99 | using (var destBmp = srcBmp.Clone(new Rectangle(new Point(0, 0), srcBmp.Size), PixelFormat.Format8bppIndexed))
100 | {
101 | img.Dispose();
102 | destBmp.Save(path, ImageFormat.Bmp);
103 | }
104 | }
105 | }
106 | }
107 | catch
108 | {
109 | }
110 | }
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/Base/Constructors/PropertyManagerPageTextBoxConstructor.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using CodeStack.SwEx.PMPage.Controls;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 | using Xarial.VPages.Framework.Attributes;
14 | using Xarial.VPages.Framework.Constructors;
15 | using Xarial.VPages.Framework.Base;
16 | using SolidWorks.Interop.swconst;
17 | using CodeStack.SwEx.PMPage.Attributes;
18 | using System.Drawing;
19 | using SolidWorks.Interop.sldworks;
20 | using CodeStack.SwEx.Common.Icons;
21 |
22 | namespace CodeStack.SwEx.PMPage.Constructors
23 | {
24 | [DefaultType(typeof(string))]
25 | internal class PropertyManagerPageTextBoxConstructor
26 | : PropertyManagerPageControlConstructor
27 | where THandler : PropertyManagerPageHandlerEx, new()
28 | {
29 | public PropertyManagerPageTextBoxConstructor(ISldWorks app, IconsConverter iconsConv)
30 | : base(app, swPropertyManagerPageControlType_e.swControlType_Textbox, iconsConv)
31 | {
32 | }
33 |
34 | protected override PropertyManagerPageTextBoxEx CreateControl(
35 | IPropertyManagerPageTextbox swCtrl, IAttributeSet atts, THandler handler, short height)
36 | {
37 | if (height != -1)
38 | {
39 | swCtrl.Height = height;
40 | }
41 |
42 | if (atts.Has())
43 | {
44 | var style = atts.Get();
45 |
46 | if (style.Style != 0)
47 | {
48 | swCtrl.Style = (int)style.Style;
49 | }
50 | }
51 |
52 | return new PropertyManagerPageTextBoxEx(atts.Id, atts.Tag, swCtrl, handler);
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/Base/Controls/PropertyManagerPageBitmapEx.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using CodeStack.SwEx.Common.Icons;
9 | using CodeStack.SwEx.PMPage.Data;
10 | using CodeStack.SwEx.PMPage.Properties;
11 | using SolidWorks.Interop.sldworks;
12 | using System.Drawing;
13 | using Xarial.VPages.Framework.PageElements;
14 |
15 | namespace CodeStack.SwEx.PMPage.Controls
16 | {
17 | internal class PropertyManagerPageBitmapEx : PropertyManagerPageControlEx
18 | {
19 | #pragma warning disable CS0067
20 | protected override event ControlValueChangedDelegate ValueChanged;
21 | #pragma warning restore CS0067
22 |
23 | private readonly IconsConverter m_IconsConv;
24 |
25 | private Image m_Image;
26 | private readonly Size m_Size;
27 |
28 | public PropertyManagerPageBitmapEx(IconsConverter iconsConv,
29 | int id, object tag, Size? size,
30 | IPropertyManagerPageBitmap bitmap,
31 | PropertyManagerPageHandlerEx handler) : base(bitmap, id, tag, handler)
32 | {
33 | m_Size = size.HasValue ? size.Value : new Size(18, 18);
34 | m_IconsConv = iconsConv;
35 | }
36 |
37 | protected override Image GetSpecificValue()
38 | {
39 | return m_Image;
40 | }
41 |
42 | protected override void SetSpecificValue(Image value)
43 | {
44 | if (value == null)
45 | {
46 | value = Resources.DefaultBitmap;
47 | }
48 |
49 | var icons = m_IconsConv.ConvertIcon(new ControlIcon(value, m_Size), true);
50 | SwSpecificControl.SetBitmapByName(icons[0], icons[1]);
51 |
52 | m_Image = value;
53 | }
54 |
55 | public override void Dispose()
56 | {
57 | base.Dispose();
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/Base/Controls/PropertyManagerPageButtonEx.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using SolidWorks.Interop.sldworks;
9 | using System;
10 | using Xarial.VPages.Framework.PageElements;
11 |
12 | namespace CodeStack.SwEx.PMPage.Controls
13 | {
14 | internal class PropertyManagerPageButtonEx : PropertyManagerPageControlEx
15 | {
16 | #pragma warning disable CS0067
17 | protected override event ControlValueChangedDelegate ValueChanged;
18 | #pragma warning restore CS0067
19 |
20 | private Action m_ButtonClickHandler;
21 |
22 | public PropertyManagerPageButtonEx(int id, object tag,
23 | IPropertyManagerPageButton button,
24 | PropertyManagerPageHandlerEx handler) : base(button, id, tag, handler)
25 | {
26 | m_Handler.ButtonPressed += OnButtonPressed;
27 | }
28 |
29 | private void OnButtonPressed(int id)
30 | {
31 | if (Id == id)
32 | {
33 | m_ButtonClickHandler.Invoke();
34 | }
35 | }
36 |
37 | protected override Action GetSpecificValue()
38 | {
39 | return m_ButtonClickHandler;
40 | }
41 |
42 | protected override void SetSpecificValue(Action value)
43 | {
44 | m_ButtonClickHandler = value;
45 | }
46 |
47 | public override void Dispose()
48 | {
49 | base.Dispose();
50 | m_Handler.ButtonPressed -= OnButtonPressed;
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Base/Controls/PropertyManagerPageCheckBoxEx.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using SolidWorks.Interop.sldworks;
9 | using Xarial.VPages.Framework.PageElements;
10 |
11 | namespace CodeStack.SwEx.PMPage.Controls
12 | {
13 | internal class PropertyManagerPageCheckBoxEx : PropertyManagerPageControlEx
14 | {
15 | protected override event ControlValueChangedDelegate ValueChanged;
16 |
17 | public PropertyManagerPageCheckBoxEx(int id, object tag,
18 | IPropertyManagerPageCheckbox checkBox,
19 | PropertyManagerPageHandlerEx handler) : base(checkBox, id, tag, handler)
20 | {
21 | m_Handler.CheckChanged += OnCheckChanged;
22 | }
23 |
24 | private void OnCheckChanged(int id, bool isChecked)
25 | {
26 | if (Id == id)
27 | {
28 | ValueChanged?.Invoke(this, isChecked);
29 | }
30 | }
31 |
32 | protected override bool GetSpecificValue()
33 | {
34 | return SwSpecificControl.Checked;
35 | }
36 |
37 | protected override void SetSpecificValue(bool value)
38 | {
39 | SwSpecificControl.Checked = value;
40 | }
41 |
42 | public override void Dispose()
43 | {
44 | base.Dispose();
45 | m_Handler.CheckChanged -= OnCheckChanged;
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/Base/Controls/PropertyManagerPageComboBoxEx.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using SolidWorks.Interop.sldworks;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Collections.ObjectModel;
12 | using System.Linq;
13 | using System.Text;
14 | using Xarial.VPages.Framework.PageElements;
15 |
16 | namespace CodeStack.SwEx.PMPage.Controls
17 | {
18 | internal class PropertyManagerPageComboBoxEx : PropertyManagerPageControlEx
19 | {
20 | protected override event ControlValueChangedDelegate ValueChanged;
21 |
22 | private ReadOnlyCollection m_Values;
23 |
24 | public PropertyManagerPageComboBoxEx(int id, object tag,
25 | IPropertyManagerPageCombobox comboBox, ReadOnlyCollection values,
26 | PropertyManagerPageHandlerEx handler) : base(comboBox, id, tag, handler)
27 | {
28 | m_Values = values;
29 | m_Handler.ComboBoxChanged += OnComboBoxChanged;
30 | }
31 |
32 | private void OnComboBoxChanged(int id, int selIndex)
33 | {
34 | if (Id == id)
35 | {
36 | ValueChanged?.Invoke(this, m_Values[selIndex]);
37 | }
38 | }
39 |
40 | protected override Enum GetSpecificValue()
41 | {
42 | var curSelIndex = SwSpecificControl.CurrentSelection;
43 |
44 | if (curSelIndex >= 0 && curSelIndex < m_Values.Count)
45 | {
46 | return m_Values[curSelIndex];
47 | }
48 | else
49 | {
50 | return null;
51 | }
52 | }
53 |
54 | protected override void SetSpecificValue(Enum value)
55 | {
56 | SwSpecificControl.CurrentSelection = (short)m_Values.IndexOf(value);
57 | }
58 |
59 | public override void Dispose()
60 | {
61 | base.Dispose();
62 | m_Handler.ComboBoxChanged -= OnComboBoxChanged;
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/Base/Controls/PropertyManagerPageControlEx.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using SolidWorks.Interop.sldworks;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 | using Xarial.VPages.Framework.Base;
14 | using Xarial.VPages.Framework.PageElements;
15 |
16 | namespace CodeStack.SwEx.PMPage.Controls
17 | {
18 | ///
19 | /// Base wrapper around native SOLIDWORKS Property Manager Page controls (i.e. TextBox, SelectionBox, NumberBox etc.)
20 | ///
21 | public interface IPropertyManagerPageControlEx : IControl, IPropertyManagerPageElementEx
22 | {
23 | ///
24 | /// Pointer to the native SOLIDWORKS control of type
25 | ///
26 | IPropertyManagerPageControl SwControl { get; }
27 | }
28 |
29 | internal abstract class PropertyManagerPageControlEx
30 | : Control, IPropertyManagerPageControlEx
31 | where TSwControl : class
32 | {
33 | protected PropertyManagerPageHandlerEx m_Handler;
34 |
35 | protected PropertyManagerPageControlEx(TSwControl ctrl, int id, object tag, PropertyManagerPageHandlerEx handler)
36 | : base(id, tag)
37 | {
38 | SwSpecificControl = ctrl;
39 | m_Handler = handler;
40 | }
41 |
42 | protected TSwControl SwSpecificControl { get; private set; }
43 |
44 | public bool Enabled
45 | {
46 | get
47 | {
48 | return SwControl.Enabled;
49 | }
50 | set
51 | {
52 | SwControl.Enabled = value;
53 | }
54 | }
55 |
56 | public bool Visible
57 | {
58 | get
59 | {
60 | return SwControl.Visible;
61 | }
62 | set
63 | {
64 | SwControl.Visible = value;
65 | }
66 | }
67 |
68 | public IPropertyManagerPageControl SwControl
69 | {
70 | get
71 | {
72 | if (SwSpecificControl is IPropertyManagerPageControl)
73 | {
74 | return SwSpecificControl as IPropertyManagerPageControl;
75 | }
76 | else
77 | {
78 | throw new InvalidCastException(
79 | $"Failed to cast {typeof(TSwControl).FullName} to {typeof(IPropertyManagerPageControl).FullName}");
80 | }
81 | }
82 | }
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/Base/Controls/PropertyManagerPageElementEx.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace CodeStack.SwEx.PMPage.Controls
7 | {
8 | ///
9 | /// Represents the base interface for elements in property manager page (e.g. controls, groups, tabs)
10 | ///
11 | public interface IPropertyManagerPageElementEx
12 | {
13 | ///
14 | /// Enable state of this control
15 | ///
16 | bool Enabled { get; set; }
17 |
18 | ///
19 | /// Visibility state of the control
20 | ///
21 | bool Visible { get; set; }
22 | }
23 |
24 | ///
25 | /// List of extension methods of property manager page element
26 | ///
27 | public static class PropertyManagerPageElementEx
28 | {
29 | ///
30 | /// Gets the value from the property manager page element
31 | ///
32 | /// Type of the control value
33 | /// Property Manager Page element
34 | /// Value extracted from the control
35 | ///
36 | ///
37 | public static T GetValue(this IPropertyManagerPageElementEx elem)
38 | {
39 | if (elem is IPropertyManagerPageControlEx)
40 | {
41 | return (T)(elem as IPropertyManagerPageControlEx).GetValue();
42 | }
43 | else
44 | {
45 | throw new NotSupportedException($"Currently only {typeof(IPropertyManagerPageControlEx).FullName} has value");
46 | }
47 | }
48 |
49 | ///
50 | /// Gets the underlying SOLIDWORKS Property Manager Page control
51 | ///
52 | /// Type of control to return
53 | /// Property Manager Page element
54 | /// Underlying control in the Property Manager Page
55 | ///
56 | ///
57 | /// For controls specify IPropertyManagerPageControl as a generic parameter to return base interface for control.
58 | /// You can also specify specific interfaces (e.g. IPropertyManagerPageNumberbox or IPropertyManagerPageTextbox.
59 | /// For groups specify IPropertyManagerPageGroup.
60 | /// For tabs specify IPropertyManagerPageTab
61 | ///
62 | public static T GetSwControl(this IPropertyManagerPageElementEx elem)
63 | {
64 | if (elem is IPropertyManagerPageControlEx)
65 | {
66 | return (T)(elem as IPropertyManagerPageControlEx).SwControl;
67 | }
68 | else if (elem is IPropertyManagerPageGroupEx)
69 | {
70 | return (T)(elem as IPropertyManagerPageGroupEx).Group;
71 | }
72 | else if (elem is IPropertyManagerPageTabEx)
73 | {
74 | return (T)(elem as IPropertyManagerPageTabEx).Tab;
75 | }
76 | else
77 | {
78 | throw new NotSupportedException();
79 | }
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/Base/Controls/PropertyManagerPageGroupBaseEx.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using SolidWorks.Interop.sldworks;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 | using Xarial.VPages.Framework.PageElements;
14 |
15 | namespace CodeStack.SwEx.PMPage.Controls
16 | {
17 | internal abstract class PropertyManagerPageGroupBaseEx : Group, IPropertyManagerPageElementEx
18 | where THandler : PropertyManagerPageHandlerEx, new()
19 | {
20 | public ISldWorks App { get; private set; }
21 | public THandler Handler { get; private set; }
22 |
23 | internal PropertyManagerPagePageEx ParentPage { get; private set; }
24 |
25 | public abstract bool Enabled { get; set; }
26 | public abstract bool Visible { get; set; }
27 |
28 | internal PropertyManagerPageGroupBaseEx(int id, object tag, THandler handler,
29 | ISldWorks app, PropertyManagerPagePageEx parentPage) : base(id, tag)
30 | {
31 | Handler = handler;
32 | App = app;
33 | ParentPage = parentPage;
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Base/Controls/PropertyManagerPageGroupEx.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using SolidWorks.Interop.sldworks;
9 | using System.ComponentModel;
10 |
11 | namespace CodeStack.SwEx.PMPage.Controls
12 | {
13 | ///
14 | /// Represents the group box control
15 | ///
16 | public interface IPropertyManagerPageGroupEx
17 | {
18 | ///
19 | /// Pointer to the underlying group box
20 | ///
21 | IPropertyManagerPageGroup Group { get; }
22 | }
23 |
24 | internal class PropertyManagerPageGroupEx : PropertyManagerPageGroupBaseEx, IPropertyManagerPageGroupEx
25 | where THandler : PropertyManagerPageHandlerEx, new()
26 | {
27 | public IPropertyManagerPageGroup Group { get; private set; }
28 |
29 | ///
30 | /// Not supported
31 | ///
32 | [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
33 | public override bool Enabled
34 | {
35 | get
36 | {
37 | return true;
38 | }
39 | set
40 | {
41 | }
42 | }
43 |
44 | ///
45 | public override bool Visible
46 | {
47 | get
48 | {
49 | return Group.Visible;
50 | }
51 | set
52 | {
53 | Group.Visible = value;
54 | }
55 | }
56 |
57 | internal PropertyManagerPageGroupEx(int id, object tag, THandler handler,
58 | IPropertyManagerPageGroup group,
59 | ISldWorks app, PropertyManagerPagePageEx parentPage) : base(id, tag, handler, app, parentPage)
60 | {
61 | Group = group;
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/Base/Controls/PropertyManagerPageNumberBoxEx.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using SolidWorks.Interop.sldworks;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Linq;
12 | using System.Text;
13 | using Xarial.VPages.Framework.PageElements;
14 |
15 | namespace CodeStack.SwEx.PMPage.Controls
16 | {
17 | internal class PropertyManagerPageNumberBoxEx : PropertyManagerPageControlEx
18 | {
19 | protected override event ControlValueChangedDelegate ValueChanged;
20 |
21 | public PropertyManagerPageNumberBoxEx(int id, object tag,
22 | IPropertyManagerPageNumberbox numberBox,
23 | PropertyManagerPageHandlerEx handler) : base(numberBox, id, tag, handler)
24 | {
25 | m_Handler.NumberChanged += OnNumberChanged;
26 | }
27 |
28 | private void OnNumberChanged(int id, double value)
29 | {
30 | if (Id == id)
31 | {
32 | ValueChanged?.Invoke(this, value);
33 | }
34 | }
35 |
36 | protected override double GetSpecificValue()
37 | {
38 | return SwSpecificControl.Value;
39 | }
40 |
41 | protected override void SetSpecificValue(double value)
42 | {
43 | SwSpecificControl.Value = value;
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/Base/Controls/PropertyManagerPageOptionBoxEx.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using SolidWorks.Interop.sldworks;
9 | using System;
10 | using System.Collections.Generic;
11 | using System.Collections.ObjectModel;
12 | using System.Linq;
13 | using System.Text;
14 | using Xarial.VPages.Framework.PageElements;
15 |
16 | namespace CodeStack.SwEx.PMPage.Controls
17 | {
18 | ///
19 | /// Wrapper class around the group of IPropertyManagerPageOption controls
20 | ///
21 | /// All set properties will be applied to all controls in the group, while get will return the value of first control
22 | public class PropertyManagerPageOptionBox : IPropertyManagerPageControl, IPropertyManagerPageOption
23 | {
24 | private readonly IPropertyManagerPageOption[] m_Ctrls;
25 |
26 | public PropertyManagerPageOptionBox(IPropertyManagerPageOption[] ctrls)
27 | {
28 | if (ctrls == null || !ctrls.Any())
29 | {
30 | throw new NullReferenceException("No controls");
31 | }
32 |
33 | m_Ctrls = ctrls;
34 | }
35 |
36 | ///
37 | /// Array of controls in the current option group
38 | ///
39 | public IPropertyManagerPageOption[] Controls
40 | {
41 | get
42 | {
43 | return m_Ctrls;
44 | }
45 | }
46 |
47 | public int BackgroundColor
48 | {
49 | get
50 | {
51 | return (m_Ctrls.First() as IPropertyManagerPageControl).BackgroundColor;
52 | }
53 | set
54 | {
55 | ForEach(c => c.BackgroundColor = value);
56 | }
57 | }
58 |
59 | public bool Enabled
60 | {
61 | get
62 | {
63 | return (m_Ctrls.First() as IPropertyManagerPageControl).Enabled;
64 | }
65 | set
66 | {
67 | ForEach(c => c.Enabled = value);
68 | }
69 | }
70 |
71 | public short Left
72 | {
73 | get
74 | {
75 | return (m_Ctrls.First() as IPropertyManagerPageControl).Left;
76 | }
77 | set
78 | {
79 | ForEach(c => c.Left = value);
80 | }
81 | }
82 |
83 | public int OptionsForResize
84 | {
85 | get
86 | {
87 | return (m_Ctrls.First() as IPropertyManagerPageControl).OptionsForResize;
88 | }
89 | set
90 | {
91 | ForEach(c => c.OptionsForResize = value);
92 | }
93 | }
94 |
95 | public int TextColor
96 | {
97 | get
98 | {
99 | return (m_Ctrls.First() as IPropertyManagerPageControl).TextColor;
100 | }
101 | set
102 | {
103 | ForEach(c => c.TextColor = value);
104 | }
105 | }
106 |
107 | public string Tip
108 | {
109 | get
110 | {
111 | return (m_Ctrls.First() as IPropertyManagerPageControl).Tip;
112 | }
113 | set
114 | {
115 | ForEach(c => c.Tip = value);
116 | }
117 | }
118 |
119 | public short Top
120 | {
121 | get
122 | {
123 | return (m_Ctrls.First() as IPropertyManagerPageControl).Top;
124 | }
125 | set
126 | {
127 | ForEach(c => c.Top = value);
128 | }
129 | }
130 |
131 | public bool Visible
132 | {
133 | get
134 | {
135 | return (m_Ctrls.First() as IPropertyManagerPageControl).Visible;
136 | }
137 | set
138 | {
139 | ForEach(c => c.Visible = value);
140 | }
141 | }
142 |
143 | public short Width
144 | {
145 | get
146 | {
147 | return (m_Ctrls.First() as IPropertyManagerPageControl).Width;
148 | }
149 | set
150 | {
151 | ForEach(c => c.Width = value);
152 | }
153 | }
154 |
155 | public bool Checked
156 | {
157 | get
158 | {
159 | return m_Ctrls.First().Checked;
160 | }
161 | set
162 | {
163 | ForEach(c => c.Checked = value);
164 | }
165 | }
166 |
167 | public string Caption
168 | {
169 | get
170 | {
171 | return m_Ctrls.First().Caption;
172 | }
173 | set
174 | {
175 | ForEach(c => c.Caption = value);
176 | }
177 | }
178 |
179 | public int Style
180 | {
181 | get
182 | {
183 | return m_Ctrls.First().Style;
184 | }
185 | set
186 | {
187 | ForEach(c => c.Style = value);
188 | }
189 | }
190 |
191 | public PropertyManagerPageGroup GetGroupBox()
192 | {
193 | return (m_Ctrls.First() as IPropertyManagerPageControl).GetGroupBox();
194 | }
195 |
196 | public bool SetPictureLabelByName(string ColorBitmap, string MaskBitmap)
197 | {
198 | var result = true;
199 |
200 | ForEach(c => result &= c.SetPictureLabelByName(ColorBitmap, MaskBitmap));
201 |
202 | return result;
203 | }
204 |
205 | public bool SetStandardPictureLabel(int Bitmap)
206 | {
207 | var result = true;
208 |
209 | ForEach(c => result &= c.SetStandardPictureLabel(Bitmap));
210 |
211 | return result;
212 | }
213 |
214 | public void ShowBubbleTooltip(string Title, string Message, string BmpFile)
215 | {
216 | ForEach(c => c.ShowBubbleTooltip(Title, Message, BmpFile));
217 | }
218 |
219 | private void ForEach(Action action)
220 | {
221 | foreach (TType ctrl in m_Ctrls)
222 | {
223 | action.Invoke(ctrl);
224 | }
225 | }
226 | }
227 |
228 | internal class PropertyManagerPageOptionBoxEx : PropertyManagerPageControlEx
229 | {
230 | protected override event ControlValueChangedDelegate ValueChanged;
231 |
232 | private ReadOnlyCollection m_Values;
233 |
234 | public PropertyManagerPageOptionBoxEx(int id, object tag,
235 | PropertyManagerPageOptionBox optionBox, ReadOnlyCollection values,
236 | PropertyManagerPageHandlerEx handler) : base(optionBox, id, tag, handler)
237 | {
238 | m_Values = values;
239 | m_Handler.OptionChecked += OnOptionChecked;
240 | }
241 |
242 | private int GetIndex(int id)
243 | {
244 | return id - Id;
245 | }
246 |
247 | private void OnOptionChecked(int id)
248 | {
249 | if (id >= Id && id < (Id + m_Values.Count))
250 | {
251 | ValueChanged?.Invoke(this, m_Values[GetIndex(id)]);
252 | }
253 | }
254 |
255 | protected override Enum GetSpecificValue()
256 | {
257 | for (int i = 0; i < SwSpecificControl.Controls.Length; i++)
258 | {
259 | if (SwSpecificControl.Controls[i].Checked)
260 | {
261 | return m_Values[i];
262 | }
263 | }
264 |
265 | //TODO: check how this condition works
266 | return null;
267 | }
268 |
269 | protected override void SetSpecificValue(Enum value)
270 | {
271 | var index = m_Values.IndexOf(value);
272 | SwSpecificControl.Controls[index].Checked = true;
273 | }
274 |
275 | public override void Dispose()
276 | {
277 | base.Dispose();
278 | m_Handler.OptionChecked -= OnOptionChecked;
279 | }
280 | }
281 | }
282 |
--------------------------------------------------------------------------------
/Base/Controls/PropertyManagerPagePageEx.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using SolidWorks.Interop.sldworks;
9 | using SolidWorks.Interop.swconst;
10 | using System;
11 | using System.Collections.Generic;
12 | using System.Linq;
13 | using System.Text;
14 | using Xarial.VPages.Framework.PageElements;
15 |
16 | namespace CodeStack.SwEx.PMPage.Controls
17 | {
18 | internal class PropertyManagerPagePageEx : Page
19 | where THandler : PropertyManagerPageHandlerEx, new()
20 | {
21 | internal IPropertyManagerPage2 Page { get; private set; }
22 | internal THandler Handler { get; private set; }
23 | internal ISldWorks App { get; private set; }
24 |
25 | private string m_HelpLink;
26 | private string m_WhatsNewLink;
27 |
28 | internal PropertyManagerPagePageEx(IPropertyManagerPage2 page,
29 | THandler handler, ISldWorks app, string helpLink, string whatsNewLink)
30 | {
31 | Page = page;
32 | Handler = handler;
33 | App = app;
34 | m_HelpLink = helpLink;
35 | m_WhatsNewLink = whatsNewLink;
36 |
37 | Handler.HelpRequested += OnHelpRequested;
38 | Handler.WhatsNewRequested += OnWhatsNewRequested;
39 | }
40 |
41 | private void OnWhatsNewRequested()
42 | {
43 | OpenLink(m_WhatsNewLink);
44 | }
45 |
46 | private void OnHelpRequested()
47 | {
48 | OpenLink(m_HelpLink);
49 | }
50 |
51 | private void OpenLink(string link)
52 | {
53 | if (!string.IsNullOrEmpty(link))
54 | {
55 | try
56 | {
57 | System.Diagnostics.Process.Start(link);
58 | }
59 | catch
60 | {
61 | }
62 | }
63 | else
64 | {
65 | App.SendMsgToUser2("Not available",
66 | (int)swMessageBoxIcon_e.swMbWarning, (int)swMessageBoxBtn_e.swMbOk);
67 | }
68 | }
69 |
70 | public override void Dispose()
71 | {
72 | base.Dispose();
73 | Handler.HelpRequested -= OnHelpRequested;
74 | Handler.WhatsNewRequested -= OnWhatsNewRequested;
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/Base/Controls/PropertyManagerPageSelectionBoxEx.cs:
--------------------------------------------------------------------------------
1 | //**********************
2 | //SwEx.PMPage - data driven framework for SOLIDWORKS Property Manager Pages
3 | //Copyright(C) 2019 www.codestack.net
4 | //License: https://github.com/codestackdev/swex-pmpage/blob/master/LICENSE
5 | //Product URL: https://www.codestack.net/labs/solidworks/swex/pmp/
6 | //**********************
7 |
8 | using CodeStack.SwEx.PMPage.Base;
9 | using SolidWorks.Interop.sldworks;
10 | using System;
11 | using System.Collections;
12 | using System.Collections.Generic;
13 | using System.Diagnostics;
14 | using System.Linq;
15 | using System.Runtime.InteropServices;
16 | using System.Text;
17 | using Xarial.VPages.Framework.PageElements;
18 |
19 | namespace CodeStack.SwEx.PMPage.Controls
20 | {
21 | internal class PropertyManagerPageSelectionBoxEx : PropertyManagerPageControlEx