CreateTextBox(this IPropertyManagerPageGroup group, int id, string caption, string tip, swPropertyManagerPageControlLeftAlign_e leftAlign = 0, IEnumerable <swAddControlOptions_e> options = null) { return(AddControl <IPropertyManagerPageTextbox>(@group, id, caption, tip, leftAlign, options)); }
/// <summary> /// 添加数字框 /// </summary> /// <param name="group"></param> /// <param name="id"></param> /// <param name="Caption"></param> /// <param name="tip"></param> /// <param name="align"></param> /// <param name="options"></param> /// <returns></returns> private static PropertyManagerPageGroup AddNumberBox(this PropertyManagerPageGroup group, int id, string Caption, string tip, swPropertyManagerPageControlLeftAlign_e align = swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge, swAddControlOptions_e options = swAddControlOptions_e.swControlOptions_Enabled | swAddControlOptions_e.swControlOptions_Visible) { short controlType = (short)swPropertyManagerPageControlType_e.swControlType_Numberbox; group.AddControl2(id, controlType, Caption, (short)align, (int)options, tip); return(group); }
public PMPageControl(int iD, string caption, string hint, swPropertyManagerPageControlType_e controlType, swPropertyManagerPageControlLeftAlign_e align, swAddControlOptions_e options) { ControlType = controlType; Align = align; Options = options; ID = iD; Caption = caption; tip = hint; }
/// <summary> /// Constructor allowing to specify control common parameters /// </summary> /// <param name="opts">Generic control options as defined in <see href="http://help.solidworks.com/2016/english/api/swconst/solidworks.interop.swconst~solidworks.interop.swconst.swaddcontroloptions_e.html">swAddControlOptions_e Enumeration</see></param> /// <param name="align">Control alignment options as defined in <see href="http://help.solidworks.com/2016/english/api/swconst/solidworks.interop.swconst~solidworks.interop.swconst.swpropertymanagerpagecontrolleftalign_e.html">swPropertyManagerPageControlLeftAlign_e Enumeration</see></param> /// <param name="backgroundColor">Background color of control. Use 0 for default color</param> /// <param name="textColor">Color of the text on the control. Use 0 for default color</param> /// <param name="left">Left alignment of the control. Use -1 for default alignment</param> /// <param name="top">Top alignment of the control. Use -1 to align the control under the previous control</param> /// <param name="width">Width of the control. Use -1 for auto width</param> /// <param name="height">Height of the control in property manager page dialog box units. Use -1 for the auto height</param> /// <param name="resizeOptions">Options to resize as defined in <see href="http://help.solidworks.com/2016/english/api/swconst/solidworks.interop.swconst~solidworks.interop.swconst.swpropmgrpagecontrolonresizeoptions_e.html">swPropMgrPageControlOnResizeOptions_e Enumeration</see></param> public ControlOptionsAttribute( swAddControlOptions_e opts = swAddControlOptions_e.swControlOptions_Enabled | swAddControlOptions_e.swControlOptions_Visible, swPropertyManagerPageControlLeftAlign_e align = swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge, KnownColor backgroundColor = 0, KnownColor textColor = 0, short left = -1, short top = -1, short width = -1, short height = -1, swPropMgrPageControlOnResizeOptions_e resizeOptions = 0) { Options = opts; Align = align; BackgroundColor = backgroundColor; TextColor = textColor; Left = left; Top = top; Width = width; Height = height; ResizeOptions = resizeOptions; }
/// <summary> /// 添加WPF控件 /// </summary> /// <param name="id"></param> /// <param name="caption"></param> /// <param name="tip"></param> /// <param name="leftAlign"></param> /// <param name="options"></param> /// <param name="uiElementConfig"></param> /// <returns></returns> public IPropertyManagerPageWindowFromHandle AddWPFUserControl(int id, string caption, string tip, swPropertyManagerPageControlLeftAlign_e leftAlign, IEnumerable <swAddControlOptions_e> options, Action <IPropertyManagerPageWindowFromHandleWrapper> uiElementConfig) { short controlType = (int)swPropertyManagerPageControlType_e.swControlType_WindowFromHandle; var WpfPMPWindow = (IPropertyManagerPageWindowFromHandle)Page.AddControl2(id, controlType, caption, (short)leftAlign, PropertyManagerPage2Extension.CombineOptions(options), tip); if (uiElementConfig != null && WpfPMPWindow != null) { uiElementConfig(new IPropertyManagerPageWindowFromHandleWrapper(WpfPMPWindow)); } return(WpfPMPWindow); }
public IPropertyManagerGroupBuilder AddControlToBuilder <T>(int id, string caption, string tip, swPropertyManagerPageControlLeftAlign_e leftAlign, IEnumerable <swAddControlOptions_e> options, Action <T> pmpageContrlConfig) { var control = Group.AddControl <T>(id, caption, tip, leftAlign, options); if (control != null) { if (!controls.ContainsKey(id)) { controls.Add(id, control); } pmpageContrlConfig?.Invoke(control); } return(this); }
/// <summary> /// 泛型添加 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="group"></param> /// <param name="id"></param> /// <param name="caption"></param> /// <param name="tip"></param> /// <param name="leftAlign"></param> /// <param name="options"></param> /// <returns></returns> public static T AddControl <T>(this IPropertyManagerPageGroup @group, int id, string caption, string tip, swPropertyManagerPageControlLeftAlign_e leftAlign, IEnumerable <swAddControlOptions_e> options) { swPropertyManagerPageControlType_e typeE; switch (typeof(T).Name) { case nameof(IPropertyManagerPageTextbox): typeE = swPropertyManagerPageControlType_e.swControlType_Textbox; break; case nameof(IPropertyManagerPageCheckbox): typeE = swPropertyManagerPageControlType_e.swControlType_Checkbox; break; case nameof(IPropertyManagerPageButton): typeE = swPropertyManagerPageControlType_e.swControlType_Button; break; case nameof(IPropertyManagerPageSelectionbox): typeE = swPropertyManagerPageControlType_e.swControlType_Selectionbox; break; case nameof(IPropertyManagerPageCombobox): typeE = swPropertyManagerPageControlType_e.swControlType_Combobox; break; case nameof(IPropertyManagerPageListbox): typeE = swPropertyManagerPageControlType_e.swControlType_Listbox; break; case nameof(IPropertyManagerPageNumberbox): typeE = swPropertyManagerPageControlType_e.swControlType_Numberbox; break; case nameof(IPropertyManagerPageOption): typeE = swPropertyManagerPageControlType_e.swControlType_Option; break; case nameof(IPropertyManagerPageLabel): typeE = swPropertyManagerPageControlType_e.swControlType_Label; break; case nameof(IPropertyManagerPageSlider): typeE = swPropertyManagerPageControlType_e.swControlType_Slider; break; case nameof(IPropertyManagerPageBitmapButton): typeE = swPropertyManagerPageControlType_e.swControlType_BitmapButton; break; case nameof(IPropertyManagerPageWindowFromHandle): throw new ArgumentException($"请使用AddWPFUserControl添加用户控件{typeof(T).Name}"); default: throw new ArgumentException($"无法处理此种{typeof(T).Name}控件,请加成是否为接口"); } return((T)@group .AddControl2(id, (short)typeE, caption, (short)leftAlign, PropertyManagerPage2Extension.CombineOptions(options), tip)); }
public static T AddControl <T>(this IPropertyManagerPageGroup @group, int id, string caption, string tip, swPropertyManagerPageControlLeftAlign_e leftAlign, IEnumerable <swAddControlOptions_e> options) { swPropertyManagerPageControlType_e typeE; switch (typeof(T).Name) { case nameof(IPropertyManagerPageTextbox): typeE = swPropertyManagerPageControlType_e.swControlType_Textbox; break; case nameof(IPropertyManagerPageCheckbox): typeE = swPropertyManagerPageControlType_e.swControlType_Checkbox; break; case nameof(IPropertyManagerPageButton): typeE = swPropertyManagerPageControlType_e.swControlType_Button; break; case nameof(IPropertyManagerPageSelectionbox): typeE = swPropertyManagerPageControlType_e.swControlType_Selectionbox; break; case nameof(IPropertyManagerPageCombobox): typeE = swPropertyManagerPageControlType_e.swControlType_Combobox; break; case nameof(IPropertyManagerPageListbox): typeE = swPropertyManagerPageControlType_e.swControlType_Listbox; break; case nameof(IPropertyManagerPageNumberbox): typeE = swPropertyManagerPageControlType_e.swControlType_Numberbox; break; case nameof(IPropertyManagerPageOption): typeE = swPropertyManagerPageControlType_e.swControlType_Option; break; case nameof(IPropertyManagerPageLabel): typeE = swPropertyManagerPageControlType_e.swControlType_Label; break; case nameof(IPropertyManagerPageSlider): typeE = swPropertyManagerPageControlType_e.swControlType_Slider; break; default: throw new ArgumentException($"Cannot handle type{typeof(T).Name}"); } return((T)@group .AddControl2(id, (short)typeE, caption, (short)leftAlign, CombineOptions(options), tip)); }