-
Notifications
You must be signed in to change notification settings - Fork 204
/
Rotator_Mobile.cs
397 lines (341 loc) · 15.6 KB
/
Rotator_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
#region Copyright Syncfusion Inc. 2001-2016.
// Copyright Syncfusion Inc. 2001-2016. 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.OS;
using Android.Runtime;
using Android.Util;
using Android.Views;
using Android.Widget;
using Android.Content;
using Com.Syncfusion.Rotator;
using System.Collections;
using Android.Graphics;
namespace SampleBrowser
{
public class Rotator_Mobile
{
/*********************************
**Local Varabile Inizialization**
*********************************/
ArrayAdapter<String> tabAdapter, directionAdapter, modeAdapter;
double navigationBarHeight, statusBarHeight;
Spinner directionSpinner, tabStripSpinner, modeSpinner;
LinearLayout propertylayout, stackView3;
LinearLayout.LayoutParams layoutParams2, layoutParams3;
int height,width;
TextView adjlabel3;
SfRotator rotator;
Context context;
public Android.Views.View GetSampleContent(Android.Content.Context context)
{
Context con = context;
List<SfRotatorItem> images = new List<SfRotatorItem>();
List<int> imageID = new List<int>();
SamplPageContent(con);
/***********
**Rotator**
***********/
rotator = new SfRotator(con);
rotator.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, height / 2);//ActionBar.LayoutParameters(ViewGroup.LayoutParams.MATCH_PARENT,height/2);
rotator.NavigationStripMode = NavigationStripMode.Dots;
rotator.NavigationDirection = NavigationDirection.Horizontal;
rotator.NavigationStripPosition = NavigationStripPosition.Bottom;
rotator.SelectedIndex = 2;
rotator.EnableAutoPlay = false;
rotator.SetBackgroundColor(Color.ParseColor("#ececec"));
//Images Id List
imageID.Add(Resource.Drawable.movie1);
imageID.Add(Resource.Drawable.movie2);
imageID.Add(Resource.Drawable.movie3);
imageID.Add(Resource.Drawable.movie4);
imageID.Add(Resource.Drawable.movie5);
SfRotatorItem item;
ImageView image;
for (int i = 0; i < imageID.Count; i++)
{
item = new SfRotatorItem(con);
image = new ImageView(con);
image.SetImageResource(imageID[i]);
image.SetScaleType(ImageView.ScaleType.FitXy);
item.Content = image;
images.Add(item);
}
rotator.DataSource = images;
//Main View
LinearLayout mainView = new LinearLayout(con);
mainView.AddView(GetView(con));
return mainView;
}
private LinearLayout GetView(Context con)
{
LinearLayout completeLayout = new LinearLayout(con);
completeLayout.Orientation = Orientation.Vertical;
completeLayout.LayoutParameters = (new ActionBar.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent));
completeLayout.AddView(rotator);
completeLayout.AddView(adjlabel3);
//ScrollView
ScrollView scrollView = new ScrollView(con);
scrollView.LayoutParameters = (new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, (int)((height / 2) - (navigationBarHeight + statusBarHeight + 20))));
scrollView.AddView(GetPropertyLayout(con));
completeLayout.AddView(scrollView);
return completeLayout;
}
private void SamplPageContent(Context con)
{
height = (int)(con.Resources.DisplayMetrics.HeightPixels);
statusBarHeight = getStatusBarHeight(con);
navigationBarHeight = getNavigationBarHeight(con);
//AdjLabel
adjlabel3 = new TextView(con);
adjlabel3.LayoutParameters = (new ActionBar.LayoutParams(ViewGroup.LayoutParams.MatchParent, 10));
}
public View GetPropertyLayout(Android.Content.Context context1)
{
context = context1;
width = context.Resources.DisplayMetrics.WidthPixels / 2;
propertylayout = new LinearLayout(context);
propertylayout.Orientation = Orientation.Vertical;
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(width * 2, 2);
layoutParams.SetMargins(0, 5, 0, 0);
DirectionLayout();
TapPositionLayout();
NavigationStripLayout();
EnableAutoPlayLayout();
return propertylayout;
}
private void DirectionLayout()
{
/******************
**DirectionLabel**
******************/
TextView directionLabel = new TextView(context);
directionLabel.Text = " " + "Navigation Direction";
directionLabel.TextSize = 15;
directionLabel.Typeface = Typeface.Create("Roboto", TypefaceStyle.Bold);
directionLabel.SetTextColor(Color.Black);
directionLabel.Gravity = GravityFlags.Left;
//AdjLabel
TextView adjLabel2 = new TextView(context);
adjLabel2.SetHeight(14);
propertylayout.AddView(adjLabel2);
//DirectionSpinner
directionSpinner = new Spinner(context,SpinnerMode.Dialog);
directionSpinner.SetPadding(0, 0, 0, 0);
propertylayout.AddView(directionLabel);
SeparatorView separate = new SeparatorView(context, width * 2);
separate.LayoutParameters = new ViewGroup.LayoutParams(width * 2, 2);
//AdjLabel
TextView adjLabel3 = new TextView(context);
adjLabel3.SetHeight(20);
propertylayout.AddView(adjLabel3);
propertylayout.AddView(directionSpinner);
TextView adjLabel4 = new TextView(context);
propertylayout.AddView(adjLabel4);
//Direction List
List<String> directionList = new List<String>();
directionList.Add("Horizontal");
directionList.Add("Vertical");
//Direction adapter
directionAdapter = new ArrayAdapter<String>(context, Android.Resource.Layout.SimpleSpinnerItem, directionList);
directionAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
//Direction Spinner Item Selected Listener
directionSpinner.Adapter = directionAdapter;
directionSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) =>
{
String selectedItem = directionAdapter.GetItem(e.Position);
if (selectedItem.Equals("Horizontal"))
{
rotator.NavigationDirection = NavigationDirection.Horizontal;
}
else if (selectedItem.Equals("Vertical"))
{
rotator.NavigationDirection = NavigationDirection.Vertical;
}
};
}
private void TapPositionLayout()
{
/****************
**Tap Position**
****************/
TextView tabPoitionLabel = new TextView(context);
tabPoitionLabel.Text = " " + "Navigation Strip Position";
tabPoitionLabel.Typeface = Typeface.Create("Roboto", TypefaceStyle.Bold);
tabPoitionLabel.Gravity = GravityFlags.Left;
tabPoitionLabel.TextSize = 15;
tabPoitionLabel.SetTextColor(Color.Black);
//Tab List
List<String> tabList = new List<String>();
tabList.Add("Bottom");
tabList.Add("Top");
tabList.Add("Right");
tabList.Add("Left");
tabStripSpinner = new Spinner(context,SpinnerMode.Dialog);
//Tap Adapter
tabAdapter = new ArrayAdapter<String>(context, Android.Resource.Layout.SimpleSpinnerItem, tabList);
tabAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
//Tab Spinner
tabStripSpinner.Adapter = tabAdapter;
tabStripSpinner.SetPadding(0, 0, 0, 0);
//Tab Spinner ItemSelected Listener
tabStripSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) =>
{
String selectedItem = tabAdapter.GetItem(e.Position);
if (selectedItem.Equals("Bottom"))
{
rotator.NavigationStripPosition = NavigationStripPosition.Bottom;
}
else if (selectedItem.Equals("Top"))
{
rotator.NavigationStripPosition = NavigationStripPosition.Top;
}
if (selectedItem.Equals("Right"))
{
rotator.NavigationStripPosition = NavigationStripPosition.Right;
}
else if (selectedItem.Equals("Left"))
{
rotator.NavigationStripPosition = NavigationStripPosition.Left;
}
};
//Layout Params
layoutParams2 = new LinearLayout.LayoutParams(width * 2, 2);
layoutParams2.SetMargins(0, 5, 0, 0);
propertylayout.AddView(tabPoitionLabel);
SeparatorView separate2 = new SeparatorView(context, width * 2);
separate2.LayoutParameters = new ViewGroup.LayoutParams(width * 2, 2);
//sanpSToLabel
TextView snapsToLabel = new TextView(context);
snapsToLabel.SetHeight(20);
propertylayout.AddView(snapsToLabel);
propertylayout.AddView(tabStripSpinner);
propertylayout.SetPadding(15, 0, 15, 0);
//AdjLabel
TextView adjLabel12 = new TextView(context);
adjLabel12.SetHeight(20);
propertylayout.AddView(adjLabel12);
}
private void NavigationStripLayout()
{
/*******************
**Navigation Mode**
*******************/
TextView modeLabel = new TextView(context);
modeLabel.Text = " " + "Navigation Strip Mode";
modeLabel.Typeface = Typeface.Create("Roboto", TypefaceStyle.Bold);
modeLabel.Gravity = GravityFlags.Left;
modeLabel.TextSize = 15;
modeLabel.SetTextColor(Color.Black);
//Mode List
List<String> modeList = new List<String>();
modeList.Add("Dots");
modeList.Add("Thumbnail");
//Mode Adapter
modeAdapter = new ArrayAdapter<String>(context, Android.Resource.Layout.SimpleSpinnerItem, modeList);
modeAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
//Mode Spinner
modeSpinner = new Spinner(context,SpinnerMode.Dialog);
modeSpinner.Adapter = modeAdapter;
modeSpinner.SetPadding(0, 0, 0, 0);
//Mode Spinner Item Selected Listener
modeSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) =>
{
String selectedItem = modeAdapter.GetItem(e.Position);
if (selectedItem.Equals("Dots"))
{
rotator.NavigationStripMode = NavigationStripMode.Dots;
}
else if (selectedItem.Equals("Thumbnail"))
{
rotator.NavigationStripMode = NavigationStripMode.Thumbnail;
}
};
//LayoutParams
layoutParams3 = new LinearLayout.LayoutParams(width * 2, 7);
layoutParams2.SetMargins(0, 5, 0, 0);
propertylayout.AddView(modeLabel);
//Separator
SeparatorView separate4 = new SeparatorView(context, width * 2);
separate4.LayoutParameters = new ViewGroup.LayoutParams(width * 2, 2);
LinearLayout.LayoutParams layoutParams8 = new LinearLayout.LayoutParams(width * 2, 2);
layoutParams8.SetMargins(0, 5, 0, 0);
//Adjust Label
TextView adjustLabel = new TextView(context);
adjustLabel.SetHeight(20);
propertylayout.AddView(adjustLabel);
propertylayout.AddView(modeSpinner);
propertylayout.SetPadding(15, 0, 15, 0);
TextView adjLabel13 = new TextView(context);
adjLabel13.SetHeight(20);
propertylayout.AddView(adjLabel13);
}
private void EnableAutoPlayLayout()
{
/********************
**Enable Auto Play**
********************/
TextView autoPlayLabel = new TextView(context);
autoPlayLabel.Text = " " + "Enable AutoPlay";
autoPlayLabel.Typeface = Typeface.Create("Roboto", TypefaceStyle.Bold);
autoPlayLabel.Gravity = GravityFlags.Center;
autoPlayLabel.TextSize = 16;
//Auto Play Switch
Switch playSwitch = new Switch(context);
playSwitch.Checked = false;
playSwitch.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) =>
{
rotator.EnableAutoPlay = e.IsChecked;
};
//LayoutParams
LinearLayout.LayoutParams layoutParams5 = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
layoutParams3.SetMargins(0, 5, 0, 0);
LinearLayout.LayoutParams layoutParams4 = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WrapContent, 55);
layoutParams4.SetMargins(0, 5, 0, 0);
//StackView
stackView3 = new LinearLayout(context);
stackView3.AddView(autoPlayLabel);
stackView3.AddView(playSwitch, layoutParams5);
stackView3.Orientation = Orientation.Horizontal;
propertylayout.AddView(stackView3);
TextView textSpacing = new TextView(context);
propertylayout.AddView(textSpacing);
//Separater
SeparatorView separate3 = new SeparatorView(context, width * 2);
separate3.LayoutParameters = new ViewGroup.LayoutParams(width * 2, 2);
LinearLayout.LayoutParams layoutParams7 = new LinearLayout.LayoutParams(
width * 2, 2);
layoutParams7.SetMargins(0, 10, 0, 0);
}
private int getStatusBarHeight(Context con)
{
int barHeight = 0;
int resourceId = con.Resources.GetIdentifier("status_bar_height", "dimen", "android");
if (resourceId > 0)
{
barHeight = con.Resources.GetDimensionPixelSize(resourceId);
}
return barHeight;
}
private int getNavigationBarHeight(Context con)
{
int navBarHeight = 0;
int resourceId = con.Resources.GetIdentifier("navigation_bar_height", "dimen", "android");
if (resourceId > 0)
{
navBarHeight = con.Resources.GetDimensionPixelSize(resourceId);
}
return navBarHeight;
}
}
}