public OptionGroup(PropertyManagerPageBase page, IPropertyManagerPageGroup pageGroup, T source, Expression <Func <T, TOption> > selector) { _Page = page; _PageGroup = pageGroup; _Source = source; _Selector = selector; }
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)); }
/// <summary> /// Don't call this as it is for SolidWorks only")] /// </summary> /// <param name="app"></param> /// <param name="modelDoc"></param> /// <param name="feature"></param> /// <returns></returns> public object Edit(object app, object modelDoc, object feature) { //if (feature == null) throw new ArgumentNullException(nameof(feature)); Init(app, modelDoc, feature); LoadSelections(); _EditPage = GetPropertyManagerPage(); _EditPage?.Show(); return(true); }
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); }