├── 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 22 | { 23 | protected override event ControlValueChangedDelegate ValueChanged; 24 | 25 | private ISldWorks m_App; 26 | 27 | private Type m_ObjType; 28 | 29 | private ISelectionCustomFilter m_CustomFilter; 30 | 31 | public PropertyManagerPageSelectionBoxEx(ISldWorks app, int id, object tag, 32 | IPropertyManagerPageSelectionbox selBox, 33 | PropertyManagerPageHandlerEx handler, Type objType, ISelectionCustomFilter customFilter = null) 34 | : base(selBox, id, tag, handler) 35 | { 36 | m_App = app; 37 | m_ObjType = objType; 38 | m_CustomFilter = customFilter; 39 | 40 | m_Handler.SelectionChanged += OnSelectionChanged; 41 | 42 | if (m_CustomFilter != null) 43 | { 44 | m_Handler.SubmitSelection += OnSubmitSelection; 45 | } 46 | } 47 | 48 | internal IPropertyManagerPageSelectionbox SelectionBox 49 | { 50 | get 51 | { 52 | return SwSpecificControl; 53 | } 54 | } 55 | 56 | private void OnSubmitSelection(int Id, object Selection, int SelType, ref string ItemText, ref bool res) 57 | { 58 | if (Id == this.Id) 59 | { 60 | Debug.Assert(m_CustomFilter != null, "This event must not be attached if custom filter is not specified"); 61 | 62 | res = m_CustomFilter.Filter(this, Selection, 63 | (SolidWorks.Interop.swconst.swSelectType_e)SelType, ref ItemText); 64 | } 65 | } 66 | 67 | private void OnSelectionChanged(int id, int count) 68 | { 69 | if (Id == id) 70 | { 71 | ValueChanged?.Invoke(this, GetSpecificValue()); 72 | } 73 | } 74 | 75 | protected override object GetSpecificValue() 76 | { 77 | var selMgr = m_App.IActiveDoc2.ISelectionManager; 78 | 79 | if (SupportsMultiEntities) 80 | { 81 | var list = Activator.CreateInstance(m_ObjType) as IList; 82 | 83 | for (int i = 0; i < SwSpecificControl.ItemCount; i++) 84 | { 85 | var selIndex = SwSpecificControl.SelectionIndex[i]; 86 | var obj = selMgr.GetSelectedObject6(selIndex, -1); 87 | list.Add(obj); 88 | } 89 | 90 | return list; 91 | } 92 | else 93 | { 94 | Debug.Assert(SwSpecificControl.ItemCount <= 1, "Single entity only"); 95 | 96 | if (SwSpecificControl.ItemCount == 1) 97 | { 98 | var selIndex = SwSpecificControl.SelectionIndex[0]; 99 | var obj = selMgr.GetSelectedObject6(selIndex, -1); 100 | return obj; 101 | } 102 | else 103 | { 104 | return null; 105 | } 106 | } 107 | } 108 | 109 | protected override void SetSpecificValue(object value) 110 | { 111 | SwSpecificControl.SetSelectionFocus(); 112 | 113 | if (value != null) 114 | { 115 | var disps = new List(); 116 | 117 | if (SupportsMultiEntities) 118 | { 119 | foreach (var item in value as IList) 120 | { 121 | disps.Add(new DispatchWrapper(item)); 122 | } 123 | } 124 | else 125 | { 126 | disps.Add(new DispatchWrapper(value)); 127 | } 128 | 129 | var selMgr = m_App.IActiveDoc2.ISelectionManager; 130 | 131 | var selData = selMgr.CreateSelectData(); 132 | selData.Mark = SwSpecificControl.Mark; 133 | 134 | m_App.IActiveDoc2.Extension.MultiSelect2(disps.ToArray(), true, selData); 135 | } 136 | } 137 | 138 | private bool SupportsMultiEntities 139 | { 140 | get 141 | { 142 | return typeof(IList).IsAssignableFrom(m_ObjType); 143 | } 144 | } 145 | 146 | public override void Dispose() 147 | { 148 | base.Dispose(); 149 | m_Handler.SelectionChanged -= OnSelectionChanged; 150 | m_Handler.SubmitSelection -= OnSubmitSelection; 151 | } 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /Base/Controls/PropertyManagerPageTabEx.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 tab control in property manager page 15 | /// 16 | public interface IPropertyManagerPageTabEx 17 | { 18 | /// 19 | /// Pointer to the underlying tab control 20 | /// 21 | IPropertyManagerPageTab Tab { get; } 22 | } 23 | 24 | internal class PropertyManagerPageTabEx : PropertyManagerPageGroupBaseEx, IPropertyManagerPageTabEx 25 | where THandler : PropertyManagerPageHandlerEx, new() 26 | { 27 | public IPropertyManagerPageTab Tab { 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 | /// Not supported 46 | /// 47 | [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] 48 | public override bool Visible 49 | { 50 | get 51 | { 52 | return true; 53 | } 54 | set 55 | { 56 | } 57 | } 58 | 59 | internal PropertyManagerPageTabEx(int id, object tag, THandler handler, 60 | IPropertyManagerPageTab tab, 61 | ISldWorks app, PropertyManagerPagePageEx parentPage) : base(id, tag, handler, app, parentPage) 62 | { 63 | Tab = tab; 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Base/Controls/PropertyManagerPageTextBoxEx.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 PropertyManagerPageTextBoxEx : PropertyManagerPageControlEx 18 | { 19 | protected override event ControlValueChangedDelegate ValueChanged; 20 | 21 | internal PropertyManagerPageTextBoxEx(int id, object tag, 22 | IPropertyManagerPageTextbox textBox, 23 | PropertyManagerPageHandlerEx handler) : base(textBox, id, tag, handler) 24 | { 25 | m_Handler.TextChanged += OnTextChanged; 26 | } 27 | 28 | private void OnTextChanged(int id, string text) 29 | { 30 | if (Id == id) 31 | { 32 | ValueChanged?.Invoke(this, text); 33 | } 34 | } 35 | 36 | protected override string GetSpecificValue() 37 | { 38 | return SwSpecificControl.Text; 39 | } 40 | 41 | protected override void SetSpecificValue(string value) 42 | { 43 | SwSpecificControl.Text = value; 44 | } 45 | 46 | public override void Dispose() 47 | { 48 | base.Dispose(); 49 | m_Handler.TextChanged -= OnTextChanged; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Base/Data/ControlIcon.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 System.Collections.Generic; 10 | using System.Drawing; 11 | 12 | namespace CodeStack.SwEx.PMPage.Data 13 | { 14 | internal class ControlIcon : IIcon 15 | { 16 | internal Image Icon { get; private set; } 17 | internal Image Mask { get; private set; } 18 | 19 | public Color TransparencyKey 20 | { 21 | get 22 | { 23 | return Color.White; 24 | } 25 | } 26 | 27 | private readonly Size m_Size; 28 | 29 | internal ControlIcon(Image icon) 30 | : this(icon, CreateMask(icon)) 31 | { 32 | } 33 | 34 | internal ControlIcon(Image icon, Size size) 35 | : this(icon, CreateMask(icon), size) 36 | { 37 | } 38 | 39 | internal ControlIcon(Image icon, Image mask) 40 | : this(icon, mask, new Size(24, 24)) 41 | { 42 | } 43 | 44 | internal ControlIcon(Image icon, Image mask, Size size) 45 | { 46 | Icon = icon; 47 | Mask = mask; 48 | m_Size = size; 49 | } 50 | 51 | public IEnumerable GetHighResolutionIconSizes() 52 | { 53 | return GetIconSizes(); 54 | } 55 | 56 | public IEnumerable GetIconSizes() 57 | { 58 | yield return new IconSizeInfo(Icon, m_Size); 59 | yield return new IconSizeInfo(Mask, m_Size); 60 | } 61 | 62 | private static Image CreateMask(Image icon) 63 | { 64 | return IconsConverter.ReplaceColor(icon, 65 | new IconsConverter.ColorReplacerDelegate((ref byte r, ref byte g, ref byte b, ref byte a) => 66 | { 67 | var mask = (byte)(255 - a); 68 | r = mask; 69 | g = mask; 70 | b = mask; 71 | a = 255; 72 | })); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Base/Data/PageSpec.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.ComponentModel; 12 | using System.Linq; 13 | using System.Text; 14 | using SolidWorks.Interop.swconst; 15 | using System.Drawing; 16 | 17 | namespace CodeStack.SwEx.PMPage.Data 18 | { 19 | [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] 20 | public class PageSpec : IPageSpec 21 | { 22 | public Image Icon 23 | { 24 | get; 25 | protected set; 26 | } 27 | 28 | public swPropertyManagerPageOptions_e Options 29 | { 30 | get; 31 | protected set; 32 | } 33 | 34 | public string Title 35 | { 36 | get; 37 | protected set; 38 | } 39 | 40 | public PageSpec(string title, Image icon, swPropertyManagerPageOptions_e opts) 41 | { 42 | Title = title; 43 | Icon = icon; 44 | Options = opts; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Base/Data/TabIcon.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 System.Collections.Generic; 10 | using System.Drawing; 11 | 12 | namespace CodeStack.SwEx.PMPage.Data 13 | { 14 | internal class TabIcon : IIcon 15 | { 16 | internal Image Icon { get; private set; } 17 | 18 | public Color TransparencyKey 19 | { 20 | get 21 | { 22 | return Color.White; 23 | } 24 | } 25 | 26 | internal TabIcon(Image icon) 27 | { 28 | Icon = icon; 29 | } 30 | 31 | public IEnumerable GetHighResolutionIconSizes() 32 | { 33 | return GetIconSizes(); 34 | } 35 | 36 | public IEnumerable GetIconSizes() 37 | { 38 | yield return new IconSizeInfo(Icon, new Size(16, 18)); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Base/Data/TitleIcon.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 System.Collections.Generic; 10 | using System.ComponentModel; 11 | using System.Drawing; 12 | 13 | namespace CodeStack.SwEx.PMPage.Data 14 | { 15 | internal class TitleIcon : IIcon 16 | { 17 | internal Image Icon { get; private set; } 18 | 19 | public Color TransparencyKey 20 | { 21 | get 22 | { 23 | return Color.White; 24 | } 25 | } 26 | 27 | internal TitleIcon(Image icon) 28 | { 29 | Icon = icon; 30 | } 31 | 32 | public IEnumerable GetHighResolutionIconSizes() 33 | { 34 | return GetIconSizes(); 35 | } 36 | 37 | public IEnumerable GetIconSizes() 38 | { 39 | yield return new IconSizeInfo(Icon, new Size(22, 22)); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Base/Helper.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 System; 10 | using System.Collections.Generic; 11 | using System.ComponentModel; 12 | using System.Linq; 13 | using System.Text; 14 | 15 | namespace CodeStack.SwEx.PMPage 16 | { 17 | internal static class Helper 18 | { 19 | internal static Dictionary GetEnumFields(Type enumType) 20 | { 21 | if (!enumType.IsEnum) 22 | { 23 | throw new InvalidCastException($"{enumType.FullName} must be an enum"); 24 | } 25 | 26 | var enumValues = Enum.GetValues(enumType).Cast().ToList(); 27 | 28 | var values = enumValues.ToDictionary(e => e, 29 | e => 30 | { 31 | var text = ""; 32 | 33 | e.TryGetAttribute(a => text = a.DisplayName); 34 | 35 | if (string.IsNullOrEmpty(text)) 36 | { 37 | text = e.ToString(); 38 | } 39 | 40 | return text; 41 | 42 | }); 43 | 44 | return values; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Base/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyTitle("SwEx.PMPage")] 5 | [assembly: AssemblyDescription("Framework for building SOLIDWORKS Property Manager Pages")] 6 | [assembly: AssemblyConfiguration("")] 7 | [assembly: AssemblyCompany("CodeStack")] 8 | [assembly: AssemblyProduct("SwEx.PMPage")] 9 | [assembly: AssemblyCopyright("Copyright © CodeStack 2019")] 10 | [assembly: AssemblyTrademark("")] 11 | [assembly: AssemblyCulture("")] 12 | 13 | [assembly: ComVisible(false)] 14 | 15 | [assembly: Guid("8ec761a6-e338-4ed1-af15-5f159341da9c")] 16 | 17 | [assembly: AssemblyVersion("0.7.2.0")] 18 | [assembly: AssemblyFileVersion("0.7.2.0")] 19 | -------------------------------------------------------------------------------- /Base/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace CodeStack.SwEx.PMPage.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CodeStack.SwEx.PMPage.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized resource of type System.Drawing.Bitmap. 65 | /// 66 | internal static System.Drawing.Bitmap DefaultBitmap { 67 | get { 68 | object obj = ResourceManager.GetObject("DefaultBitmap", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Base/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | ..\Resources\DefaultBitmap.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 123 | 124 | -------------------------------------------------------------------------------- /Base/PropertyManagerPageBuilder.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.Constructors; 10 | using CodeStack.SwEx.PMPage.Controls; 11 | using SolidWorks.Interop.sldworks; 12 | using Xarial.VPages.Core; 13 | using Xarial.VPages.Framework.Base; 14 | using Xarial.VPages.Framework.Binders; 15 | using Xarial.VPages.Framework.PageElements; 16 | using System.Linq; 17 | using System.Collections.Generic; 18 | using CodeStack.SwEx.Common.Diagnostics; 19 | using System; 20 | using CodeStack.SwEx.PMPage.Base; 21 | using CodeStack.SwEx.PMPage.Attributes; 22 | using CodeStack.SwEx.PMPage.Data; 23 | using System.Reflection; 24 | 25 | namespace CodeStack.SwEx.PMPage 26 | { 27 | internal class PropertyManagerPageBuilder 28 | : PageBuilder, PropertyManagerPageGroupBaseEx, IPropertyManagerPageControlEx> 29 | where THandler : PropertyManagerPageHandlerEx, new() 30 | { 31 | private class PmpTypeDataBinder : TypeDataBinder 32 | { 33 | internal event Action> BeforeControlsDataLoad; 34 | internal event Func GetPageAttributeSet; 35 | protected override void OnBeforeControlsDataLoad(IEnumerable bindings) 36 | { 37 | base.OnBeforeControlsDataLoad(bindings); 38 | 39 | BeforeControlsDataLoad?.Invoke(bindings); 40 | } 41 | 42 | protected override void OnGetPageAttributeSet(Type pageType, ref IAttributeSet attSet) 43 | { 44 | attSet = GetPageAttributeSet?.Invoke(attSet); 45 | } 46 | } 47 | 48 | private class PmpAttributeSet : IAttributeSet 49 | { 50 | private readonly IAttributeSet m_BaseAttSet; 51 | private readonly string m_Title; 52 | 53 | public Type BoundType => m_BaseAttSet.BoundType; 54 | public string Description => m_BaseAttSet.Description; 55 | public int Id => m_BaseAttSet.Id; 56 | public string Name => m_Title; 57 | public object Tag => m_BaseAttSet.Tag; 58 | public MemberInfo BoundMemberInfo => m_BaseAttSet.BoundMemberInfo; 59 | 60 | public void Add(TAtt att) where TAtt : Xarial.VPages.Framework.Base.IAttribute 61 | { 62 | m_BaseAttSet.Add(att); 63 | } 64 | 65 | public TAtt Get() where TAtt : Xarial.VPages.Framework.Base.IAttribute 66 | { 67 | return m_BaseAttSet.Get(); 68 | } 69 | 70 | public IEnumerable GetAll() where TAtt : Xarial.VPages.Framework.Base.IAttribute 71 | { 72 | return m_BaseAttSet.GetAll(); 73 | } 74 | 75 | public bool Has() where TAtt : Xarial.VPages.Framework.Base.IAttribute 76 | { 77 | return m_BaseAttSet.Has(); 78 | } 79 | 80 | internal PmpAttributeSet(IAttributeSet baseAttSet, IPageSpec pageSpec) 81 | { 82 | m_BaseAttSet = baseAttSet; 83 | 84 | if (!Has()) 85 | { 86 | Add(new PageOptionsAttribute(new TitleIcon(pageSpec.Icon), pageSpec.Options)); 87 | } 88 | 89 | if (string.IsNullOrEmpty(baseAttSet.Name) 90 | || baseAttSet.Name == BoundType.Name) 91 | { 92 | m_Title = pageSpec.Title; 93 | } 94 | else 95 | { 96 | m_Title = baseAttSet.Name; 97 | } 98 | } 99 | } 100 | 101 | private readonly IPropertyManagerPageElementConstructor[] m_CtrlsContstrs; 102 | private readonly PmpTypeDataBinder m_DataBinder; 103 | private readonly IPageSpec m_PageSpec; 104 | 105 | internal PropertyManagerPageBuilder(ISldWorks app, IconsConverter iconsConv, THandler handler, IPageSpec pageSpec, ILogger logger) 106 | : this(new PmpTypeDataBinder(), 107 | new PropertyManagerPageConstructor(app, iconsConv, handler), 108 | new PropertyManagerPageGroupConstructor(), 109 | new PropertyManagerPageTextBoxConstructor(app, iconsConv), 110 | new PropertyManagerPageNumberBoxConstructor(app, iconsConv), 111 | new PropertyManagerPageCheckBoxConstructor(app, iconsConv), 112 | new PropertyManagerPageComboBoxConstructor(app, iconsConv), 113 | new PropertyManagerPageSelectionBoxConstructor(app, iconsConv, logger), 114 | new PropertyManagerPageOptionBoxConstructor(app, iconsConv), 115 | new PropertyManagerPageButtonConstructor(app, iconsConv), 116 | new PropertyManagerPageBitmapConstructor(app, iconsConv), 117 | new PropertyManagerPageTabConstructor(iconsConv)) 118 | { 119 | m_PageSpec = pageSpec; 120 | } 121 | 122 | private PropertyManagerPageBuilder(PmpTypeDataBinder dataBinder, PropertyManagerPageConstructor pageConstr, 123 | params IPropertyManagerPageElementConstructor[] ctrlsContstrs) 124 | : base(dataBinder, pageConstr, ctrlsContstrs) 125 | { 126 | m_DataBinder = dataBinder; 127 | m_CtrlsContstrs = ctrlsContstrs; 128 | 129 | m_DataBinder.GetPageAttributeSet += OnGetPageAttributeSet; 130 | m_DataBinder.BeforeControlsDataLoad += OnBeforeControlsDataLoad; 131 | } 132 | 133 | private IAttributeSet OnGetPageAttributeSet(IAttributeSet attSet) 134 | { 135 | if (m_PageSpec != null) 136 | { 137 | return new PmpAttributeSet(attSet, m_PageSpec); 138 | } 139 | 140 | return attSet; 141 | } 142 | 143 | private void OnBeforeControlsDataLoad(IEnumerable bindings) 144 | { 145 | var ctrls = bindings.Select(b => b.Control) 146 | .OfType().ToArray(); 147 | 148 | foreach (var ctrlGroup in ctrls.GroupBy(c => c.GetType())) 149 | { 150 | foreach (var constr in m_CtrlsContstrs.Where(c => c.ControlType == ctrlGroup.Key)) 151 | { 152 | constr.PostProcessControls(ctrlGroup); 153 | } 154 | } 155 | } 156 | 157 | protected override void UpdatePageDependenciesState(PropertyManagerPagePageEx page) 158 | { 159 | //NOTE: skipping the updated before page is shown otherwise control state won't be updated correctly 160 | //instead updating it with UpdateAll after page is shown 161 | } 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /Base/PropertyManagerPageEx.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.Attributes; 9 | using CodeStack.SwEx.Common.Base; 10 | using CodeStack.SwEx.Common.Icons; 11 | using CodeStack.SwEx.PMPage.Attributes; 12 | using CodeStack.SwEx.PMPage.Base; 13 | using CodeStack.SwEx.PMPage.Controls; 14 | using SolidWorks.Interop.sldworks; 15 | using System; 16 | using System.Collections; 17 | using System.Collections.Generic; 18 | using System.Linq; 19 | using Xarial.VPages.Framework.Base; 20 | using CodeStack.SwEx.Common.Diagnostics; 21 | using System.ComponentModel; 22 | 23 | namespace CodeStack.SwEx.PMPage 24 | { 25 | /// 26 | [ModuleInfo("SwEx.PMPage")] 27 | public class PropertyManagerPageEx : IPropertyManagerPageEx, IDisposable, IModule 28 | where THandler : PropertyManagerPageHandlerEx, new() 29 | { 30 | private PropertyManagerPageBuilder m_PmpBuilder; 31 | private PropertyManagerPagePageEx m_ActivePage; 32 | 33 | private IEnumerable m_Controls; 34 | 35 | /// 36 | public TModel Model { get; private set; } 37 | 38 | /// 39 | public THandler Handler 40 | { 41 | get 42 | { 43 | return m_Handler; 44 | } 45 | } 46 | 47 | /// 48 | public IEnumerable Controls 49 | { 50 | get 51 | { 52 | return m_Controls; 53 | } 54 | } 55 | 56 | public ILogger Logger 57 | { 58 | get 59 | { 60 | return m_Logger; 61 | } 62 | } 63 | 64 | private readonly IconsConverter m_IconsConv; 65 | private readonly ILogger m_Logger; 66 | private readonly THandler m_Handler; 67 | private readonly ISldWorks m_App; 68 | 69 | /// Creates instance of property manager page 70 | /// Pointer to session of SOLIDWORKS where the property manager page to be created 71 | public PropertyManagerPageEx(ISldWorks app) 72 | : this(app, null) 73 | { 74 | 75 | } 76 | 77 | [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] 78 | public PropertyManagerPageEx(ISldWorks app, IPageSpec pageSpec) 79 | { 80 | m_App = app; 81 | 82 | m_Logger = LoggerFactory.Create(this); 83 | 84 | m_IconsConv = new IconsConverter(); 85 | 86 | m_Handler = new THandler(); 87 | 88 | m_PmpBuilder = new PropertyManagerPageBuilder(app, m_IconsConv, m_Handler, pageSpec, Logger); 89 | } 90 | 91 | /// 92 | public void Show(TModel model) 93 | { 94 | Logger.Log("Opening page"); 95 | 96 | const int OPTS_DEFAULT = 0; 97 | 98 | DisposeActivePage(); 99 | 100 | m_App.IActiveDoc2.ClearSelection2(true); 101 | 102 | m_ActivePage = m_PmpBuilder.CreatePage(model); 103 | m_Controls = m_ActivePage.Binding.Bindings.Select(b => b.Control) 104 | .OfType().ToArray(); 105 | 106 | m_ActivePage.Page.Show2(OPTS_DEFAULT); 107 | 108 | //updating control states 109 | m_ActivePage.Binding.Dependency.UpdateAll(); 110 | } 111 | 112 | private void DisposeActivePage() 113 | { 114 | if (m_ActivePage != null) 115 | { 116 | foreach (var ctrl in m_ActivePage.Binding.Bindings.Select(b => b.Control).OfType()) 117 | { 118 | ctrl.Dispose(); 119 | } 120 | 121 | m_ActivePage = null; 122 | } 123 | } 124 | 125 | public void Dispose() 126 | { 127 | Logger.Log("Disposing page"); 128 | 129 | DisposeActivePage(); 130 | 131 | m_IconsConv.Dispose(); 132 | } 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /Base/Resources/DefaultBitmap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codestackdev/swex-pmpage/a8d5eac8d3eb7cf1b4b50dba32cb263c95fc21fe/Base/Resources/DefaultBitmap.png -------------------------------------------------------------------------------- /Base/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Base/readme.txt: -------------------------------------------------------------------------------- 1 | Changelog: https://docs.codestack.net/swex/pmpage/html/version-history.htm 2 | User Guide: https://www.codestack.net/labs/solidworks/swex/pmpage/ 3 | API Reference: https://docs.codestack.net/swex/pmpage/html/welcome.htm -------------------------------------------------------------------------------- /HelpDoc/Common.tokens: -------------------------------------------------------------------------------- 1 |  2 | 3 | Type of the resource static class 4 | -------------------------------------------------------------------------------- /HelpDoc/Content/VersionHistory/VersionHistory.aml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | The topics in this section describe the various changes made to the SwEx.Pmp over the life of the project. 6 | 7 | 8 |
9 | Version History 10 | 11 | Select a version below to see a description of its changes. 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
64 | 65 | 66 | 67 | 68 | 69 |
70 |
71 | -------------------------------------------------------------------------------- /HelpDoc/Content/VersionHistory/v0.1.0.aml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Version 0.1.0 was released on August 17 2018. 6 | 7 | 8 | 9 |
10 | Initial beta release 11 | 12 | 13 | 14 | 15 | Added support for number box, selection box, chech box, group box, text box 16 | 17 | 18 | Added the handlers for closing the property page with an ability to cancel the closing 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 |
30 |
31 | -------------------------------------------------------------------------------- /HelpDoc/Content/VersionHistory/v0.2.0.aml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Version 0.2.0 was released on September 2 2018 6 | 7 | 8 | 9 |
10 | Second beta release 11 | 12 | 13 | 14 | 15 | Added support for combo box 16 | 17 | 18 | Created public PropertyManagerPageEx for managing the property page 19 | 20 | 21 | Added documentation 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 | 31 | 32 | 33 |
34 |
35 | -------------------------------------------------------------------------------- /HelpDoc/Content/VersionHistory/v0.4.0.aml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Version 0.4.0 was released on November 10 2018 6 | 7 | 8 | 9 |
10 | First stable release 11 | 12 | 13 | 14 | 15 | Added support for control tags and dependencies 16 | 17 | 18 | Exposed control interface to access native SOLIDWORKS Property Manager Page Control 19 | 20 | 21 | Added support for custom icons for controls and property page 22 | 23 | 24 | Added the ability to add message to property page 25 | 26 | 27 | Added ability to specify display text for enumeration fields used as items for combo box control 28 | 29 | 30 | Added the ability to provide custom selection filter for the selection box control 31 | 32 | 33 | Added the ability to ignore properties from creation property page controls 34 | 35 | 36 | 37 | 38 |
39 | 40 | 41 | 42 | 43 | 44 |
45 |
46 | -------------------------------------------------------------------------------- /HelpDoc/Content/VersionHistory/v0.4.5.aml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Version 0.4.5 was released on December 31 2018 6 | 7 | 8 | 9 |
10 | Enhancements and bug fixes 11 | 12 | 13 | 14 | 15 | 16 | 17 | Issue 2 18 | https://github.com/codestackdev/swex-pmpage/issues/2 19 | Need to clear selection before showing property page with selection boxes 20 | 21 | 22 | 23 | 24 | 25 | Issue 3 26 | https://github.com/codestackdev/swex-pmpage/issues/3 27 | Selected entities appeared in wrong selection boxes 28 | 29 | 30 | 31 | 32 | 33 | Issue 6 34 | https://github.com/codestackdev/swex-pmpage/issues/6 35 | Enable dependency doesn't work when page is reloaded 36 | 37 | 38 | 39 | 40 | 41 | Issue 7 42 | https://github.com/codestackdev/swex-pmpage/issues/7 43 | Explain better how to handle multiple selection boxes in one page 44 | 45 | 46 | 47 | 48 | 49 |
50 | 51 | 52 | 53 | 54 | 55 |
56 |
57 | -------------------------------------------------------------------------------- /HelpDoc/Content/VersionHistory/v0.5.0.aml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Version 0.5.0 was released on August 25 2019 6 | 7 | 8 | 9 |
10 | Removed members 11 | 12 | 13 | 14 | 15 | 16 | CodeStack.SwEx.PMPage.Attributes.ComboBoxItemTextAttribute. Replaced with Common.Attributes.TitleAttribute 17 | 18 | 19 | 20 | 21 | CodeStack.SwEx.PMPage.Base.IPropertyManagerPageEx{THandler, TModel}.Show. Replaced with CodeStack.SwEx.PMPage.Base.IPropertyManagerPageEx{THandler, TModel}.Show(TModel model) 22 | 23 | 24 | 25 | 26 | CodeStack.SwEx.PMPage.PropertyManagerPageEx(TModel model, ISldWorks app). Replaced with CodeStack.SwEx.PMPage.PropertyManagerPageEx(ISldWorks app) 27 | 28 | 29 | 30 | 31 | 32 |
33 | 34 |
35 | Enhancements and bug fixes 36 | 37 | 38 | 39 | 40 | 41 | 42 | Issue 8 43 | https://github.com/codestackdev/swex-pmpage/issues/8 44 | Tooltip is not displayed if ClosingArg.Cancel = true but either title or description is not specified 45 | 46 | 47 | 48 | 49 | 50 | Issue 9 51 | https://github.com/codestackdev/swex-pmpage/issues/9 52 | Need to support IconAttribute for the control icons 53 | 54 | 55 | 56 | 57 | 58 | Issue 10 59 | https://github.com/codestackdev/swex-pmpage/issues/10 60 | Need to support IconAttribute for the page title icon 61 | 62 | 63 | 64 | 65 | 66 | Issue 4 (Common) 67 | https://github.com/codestackdev/swex-common/issues/4 68 | Protect transparency key when generating icons with IconConverter utility 69 | 70 | 71 | 72 | 73 | 74 |
75 | 76 | 77 | 78 | 79 | 80 |
81 |
82 | -------------------------------------------------------------------------------- /HelpDoc/Content/VersionHistory/v0.6.0.aml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Version 0.6.0 and 0.6.1 were released on September 8 2019 6 | 7 | 8 | 9 |
10 | Enhancements 11 | 12 | 13 | 14 | 15 | 16 | 17 | Issue 11 18 | https://github.com/codestackdev/swex-pmpage/issues/11 19 | Add ability to render enum as option boxes (in addition to combobox) 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
32 |
33 | -------------------------------------------------------------------------------- /HelpDoc/Content/VersionHistory/v0.7.0.aml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Version 0.7.0 was released on September 22 2019 6 | 7 | 8 | 9 |
10 | Enhancements 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | Issue 12 19 | https://github.com/codestackdev/swex-pmpage/issues/12 20 | Add the ability to create Tabs 21 | 22 | 23 | 24 | 25 | 26 | 27 | Issue 13 28 | https://github.com/codestackdev/swex-pmpage/issues/13 29 | Need to be able to define button 30 | 31 | 32 | 33 | 34 | 35 | 36 | Issue 18 37 | https://github.com/codestackdev/swex-pmpage/issues/18 38 | Add an option to create picture in the property manager page 39 | 40 | 41 | 42 | 43 | 44 | 45 | Issue 19 46 | https://github.com/codestackdev/swex-pmpage/issues/19 47 | Need support for INotifyPropertyChanged 48 | 49 | 50 | 51 | 52 | 53 | 54 |
55 | 56 | 57 | 58 | 59 | 60 |
61 |
62 | -------------------------------------------------------------------------------- /HelpDoc/Content/VersionHistory/v0.7.1.aml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Version 0.7.1 was released on October 4 2019 6 | 7 | 8 | 9 |
10 | Other 11 | 12 | 13 | 14 | 15 | 16 | Updated SwEx.Common to version 0.9.9 17 | 18 | 19 | 20 | 21 | Added the backward compatibility to version SOLIDWORKS 2012 onwards 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 | 32 |
33 |
34 | -------------------------------------------------------------------------------- /HelpDoc/Content/VersionHistory/v0.7.2.aml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Version 0.7.2 was released on November 10 2019 6 | 7 | 8 | 9 |
10 | Bug fixes 11 | 12 | 13 | 14 | 15 | 16 | 17 | Issue 21 18 | https://github.com/codestackdev/swex-pmpage/issues/21 19 | DependentOn attribute doesn't work for groups and tabs 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
32 |
33 | -------------------------------------------------------------------------------- /HelpDoc/Content/Welcome.aml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SwEx.PMPage enables SOLIDWORKS developers to develop property manager pages based on the data model 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /HelpDoc/ContentLayout.content: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /HelpDoc/HelpDoc.shfbproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 6 | Debug 7 | AnyCPU 8 | 2.0 9 | 33b3755c-c91a-4114-aa71-33107995e3f0 10 | 2017.9.26.0 11 | 12 | HelpDoc 13 | HelpDoc 14 | HelpDoc 15 | 16 | .NET Framework 4.5 17 | .\Help\ 18 | HelpDoc 19 | en-US 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 100 30 | OnlyWarningsAndErrors 31 | Website 32 | False 33 | True 34 | False 35 | True 36 | 1.0.0.0 37 | 2 38 | False 39 | C#, Visual Basic, Managed C++ 40 | Blank 41 | False 42 | VS2013 43 | False 44 | MemberName 45 | SwEx.PMPage 46 | AboveNamespaces 47 | InheritedMembers, Protected, EditorBrowsableNever, NonBrowsable 48 | https://www.codestack.net 49 | Copyright &#169%3b CodeStack 2018 50 | codestack.net%40gmail.com 51 | Contact Us 52 | SwEx.PMPage is a library for developing SOLIDWORKS property manager pages 53 | 54 | 55 | 56 | 57 | Main classes for SwEx.PMPage framework 58 | Attributes collection for SwEx.PMPage framework 59 | Base classes and interfaces for SwEx.PMPage framework 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | {@TokenFiles} 81 | 82 | 83 | 84 | 85 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 136 | 137 | 138 | 139 | 140 | 141 | OnBuildSuccess 142 | 143 | -------------------------------------------------------------------------------- /HelpDoc/icons/Help.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codestackdev/swex-pmpage/a8d5eac8d3eb7cf1b4b50dba32cb263c95fc21fe/HelpDoc/icons/Help.png -------------------------------------------------------------------------------- /HelpDoc/icons/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codestackdev/swex-pmpage/a8d5eac8d3eb7cf1b4b50dba32cb263c95fc21fe/HelpDoc/icons/favicon.ico -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Documentation](https://img.shields.io/badge/-Documentation-green.svg)](https://www.codestack.net/labs/solidworks/swex/pmpage/) 2 | [![NuGet](https://img.shields.io/nuget/v/CodeStack.SwEx.PMPage.svg)](https://www.nuget.org/packages/CodeStack.SwEx.PMPage/) 3 | [![Issues](https://img.shields.io/github/issues/codestackdev/swex-pmpage.svg)](https://github.com/codestackdev/swex-pmpage/issues) 4 | 5 | # SwEx.PMPage 6 | ![SwEx.PMPage](https://www.codestack.net/labs/solidworks/swex/pmpage/logo.png) 7 | Inspired by PropertyGrid Control in .NET Framework, SwEx.PMPage brings the flexibility of data model driven User Interface into SOLIDWORKS API. 8 | 9 | Framework allows to use data model structure as a driver of the User Interface. Framework will automatically generate required interface and implement the binding of the model. 10 | 11 | This will greatly reduce the implementation time as well as make the property pages scalable, easily maintainable and extendable. 12 | 13 | ## Getting started 14 | 15 | Start by defining the data model required to be filled by property manager page. 16 | 17 | #### C# 18 | ~~~ cs 19 | public class DataModel 20 | { 21 | public string Text { get; set; } 22 | public int Size { get; set; } = 48; 23 | public double Number { get;set; } = 10.5; 24 | } 25 | ~~~ 26 | 27 | #### VB.NET 28 | ~~~ vb 29 | Public Class DataModel 30 | Public Property Text As String 31 | Public Property Size As Integer = 48 32 | Public Property Number As Double = 10.5 33 | End Class 34 | ~~~ 35 | 36 | Create handler for property manager page by inheriting the public COM-visible class from [PropertyManagerPageHandlerEx](https://docs.codestack.net/swex/pmpage/html/T_CodeStack_SwEx_PMPage_PropertyManagerPageHandlerEx.htm) class. 37 | 38 | This class will be instantiated by the framework and will allow handling the property manager specific events from the add-in. 39 | 40 | #### C# 41 | ~~~ cs 42 | [ComVisible(true)] 43 | public class MyPMPageHandler : PropertyManagerPageHandlerEx 44 | { 45 | } 46 | ~~~ 47 | 48 | #### VB.NET 49 | ~~~ vb 50 | 51 | Public Class MyPMPageHandler 52 | Inherits PropertyManagerPageHandlerEx 53 | End Class 54 | ~~~ 55 | 56 | Create instance of the property manager page by passing the type of the handler and data model instance into the generic arguments 57 | 58 | #### C# 59 | ~~~ cs 60 | private PropertyManagerPageEx m_MyPage; 61 | private DataModel m_Data = new DataModel(); 62 | ... 63 | m_Page = new PropertyManagerPageEx(m_Data, m_App); 64 | m_Page.Show(); 65 | ~~~ 66 | 67 | #### VB.NET 68 | ~~~ vb 69 | Dim m_MyPage As PropertyManagerPageEx(Of MyPMPageHandler, DataModel) 70 | Dim m_Data As DataModel = New DataModel() 71 | ... 72 | m_Page = New PropertyManagerPageEx(Of MyPMPageHandler, DataModel)(m_Data, m_App) 73 | m_Page.Show() 74 | ~~~ 75 | 76 | Refer documentation and API reference for more information about additional options. -------------------------------------------------------------------------------- /Samples/AddIn/AddIn.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Local 5 | 8.0.50727 6 | 2.0 7 | {7ACEDAA9-2DE8-4485-837A-E7D58812A6DC} 8 | Debug 9 | AnyCPU 10 | 11 | 12 | 13 | 14 | SwVPagesSample 15 | 16 | 17 | JScript 18 | Grid 19 | IE50 20 | false 21 | Library 22 | SwVPagesSample 23 | OnBuildSuccess 24 | 25 | 26 | 27 | 28 | 29 | 30 | C:\Program Files\SOLIDWORKS Corp\SOLIDWORKS (2)\\SldWorks.exe 31 | Program 32 | v4.0 33 | 2.0 34 | 35 | publish\ 36 | true 37 | Disk 38 | false 39 | Foreground 40 | 7 41 | Days 42 | false 43 | false 44 | true 45 | 0 46 | 1.0.0.%2a 47 | false 48 | false 49 | true 50 | 51 | 52 | bin\Debug\ 53 | false 54 | 285212672 55 | false 56 | 57 | 58 | DEBUG;TRACE 59 | 60 | 61 | true 62 | 4096 63 | false 64 | 65 | 66 | false 67 | true 68 | false 69 | false 70 | 4 71 | full 72 | prompt 73 | 74 | 75 | bin\Release\ 76 | false 77 | 285212672 78 | false 79 | 80 | 81 | TRACE 82 | 83 | 84 | false 85 | 4096 86 | false 87 | 88 | 89 | true 90 | true 91 | false 92 | false 93 | 4 94 | none 95 | prompt 96 | 97 | 98 | false 99 | 100 | 101 | 102 | ..\..\packages\CodeStack.SwEx.Common.0.9.9\lib\net40\CodeStack.SwEx.Common.dll 103 | 104 | 105 | ..\..\packages\CodeStack.SwEx.Common.0.9.9\lib\net40\SolidWorks.Interop.sldworks.dll 106 | False 107 | 108 | 109 | ..\..\packages\CodeStack.SwEx.Common.0.9.9\lib\net40\SolidWorks.Interop.swconst.dll 110 | False 111 | 112 | 113 | ..\..\packages\CodeStack.SwEx.Common.0.9.9\lib\net40\SolidWorks.Interop.swpublished.dll 114 | False 115 | 116 | 117 | ..\..\packages\CodeStack.SwEx.Common.0.9.9\lib\net40\SolidWorksTools.dll 118 | 119 | 120 | System 121 | 122 | 123 | System.Data 124 | 125 | 126 | System.Drawing 127 | 128 | 129 | 130 | System.XML 131 | 132 | 133 | ..\..\packages\Xarial.VPages.Framework.0.4.0\lib\net40\Xarial.VPages.Framework.dll 134 | True 135 | 136 | 137 | 138 | 139 | Code 140 | 141 | 142 | True 143 | True 144 | Resources.resx 145 | 146 | 147 | 148 | 149 | Code 150 | 151 | 152 | 153 | 154 | 155 | ResXFileCodeGenerator 156 | Resources.Designer.cs 157 | 158 | 159 | 160 | 161 | False 162 | .NET Framework 3.5 SP1 163 | true 164 | 165 | 166 | 167 | 168 | {8ec761a6-e338-4ed1-af15-5f159341da9c} 169 | Base 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | "%25Windir%25\Microsoft.NET\Framework64\v4.0.30319\regasm" /codebase "$(TargetPath)" 184 | 185 | -------------------------------------------------------------------------------- /Samples/AddIn/DataModel.cs: -------------------------------------------------------------------------------- 1 | using CodeStack.SwEx.PMPage.Attributes; 2 | using SolidWorks.Interop.swconst; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Drawing; 8 | using System.ComponentModel; 9 | using SolidWorks.Interop.sldworks; 10 | using CodeStack.SwEx.PMPage.Base; 11 | using CodeStack.SwEx.PMPage.Controls; 12 | using SwVPagesSample.Properties; 13 | using CodeStack.SwEx.Common.Attributes; 14 | using System.Windows.Forms; 15 | 16 | namespace SwVPagesSample 17 | { 18 | [Icon(typeof(Resources), nameof(Resources.shield_icon))] 19 | [PageOptions(/*typeof(Resources), nameof(Resources.shield_icon),*/ 20 | swPropertyManagerPageOptions_e.swPropertyManagerOptions_OkayButton 21 | | swPropertyManagerPageOptions_e.swPropertyManagerOptions_CancelButton 22 | | swPropertyManagerPageOptions_e.swPropertyManagerOptions_WhatsNew)] 23 | [Message("This is a sample property page", "MyCaption", 24 | swPropertyManagerPageMessageVisibility.swImportantMessageBox, 25 | swPropertyManagerPageMessageExpanded.swMessageBoxMaintainExpandState)] 26 | public class DataModel : INotifyPropertyChanged 27 | { 28 | public event PropertyChangedEventHandler PropertyChanged; 29 | 30 | private string m_Text1; 31 | 32 | [ControlOptions(backgroundColor: KnownColor.Green, textColor: KnownColor.Yellow)] 33 | public string Text1 34 | { 35 | get 36 | { 37 | return m_Text1; 38 | } 39 | set 40 | { 41 | m_Text1 = value; 42 | this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Text1))); 43 | } 44 | } 45 | 46 | [ControlAttribution(swControlBitmapLabelType_e.swBitmapLabel_Depth)] 47 | public string Text2 { get; set; } 48 | 49 | [ControlAttribution(typeof(Resources), nameof(Resources.shield_icon))] 50 | public int Number1 { get; set; } 51 | 52 | public double FloatingNumber1 { get; set; } 53 | 54 | [Description("Sample Toggle")] 55 | [DisplayName("CheckBox")] 56 | public bool Toggle { get; private set; } 57 | 58 | public DataGroup Group { get; set; } 59 | 60 | [SelectionBox(swSelectType_e.swSelDATUMPLANES, swSelectType_e.swSelEDGES, swSelectType_e.swSelFACES)] 61 | [ControlOptions(height: 50)] 62 | public List Selection { get; set; } 63 | 64 | [SelectionBox(swSelectType_e.swSelSOLIDBODIES)] 65 | public IBody2 Body { get; set; } 66 | 67 | public ComboOptions_e Options { get; set; } 68 | 69 | [DisplayName("Second Data Group")] 70 | public DataGroup1 Group1 { get; set; } 71 | 72 | public DependencyGroup DepGroup { get; set; } 73 | 74 | [OptionBox] 75 | public Options_e Options2 { get; set; } 76 | 77 | [Title("Sample Button")] 78 | public Action Button => OnButtonClick; 79 | 80 | public Image Image1 { get; set; } = Resources.shield_icon; 81 | 82 | private Image m_Image2 = Resources.shield_icon; 83 | 84 | [BitmapOptions(48, 48)] 85 | public Image Image2 86 | { 87 | get 88 | { 89 | return m_Image2; 90 | } 91 | set 92 | { 93 | m_Image2 = value; 94 | this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(Image2))); 95 | } 96 | } 97 | 98 | private void OnButtonClick() 99 | { 100 | Text1 = Guid.NewGuid().ToString(); 101 | DepGroup.IsEnabled = !DepGroup.IsEnabled; 102 | 103 | //var fileBrowseDlg = new OpenFileDialog(); 104 | //if (fileBrowseDlg.ShowDialog() == DialogResult.OK) 105 | //{ 106 | // var file = fileBrowseDlg.FileName; 107 | // Image2 = Image.FromFile(file); 108 | //} 109 | } 110 | } 111 | 112 | public class DataGroup 113 | { 114 | [IgnoreBinding] 115 | public string Text3 { get; set; } 116 | public string Text4 { get; set; } 117 | 118 | [SelectionBox(typeof(PlanarFaceFilter), swSelectType_e.swSelFACES)] 119 | [ControlAttribution(swControlBitmapLabelType_e.swBitmapLabel_SelectFace)] 120 | public IFace2 PlanarFace { get; set; } 121 | } 122 | 123 | public enum ComboOptions_e 124 | { 125 | [Title("Combo Option One")] 126 | ComboOption1, 127 | ComboOption2, 128 | ComboOption3 129 | } 130 | 131 | public enum Options_e 132 | { 133 | [Title("Option One")] 134 | Option1, 135 | Option2, 136 | Option3 137 | } 138 | 139 | public class DataGroup1 140 | { 141 | public int Number { get; set; } 142 | 143 | public NestedDataGroup NestedGroup { get; set; } 144 | } 145 | 146 | public class NestedDataGroup 147 | { 148 | public double Double { get; set; } 149 | } 150 | 151 | public class DependencyGroup : INotifyPropertyChanged 152 | { 153 | public event PropertyChangedEventHandler PropertyChanged; 154 | 155 | private bool m_IsEnabled; 156 | 157 | [ControlTag(ControlTags_e.IsEnabled)] 158 | public bool IsEnabled 159 | { 160 | get 161 | { 162 | return m_IsEnabled; 163 | } 164 | set 165 | { 166 | m_IsEnabled = value; 167 | this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsEnabled))); 168 | } 169 | } 170 | 171 | [ControlTag(ControlTags_e.EnableBox)] 172 | [DependentOn(typeof(CheckBoxDrivenEnableHandler), ControlTags_e.IsEnabled)] 173 | public string EnabledBox { get; set; } 174 | } 175 | 176 | public enum ControlTags_e 177 | { 178 | IsEnabled, 179 | EnableBox 180 | } 181 | 182 | public class CheckBoxDrivenEnableHandler : DependencyHandler 183 | { 184 | protected override void UpdateControlState(IPropertyManagerPageControlEx control, 185 | IPropertyManagerPageControlEx[] parents) 186 | { 187 | control.Enabled = !parents.Any(p => !((bool)p.GetValue())); 188 | } 189 | } 190 | 191 | public class PlanarFaceFilter : SelectionCustomFilter 192 | { 193 | protected override bool Filter(IFace2 selection) 194 | { 195 | return selection.IGetSurface().IsPlane(); 196 | } 197 | } 198 | } 199 | -------------------------------------------------------------------------------- /Samples/AddIn/Icons/IconLarge.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codestackdev/swex-pmpage/a8d5eac8d3eb7cf1b4b50dba32cb263c95fc21fe/Samples/AddIn/Icons/IconLarge.bmp -------------------------------------------------------------------------------- /Samples/AddIn/Icons/IconSmall.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codestackdev/swex-pmpage/a8d5eac8d3eb7cf1b4b50dba32cb263c95fc21fe/Samples/AddIn/Icons/IconSmall.bmp -------------------------------------------------------------------------------- /Samples/AddIn/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codestackdev/swex-pmpage/a8d5eac8d3eb7cf1b4b50dba32cb263c95fc21fe/Samples/AddIn/Properties/AssemblyInfo.cs -------------------------------------------------------------------------------- /Samples/AddIn/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace SwVPagesSample.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SwVPagesSample.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized resource of type System.Drawing.Bitmap. 65 | /// 66 | internal static System.Drawing.Bitmap shield_icon { 67 | get { 68 | object obj = ResourceManager.GetObject("shield_icon", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Samples/AddIn/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | 122 | ..\Resources\shield-icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 123 | 124 | -------------------------------------------------------------------------------- /Samples/AddIn/PropertyPageEventsHandler.cs: -------------------------------------------------------------------------------- 1 | using CodeStack.SwEx.PMPage; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Runtime.InteropServices; 6 | using System.Text; 7 | 8 | namespace SwVPagesSample 9 | { 10 | [ComVisible(true)] 11 | public class PropertyPageEventsHandler : PropertyManagerPageHandlerEx 12 | { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Samples/AddIn/Resources/button-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codestackdev/swex-pmpage/a8d5eac8d3eb7cf1b4b50dba32cb263c95fc21fe/Samples/AddIn/Resources/button-icon.png -------------------------------------------------------------------------------- /Samples/AddIn/Resources/shield-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codestackdev/swex-pmpage/a8d5eac8d3eb7cf1b4b50dba32cb263c95fc21fe/Samples/AddIn/Resources/shield-icon.png -------------------------------------------------------------------------------- /Samples/AddIn/TabDataModel.cs: -------------------------------------------------------------------------------- 1 | using CodeStack.SwEx.Common.Attributes; 2 | using CodeStack.SwEx.PMPage.Attributes; 3 | using SwVPagesSample.Properties; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | 9 | namespace SwVPagesSample 10 | { 11 | public class TabDataModel 12 | { 13 | public Tab1 Tab1 { get; set; } 14 | 15 | [Tab] 16 | public Tab2 Tab2 { get; set; } 17 | } 18 | 19 | [Tab] 20 | [Icon(typeof(Resources), nameof(Resources.shield_icon))] 21 | public class Tab1 22 | { 23 | public string Field1 { get; set; } 24 | public int Field2 { get; set; } 25 | } 26 | 27 | public class Tab2 28 | { 29 | [SelectionBox] 30 | public object Field3 { get; set; } 31 | public bool Field4 { get; set; } 32 | public Group1 Group1 { get; set; } 33 | } 34 | 35 | public class Group1 36 | { 37 | public enum Enum_e 38 | { 39 | Opt1, 40 | Opt2 41 | } 42 | 43 | public Enum_e Field5 { get; set; } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Samples/AddIn/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /Samples/AddIn/thirdpty/SolidWorksTools.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codestackdev/swex-pmpage/a8d5eac8d3eb7cf1b4b50dba32cb263c95fc21fe/Samples/AddIn/thirdpty/SolidWorksTools.dll -------------------------------------------------------------------------------- /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codestackdev/swex-pmpage/a8d5eac8d3eb7cf1b4b50dba32cb263c95fc21fe/favicon.ico -------------------------------------------------------------------------------- /swex-pmpage-docs.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.2026 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{7D361ABA-D9C2-4696-932A-BA693462CB36}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddIn", "Samples\AddIn\AddIn.csproj", "{7ACEDAA9-2DE8-4485-837A-E7D58812A6DC}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Base", "Base\Base.csproj", "{8EC761A6-E338-4ED1-AF15-5F159341DA9C}" 11 | EndProject 12 | Project("{7CF6DF6D-3B04-46F8-A40B-537D21BCA0B4}") = "HelpDoc", "HelpDoc\HelpDoc.shfbproj", "{33B3755C-C91A-4114-AA71-33107995E3F0}" 13 | ProjectSection(ProjectDependencies) = postProject 14 | {8EC761A6-E338-4ED1-AF15-5F159341DA9C} = {8EC761A6-E338-4ED1-AF15-5F159341DA9C} 15 | EndProjectSection 16 | EndProject 17 | Global 18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 19 | Debug|Any CPU = Debug|Any CPU 20 | Release|Any CPU = Release|Any CPU 21 | EndGlobalSection 22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 23 | {7ACEDAA9-2DE8-4485-837A-E7D58812A6DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 24 | {7ACEDAA9-2DE8-4485-837A-E7D58812A6DC}.Debug|Any CPU.Build.0 = Debug|Any CPU 25 | {7ACEDAA9-2DE8-4485-837A-E7D58812A6DC}.Release|Any CPU.ActiveCfg = Release|Any CPU 26 | {7ACEDAA9-2DE8-4485-837A-E7D58812A6DC}.Release|Any CPU.Build.0 = Release|Any CPU 27 | {8EC761A6-E338-4ED1-AF15-5F159341DA9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 28 | {8EC761A6-E338-4ED1-AF15-5F159341DA9C}.Debug|Any CPU.Build.0 = Debug|Any CPU 29 | {8EC761A6-E338-4ED1-AF15-5F159341DA9C}.Release|Any CPU.ActiveCfg = Release|Any CPU 30 | {8EC761A6-E338-4ED1-AF15-5F159341DA9C}.Release|Any CPU.Build.0 = Release|Any CPU 31 | {33B3755C-C91A-4114-AA71-33107995E3F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 32 | {33B3755C-C91A-4114-AA71-33107995E3F0}.Debug|Any CPU.Build.0 = Debug|Any CPU 33 | {33B3755C-C91A-4114-AA71-33107995E3F0}.Release|Any CPU.ActiveCfg = Release|Any CPU 34 | {33B3755C-C91A-4114-AA71-33107995E3F0}.Release|Any CPU.Build.0 = Release|Any CPU 35 | EndGlobalSection 36 | GlobalSection(SolutionProperties) = preSolution 37 | HideSolutionNode = FALSE 38 | EndGlobalSection 39 | GlobalSection(NestedProjects) = preSolution 40 | {7ACEDAA9-2DE8-4485-837A-E7D58812A6DC} = {7D361ABA-D9C2-4696-932A-BA693462CB36} 41 | EndGlobalSection 42 | GlobalSection(ExtensibilityGlobals) = postSolution 43 | SolutionGuid = {E134D156-1960-45E4-88F5-9F8765CE8768} 44 | EndGlobalSection 45 | EndGlobal 46 | -------------------------------------------------------------------------------- /swex-pmpage.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.2026 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{7D361ABA-D9C2-4696-932A-BA693462CB36}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddIn", "Samples\AddIn\AddIn.csproj", "{7ACEDAA9-2DE8-4485-837A-E7D58812A6DC}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Base", "Base\Base.csproj", "{8EC761A6-E338-4ED1-AF15-5F159341DA9C}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {7ACEDAA9-2DE8-4485-837A-E7D58812A6DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {7ACEDAA9-2DE8-4485-837A-E7D58812A6DC}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {7ACEDAA9-2DE8-4485-837A-E7D58812A6DC}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {7ACEDAA9-2DE8-4485-837A-E7D58812A6DC}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {8EC761A6-E338-4ED1-AF15-5F159341DA9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {8EC761A6-E338-4ED1-AF15-5F159341DA9C}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {8EC761A6-E338-4ED1-AF15-5F159341DA9C}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {8EC761A6-E338-4ED1-AF15-5F159341DA9C}.Release|Any CPU.Build.0 = Release|Any CPU 26 | EndGlobalSection 27 | GlobalSection(SolutionProperties) = preSolution 28 | HideSolutionNode = FALSE 29 | EndGlobalSection 30 | GlobalSection(NestedProjects) = preSolution 31 | {7ACEDAA9-2DE8-4485-837A-E7D58812A6DC} = {7D361ABA-D9C2-4696-932A-BA693462CB36} 32 | EndGlobalSection 33 | GlobalSection(ExtensibilityGlobals) = postSolution 34 | SolutionGuid = {E134D156-1960-45E4-88F5-9F8765CE8768} 35 | EndGlobalSection 36 | EndGlobal 37 | --------------------------------------------------------------------------------