//Controls are displayed on the page top to bottom in the order //in which they are added to the object. protected void AddControls() { short controlType = -1; short textctlType = -1; short align = -1; int options = -1; //Add the groups options = (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Expanded | (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Visible; group1 = (IPropertyManagerPageGroup)swPropertyPage.AddGroupBox(group1ID, "尺寸选择", options); //textbox1 controlType = (int)swPropertyManagerPageControlType_e.swControlType_Label; align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge; options = (int)swAddControlOptions_e.swControlOptions_Enabled | (int)swAddControlOptions_e.swControlOptions_Visible; textctlType = (int)swPropertyManagerPageControlType_e.swControlType_Textbox; lbLength = (IPropertyManagerPageLabel)group1.AddControl(lbLengthID, controlType, "长:", align, options, "阀块基体长度"); tbLength = (IPropertyManagerPageTextbox)group1.AddControl(tbLengthID, textctlType, "", align, options, "阀块长度"); lbWidth = (IPropertyManagerPageLabel)group1.AddControl(lbWidthID, controlType, "宽:", align, options, "阀块基体宽度"); tbWidth = (IPropertyManagerPageTextbox)group1.AddControl(tbWidthID, textctlType, "", align, options, "阀块宽度"); lbHeight = (IPropertyManagerPageLabel)group1.AddControl(lbHeightID, controlType, "高:", align, options, "阀块基体高度"); tbHeight = (IPropertyManagerPageTextbox)group1.AddControl(tbHeightID, textctlType, "", align, options, "阀块高度"); tbLength.Text = ValueConst.VALUE_DEFAULT_LENGTH.ToString(); tbWidth.Text = ValueConst.VALUE_DEFAULT_WIDTH.ToString(); tbHeight.Text = ValueConst.VALUE_DEFAULT_HEIGHT.ToString(); }
internal static void SetLabelOptions(this IPropertyManagerPageLabel label, FontStyle_e style, string font, KnownColor?textColor) { if (style.HasFlag(FontStyle_e.Bold)) { label.Bold[0, (short)(label.Caption.Length - 1)] = true; } if (style.HasFlag(FontStyle_e.Italic)) { label.Italic[0, (short)(label.Caption.Length - 1)] = true; } if (style.HasFlag(FontStyle_e.Underline)) { label.Underline[0, (short)(label.Caption.Length - 1)] = (int)swPropMgrPageLabelUnderlineStyle_e.swPropMgrPageLabel_SolidUnderline; } if (!string.IsNullOrEmpty(font)) { label.Font[0, (short)(label.Caption.Length - 1)] = font; } if (textColor.HasValue) { label.CharacterColor[0, (short)(label.Caption.Length - 1)] = ColorUtils.ToColorRef(Color.FromKnownColor(textColor.Value)); } }
protected override PropertyManagerPageBitmapButtonControl CreateControl( IPropertyManagerPageBitmapButton swCtrl, IAttributeSet atts, IMetadata[] metadata, SwPropertyManagerPageHandler handler, short height, IPropertyManagerPageLabel label) { var bmpAtt = atts.Get <BitmapButtonAttribute>(); if (bmpAtt.StandardIcon.HasValue) { swCtrl.SetStandardBitmaps((int)bmpAtt.StandardIcon.Value); } else { var bmpWidth = bmpAtt.Width; var bmpHeight = bmpAtt.Height; var icon = bmpAtt.Icon ?? Defaults.Icon; if (m_App.IsVersionNewerOrEqual(Enums.SwVersion_e.Sw2016)) { var icons = m_IconsConv.ConvertIcon(new BitmapButtonHighResIcon(icon, bmpWidth, bmpHeight)); var imgList = icons.Take(6).ToArray(); var maskImgList = icons.Skip(6).ToArray(); swCtrl.SetBitmapsByName3(imgList, maskImgList); } else { var icons = m_IconsConv.ConvertIcon(new BitmapButtonIcon(icon, bmpWidth, bmpHeight)); swCtrl.SetBitmapsByName2(icons[0], icons[1]); } } return(new PropertyManagerPageBitmapButtonControl(atts.Id, atts.Tag, swCtrl, handler, label, metadata)); }
protected override PropertyManagerPageComboBoxControl <TVal> CreateControl( IPropertyManagerPageCombobox swCtrl, IAttributeSet atts, IMetadata[] metadata, SwPropertyManagerPageHandler handler, short height, IPropertyManagerPageLabel label) { if (height != -1) { swCtrl.Height = height; } if (atts.Has <ComboBoxOptionsAttribute>()) { var opts = atts.Get <ComboBoxOptionsAttribute>(); if (opts.Style != 0) { swCtrl.Style = (int)opts.Style; } } m_Helper.ParseItems(m_SwApp, atts, metadata, out bool isStatic, out ItemsControlItem[] staticItems, out IMetadata srcMetadata); var ctrl = new PropertyManagerPageComboBoxControl <TVal>(atts.Id, atts.Tag, swCtrl, handler, srcMetadata, label, atts.ContextType, isStatic, staticItems, metadata); return(ctrl); }
protected override PropertyManagerPageNumberBoxControl CreateControl( IPropertyManagerPageNumberbox swCtrl, IAttributeSet atts, IMetadata[] metadata, SwPropertyManagerPageHandler handler, short height, IPropertyManagerPageLabel label) { if (height != -1) { swCtrl.Height = height; } if (atts.Has <NumberBoxOptionsAttribute>()) { var style = atts.Get <NumberBoxOptionsAttribute>(); if (style.Style != 0) { swCtrl.Style = (int)style.Style; } if (style.Units != 0) { swCtrl.SetRange2((int)style.Units, style.Minimum, style.Maximum, style.Inclusive, style.Increment, style.FastIncrement, style.SlowIncrement); } } return(new PropertyManagerPageNumberBoxControl(atts.Id, atts.Tag, swCtrl, handler, label, metadata)); }
protected PropertyManagerPageBaseControl(TSwControl ctrl, int id, object tag, SwPropertyManagerPageHandler handler, IPropertyManagerPageLabel label, IMetadata[] metadata) : base(id, tag, metadata) { SwSpecificControl = ctrl; m_Handler = handler; m_Label = label; }
protected override PropertyManagerPageButtonControl CreateControl( IPropertyManagerPageButton swCtrl, IAttributeSet atts, IMetadata[] metadata, SwPropertyManagerPageHandler handler, short height, IPropertyManagerPageLabel label) { swCtrl.Caption = atts.Name; return(new PropertyManagerPageButtonControl(atts.Id, atts.Tag, swCtrl, handler, label, metadata)); }
protected override PropertyManagerPageListBoxControl CreateControl( IPropertyManagerPageListbox swCtrl, IAttributeSet atts, IMetadata[] metadata, SwPropertyManagerPageHandler handler, short height, IPropertyManagerPageLabel label) { if (height <= 0) { height = 50; } swCtrl.Height = height; int style = 0; bool sortItems = false; if (atts.Has <ListBoxOptionsAttribute>()) { var opts = atts.Get <ListBoxOptionsAttribute>(); if (opts.Style != 0) { style = (int)opts.Style; if (opts.Style.HasFlag(ListBoxStyle_e.Sorted)) { sortItems = true; style -= (int)ListBoxStyle_e.Sorted; } } } var isMultiSelect = (atts.ContextType.IsEnum && atts.ContextType.GetCustomAttribute <FlagsAttribute>() != null) || typeof(IList).IsAssignableFrom(atts.ContextType); if (isMultiSelect) { style = style + (int)swPropMgrPageListBoxStyle_e.swPropMgrPageListBoxStyle_MultipleItemSelect; } swCtrl.Style = style; m_Helper.ParseItems(m_SwApp, atts, metadata, out bool isStatic, out ItemsControlItem[] staticItems, out IMetadata srcMetadata); var ctrl = new PropertyManagerPageListBoxControl(atts.Id, atts.Tag, swCtrl, atts.ContextType, isMultiSelect, handler, srcMetadata, label, atts.ContextType, metadata); if (isStatic) { if (sortItems) { staticItems = staticItems.OrderBy(i => i.DisplayName).ToArray(); } ctrl.Items = staticItems; } return(ctrl); }
protected override PropertyManagerPageBitmapControl CreateControl( IPropertyManagerPageBitmap swCtrl, IAttributeSet atts, IMetadata[] metadata, SwPropertyManagerPageHandler handler, short height, IPropertyManagerPageLabel label) { Size?size = null; if (atts.Has <BitmapOptionsAttribute>()) { var opts = atts.Get <BitmapOptionsAttribute>(); size = opts.Size; } return(new PropertyManagerPageBitmapControl(m_IconsConv, atts.Id, atts.Tag, size, swCtrl, handler, label, metadata)); }
protected override PropertyManagerPageCustomControl CreateControl( IPropertyManagerPageWindowFromHandle swCtrl, IAttributeSet atts, IMetadata[] metadata, SwPropertyManagerPageHandler handler, short height, IPropertyManagerPageLabel label) { if (height <= 0) { height = 50; } swCtrl.Height = height; var ctrlType = atts.Get <CustomControlAttribute>().ControlType; return(new PropertyManagerPageCustomControl(ctrlType, atts.Id, atts.Tag, swCtrl, handler, new PropertyPageControlCreator <object>(swCtrl), label, metadata)); }
protected override PropertyManagerPageOptionBoxControl CreateControl( PropertyManagerPageOptionBox swCtrl, IAttributeSet atts, IMetadata[] metadata, SwPropertyManagerPageHandler handler, short height, IPropertyManagerPageLabel label) { var options = EnumExtension.GetEnumFields(atts.ContextType); if (atts.Has <OptionBoxOptionsAttribute>()) { var style = atts.Get <OptionBoxOptionsAttribute>(); if (style.Style != 0) { swCtrl.Style = (int)style.Style; } } return(new PropertyManagerPageOptionBoxControl(atts.Id, atts.Tag, swCtrl, options.Keys.ToList().AsReadOnly(), handler, label, metadata)); }
protected override PropertyManagerPageLabelEx CreateControl(IPropertyManagerPageLabel swCtrl, IAttributeSet atts, THandler handler, short height) { if (height != -1) { swCtrl.Height = height; } if (atts.Has <LabelOptionsAttribute>()) { var style = atts.Get <ComboBoxOptionsAttribute>(); if (style.Style != 0) { swCtrl.Style = (int)style.Style; } } return(new PropertyManagerPageLabelEx(swCtrl, atts.Id, atts.Tag, handler)); }
protected override PropertyManagerPageTextBoxControl CreateControl( IPropertyManagerPageTextbox swCtrl, IAttributeSet atts, IMetadata[] metadata, SwPropertyManagerPageHandler handler, short height, IPropertyManagerPageLabel label) { if (height != -1) { swCtrl.Height = height; } if (atts.Has <TextBoxOptionsAttribute>()) { var style = atts.Get <TextBoxOptionsAttribute>(); if (style.Style != 0) { swCtrl.Style = (int)style.Style; } } return(new PropertyManagerPageTextBoxControl(atts.Id, atts.Tag, swCtrl, handler, label, metadata)); }
public PropertyManagerPageSelectionBoxControl(ISwApplication app, int id, object tag, IPropertyManagerPageSelectionbox selBox, SwPropertyManagerPageHandler handler, Type objType, ISelectionCustomFilter customFilter, bool defaultFocus, IPropertyManagerPageLabel label, IMetadata[] metadata) : base(selBox, id, tag, handler, label, metadata) { m_App = app; m_ObjType = objType; m_ElementType = SelectionBoxConstructorHelper.GetElementType(m_ObjType); m_CustomFilter = customFilter; m_DefaultFocus = defaultFocus; m_Handler.SelectionChanged += OnSelectionChanged; if (m_DefaultFocus) { m_Handler.Opened += OnPageOpened; } m_Handler.SubmitSelection += OnSubmitSelection; }
public PropertyManagerPageBitmapButtonControl(int id, object tag, IPropertyManagerPageBitmapButton bmpButton, SwPropertyManagerPageHandler handler, IPropertyManagerPageLabel label, IMetadata[] metadata) : base(bmpButton, id, tag, handler, label, metadata) { m_Handler.ButtonPressed += OnButtonPressed; }
protected override PropertyManagerPageSelectionBoxControl CreateControl( IPropertyManagerPageSelectionbox swCtrl, IAttributeSet atts, IMetadata[] metadata, SwPropertyManagerPageHandler handler, short height, IPropertyManagerPageLabel label) { swCtrl.SingleEntityOnly = !typeof(IList).IsAssignableFrom(atts.ContextType); if (height == -1) { height = 20; } swCtrl.Height = height; ISelectionCustomFilter customFilter = null; var filters = SelectionBoxConstructorHelper.GetDefaultFilters(atts); bool focusOnOpen = false; if (atts.Has <SelectionBoxOptionsAttribute>()) { var selAtt = atts.Get <SelectionBoxOptionsAttribute>(); if (selAtt.Style != 0) { swCtrl.Style = (int)selAtt.Style; } if (selAtt.SelectionColor != 0) { swCtrl.SetSelectionColor(true, (int)selAtt.SelectionColor); } if (selAtt.Filters?.Any() == true) { filters = selAtt.Filters; } swCtrl.Mark = selAtt.SelectionMark; focusOnOpen = selAtt.Focused; if (selAtt.CustomFilter != null) { customFilter = Activator.CreateInstance(selAtt.CustomFilter) as ISelectionCustomFilter; if (customFilter == null) { throw new InvalidCastException( $"Specified custom filter of type {selAtt.CustomFilter.FullName} cannot be cast to {typeof(ISelectionCustomFilter).FullName}"); } } } if (filters != null && !filters.Contains(SelectType_e.Everything)) { swCtrl.SetSelectionFilters(ConvertToSwSelFilters(filters)); } else { swCtrl.SetSelectionFilters(m_AllFilters); } return(new PropertyManagerPageSelectionBoxControl(m_SwApp, atts.Id, atts.Tag, swCtrl, handler, atts.ContextType, customFilter, focusOnOpen, label, metadata)); }
public PropertyManagerPageBitmapControl(IIconsCreator iconsConv, int id, object tag, Size?size, IPropertyManagerPageBitmap bitmap, SwPropertyManagerPageHandler handler, IPropertyManagerPageLabel label, IMetadata[] metadata) : base(bitmap, id, tag, handler, label, metadata) { m_Size = size.HasValue ? size.Value : new Size(36, 36); m_IconsConv = iconsConv; }
public PropertyManagerPageNumberBoxControl(int id, object tag, IPropertyManagerPageNumberbox numberBox, SwPropertyManagerPageHandler handler, IPropertyManagerPageLabel label, IMetadata[] metadata) : base(numberBox, id, tag, handler, label, metadata) { m_Handler.NumberChanged += OnNumberChanged; }
public PropertyManagerPageOptionBoxControl(int id, object tag, PropertyManagerPageOptionBox optionBox, ReadOnlyCollection <Enum> values, SwPropertyManagerPageHandler handler, IPropertyManagerPageLabel label, IMetadata[] metadata) : base(optionBox, id, tag, handler, label, metadata) { m_Values = values; m_Handler.OptionChecked += OnOptionChecked; }
private bool AddLabelIfNeeded(object host, IAttributeSet atts, ref int numberOfUsedIds, out IPropertyManagerPageLabel label) { if (atts.Has <LabelAttribute>()) { numberOfUsedIds++; var id = atts.Id + numberOfUsedIds - 1; var labelAtt = atts.Get <LabelAttribute>(); var legacy = !m_App.IsVersionNewerOrEqual(SwVersion_e.Sw2014, 1); var type = swPropertyManagerPageControlType_e.swControlType_Label; var align = (swPropertyManagerPageControlLeftAlign_e)labelAtt.Align; var opts = swAddControlOptions_e.swControlOptions_Enabled | swAddControlOptions_e.swControlOptions_SmallGapAbove | swAddControlOptions_e.swControlOptions_Visible; switch (host) { case IPropertyManagerPage2 page: if (!legacy) { label = (IPropertyManagerPageLabel)page.AddControl2(id, (short)type, labelAtt.Caption, (short)align, (short)opts, atts.Description); } else { label = (IPropertyManagerPageLabel)page.AddControl(id, (short)type, labelAtt.Caption, (short)align, (short)opts, atts.Description); } break; case IPropertyManagerPageTab tab: if (!legacy) { label = (IPropertyManagerPageLabel)tab.AddControl2(id, (short)type, labelAtt.Caption, (short)align, (short)opts, atts.Description); } else { label = (IPropertyManagerPageLabel)tab.AddControl(id, (short)type, labelAtt.Caption, (short)align, (short)opts, atts.Description); } break; case IPropertyManagerPageGroup group: if (!legacy) { label = (IPropertyManagerPageLabel)group.AddControl2(id, (short)type, labelAtt.Caption, (short)align, (short)opts, atts.Description); } else { label = (IPropertyManagerPageLabel)group.AddControl(id, (short)type, labelAtt.Caption, (short)align, (short)opts, atts.Description); } break; default: throw new NotSupportedException("Host is not supported"); } label.Caption = labelAtt.Caption; label.SetLabelOptions(labelAtt.FontStyle, "", null); return(true); } else { label = null; return(false); } }
public PropertyManagerPageCheckBoxControl(int id, object tag, IPropertyManagerPageCheckbox checkBox, SwPropertyManagerPageHandler handler, IPropertyManagerPageLabel label, IMetadata[] metadata) : base(checkBox, id, tag, handler, label, metadata) { m_Handler.CheckChanged += OnCheckChanged; }
protected abstract TControl CreateControl(TControlSw swCtrl, IAttributeSet atts, IMetadata[] metadata, SwPropertyManagerPageHandler handler, short height, IPropertyManagerPageLabel label);
internal PropertyManagerPageCustomControl(Type ctrlType, int id, object tag, IPropertyManagerPageWindowFromHandle wndFromHandler, SwPropertyManagerPageHandler handler, PropertyPageControlCreator <object> creator, IPropertyManagerPageLabel label, IMetadata[] metadata) : base(wndFromHandler, id, tag, handler, label, metadata) { m_CtrlType = ctrlType; m_Handler.CustomControlCreated += OnCustomControlCreated; m_Handler.Opening += OnPageOpening; m_Handler.Closed += OnPageClosed; m_Creator = creator; }
public PropertyManagerPageComboBoxControl(int id, object tag, IPropertyManagerPageCombobox comboBox, SwPropertyManagerPageHandler handler, IMetadata srcMetadata, IPropertyManagerPageLabel label, Type specificItemType, bool isStatic, ItemsControlItem[] staticItems, IMetadata[] metadata) : base(id, tag, comboBox, handler, srcMetadata, label, specificItemType, metadata) { m_IsStatic = isStatic; m_StaticItems = staticItems; m_Handler.ComboBoxChanged += OnComboBoxChanged; m_Handler.Opened += OnPageOpened; m_Handler.Closed += OnPageClosed; m_IsPageOpened = false; }
public IPropertyManagerPageLabelObject(IPropertyManagerPageLabel IPropertyManagerPageLabelinstance) { IPropertyManagerPageLabelInstance = IPropertyManagerPageLabelinstance; }
public PropertyManagerPageListBoxControl(int id, object tag, IPropertyManagerPageListbox listBox, Type targetType, bool isMultiSel, SwPropertyManagerPageHandler handler, IMetadata srcMetadata, IPropertyManagerPageLabel label, Type specificItemType, IMetadata[] metadata) : base(id, tag, listBox, handler, srcMetadata, label, specificItemType, metadata) { m_IsMultiSelect = isMultiSel; m_TargetType = targetType; m_Handler.ListBoxChanged += OnListBoxChanged; }
internal PropertyManagerPageTextBoxControl(int id, object tag, IPropertyManagerPageTextbox textBox, SwPropertyManagerPageHandler handler, IPropertyManagerPageLabel label, IMetadata[] metadata) : base(textBox, id, tag, handler, label, metadata) { m_Handler.TextChanged += OnTextChanged; }