forked from syncfusion/xamarin-demos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GettingStarted_Mobile.cs
496 lines (437 loc) · 20.3 KB
/
GettingStarted_Mobile.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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
#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 Android.Content;
using Com.Syncfusion.Sfrangeslider;
using Android.Widget;
using Android.Views;
using Android.Graphics;
using SampleBrowser;
using droid = Android.Widget.Orientation;
using System.Collections.Generic;
using System;
namespace SampleBrowser
{
//[con(Label = "Getting Started")]
public class GettingStarted_Mobile
{
/*********************************
**Local Variable Inizialisation**
*********************************/
SfRangeSlider range, range2;
public static TickPlacement tickplacement = TickPlacement.BottomRight;
public static ValuePlacement valueplacement = ValuePlacement.BottomRight;
public static bool showlabel = true;
public static SnapsTo snapsto = SnapsTo.None;
string fromvalue, toValue, fromValue1, toValue1;
public static int rangeHeight;
LinearLayout linearLayout;
TextView departureLabel;
Context con,context;
TextView arrivalLabel, snapsToLabel;
Spinner tickSpinner, labelSpinner;
LinearLayout propertylayout, stackView3, stackView4;
ArrayAdapter<String> labelAdapter, dataAdapter;
int width;
public View GetSampleContent(Context con1)
{
con = con1;
linearLayout = new LinearLayout(con);
linearLayout.SetPadding(20, 20, 20, 30);
linearLayout.SetBackgroundColor(Color.Rgb(236, 235, 242));
linearLayout.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent);
linearLayout.Orientation = Android.Widget.Orientation.Vertical;
rangeHeight = getDimensionPixelSize(con, Resource.Dimension.range_ht);
DepatureLayout();
//RangeSlider
range = new SfRangeSlider(con);
range.Minimum = 0;
range.Maximum = 12;
range.TickFrequency = 2;
range.ShowValueLabel = true;
range.StepFrequency = 6;
range.DirectionReversed = false;
range.ValuePlacement =Com.Syncfusion.Sfrangeslider.ValuePlacement.BottomRight;
range.RangeEnd = 12;
range.RangeStart = 0;
range.TickPlacement = Com.Syncfusion.Sfrangeslider.TickPlacement.BottomRight;
range.ShowRange = true;
range.SnapsTo = Com.Syncfusion.Sfrangeslider.SnapsTo.None;
range.Orientation = Com.Syncfusion.Sfrangeslider.Orientation.Horizontal;
range.LayoutParameters = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, rangeHeight);
TimeLabelLayout();
linearLayout.AddView(range);
ArrivalLabelLayout();
//rangeSlider
range2 = new SfRangeSlider(con);
range2.Minimum = 0;
range2.Maximum = 12;
range2.TickFrequency = 2;
range2.ShowValueLabel = true;
range2.StepFrequency = 6;
range2.DirectionReversed = false;
range2.ValuePlacement = Com.Syncfusion.Sfrangeslider.ValuePlacement.BottomRight;
range2.RangeEnd = 12;
range2.RangeStart = 0;
range2.TickPlacement = Com.Syncfusion.Sfrangeslider.TickPlacement.BottomRight;
range2.ShowRange = true;
range2.SnapsTo = Com.Syncfusion.Sfrangeslider.SnapsTo.None;
range2.Orientation = Com.Syncfusion.Sfrangeslider.Orientation.Horizontal;
range2.LayoutParameters = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, rangeHeight);
TimeLableLayout2();
return linearLayout;
}
private void DepatureLayout()
{
//departureLabel
departureLabel = new TextView(con);
departureLabel.TextSize = 20;
departureLabel.Text = " " + "Departure";
departureLabel.SetTextColor(Color.Black);
}
private void TimeLabelLayout()
{
//depstack
LinearLayout depstack = new LinearLayout(con);
depstack.Orientation = Android.Widget.Orientation.Horizontal;
depstack.AddView(departureLabel);
TextView timeLabel = new TextView(con);
timeLabel.TextSize = 13;
timeLabel.Text = " " + "(in Hours)";
timeLabel.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent);
timeLabel.SetTextColor(Color.ParseColor("#939394"));
timeLabel.Gravity = GravityFlags.Center;
depstack.AddView(timeLabel);
//snapsToLabel
TextView snapsToLabel = new TextView(con);
snapsToLabel.SetHeight(50);
//linearLayout.AddView(snapsToLabel);
linearLayout.AddView(depstack);
TextView timeLabel1 = new TextView(con);
TextView textView12 = new TextView(con);
linearLayout.AddView(textView12);
linearLayout.AddView(timeLabel1);
//timeLabel1
timeLabel1.TextSize = 13;
fromValue1 = "12";
toValue1 = Math.Round(range.RangeEnd).ToString();
timeLabel1.SetTextColor(Color.ParseColor("#939394"));
timeLabel1.Text = " " + "Time: " + fromValue1 + "AM " + " - " + toValue1 + " PM";
timeLabel1.Gravity = GravityFlags.Left;
range.RangeChanged += (object sender, RangeChangedEventArgs e) => {
String pMeridian = "AM", pMeridian1 = "AM";
if (Math.Round(e.RangeStart).ToString() == "0")
{
fromValue1 = "12";
pMeridian1 = "AM";
}
else
fromValue1 = Convert.ToString(Math.Round(e.RangeStart));
if (e.RangeEnd <= 12)
toValue1 = Convert.ToString(Math.Round(e.RangeEnd));
if (Math.Round(e.RangeEnd).ToString() == "12")
pMeridian = "PM";
if (Math.Round(e.RangeEnd).ToString() == "12")
pMeridian = "PM";
if (Convert.ToString(Math.Round(e.RangeStart)).Equals(Convert.ToString(Math.Round(e.RangeEnd))))
{
if (Math.Round(e.RangeStart).ToString() == "0")
timeLabel1.Text = " " + "Time: " + fromValue1 + " " + pMeridian1;
else if (Math.Round(e.RangeEnd).ToString() == "12")
timeLabel1.Text = " " + "Time: " + toValue1 + " " + pMeridian;
else
timeLabel1.Text = " " + "Time: " + fromValue1 + " " + pMeridian1;
}
else
timeLabel1.Text = " " + "Time: " + fromValue1 + " " + pMeridian1 + " - " + toValue1 + " " + pMeridian;
};
}
private void ArrivalLabelLayout()
{
//showLabel
TextView showLabel = new TextView(con);
// showLabel.SetHeight(30);
linearLayout.AddView(showLabel);
arrivalLabel = new TextView(con);
arrivalLabel.TextSize = 20;
arrivalLabel.Text = " " + "Arrival";
arrivalLabel.SetTextColor(Color.Black);
}
private void TimeLableLayout2()
{
//timeLabel
TextView timeLabel2 = new TextView(con);
timeLabel2.TextSize = 13;
timeLabel2.Text = " " + "(in Hours)";
timeLabel2.Gravity = GravityFlags.Center;
timeLabel2.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent);
timeLabel2.SetTextColor(Color.ParseColor("#939394"));
//AdjLabel
TextView adjLabel8 = new TextView(con);
adjLabel8.SetHeight(50);
LinearLayout arrivestack = new LinearLayout(con);
arrivestack.Orientation = Android.Widget.Orientation.Horizontal;
arrivestack.AddView(arrivalLabel);
arrivestack.AddView(timeLabel2);
//linearLayout
linearLayout.AddView(adjLabel8);
linearLayout.AddView(arrivestack);
TextView adjLabel9 = new TextView(con);
linearLayout.AddView(adjLabel9);
TextView timeLabel3 = new TextView(con);
linearLayout.AddView(timeLabel3);
linearLayout.AddView(range2);
//timeLabel
timeLabel3.TextSize = 13;
timeLabel3.SetTextColor(Color.ParseColor("#939394"));
fromvalue = "12";
toValue = Math.Round(range2.RangeEnd).ToString();
timeLabel3.Text = " " + "Time: " + fromvalue + "AM " + " - " + toValue + " PM";
timeLabel3.Gravity = GravityFlags.Left;
range2.RangeChanged += (object sender, RangeChangedEventArgs e) => {
String pMeridian = "AM", pMeridian1 = "AM";
if (Math.Round(e.RangeStart).ToString() == "0")
{
fromvalue = "12";
pMeridian1 = "AM";
}
else
fromvalue = Convert.ToString(Math.Round(e.RangeStart));
if (e.RangeEnd <= 12)
toValue = Convert.ToString(Math.Round(e.RangeEnd));
if (Math.Round(e.RangeEnd).ToString() == "12")
pMeridian = "PM";
if (Convert.ToString(Math.Round(e.RangeStart)).Equals(Convert.ToString(Math.Round(e.RangeEnd))))
{
if (Math.Round(e.RangeStart).ToString() == "0")
timeLabel3.Text = " " + "Time: " + fromvalue + " " + pMeridian1;
else if (Math.Round(e.RangeEnd).ToString() == "12")
timeLabel3.Text = " " + "Time: " + toValue + " " + pMeridian;
else
timeLabel3.Text = " " + "Time: " + fromvalue + " " + pMeridian1;
}
else
timeLabel3.Text = " " + "Time: " + fromvalue + " " + pMeridian1 + " - " + toValue + " " + pMeridian;
};
}
public View GetPropertyWindowLayout(Android.Content.Context context1)
{
context = context1;
width = context.Resources.DisplayMetrics.WidthPixels / 2;
TickPlacementLayout();
LabelPlacementLayout();
ShowLabelLayout();
SnapsToLayout();
return propertylayout;
}
private void TickPlacementLayout()
{
propertylayout = new LinearLayout(context);
propertylayout.Orientation = droid.Vertical;
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(width * 2, 5);
layoutParams.SetMargins(0, 5, 0, 0);
//TICK PLACEMENT
TextView placementLabel = new TextView(context);
placementLabel.Text = " " + "Tick Placement";
placementLabel.TextSize = 20;
placementLabel.Typeface = Typeface.Create("Roboto", TypefaceStyle.Normal);
placementLabel.SetTextColor(Color.Black);
placementLabel.Gravity = GravityFlags.Left;
TextView adjLabel2 = new TextView(context);
adjLabel2.SetHeight(14);
propertylayout.AddView(adjLabel2);
//tickSpinner
tickSpinner = new Spinner(context,SpinnerMode.Dialog);
tickSpinner.SetPadding(0, 0, 0, 0);
propertylayout.AddView(placementLabel);
SeparatorView separate = new SeparatorView(context, width * 2);
separate.LayoutParameters = new ViewGroup.LayoutParams(width * 2, 5);
//propertylayout.AddView(separate, layoutParams);
TextView adjLabel3 = new TextView(context);
adjLabel3.SetHeight(20);
//propertylayout.AddView(adjLabel3);
propertylayout.AddView(tickSpinner);
TextView adjLabel4 = new TextView(context);
propertylayout.AddView(adjLabel4);
//positionList
List<String> positionList = new List<String>();
positionList.Add("BottomRight");
positionList.Add("TopLeft");
positionList.Add("Outside");
positionList.Add("Inline");
positionList.Add("None");
//dataAdapter
dataAdapter = new ArrayAdapter<String>(context, Android.Resource.Layout.SimpleSpinnerItem, positionList);
dataAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
//tickSpinner
tickSpinner.Adapter = dataAdapter;
tickSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) => {
String selectedItem = dataAdapter.GetItem(e.Position);
if (selectedItem.Equals("BottomRight"))
{
tickplacement = TickPlacement.BottomRight;
}
else if (selectedItem.Equals("TopLeft"))
{
tickplacement = TickPlacement.TopLeft;
}
else if (selectedItem.Equals("Inline"))
{
tickplacement = TickPlacement.Inline;
}
else if (selectedItem.Equals("Outside"))
{
tickplacement = TickPlacement.Outside;
}
else if (selectedItem.Equals("None"))
{
tickplacement = TickPlacement.None;
}
};
}
private void LabelPlacementLayout()
{
//LABEL PLACEMENT
TextView departureLabel = new TextView(context);
departureLabel.Text = " " + "Label Placement";
departureLabel.Typeface = Typeface.Create("Roboto", TypefaceStyle.Normal);
departureLabel.Gravity = GravityFlags.Left;
departureLabel.TextSize = 20;
departureLabel.SetTextColor(Color.Black);
List<String> labelList = new List<String>();
labelList.Add("BottomRight");
labelList.Add("TopLeft");
//labelSpinner
labelSpinner = new Spinner(context,SpinnerMode.Dialog);
labelSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) => {
String selectedItem = dataAdapter.GetItem(e.Position);
if (selectedItem.Equals("TopLeft"))
{
valueplacement = ValuePlacement.TopLeft;
}
else if (selectedItem.Equals("BottomRight"))
{
valueplacement = ValuePlacement.BottomRight;
}
};
//labelAdapter
labelAdapter = new ArrayAdapter<String>(context, Android.Resource.Layout.SimpleSpinnerItem, labelList);
labelAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
labelSpinner.Adapter = labelAdapter;
labelSpinner.SetPadding(0, 0, 0, 0);
LinearLayout.LayoutParams layoutParams2 = new LinearLayout.LayoutParams(width * 2, 7);
layoutParams2.SetMargins(0, 5, 0, 0);
propertylayout.AddView(departureLabel);
//separate2
SeparatorView separate2 = new SeparatorView(context, width * 2);
separate2.LayoutParameters = new ViewGroup.LayoutParams(width * 2, 7);
// propertylayout.AddView(separate2, layoutParams2);
//snapsToLabel
snapsToLabel = new TextView(context);
snapsToLabel.SetHeight(20);
//propertylayout.AddView(snapsToLabel);
propertylayout.AddView(labelSpinner);
propertylayout.SetPadding(15, 0, 15, 0);
TextView adjLabel12 = new TextView(context);
adjLabel12.SetHeight(20);
propertylayout.AddView(adjLabel12);
}
private void ShowLabelLayout()
{
//showLabel
TextView showLabel = new TextView(context);
showLabel.Text = " " + "Show Label";
showLabel.Typeface = Typeface.Create("Roboto", TypefaceStyle.Normal);
showLabel.Gravity = GravityFlags.Center;
showLabel.TextSize = 20;
//checkBox
Switch checkBox = new Switch(context);
checkBox.Checked = true;
checkBox.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) => {
if (e.IsChecked)
showlabel = true;
else
showlabel = false;
};
//layoutParams
LinearLayout.LayoutParams layoutParams3 = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
layoutParams3.SetMargins(0, 10, 0, 0);
LinearLayout.LayoutParams layoutParams4 = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WrapContent, 55);
layoutParams4.SetMargins(0, 10, 0, 0);
TextView textSpacing1 = new TextView(context);
propertylayout.AddView(textSpacing1);
//stackView
stackView3 = new LinearLayout(context);
stackView3.AddView(showLabel);
stackView3.AddView(checkBox, layoutParams3);
stackView3.Orientation = droid.Horizontal;
propertylayout.AddView(stackView3);
SeparatorView separate3 = new SeparatorView(context, width * 2);
separate3.LayoutParameters = new ViewGroup.LayoutParams(width * 2, 5);
LinearLayout.LayoutParams layoutParams7 = new LinearLayout.LayoutParams(width * 2, 5);
layoutParams7.SetMargins(0, 30, 0, 0);
//propertylayout.AddView(separate3, layoutParams7);
}
private void SnapsToLayout()
{
//SnapsToTicks
snapsToLabel = new TextView(context);
snapsToLabel.Text = " " + "Snaps To Tick";
snapsToLabel.Typeface = Typeface.Create("Roboto", TypefaceStyle.Normal);
snapsToLabel.Gravity = GravityFlags.Center;
snapsToLabel.TextSize = 20;
//SnapsToTicks CheckBox
Switch checkBox2 = new Switch(context);
checkBox2.Checked = false;
checkBox2.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) => {
if (e.IsChecked)
snapsto = SnapsTo.Ticks;
else
snapsto = SnapsTo.None;
};
//layoutParams
LinearLayout.LayoutParams layoutParams5 = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
layoutParams5.SetMargins(0, 20, 0, 0);
LinearLayout.LayoutParams layoutParams6 = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WrapContent, 55);
layoutParams6.SetMargins(0, 20, 0, 0);
TextView textSpacing = new TextView(context);
propertylayout.AddView(textSpacing);
//stackView
stackView4 = new LinearLayout(context);
stackView4.AddView(snapsToLabel);
stackView4.AddView(checkBox2, layoutParams5);
stackView4.Orientation = droid.Horizontal;
propertylayout.AddView(stackView4);
SeparatorView separate4 = new SeparatorView(context, width * 2);
separate4.LayoutParameters = new ViewGroup.LayoutParams(width * 2, 5);
LinearLayout.LayoutParams layoutParams8 = new LinearLayout.LayoutParams(width * 2, 5);
layoutParams8.SetMargins(0, 30, 0, 0);
// propertylayout.AddView(separate4, layoutParams8);
TextView textSpacing1 = new TextView(context);
propertylayout.AddView(textSpacing1);
}
public static int getDimensionPixelSize(Context con, int id)
{
return con.Resources.GetDimensionPixelSize(id);
}
public void OnApplyChanges()
{
range2.TickPlacement = tickplacement;
range.TickPlacement = tickplacement;
range2.ValuePlacement = valueplacement;
range.ValuePlacement = valueplacement;
range2.ShowValueLabel = showlabel;
range.ShowValueLabel = showlabel;
range2.SnapsTo = snapsto;
range.SnapsTo = snapsto;
}
}
}