private View UpdateAttributesUI(ComosWebSDK.UI.UIEdit ui) { StackLayout layout = new StackLayout() { Orientation = StackOrientation.Horizontal, }; var lbl = new Label() { Text = ui.Text, WidthRequest = ui.WidthLabel / (App.PixelDensity * 0.8), HorizontalTextAlignment = TextAlignment.End, VerticalTextAlignment = TextAlignment.Center, }; layout.Children.Add(lbl); if (ui.HasUnit && ui.Unit == "%") { // Use a slider bar. Slider slider = new Slider { Minimum = 0, Maximum = 100, HorizontalOptions = LayoutOptions.FillAndExpand, BindingContext = ui, Value = int.Parse(ui.Value), IsEnabled = !ui.ReadOnly, }; slider.ValueChanged += Slider_ValueChanged; layout.Children.Add(slider); } else { var txt = new Entry() { Text = ui.Value, HorizontalOptions = LayoutOptions.FillAndExpand, BindingContext = ui, IsEnabled = !ui.ReadOnly, }; txt.TextChanged += Entry_TextChanged; layout.Children.Add(txt); if (ui.HasUnit) { layout.Children.Add(new Label() { Text = ui.Unit, }); } } AbsoluteLayout.SetLayoutBounds(layout, new Rectangle( ui.x, ui.y, ui.width, ui.height)); return(layout); }
private void Slider_ValueChanged(object sender, ValueChangedEventArgs e) { Slider ctrl = (Slider)sender; ComosWebSDK.UI.UIEdit b = (ComosWebSDK.UI.UIEdit)ctrl.BindingContext; IBRServiceContracts.CWriteValue value = null; if (!Values.TryGetValue(b.NestedName, out value)) { value = new IBRServiceContracts.CWriteValue() { NestedName = b.NestedName, NewValue = ((int)e.NewValue).ToString(), OldValue = b.Value, WebSystemUID = this.SystemUID, }; Values.Add(b.NestedName, value); } else { value.NewValue = ((int)ctrl.Value).ToString(); } }
// Service public TResult<CWriteValueResult[]> WriteComosValues(CWriteValueCollection values, string user, string projectname, string workinglayer, string language) private void Entry_TextChanged(object sender, TextChangedEventArgs e) { Entry ctrl = (Entry)sender; ComosWebSDK.UI.UIEdit b = (ComosWebSDK.UI.UIEdit)ctrl.BindingContext; IBRServiceContracts.CWriteValue value = null; if (!Values.TryGetValue(b.NestedName, out value)) { value = new IBRServiceContracts.CWriteValue() { NestedName = b.NestedName, NewValue = e.NewTextValue, OldValue = b.Value, WebSystemUID = this.SystemUID, }; Values.Add(b.NestedName, value); } else { value.NewValue = e.NewTextValue; } }