using Syncfusion.SfGauge.XForms;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using UIDesign.Model;
using Xamarin.Forms;
namespace UIDesign {
public class SensorValuesDetailPage : ContentPage {
public SensorValuesDetailPage(ObservableSensorClass sensor) {
this.Title = "Werte";
Grid grid = new Grid {
VerticalOptions = LayoutOptions.FillAndExpand,
RowDefinitions = {
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto },
new RowDefinition { Height = GridLength.Auto }
},
ColumnDefinitions = {
new ColumnDefinition { Width = GridLength.Auto }
}
};
this.BindingContext = sensor;
Slider slider = new Slider {
Minimum = 0,
Maximum = 100,
Value = sensor.Value,
VerticalOptions = LayoutOptions.CenterAndExpand,
WidthRequest = 300
};
slider.ValueChanged += (sender, e) => {
sensor.Value = e.NewValue;
};
grid.Children.Add(slider, 1, 1);
Label valueLabel = new Label {
Text = sensor.Value.ToString()
};
valueLabel.SetBinding(Label.TextProperty, "Value");
grid.Children.Add(valueLabel, 1, 2);
SfCircularGauge circularGauge = new SfCircularGauge();
Scale scale = new Scale();
scale.StartValue = 0;
scale.EndValue = 100;
scale.Interval =10;
scale.StartAngle = 135;
scale.SweepAngle = 270;
scale.RimThickness = 20;
scale.RimColor = Color.FromHex("#FB0101");
scale.MinorTicksPerInterval = 3;
scale.LabelFontSize = 0.1;
NeedlePointer needlePointer = new NeedlePointer();
needlePointer.Color = Color.White;
needlePointer.KnobColor = Color.White;
needlePointer.Thickness = 5;
needlePointer.KnobRadius = 20;
needlePointer.LengthFactor = 0.8;
needlePointer.SetBinding(NeedlePointer.ValueProperty, "Value");
scale.Pointers.Add(needlePointer);
RangePointer rangePointer = new RangePointer();
rangePointer.Value = 60;
rangePointer.Color = Color.FromHex("#FFA9A9A9");
rangePointer.Thickness = 20;
rangePointer.SetBinding(RangePointer.ValueProperty, "Value");
scale.Pointers.Add(rangePointer);
circularGauge.Scales.Add(scale);
grid.Children.Add(circularGauge, 1, 3);
Label label = new Label {
Text = "Line1\nLine2\nLine3\nLine4\nLine5\nLine6\nLine7\nLine8\nLine9\nLine10\nLine11\nLine12\nLine13\nLine14\nLine15\nLine16\nLine17\nLine18\nLine19\nLine20\n",
FontSize = 20,
HorizontalOptions = LayoutOptions.CenterAndExpand
};
grid.Children.Add(label, 1, 4);
SfDigitalGauge digitalGauge1 = new SfDigitalGauge();
digitalGauge1.CharacterStrokeColor = Color.FromRgb(20, 108, 237);
digitalGauge1.CharacterHeight = 25;
digitalGauge1.CharacterSpacing = 2;
digitalGauge1.CharacterWidth = 12;
digitalGauge1.SegmentStrokeWidth = 2;
digitalGauge1.CharacterType = CharacterType.EightCrossEightDotMatrix;
digitalGauge1.SetBinding(SfDigitalGauge.ValueProperty, "Value");
grid.Children.Add(digitalGauge1, 1, 5);
SfDigitalGauge digitalGauge2 = new SfDigitalGauge();
digitalGauge2.CharacterStrokeColor = Color.FromRgb(20, 108, 237);
digitalGauge2.CharacterHeight = 25;
digitalGauge2.CharacterSpacing = 2;
digitalGauge2.CharacterWidth = 12;
digitalGauge2.SegmentStrokeWidth = 2;
digitalGauge2.CharacterType = CharacterType.EightCrossEightDotMatrix;
digitalGauge2.SetBinding(SfDigitalGauge.ValueProperty, "Value");
grid.Children.Add(digitalGauge2, 1, 6);
ScrollView scrollview = new ScrollView {
Padding = new Thickness(20)
};
StackLayout stack = new StackLayout {
HorizontalOptions = LayoutOptions.StartAndExpand,
VerticalOptions = LayoutOptions.Fill
};
stack.Children.Add(grid);
scrollview.Content = stack;
Content = scrollview;
}
}
}