-
Notifications
You must be signed in to change notification settings - Fork 203
/
DirectionCompass.cs
183 lines (159 loc) · 6.64 KB
/
DirectionCompass.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
#region Copyright Syncfusion Inc. 2001-2024.
// Copyright Syncfusion Inc. 2001-2024. 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;
namespace SampleBrowser
{
public class DirectionCompass : SamplePage
{
List<String> adapter;
NeedlePointer pointer;
public override View GetSampleContent (Context con)
{
SfCircularGauge sfCircularGauge = new SfCircularGauge(con);
ObservableCollection<CircularScale> circularScales = new ObservableCollection<CircularScale>();
CircularScale scale = new CircularScale();
scale.StartAngle = 270;
scale.StartValue = 0;
scale.EndValue = 16;
scale.Interval = 2;
scale.LabelOffset = 0.75;
scale.SweepAngle = 360;
scale.MinorTicksPerInterval = 1;
scale.ShowLastLabel = false;
scale.ScaleStartOffset = 0.99;
scale.ScaleEndOffset = 0.9;
scale.LabelCreated += Scale_LabelCreated;
scale.RimColor = Color.ParseColor("#E0E0E0");
scale.LabelColor = Color.ParseColor("#4B4B4B");
scale.MajorTickSettings.StartOffset = 0.9;
scale.MajorTickSettings.EndOffset = 0.83;
scale.MajorTickSettings.Width = 2;
scale.MajorTickSettings.Color = Color.ParseColor("#9E9E9E");
scale.MinorTickSettings.StartOffset = 0.9;
scale.MinorTickSettings.EndOffset = 0.85;
scale.MinorTickSettings.Width = 2;
scale.MinorTickSettings.Color = Color.ParseColor("#9E9E9E");
ObservableCollection<CircularPointer> pointers = new ObservableCollection<CircularPointer>();
pointer = new NeedlePointer();
pointer.Value = 14;
pointer.Color = Color.ParseColor("#f03e3e");
pointer.Type = Com.Syncfusion.Gauges.SfCircularGauge.Enums.NeedleType.Triangle;
pointer.LengthFactor = 0.65;
pointer.Width = 20;
pointer.KnobRadiusFactor = 0;
pointer.KnobColor = Color.White;
pointer.KnobStrokeWidth = 3;
pointer.KnobStrokeColor = Color.White;
pointer.EnableAnimation = false;
pointers.Add(pointer);
NeedlePointer needlePointer = new NeedlePointer();
needlePointer.Value = 6;
needlePointer.Type = Com.Syncfusion.Gauges.SfCircularGauge.Enums.NeedleType.Triangle;
needlePointer.LengthFactor = 0.65;
needlePointer.Width = 20;
needlePointer.Color = Color.ParseColor("#9E9E9E");
needlePointer.KnobRadiusFactor = 0.11;
needlePointer.KnobColor = Color.White;
needlePointer.KnobStrokeWidth = 3;
needlePointer.KnobStrokeColor = Color.White;
needlePointer.EnableAnimation = false;
pointers.Add(needlePointer);
scale.CircularPointers = pointers;
circularScales.Add(scale);
sfCircularGauge.CircularScales = circularScales;
sfCircularGauge.SetBackgroundColor(Color.White);
LinearLayout linearLayout = new LinearLayout(con);
linearLayout.AddView(sfCircularGauge);
linearLayout.SetPadding(30, 30, 30, 30);
linearLayout.SetBackgroundColor(Color.White);
return linearLayout;
}
private void Scale_LabelCreated(object sender, LabelCreatedEventArgs e)
{
switch ((string)e.LabelContent)
{
case "0":
e.LabelContent = "N";
break;
case "2":
e.LabelContent = "NE";
break;
case "4":
e.LabelContent = "E";
break;
case "6":
e.LabelContent = "SE";
break;
case "8":
e.LabelContent = "S";
break;
case "10":
e.LabelContent = "SW";
break;
case "12":
e.LabelContent = "W";
break;
case "14":
e.LabelContent = "NW";
break;
}
}
public override View GetPropertyWindowLayout(Android.Content.Context context)
{
TextView pointervalue1 = new TextView(context);
pointervalue1.Text = "RangePointer Color";
pointervalue1.Typeface = Typeface.DefaultBold;
pointervalue1.SetTextColor(Color.ParseColor("#262626"));
pointervalue1.TextSize = 20;
Spinner selectLabelMode = new Spinner(context, SpinnerMode.Dialog);
adapter = new List<String>() { "Red", "Blue", "Orange" };
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>
(context, Android.Resource.Layout.SimpleSpinnerItem, adapter);
dataAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleDropDownItem1Line);
selectLabelMode.Adapter = dataAdapter;
selectLabelMode.ItemSelected += SelectLabelMode_ItemSelected;
LinearLayout optionsPage = new LinearLayout(context);
optionsPage.Orientation = Orientation.Vertical;
optionsPage.AddView(pointervalue1);
optionsPage.AddView(selectLabelMode);
optionsPage.SetPadding(10, 10, 10, 10);
optionsPage.SetBackgroundColor(Color.White);
return optionsPage;
}
private void SelectLabelMode_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
{
String selectedItem = adapter[e.Position];
if (selectedItem.Equals("Red"))
{
pointer.Color = Color.Red;
}
else if (selectedItem.Equals("Blue"))
{
pointer.Color = Color.Blue;
}
else if (selectedItem.Equals("Orange"))
{
pointer.Color = Color.Orange;
}
}
}
}