-
Notifications
You must be signed in to change notification settings - Fork 204
/
Copy pathTabViewGettingStarted.cs
195 lines (173 loc) · 7.64 KB
/
TabViewGettingStarted.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
#region Copyright Syncfusion Inc. 2001-2018.
// Copyright Syncfusion Inc. 2001-2018. 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.Util;
using Android.Views;
using Android.Widget;
namespace SampleBrowser
{
internal class TabViewGettingStarted : SamplePage
{
Spinner DisplayModeSpinner, TabPositionSpinner, SelectionIndicatorSpinner;
Context context1;
TextView ModeText, PositionText, SelectionIndicatorText;
ArrayAdapter<String> dataAdapter,dataAdapter1;
private TabControl tabControl;
public override View GetSampleContent(Context context)
{
tabControl = new TabControl(context);
return tabControl;
}
public override View GetPropertyWindowLayout(Context context)
{
context1 = context;
DisplayModeLayout();
TabPositionLayout();
SelectionIndicatorLayout();
LinearLayout propertylayout = new LinearLayout(context);
propertylayout.Orientation = Orientation.Vertical;
//if(IsTabletDevice(context))
//{
ModeText.SetPadding(0,0,0,40);
DisplayModeSpinner.SetPadding(0,0,0,50);
PositionText.SetPadding(0, 40, 0, 40);
TabPositionSpinner.SetPadding(0, 0, 0, 50);
SelectionIndicatorText.SetPadding(0, 40, 0, 40);
SelectionIndicatorSpinner.SetPadding(0, 0, 0, 50);
// }
propertylayout.AddView(ModeText);
propertylayout.AddView(DisplayModeSpinner);
propertylayout.SetPadding(10, 10, 10, 40);
propertylayout.AddView(PositionText);
propertylayout.AddView(TabPositionSpinner);
propertylayout.SetPadding(10, 10, 10, 40);
propertylayout.AddView(SelectionIndicatorText);
propertylayout.AddView(SelectionIndicatorSpinner);
return propertylayout;
}
public static bool IsTabletDevice(Android.Content.Context context)
{
try
{
DisplayMetrics displayMetrics = context.Resources.DisplayMetrics;
float screenWidth = displayMetrics.WidthPixels / displayMetrics.Xdpi;
float screenHeight = displayMetrics.HeightPixels / displayMetrics.Ydpi;
double size = Math.Sqrt(Math.Pow(screenWidth, 2) + Math.Pow(screenHeight, 2));
return size >= 6;
}
catch
{
return false;
}
}
private void TabPositionLayout()
{
PositionText = new TextView(context1);
PositionText.TextSize = 20;
PositionText.Text = "Tab Position";
TabPositionSpinner = new Spinner(context1, SpinnerMode.Dialog);
List<String> TabPostionList = new List<String>();
TabPostionList.Add("Top");
TabPostionList.Add("Bottom");
//Data Adapter
dataAdapter = new ArrayAdapter<String>(context1, Android.Resource.Layout.SimpleSpinnerItem, TabPostionList);
dataAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
TabPositionSpinner.Adapter = dataAdapter;
//Mode Spinner Item Selected Listener
TabPositionSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) =>
{
String selectedItem = dataAdapter.GetItem(e.Position);
if (selectedItem.Equals("Top"))
{
tabControl.TabHeaderPosition = Syncfusion.Android.TabView.TabHeaderPosition.Top;
}
if (selectedItem.Equals("Bottom"))
{
tabControl.TabHeaderPosition = Syncfusion.Android.TabView.TabHeaderPosition.Bottom;
}
};
}
private void SelectionIndicatorLayout()
{
SelectionIndicatorText = new TextView(context1);
SelectionIndicatorText.TextSize = 20;
SelectionIndicatorText.Text = "SelectionIndicator Position";
SelectionIndicatorSpinner = new Spinner(context1, SpinnerMode.Dialog);
List<String> SelectionIndicatorList = new List<String>();
SelectionIndicatorList.Add("Top");
SelectionIndicatorList.Add("Bottom");
//Data Adapter
dataAdapter = new ArrayAdapter<String>(context1, Android.Resource.Layout.SimpleSpinnerItem, SelectionIndicatorList);
dataAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
SelectionIndicatorSpinner.Adapter = dataAdapter;
//Mode Spinner Item Selected Listener
SelectionIndicatorSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) =>
{
String selectedItem = dataAdapter.GetItem(e.Position);
if (selectedItem.Equals("Top"))
{
tabControl.SelectionIndicatorSettings.Position = Syncfusion.Android.TabView.SelectionIndicatorPosition.Top;
}
if (selectedItem.Equals("Bottom"))
{
tabControl.SelectionIndicatorSettings.Position = Syncfusion.Android.TabView.SelectionIndicatorPosition.Bottom;
}
};
}
private void DisplayModeLayout()
{
ModeText = new TextView(context1);
ModeText.TextSize = 20;
ModeText.Text = "Display Mode";
DisplayModeSpinner = new Spinner(context1, SpinnerMode.Dialog);
//View Mode List
List<String> DisplayModeList = new List<String>();
DisplayModeList.Add("Text");
DisplayModeList.Add("Image");
DisplayModeList.Add("NoHeader");
DisplayModeList.Add("ImageWithText");
//Data Adapter
dataAdapter1 = new ArrayAdapter<String>(context1, Android.Resource.Layout.SimpleSpinnerItem, DisplayModeList);
dataAdapter1.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
DisplayModeSpinner.Adapter = dataAdapter1;
//Mode Spinner Item Selected Listener
DisplayModeSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) =>
{
String selectedItem = dataAdapter1.GetItem(e.Position);
if (selectedItem.Equals("Text"))
{
tabControl.DisplayMode = Syncfusion.Android.TabView.TabDisplayMode.Text;
}
if (selectedItem.Equals("Image"))
{
tabControl.DisplayMode = Syncfusion.Android.TabView.TabDisplayMode.Image;
}
if (selectedItem.Equals("NoHeader"))
{
tabControl.DisplayMode = Syncfusion.Android.TabView.TabDisplayMode.NoHeader;
}
if (selectedItem.Equals("ImageWithText"))
{
tabControl.DisplayMode = Syncfusion.Android.TabView.TabDisplayMode.ImageWithText;
}
};
}
public override void OnApplyChanges()
{
base.OnApplyChanges();
tabControl.ApplyChanges();
}
}
}