Exemple #1
0
        public IPropertyManagerPageGroup CreateGroupBoxEx(int id, string Caption,
                                                          IEnumerable <swAddGroupBoxOptions_e> options = null)
        {
            options = options ??
                      new[]
            {
                swAddGroupBoxOptions_e.swGroupBoxOptions_Expanded,
                swAddGroupBoxOptions_e.swGroupBoxOptions_Visible
            };
            var optionsShort = (short)PropertyManagerPage2Extension.CombineToInt(options, v => (short)v);

            return(Page.AddGroupBox(id, Caption, optionsShort) as PropertyManagerPageGroup);
        }
Exemple #2
0
        /// <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);
        }
        /// <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));
        }