示例#1
0
        private static IDisposable InitControl <T, TContrl, TCtrlProp, TDataProp>(
            IPropertyManagerPageGroup @group,
            TContrl control,
            Func <TContrl, IDisposable> controlConfig,
            Expression <Func <TContrl, TCtrlProp> > ctrlPropSelector,
            IObservable <TCtrlProp> ctrlPropChangeObservable,
            T propParent,
            Expression <Func <T, TDataProp> > propSelector,
            Func <TCtrlProp, TDataProp> controlToDataConversion,
            Func <TDataProp, TCtrlProp> dataToControlConversion)
        {
            var proxy     = propSelector.GetProxy(propParent);
            var ctrlProxy = ctrlPropSelector.GetProxy(control);

            var d5 = controlConfig?.Invoke(control);

            var d2 = propParent
                     .WhenAnyValue(propSelector)
                     .Select(dataToControlConversion)
                     .Subscribe(v => ctrlProxy.Value = v);

            var d1 = ctrlPropChangeObservable
                     .Select(controlToDataConversion)
                     .Subscribe(v => proxy.Value = v);

            return(ControlHolder.Create(@group, control, d1, d2, d5));
        }
示例#2
0
 public OptionGroup(PropertyManagerPageBase page, IPropertyManagerPageGroup pageGroup, T source, Expression <Func <T, TOption> > selector)
 {
     _Page      = page;
     _PageGroup = pageGroup;
     _Source    = source;
     _Selector  = selector;
 }
        protected IDisposable CreateSelectionBox <TModel>(
            IPropertyManagerPageGroup @group,
            string tip,
            string caption,
            swSelectType_e[] selectType,
            TModel model,
            Expression <Func <TModel, SelectionData> > propertyExpr,
            Action <IPropertyManagerPageSelectionbox> config,
            Action onFocus)
        {
            var id  = NextId();
            var box = @group.CreateSelectionBox(id, caption, tip);

            config(box);
            box.SetSelectionFilters(selectType);
            var d0 = SelectionBoxFocusChangedObservable(id).Subscribe(_ => onFocus());

            var d1 = TwoWayBind(
                sourceObservable: model.WhenAnyValue(propertyExpr),
                onSourceChanged: s => ModelDoc.AddSelection(s),
                targetObservable: SelectionChangedObservable(id),
                onTargetChanged: _ => SetSelection(box, selectType, model, propertyExpr)
                );

            return(ControlHolder.Create(@group, box, d0, d1));
        }
示例#4
0
        /// <summary>
        /// ReactiveUI version of CreateNumberBox
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="group"></param>
        /// <param name="tip"></param>
        /// <param name="caption"></param>
        /// <param name="source"></param>
        /// <param name="selector"></param>
        /// <param name="config"></param>
        /// <param name="gainedFocusObserver"></param>
        /// <param name="lostFocusObserver"></param>
        /// <returns></returns>
        protected IDisposable CreateNumberBox <T>(IPropertyManagerPageGroup @group,
                                                  string tip,
                                                  string caption,
                                                  T source,
                                                  Expression <Func <T, double> > selector,
                                                  Func <IPropertyManagerPageNumberbox, IDisposable> config = null,
                                                  IObserver <Unit> gainedFocusObserver = null,
                                                  IObserver <Unit> lostFocusObserver   = null)
        {
            var id  = NextId();
            var box = @group.CreateNumberBox(id, caption, tip);
            var d   = new CompositeDisposable();

            if (gainedFocusObserver != null)
            {
                GainedFocusObservable(id)
                .Ignore()
                .Subscribe(gainedFocusObserver)
                .DisposeWith(d);
            }
            if (lostFocusObserver != null)
            {
                LostFocusObservable(id)
                .Ignore()
                .Subscribe(lostFocusObserver)
                .DisposeWith(d);
            }
            InitControl(@group, box, config, c => c.Value, NumberBoxChangedObservable(id), source, selector)
            .DisposeWith(d);
            return(d);
        }
示例#5
0
        /// <summary>
        /// add WinformHandleControl for Page
        /// </summary>
        private void AddUserControl()
        {
            int options = (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Expanded |
                          (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Visible;

            if (string.IsNullOrWhiteSpace(GroupTitle))
            {
                PMPageWinformHandle = (IPropertyManagerPageWindowFromHandle)Page.AddControl2(
                    _idIndex++,
                    (int)swPropertyManagerPageControlType_e.swControlType_WindowFromHandle,
                    "WPF Control",
                    (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge,
                    options,
                    "wpf control");
            }
            else
            {
                _wpfGroup = Page.AddGroupBox(
                    _idIndex++,
                    GroupTitle,
                    (int)(swAddGroupBoxOptions_e.swGroupBoxOptions_Expanded | swAddGroupBoxOptions_e.swGroupBoxOptions_Visible)) as IPropertyManagerPageGroup;

                _wpfGroup.Expanded = GroupExpanded;

                PMPageWinformHandle = (IPropertyManagerPageWindowFromHandle)_wpfGroup.AddControl2(
                    _idIndex++,
                    (int)swPropertyManagerPageControlType_e.swControlType_WindowFromHandle,
                    "WPF Control",
                    (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge,
                    options,
                    "wpf control");
            }

            PMPageWinformHandle.Height = PageHeight;
        }
示例#6
0
        //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();
        }
        public static IDisposable CreateControl(PropertyManagerPageBase pmp, IPropertyManagerPageGroup @group, CompositeSourceList<SwEq> list, int index)
        {
            var equation = list.Source[index];

            var caption = equation.Id.CamelCaseToHumanReadable();
            var label = pmp.CreateLabel(@group, caption, caption);
            var id = pmp.NextId();
            var box = @group.CreateNumberBox(id, caption, caption);

            if (equation.UnitsType == UnitsEnum.Angle)
            {
                box.SetRange2((int) swNumberboxUnitType_e.swNumberBox_Angle, -10, 10, true, 0.005, 0.010, 0.001);
                box.DisplayedUnit = (int) swAngleUnit_e.swDEGREES;
            }
            else
            {
                const double increment = 1e-2;
                box.SetRange2((int)swNumberboxUnitType_e.swNumberBox_Length, -10, 10, true, increment, increment * 10, increment / 10);
                box.DisplayedUnit = (int)swLengthUnit_e.swMM;
            }
            var obs = pmp.NumberBoxChangedObservable(id);
            var d2 = obs.Subscribe(value => list.ReplaceAt(index,equation.WithValue(value)));

            var d3 = list.ChangesObservable()
                .Ignore()
                .StartWith(Unit.Default)
                // Don't set value when we selected another model with less equations. We will recreate the controls anyway.
                .Where(_ => list.Source.Count > index)
                .Subscribe(v => box.Value = list.Source[index].Val);

            return ControlHolder.Create(@group, box, d2, label, d3);
        }
示例#8
0
        public static IDisposable CreateControl(PropertyManagerPageBase pmp, IPropertyManagerPageGroup @group, CompositeSourceList <SwEq> list, int index)
        {
            var equation = list.Source[index];

            var caption = equation.Id.CamelCaseToHumanReadable();
            var label   = pmp.CreateLabel(@group, caption, caption);
            var id      = pmp.NextId();
            var box     = @group.CreateNumberBox(id, caption, caption);

            if (equation.UnitsType == UnitsEnum.Angle)
            {
                box.SetRange2((int)swNumberboxUnitType_e.swNumberBox_Angle, -10, 10, true, 0.005, 0.010, 0.001);
                box.DisplayedUnit = (int)swAngleUnit_e.swDEGREES;
            }
            else
            {
                const double increment = 1e-2;
                box.SetRange2((int)swNumberboxUnitType_e.swNumberBox_Length, -10, 10, true, increment, increment * 10, increment / 10);
                box.DisplayedUnit = (int)swLengthUnit_e.swMM;
            }
            var obs = pmp.NumberBoxChangedObservable(id);
            var d2  = obs.Subscribe(value => list.ReplaceAt(index, equation.WithValue(value)));

            var d3 = list.ChangesObservable()
                     .Ignore()
                     .StartWith(Unit.Default)
                     // Don't set value when we selected another model with less equations. We will recreate the controls anyway.
                     .Where(_ => list.Source.Count > index)
                     .Subscribe(v => box.Value = list.Source[index].Val);

            return(ControlHolder.Create(@group, box, d2, label, d3));
        }
        protected IDisposable CreateButton(IPropertyManagerPageGroup @group, string tip, string caption, Action onClick)
        {
            var id  = NextId();
            var box = PropertyManagerGroupExtensions.CreateButton(@group, id, caption, tip);
            var d0  = ButtonPressedObservable(id).Subscribe(_ => onClick());

            return(ControlHolder.Create(@group, box, d0));
        }
示例#10
0
        protected IDisposable CreateButton(IPropertyManagerPageGroup @group, string tip, string caption, Action onClick, Func <IPropertyManagerPageButton, IDisposable> config = null)
        {
            var id  = NextId();
            var box = PropertyManagerGroupExtensions.CreateButton(@group, id, caption, tip);
            var d0  = ButtonPressedObservable(id).Subscribe(_ => onClick());

            return(ControlHolder.Create(@group, box, d0, config?.Invoke(box) ?? Disposable.Empty));
        }
示例#11
0
        /// <summary>
        /// Creates an options group
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="TOption"></typeparam>
        /// <param name="pageGroup">The page group the options group belongs to</param>
        /// <param name="source">The model object</param>
        /// <param name="selector">The binding selector for the property on the model</param>
        /// <param name="builder">A callback which is passed the options group object. You can add options here. </param>
        /// <returns></returns>
        protected IDisposable CreateOptionGroup <T, TOption>
            (IPropertyManagerPageGroup pageGroup, T source, Expression <Func <T, TOption> > selector, Action <OptionGroup <T, TOption> > builder)
        {
            var optionGroup = new OptionGroup <T, TOption>(this, pageGroup, source, selector);

            builder(optionGroup);
            return(optionGroup);
        }
示例#12
0
        private IDisposable CreateLabel(IPropertyManagerPageGroup @group, string tip, IObservable <string> captionObs, Func <IPropertyManagerPageLabel, IDisposable> config)
        {
            var id  = NextId();
            var box = @group.CreateLabel(id, string.Empty, tip);
            var d1  = config?.Invoke(box) ?? Disposable.Empty;
            var d0  = captionObs.Subscribe(caption => box.Caption = caption);

            return(ControlHolder.Create(@group, box, d0, d1));
        }
 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));
 }
示例#14
0
        protected IDisposable CreateTextBox(IPropertyManagerPageGroup @group, string caption, string tip, Func <string> get, Action <string> set)
        {
            var id   = NextId();
            var text = PropertyManagerGroupExtensions.CreateTextBox(@group, id, caption, tip);

            text.Text = get();
            var d = TextBoxChangedObservable(id).Subscribe(set);

            return(ControlHolder.Create(@group, text, d));
        }
示例#15
0
 public IDisposable CreatePMPControlFromForm(IPropertyManagerPageGroup @group,
                                             Form host,
                                             Action <IPropertyManagerPageWindowFromHandle> config = null) => CreatePMPControlFromForm
     (@group,
     host,
     c =>
 {
     config?.Invoke(c);
     return(Disposable.Empty);
 });
示例#16
0
 protected IDisposable CreateSelectionBox <TModel>(
     IPropertyManagerPageGroup @group,
     string tip,
     string caption,
     swSelectType_e[] selectType,
     TModel model,
     Expression <Func <TModel, SelectionData> > propertyExpr,
     Action <IPropertyManagerPageSelectionbox> config)
 {
     return(CreateSelectionBox(@group, tip, caption, selectType, model, propertyExpr, config, () => { }));
 }
示例#17
0
        protected IDisposable CreateListBox(IPropertyManagerPageGroup @group, string caption, string tip, Func <int> get, Action <int> set, Action <IPropertyManagerPageListbox> config)
        {
            var id   = NextId();
            var list = PropertyManagerGroupExtensions.CreateListBox(@group, id, caption, tip);

            config(list);
            list.CurrentSelection = (short)get();
            var d = ListBoxSelectionObservable(id).Subscribe(set);

            return(ControlHolder.Create(@group, list, d));
        }
示例#18
0
 private static IDisposable InitControl <T, TContrl, TProp>(
     IPropertyManagerPageGroup @group,
     TContrl control,
     Func <TContrl, IDisposable> controlConfig,
     Expression <Func <TContrl, TProp> > ctrlPropSelector,
     IObservable <TProp> ctrlPropChangeObservable,
     T propParent,
     Expression <Func <T, TProp> > propSelector)
 {
     return(InitControl(@group, control, controlConfig, ctrlPropSelector, ctrlPropChangeObservable, propParent, propSelector, x => x, x => x));
 }
        /// <summary>
        /// ReactiveUI version of CreateNumberBox
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="group"></param>
        /// <param name="tip"></param>
        /// <param name="caption"></param>
        /// <param name="source"></param>
        /// <param name="selector"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        protected IDisposable CreateNumberBox <T>(IPropertyManagerPageGroup @group,
                                                  string tip,
                                                  string caption,
                                                  T source,
                                                  Expression <Func <T, double> > selector,
                                                  Func <IPropertyManagerPageNumberbox, IDisposable> config = null)
        {
            var id  = NextId();
            var box = @group.CreateNumberBox(id, caption, tip);

            return(InitControl(@group, box, config, c => c.Value, NumberBoxChangedObservable(id), source, selector));
        }
示例#20
0
        public static IDisposable CreateControls(PropertyManagerPageBase pmp,
                                                 IPropertyManagerPageGroup @group,
                                                 CompositeSourceList <SwEq> list)
        {
            var d = new CompositeDisposable();

            for (var i = 0; i < list.Source.Count; i++)
            {
                d.Add(CreateControl(pmp, @group, list, i));
            }
            return(d);
        }
示例#21
0
        protected IDisposable CreateCheckBox <T>(IPropertyManagerPageGroup @group,
                                                 string tip,
                                                 string caption,
                                                 T source,
                                                 Expression <Func <T, bool> > selector,
                                                 Func <IPropertyManagerPageCheckbox, IDisposable> config = null,
                                                 bool enable = true)
        {
            var id  = NextId();
            var box = @group.CreateCheckBox(id, caption, tip);

            return(InitControl(@group, box, config, c => c.Checked, CheckBoxChangedObservable(id), source, selector));
        }
示例#22
0
 protected virtual TControlSw CreateSwControlInGroup(IPropertyManagerPageGroup group,
                                                     ControlOptionsAttribute opts, IAttributeSet atts)
 {
     if (m_App.IsVersionNewerOrEqual(SwVersion_e.Sw2014, 1))
     {
         return(group.AddControl2(atts.Id, (short)m_Type, atts.Name,
                                  (short)opts.Align, (short)opts.Options, atts.Description) as TControlSw);
     }
     else
     {
         return(group.AddControl(atts.Id, (short)m_Type, atts.Name,
                                 (short)opts.Align, (short)opts.Options, atts.Description) as TControlSw);
     }
 }
示例#23
0
        protected IDisposable CreateSlider <T, TProp>(
            IPropertyManagerPageGroup @group,
            string tip,
            string caption,
            T source,
            Expression <Func <T, TProp> > selector,
            Func <IPropertyManagerPageSlider, IDisposable> config,
            Func <int, TProp> controlToDataConversion,
            Func <TProp, int> dataToControlConversion)
        {
            var id      = NextId();
            var control = group.CreateSlider(id, caption, tip);

            return(InitControl(group, control, config, c => c.Position, SliderPositionChangedObservable(id), source, selector, controlToDataConversion, dataToControlConversion));
        }
 protected override PropertyManagerPageOptionBox CreateSwControlInGroup(IPropertyManagerPageGroup group,
                                                                        ControlOptionsAttribute opts, IAttributeSet atts)
 {
     return(CreateOptionBoxControl(opts, atts,
                                   (int id, short controlType, string caption, short leftAlign, int options, string tip) =>
     {
         if (m_App.IsVersionNewerOrEqual(SwVersion_e.Sw2014, 1))
         {
             return group.AddControl2(id, controlType, caption, leftAlign, options, tip) as IPropertyManagerPageOption;
         }
         else
         {
             return group.AddControl(id, controlType, caption, leftAlign, options, tip) as IPropertyManagerPageOption;
         }
     }));
 }
示例#25
0
        //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 align       = -1;
            int   options     = -1;


            //Add the groups
            options = (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Expanded |
                      (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Visible;

            group1 = (IPropertyManagerPageGroup)swPropertyPage.AddGroupBox(group1ID, "Window Form", options);

            options = (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Checkbox |
                      (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Visible;

            group2 = (IPropertyManagerPageGroup)swPropertyPage.AddGroupBox(group2ID, "User Control", options);

            options = (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Checkbox |
                      (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Visible;

            group3 = (IPropertyManagerPageGroup)swPropertyPage.AddGroupBox(group3ID, "WPF Control", options);

            //Add the controls to group1`
            controlType = (int)swPropertyManagerPageControlType_e.swControlType_WindowFromHandle;
            align       = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
            options     = (int)swAddControlOptions_e.swControlOptions_Enabled |
                          (int)swAddControlOptions_e.swControlOptions_Visible;

            dotnet1        = (IPropertyManagerPageWindowFromHandle)group1.AddControl(DotNet1ID, controlType, ".Net Windows Form Control", align, options, "This Control is added without COM");
            dotnet1.Height = 150;

            controlType = (int)swPropertyManagerPageControlType_e.swControlType_WindowFromHandle;
            align       = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
            options     = (int)swAddControlOptions_e.swControlOptions_Enabled |
                          (int)swAddControlOptions_e.swControlOptions_Visible;

            dotnet2        = (IPropertyManagerPageWindowFromHandle)group2.AddControl(DotNet2ID, controlType, ".Net User Form Control", align, options, "This Control is added without COM");
            dotnet2.Height = 150;

            dotnet3        = (IPropertyManagerPageWindowFromHandle)group3.AddControl(DotNet3ID, controlType, ".Net WPF Control", align, options, "This Control is added without COM");
            dotnet3.Height = 50;
        }
示例#26
0
        protected void DisposePage()
        {
            // 释放托管状态(托管对象)。
            if (_host != null)
            {
                _host.Parent = null;
                _host.Child  = null;
                _host.Dispose();
            }

            Marshal.FinalReleaseComObject(Page);
            Marshal.FinalReleaseComObject(PMPageWinformHandle);

            Page = null;
            PMPageWinformHandle = null;
            _wpfGroup           = null;
            _doc = null;
            App  = null;
        }
示例#27
0
        internal PropertyManagerPageGroupControl(int id, object tag, SwPropertyManagerPageHandler handler,
                                                 IPropertyManagerPageGroup group,
                                                 ISldWorks app, PropertyManagerPagePage parentPage, IMetadata metadata, bool isCheckable, bool collapse)
            : base(id, tag, handler, app, parentPage)
        {
            Group            = group;
            m_ToggleMetadata = metadata;

            m_IsCheckable = isCheckable;
            m_Collapse    = collapse;

            Handler.GroupChecked += OnGroupChecked;

            if (m_ToggleMetadata != null)
            {
                m_ToggleMetadata.Changed += OnToggleChanged;
            }

            Handler.Opened += OnPageOpened;
        }
        public static IPropertyManagerPageWindowFromHandle AddWPFUserControl(this IPropertyManagerPageGroup @group,
                                                                             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)@group.AddControl2(id,
                                                                                        controlType, caption,
                                                                                        (short)leftAlign, PropertyManagerPage2Extension.CombineOptions(options), tip);

            if (uiElementConfig != null && WpfPMPWindow != null)
            {
                uiElementConfig(new IPropertyManagerPageWindowFromHandleWrapper(WpfPMPWindow));
            }
            return(WpfPMPWindow);
        }
示例#29
0
        protected IDisposable CreateSelectionBox <TModel>(
            IPropertyManagerPageGroup @group,
            string tip,
            string caption,
            swSelectType_e[] selectType,
            TModel model,
            Expression <Func <TModel, SelectionData> > propertyExpr,
            Action <IPropertyManagerPageSelectionbox> config,
            Action onFocus)
        {
            var d = new CompositeDisposable();

            var id  = NextId();
            var box = @group.CreateSelectionBox(id, caption, tip);

            config(box);
            box.SetSelectionFilters(selectType);

            SelectionBoxFocusChangedObservable(id)
            .Subscribe(_ => onFocus())
            .DisposeWith(d);

            var canSetSelectionSubject          = new BehaviorSubject <bool>(true).DisposeWith(d);
            Func <IDisposable> startTransaction = () =>
            {
                canSetSelectionSubject.OnNext(false);
                return(Disposable.Create(() => canSetSelectionSubject.OnNext(true)));
            };

            BindFromSource(model, propertyExpr, startTransaction)
            .DisposeWith(d);

            var inTransactionObservable = canSetSelectionSubject.AsObservable();

            BindFromTarget(selectType, model, propertyExpr, id, inTransactionObservable, box)
            .DisposeWith(d);

            return(ControlHolder.Create(@group, box, d));
        }
示例#30
0
        protected IDisposable CreateComboBox <TEnum, TModel>(
            IPropertyManagerPageGroup @group,
            string caption,
            string tip,
            Func <TEnum, string> itemToStringFn,
            TModel model,
            Expression <Func <TModel, TEnum> > selectedItemExpression,
            Action <IPropertyManagerPageCombobox> config = null)
        {
            var items = Enum.GetValues(typeof(TEnum))
                        .CastArray <TEnum>()
                        .ToCompositeList();

            return(CreateComboBox(group,
                                  caption,
                                  tip,
                                  items,
                                  EqualityComparer <TEnum> .Default,
                                  itemToStringFn,
                                  model,
                                  selectedItemExpression,
                                  config));
        }
示例#31
0
 /// <summary>
 /// Creates a simple label that when the option is some it becomes
 /// visibile and displays the text in red.
 /// </summary>
 /// <param name="group"></param>
 /// <param name="errorObservable"></param>
 /// <returns></returns>
 protected IDisposable CreateErrorLabel(IPropertyManagerPageGroup @group, IObservable <LanguageExt.Option <string> > errorObservable)
 {
     return(CreateLabel(@group, "", "",
                        label =>
     {
         var ctrl = (IPropertyManagerPageControl)label;
         ctrl.TextColor = ColorTranslator.ToWin32(System.Drawing.Color.Red);
         return errorObservable.Subscribe
             (errorOpt =>
         {
             errorOpt.Match
                 (text =>
             {
                 label.Caption = text;
                 ctrl.Visible = true;
             },
                 () =>
             {
                 ctrl.Visible = false;
             });
         });
     }));
 }
示例#32
0
        //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 align = -1;
            int options = -1;

            //Add the groups
            options = (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Expanded |
                      (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Visible;

            group1 = (IPropertyManagerPageGroup)swPropertyPage.AddGroupBox(group1ID, "Sample Group 1", options);

            options = (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Checkbox |
                      (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Visible;

            group2 = (IPropertyManagerPageGroup)swPropertyPage.AddGroupBox(group2ID, "Sample Group 2", options);

            //Add the controls to group1

            //textbox1
            controlType = (int)swPropertyManagerPageControlType_e.swControlType_Textbox;
            align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
            options = (int)swAddControlOptions_e.swControlOptions_Enabled |
                      (int)swAddControlOptions_e.swControlOptions_Visible;

            textbox1 = (IPropertyManagerPageTextbox)group1.AddControl(textbox1ID, controlType, "Type Here", align, options, "This is an example textbox");

            //checkbox1
            controlType = (int)swPropertyManagerPageControlType_e.swControlType_Checkbox;
            align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
            options = (int)swAddControlOptions_e.swControlOptions_Enabled |
                      (int)swAddControlOptions_e.swControlOptions_Visible;

            checkbox1 = (IPropertyManagerPageCheckbox)group1.AddControl(checkbox1ID, controlType, "Sample Checkbox", align, options, "This is a sample checkbox");

            //option1
            controlType = (int)swPropertyManagerPageControlType_e.swControlType_Option;
            align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
            options = (int)swAddControlOptions_e.swControlOptions_Enabled |
                      (int)swAddControlOptions_e.swControlOptions_Visible;

            option1 = (IPropertyManagerPageOption)group1.AddControl(option1ID, controlType, "Option1", align, options, "Radio Buttons");

            //option2
            controlType = (int)swPropertyManagerPageControlType_e.swControlType_Option;
            align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
            options = (int)swAddControlOptions_e.swControlOptions_Enabled |
                      (int)swAddControlOptions_e.swControlOptions_Visible;

            option2 = (IPropertyManagerPageOption)group1.AddControl(option2ID, controlType, "Option2", align, options, "Radio Buttons");

            //option3
            controlType = (int)swPropertyManagerPageControlType_e.swControlType_Option;
            align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
            options = (int)swAddControlOptions_e.swControlOptions_Enabled |
                      (int)swAddControlOptions_e.swControlOptions_Visible;

            option3 = (IPropertyManagerPageOption)group1.AddControl(option3ID, controlType, "Option3", align, options, "Radio Buttons");

            //list1
            controlType = (int)swPropertyManagerPageControlType_e.swControlType_Listbox;
            align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
            options = (int)swAddControlOptions_e.swControlOptions_Enabled |
                      (int)swAddControlOptions_e.swControlOptions_Visible;

            list1 = (IPropertyManagerPageListbox)group1.AddControl(list1ID, controlType, "Sample Listbox", align, options, "List of selectable items");
            if (list1 != null)
            {
                string[] items = { "One Fish", "Two Fish", "Red Fish", "Blue Fish" };
                list1.Height = 50;
                list1.AddItems(items);
            }

            //Add controls to group2
            //selection1
            controlType = (int)swPropertyManagerPageControlType_e.swControlType_Selectionbox;
            align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
            options = (int)swAddControlOptions_e.swControlOptions_Enabled |
                      (int)swAddControlOptions_e.swControlOptions_Visible;

            selection1 = (IPropertyManagerPageSelectionbox)group2.AddControl(selection1ID, controlType, "Sample Selection", align, options, "Displays features selected in main view");
            if (selection1 != null)
            {
                int[] filter = { (int)swSelectType_e.swSelEDGES, (int)swSelectType_e.swSelVERTICES };
                selection1.Height = 40;
                selection1.SetSelectionFilters(filter);
            }

            //num1
            controlType = (int)swPropertyManagerPageControlType_e.swControlType_Numberbox;
            align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
            options = (int)swAddControlOptions_e.swControlOptions_Enabled |
                      (int)swAddControlOptions_e.swControlOptions_Visible;

            num1 = (IPropertyManagerPageNumberbox)group2.AddControl(num1ID, controlType, "Sample Numberbox", align, options, "Allows for numerical input");
            if (num1 != null)
            {
                num1.Value = 50.0;
                num1.SetRange((int)swNumberboxUnitType_e.swNumberBox_UnitlessDouble, 0.0, 100.0, 0.01, true);
            }

            //combo1
            controlType = (int)swPropertyManagerPageControlType_e.swControlType_Combobox;
            align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
            options = (int)swAddControlOptions_e.swControlOptions_Enabled |
                      (int)swAddControlOptions_e.swControlOptions_Visible;

            combo1 = (IPropertyManagerPageCombobox)group2.AddControl(combo1ID, controlType, "Sample Combobox", align, options, "Combo list");
            if (combo1 != null)
            {
                string[] items = { "One Fish", "Two Fish", "Red Fish", "Blue Fish" };
                combo1.AddItems(items);
                combo1.Height = 50;

            }
        }
 public static IDisposable CreateControls(PropertyManagerPageBase pmp,
     IPropertyManagerPageGroup @group,
     CompositeSourceList<SwEq> list)
 {
     var d = new CompositeDisposable();
     for (var i = 0; i < list.Source.Count; i++)
     {
         d.Add(CreateControl(pmp, @group, list, i));
     }
     return d;
 }
示例#34
0
        //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 align = -1;
            int options = -1;


            //Add the groups
            options = (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Expanded |
                      (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Visible;

            group1 = (IPropertyManagerPageGroup)swPropertyPage.AddGroupBox(group1ID, "Window Form", options);

            options = (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Checkbox |
                      (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Visible;

            group2 = (IPropertyManagerPageGroup)swPropertyPage.AddGroupBox(group2ID, "User Control", options);

            options = (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Checkbox |
                        (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Visible;

            group3 = (IPropertyManagerPageGroup)swPropertyPage.AddGroupBox(group3ID, "WPF Control", options);

            //Add the controls to group1`
            controlType = (int)swPropertyManagerPageControlType_e.swControlType_WindowFromHandle;
            align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
            options = (int)swAddControlOptions_e.swControlOptions_Enabled |
                      (int)swAddControlOptions_e.swControlOptions_Visible;

            dotnet1 = (IPropertyManagerPageWindowFromHandle)group1.AddControl(DotNet1ID, controlType, ".Net Windows Form Control", align, options, "This Control is added without COM");
            dotnet1.Height = 150;

            controlType = (int)swPropertyManagerPageControlType_e.swControlType_WindowFromHandle;
            align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
            options = (int)swAddControlOptions_e.swControlOptions_Enabled |
                      (int)swAddControlOptions_e.swControlOptions_Visible;

            dotnet2 = (IPropertyManagerPageWindowFromHandle)group2.AddControl(DotNet2ID, controlType, ".Net User Form Control", align, options, "This Control is added without COM");
            dotnet2.Height = 150;

            dotnet3 = (IPropertyManagerPageWindowFromHandle)group3.AddControl(DotNet3ID, controlType, ".Net WPF Control", align, options, "This Control is added without COM");
            dotnet3.Height = 50;


        }
示例#35
0
        //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 align = -1;
            int options = -1;

            //Add the groups
            options = (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Expanded |
                      (int)swAddGroupBoxOptions_e.swGroupBoxOptions_Visible;

            groupDimensions = (IPropertyManagerPageGroup)swPropertyPage.AddGroupBox(groupDimensionsID, Lang.DIMENSIONS, options);
            groupObjects = (IPropertyManagerPageGroup)swPropertyPage.AddGroupBox(groupObjectsID, Lang.POINTS, options);
            groupEvents = (IPropertyManagerPageGroup)swPropertyPage.AddGroupBox(groupEventsID, Lang.EVENTS, options);
            groupOptions = (IPropertyManagerPageGroup)swPropertyPage.AddGroupBox(groupOptionsID, Lang.OPTIONS, options);

            //Selection of dimensions
            controlType = (int)swPropertyManagerPageControlType_e.swControlType_Selectionbox;
            align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
            options = (int)swAddControlOptions_e.swControlOptions_Enabled |
                (int)swAddControlOptions_e.swControlOptions_Visible;

            selectionDimensions = (IPropertyManagerPageSelectionbox)groupDimensions.AddControl(selectionDimensionsID, controlType, Lang.RECORD_DIMENSIONS, align, options, Lang.RECORD_DIMENSIONS_HINT);
            if (selectionDimensions != null)
            {
                selectionDimensions.Height = 40;
                selectionDimensions.SetSelectionFilters(Target.dimensionFilters);
            }

            //Selection of objects
            controlType = (int)swPropertyManagerPageControlType_e.swControlType_Selectionbox;
            align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
            options = (int)swAddControlOptions_e.swControlOptions_Enabled |
                (int)swAddControlOptions_e.swControlOptions_Visible;

            selectionObjects = (IPropertyManagerPageSelectionbox)groupObjects.AddControl(selectionObjectsID, controlType, Lang.RECORD_POSITIONS, align, options, Lang.RECORD_POSITIONS_HINT);
            if (selectionObjects != null)
            {
                selectionObjects.Height = 40;
                selectionObjects.SetSelectionFilters(Target.objectFilters);
            }

            //Trace options
            traceDialog = null;
            traceDrag = null;
            traceSketch = null;
            traceRegen = null;

            // Trace drag events
            controlType = (int)swPropertyManagerPageControlType_e.swControlType_Checkbox;
            align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
            options = (int)swAddControlOptions_e.swControlOptions_Enabled |
            (int)swAddControlOptions_e.swControlOptions_Visible;

            traceDrag = (IPropertyManagerPageCheckbox)groupEvents.AddControl(cb_idDrag, controlType, Lang.DRAG, align, options, Lang.DRAG_HINT);

            // Trace dimension change events
            controlType = (int)swPropertyManagerPageControlType_e.swControlType_Checkbox;
            align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
            options = (int)swAddControlOptions_e.swControlOptions_Enabled |
                (int)swAddControlOptions_e.swControlOptions_Visible;

            traceDialog = (IPropertyManagerPageCheckbox)groupEvents.AddControl(cb_idDialog, controlType, Lang.CHANGE_DIMENSION, align, options, Lang.CHANGE_DIMENSION_HINT);

            // Trace Sketch change events
            controlType = (int)swPropertyManagerPageControlType_e.swControlType_Checkbox;
            align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
            options = (int)swAddControlOptions_e.swControlOptions_Enabled |
                (int)swAddControlOptions_e.swControlOptions_Visible;

            traceSketch = (IPropertyManagerPageCheckbox)groupEvents.AddControl(cb_idSketch, controlType, Lang.SKETCH_SOLVE, align, options, Lang.SKETCH_SOLVE_HINT);

            // Regenerate events
            controlType = (int)swPropertyManagerPageControlType_e.swControlType_Checkbox;
            align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
            options = (int)swAddControlOptions_e.swControlOptions_Enabled |
                (int)swAddControlOptions_e.swControlOptions_Visible;

            traceRegen = (IPropertyManagerPageCheckbox)groupEvents.AddControl(cb_idRegen, controlType, Lang.MODEL_REGENERATION, align, options, Lang.MODEL_REGENERATION_HINT);

            // Other Options
            // do not record double
            controlType = (int)swPropertyManagerPageControlType_e.swControlType_Checkbox;
            align = (int)swPropertyManagerPageControlLeftAlign_e.swControlAlign_LeftEdge;
            options = (int)swAddControlOptions_e.swControlOptions_Enabled |
            (int)swAddControlOptions_e.swControlOptions_Visible;

            supprDouble = (IPropertyManagerPageCheckbox)groupOptions.AddControl(optionDropDoubleID, controlType, Lang.DROP_DOUBLE, align, options, Lang.DROP_DOUBLE_HINT);
        }