Example #1
0
        private View UpdateAttributesUI(ComosWebSDK.UI.UICheckBox ui)
        {
            StackLayout layout = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal,
            };
            Switch elm = new Switch()
            {
                IsToggled = ui.Value,
                IsEnabled = !ui.ReadOnly,
            };

            elm.BindingContext = ui;
            elm.Toggled       += SwitchToggled;
            var lbl = new Label()
            {
                HorizontalOptions       = LayoutOptions.FillAndExpand,
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment   = TextAlignment.Center,
                WidthRequest            = ui.WidthLabel / (App.PixelDensity * 0.8),
            };

            lbl.Text = ui.Text;

            layout.Children.Add(lbl);
            layout.Children.Add(elm);
            AbsoluteLayout.SetLayoutBounds(layout, new Rectangle(
                                               ui.x, ui.y, ui.width, ui.height));
            return(layout);
        }
Example #2
0
        // User changes handling
        private void SwitchToggled(object sender, ToggledEventArgs e)
        {
            Switch ctrl = (Switch)sender;

            ComosWebSDK.UI.UICheckBox b = (ComosWebSDK.UI.UICheckBox)ctrl.BindingContext;

            IBRServiceContracts.CWriteValue value = null;
            if (!Values.TryGetValue(b.NestedName, out value))
            {
                value = new IBRServiceContracts.CWriteValue()
                {
                    NestedName   = b.NestedName,
                    NewValue     = e.Value ? "1" : "0",
                    OldValue     = b.Value ? "1" : "0",
                    WebSystemUID = this.SystemUID,
                };
                Values.Add(b.NestedName, value);
            }
            else
            {
                value.NewValue = e.Value ? "1" : "0";
            }
        }