Ejemplo n.º 1
0
        public void CreateOption(
            string caption,
            TOption match)
        {
            var id  = _Page.NextId();
            var box = _PageGroup.CreateOption(id, caption, caption);

            _Options.Add(box);
            if (_Options.Count == 1)
            {
                box.Style = (int)swPropMgrPageOptionStyle_e.swPropMgrPageOptionStyle_FirstInGroup;
            }

            var proxy = _Selector.GetProxy(_Source);

            var d2 = _Source
                     .WhenAnyValue(_Selector)
                     .Subscribe(v1 => box.Checked = v1.Equals(match));

            var d1 = _Page.OptionCheckedObservable(id).Subscribe(v2 => proxy.Value = match);

            var d = ControlHolder.Create(_PageGroup, box, d1, d2);

            _Disposable.Add(d);
        }
Ejemplo n.º 2
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));
        }