forked from syncfusion/xamarin-demos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pointers.cs
274 lines (233 loc) · 11.4 KB
/
Pointers.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
#region Copyright Syncfusion Inc. 2001-2022.
// Copyright Syncfusion Inc. 2001-2022. All rights reserved.
// Use of this code is subject to the terms of our license.
// A copy of the current license can be obtained at any time by e-mailing
// [email protected]. Any infringement will be prosecuted under
// applicable laws.
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Com.Syncfusion.Gauges.SfCircularGauge;
using System.Collections.ObjectModel;
using Android.Graphics;
using Com.Syncfusion.Gauges.SfCircularGauge.Enums;
using Android.Renderscripts;
using static Android.App.ActionBar;
namespace SampleBrowser
{
public class Pointers : SamplePage
{
public override View GetSampleContent(Context con)
{
SfCircularGauge sfCircularGauge = new SfCircularGauge(con);
ObservableCollection<Header> headers = new ObservableCollection<Header>();
Header header = new Header();
header.Text = "Inverted Traingle";
header.TextSize = 18;
header.TextColor = Color.Black;
header.Position = new PointF((float)0.5, (float)0.6);
headers.Add(header);
sfCircularGauge.Headers = headers;
ObservableCollection<CircularScale> circularScales = new ObservableCollection<CircularScale>();
CircularScale scale = new CircularScale();
scale.StartAngle = 180;
scale.SweepAngle = 180;
scale.ScaleStartOffset = 0.7;
scale.ScaleEndOffset = 0.68;
scale.StartValue = 0;
scale.EndValue = 100;
scale.RimColor = Color.Gray;
scale.Interval = 50;
scale.ShowLabels = false;
scale.ShowTicks = false;
scale.MinorTicksPerInterval = 0;
ObservableCollection<CircularPointer> pointers = new ObservableCollection<CircularPointer>();
MarkerPointer markerPointer = new MarkerPointer();
markerPointer.Value = 80;
markerPointer.Color = Color.ParseColor("#00bdae");
markerPointer.Offset = 0.7;
markerPointer.MarkerShape = Com.Syncfusion.Gauges.SfCircularGauge.Enums.MarkerShape.InvertedTriangle;
pointers.Add(markerPointer);
scale.CircularPointers = pointers;
circularScales.Add(scale);
sfCircularGauge.CircularScales = circularScales;
sfCircularGauge.SetBackgroundColor(Color.White);
//triangle
SfCircularGauge sfCircularGauge1 = new SfCircularGauge(con);
ObservableCollection<Header> headers1 = new ObservableCollection<Header>();
Header header1 = new Header();
header1.Text = "Traingle";
header1.TextSize = 18;
header1.TextColor = Color.Black;
header1.Position = new PointF((float)0.5, (float)0.6);
headers1.Add(header1);
sfCircularGauge1.Headers = headers1;
ObservableCollection<CircularScale> circularScales1 = new ObservableCollection<CircularScale>();
CircularScale scale1 = new CircularScale();
scale1.StartAngle = 180;
scale1.SweepAngle = 180;
scale1.ScaleStartOffset = 0.7;
scale1.ScaleEndOffset = 0.68;
scale1.StartValue = 0;
scale1.EndValue = 100;
scale1.RimColor = Color.Gray;
scale1.Interval = 50;
scale1.ShowLabels = false;
scale1.ShowTicks = false;
scale1.MinorTicksPerInterval = 0;
ObservableCollection<CircularPointer> pointers1 = new ObservableCollection<CircularPointer>();
MarkerPointer markerPointer1 = new MarkerPointer();
markerPointer1.Value = 80;
markerPointer1.Color = Color.Green;
markerPointer1.Offset = 0.68;
markerPointer1.MarkerShape = Com.Syncfusion.Gauges.SfCircularGauge.Enums.MarkerShape.Triangle;
pointers1.Add(markerPointer1);
scale1.CircularPointers = pointers1;
circularScales1.Add(scale1);
sfCircularGauge1.CircularScales = circularScales1;
sfCircularGauge1.SetBackgroundColor(Color.White);
//range pointer
SfCircularGauge sfCircularGauge2 = new SfCircularGauge(con);
ObservableCollection<Header> headers2 = new ObservableCollection<Header>();
Header header2 = new Header();
header2.Text = "Range Pointer";
header2.TextSize = 18;
header2.TextColor = Color.Black;
header2.Position = new PointF((float)0.5, (float)0.6);
headers2.Add(header2);
sfCircularGauge2.Headers = headers2;
ObservableCollection<CircularScale> circularScales2 = new ObservableCollection<CircularScale>();
CircularScale scale2 = new CircularScale();
scale2.StartAngle = 180;
scale2.SweepAngle = 180;
scale2.StartValue = 0;
scale2.EndValue = 100;
scale2.RadiusFactor = 0.7;
scale2.RimColor = Color.Gray;
scale2.Interval = 50;
scale2.ShowLabels = false;
scale2.ShowTicks = false;
scale2.RimWidth = 3;
scale2.MinorTicksPerInterval = 0;
ObservableCollection<CircularPointer> pointers2 = new ObservableCollection<CircularPointer>();
RangePointer rangePointer = new RangePointer();
rangePointer.Value = 60;
rangePointer.Color = Color.ParseColor("#FF2680");
rangePointer.Offset = 0.6;
rangePointer.Width = 20;
rangePointer.EnableAnimation = false;
pointers2.Add(rangePointer);
scale2.CircularPointers = pointers2;
circularScales2.Add(scale2);
sfCircularGauge2.CircularScales = circularScales2;
sfCircularGauge2.SetBackgroundColor(Color.White);
//needlepointer
SfCircularGauge sfCircularGauge3 = new SfCircularGauge(con);
ObservableCollection<Header> headers3 = new ObservableCollection<Header>();
Header header3 = new Header();
header3.Text = "Needle Pointer";
header3.TextSize = 18;
header3.TextColor = Color.Black;
header3.Position = new PointF((float)0.5, (float)0.6);
headers3.Add(header3);
sfCircularGauge3.Headers = headers3;
ObservableCollection<CircularScale> circularScales3 = new ObservableCollection<CircularScale>();
CircularScale scale3 = new CircularScale();
scale3.StartAngle = 180;
scale3.SweepAngle = 180;
scale3.StartValue = 0;
scale3.EndValue = 100;
scale3.RadiusFactor = 0.7;
scale3.RimColor = Color.Gray;
scale3.Interval = 50;
scale3.ShowLabels = false;
scale3.ShowTicks = false;
scale3.RimWidth = 3;
scale3.MinorTicksPerInterval = 0;
ObservableCollection<CircularPointer> pointers3 = new ObservableCollection<CircularPointer>();
NeedlePointer needlePointer = new NeedlePointer();
needlePointer.Value = 80;
needlePointer.Color = Color.Purple;
needlePointer.LengthFactor = 0.7;
needlePointer.KnobRadius = 0;
needlePointer.Width = 10;
needlePointer.Type = NeedleType.Triangle;
pointers3.Add(needlePointer);
scale3.CircularPointers = pointers3;
circularScales3.Add(scale3);
sfCircularGauge3.CircularScales = circularScales3;
sfCircularGauge3.SetBackgroundColor(Color.White);
SfCircularGauge sfCircularGauge4 = new SfCircularGauge(con);
ObservableCollection<Header> headers4 = new ObservableCollection<Header>();
Header header4 = new Header();
header4.Text = "Multiple Needle";
header4.TextSize = 18;
header4.TextColor = Color.Black;
header4.Position = new PointF((float)0.5, (float)0.7);
headers4.Add(header4);
sfCircularGauge4.Headers = headers4;
ObservableCollection<CircularScale> circularScales4 = new ObservableCollection<CircularScale>();
CircularScale scale4 = new CircularScale();
scale4.StartAngle = 180;
scale4.SweepAngle = 180;
scale4.StartValue = 0;
scale4.EndValue = 100;
scale4.RadiusFactor = 0.7;
scale4.RimColor = Color.Gray;
scale4.Interval = 50;
scale4.ShowLabels = false;
scale4.ShowTicks = false;
scale4.RimWidth = 3;
scale4.MinorTicksPerInterval = 0;
ObservableCollection<CircularPointer> pointers4 = new ObservableCollection<CircularPointer>();
NeedlePointer needlePointer1 = new NeedlePointer();
needlePointer1.Value = 40;
needlePointer1.Color = Color.ParseColor("#ed7d31");
needlePointer1.LengthFactor = 0.5;
needlePointer1.KnobRadiusFactor = 0.05;
needlePointer1.KnobColor = Color.White;
needlePointer1.Width = 10;
needlePointer1.Type = NeedleType.Triangle;
needlePointer1.TailStrokeColor = Color.ParseColor("#ed7d31");
needlePointer1.KnobStrokeWidth = 2;
needlePointer1.KnobStrokeColor = Color.ParseColor("#ed7d31");
pointers4.Add(needlePointer1);
NeedlePointer needlePointer2 = new NeedlePointer();
needlePointer2.Value = 70;
needlePointer2.Color = Color.ParseColor("#ed7d31");
needlePointer2.LengthFactor = 0.6;
needlePointer2.KnobRadiusFactor = 0.05;
needlePointer2.KnobColor = Color.White;
needlePointer2.Width = 10;
needlePointer2.Type = NeedleType.Triangle;
needlePointer2.TailStrokeColor = Color.ParseColor("#ed7d31");
needlePointer2.KnobStrokeWidth = 2;
needlePointer2.KnobStrokeColor = Color.ParseColor("#ed7d31");
pointers4.Add(needlePointer2);
scale4.CircularPointers = pointers4;
circularScales4.Add(scale4);
sfCircularGauge4.CircularScales = circularScales4;
sfCircularGauge4.SetBackgroundColor(Color.White);
LinearLayout linearLayout = new LinearLayout(con);
linearLayout.Orientation = Orientation.Vertical;
linearLayout.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
linearLayout.AddView(sfCircularGauge, LayoutParams.WrapContent, (int)(250 * con.Resources.DisplayMetrics.Density));
linearLayout.AddView(sfCircularGauge1, LayoutParams.WrapContent, (int)(250 * con.Resources.DisplayMetrics.Density));
linearLayout.AddView(sfCircularGauge2, LayoutParams.WrapContent, (int)(250 * con.Resources.DisplayMetrics.Density));
linearLayout.AddView(sfCircularGauge3, LayoutParams.WrapContent, (int)(250 * con.Resources.DisplayMetrics.Density));
linearLayout.AddView(sfCircularGauge4, LayoutParams.WrapContent, (int)(250 * con.Resources.DisplayMetrics.Density));
linearLayout.SetPadding(30, 30, 30, 30);
ScrollView mainView = new ScrollView(con);
mainView.AddView(linearLayout);
return mainView;
}
}
}