Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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;
 }