-
Notifications
You must be signed in to change notification settings - Fork 204
/
SfPickerDemo_Tab.cs
244 lines (199 loc) · 9.06 KB
/
SfPickerDemo_Tab.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
using System;
using System.Collections.Generic;
using Android.Content;
using Android.Graphics;
using Android.Views;
using Android.Widget;
using Com.Syncfusion.SfPicker;
namespace SampleBrowser
{
public class SfPickerDemo_Tab: SamplePage
{
SfPicker sfpicker;
TextView eventLog;
Spinner showHeaderSpinner, showColumnHeaderSpinner;
int width;
Context context1;
TextView showHeaderText, showColumnHeaderText, headerText;
EditText headerTextView;
ArrayAdapter<String> dataAdapter;
LinearLayout propertylayout;
public SfPickerDemo_Tab()
{
}
public override View GetSampleContent(Context con)
{
float height = con.Resources.DisplayMetrics.HeightPixels; ;
LinearLayout layout = new LinearLayout(con);
Typeface tf = Typeface.CreateFromAsset(con.Assets, "Segoe_MDL2_Assets.ttf");
layout.Orientation = Android.Widget.Orientation.Vertical;
sfpicker = new SfPicker(con);
sfpicker.ShowHeader = true;
List<String> source = new List<string>();
source.Add("Yellow");
source.Add("Green");
source.Add("Orange");
source.Add("Lime");
source.Add("LightBlue");
source.Add("Pink");
source.Add("SkyBlue");
source.Add("White");
source.Add("Red");
source.Add("Aqua");
sfpicker.ItemsSource = source;
sfpicker.LayoutParameters = new ViewGroup.LayoutParams(Android.Views.ViewGroup.LayoutParams.MatchParent, (int)(height * 0.60));
sfpicker.PickerMode = PickerMode.Default;
sfpicker.ShowFooter = false;
sfpicker.SelectedItemTextSize = 20*con.Resources.DisplayMetrics.Density;
sfpicker.UnSelectedItemTextSize= 20 * con.Resources.DisplayMetrics.Density;
sfpicker.HeaderHeight = 40 * con.Resources.DisplayMetrics.Density;
sfpicker.ShowColumnHeader = false;
sfpicker.UnSelectedItemTextColor = Color.Black;
sfpicker.SelectedIndex = 7;
float density = con.Resources.DisplayMetrics.Density;
eventLog = new TextView(con);
eventLog.LayoutParameters = new ViewGroup.LayoutParams(800, 400);
layout.SetGravity(GravityFlags.CenterHorizontal);
layout.AddView(sfpicker);
string headerText1 = "PICK A COLOR";
sfpicker.ShowHeader = true;
sfpicker.HeaderText = headerText1;
sfpicker.BorderColor = Color.Red;
TextView textview = new TextView(con);
textview.Text = "Event Log";
textview.Typeface = tf;
textview.SetTextColor(Color.Black);
textview.TextSize = 20;
if (density > 2)
textview.SetPadding(20, 0, 0, 20);
else
textview.SetPadding(10, 0, 0, 10);
layout.AddView(textview);
var scrollviewer = new ScrollView(con);
var textFrame = new LinearLayout(con);
textFrame.Orientation = Android.Widget.Orientation.Vertical;
scrollviewer.AddView(textFrame);
scrollviewer.VerticalScrollBarEnabled = true;
FrameLayout bottomFrame = new FrameLayout(con);
bottomFrame.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, (int)(height));
bottomFrame.SetBackgroundColor(Color.Silver);
bottomFrame.AddView(scrollviewer);
bottomFrame.SetPadding(10, 30, 10, 0);
layout.AddView(bottomFrame);
sfpicker.ColumnHeaderText = "COLOR";
sfpicker.OnSelectionChanged += (sender, e) =>
{
eventLog = new TextView(con);
eventLog.SetTextColor(Color.Black);
if (textFrame.ChildCount == 6)
textFrame.RemoveViewAt(0);
textFrame.AddView(eventLog);
eventLog.Text = (e.NewValue).ToString() + " " + "has been Selected";
Color color = PickerHelper.GetColor(e.NewValue.ToString());
sfpicker.SetBackgroundColor(color);
sfpicker.Background.Alpha = 128;
// scrollviewer.ScrollTo(0, textFrame.Bottom);
};
return layout;
}
public override View GetPropertyWindowLayout(Android.Content.Context context)
{
context1 = context;
width = (context.Resources.DisplayMetrics.WidthPixels) / 2;
propertylayout = new LinearLayout(context);
propertylayout.SetPadding(0,30,0,0);
propertylayout.Orientation = Orientation.Vertical;
showHeaderLayout();
showColumnHeaderLayout();
HeaderTextLayout();
return propertylayout;
}
private void showHeaderLayout()
{
showHeaderText = new TextView(context1);
showHeaderText.TextSize = 20;
showHeaderText.SetPadding(0, 0, 0, 10);
showHeaderText.Text = "Show Header";
showHeaderSpinner = new Spinner(context1, SpinnerMode.Dialog);
//View Mode List
List<String> showHeaderList = new List<String>();
showHeaderList.Add("False");
showHeaderList.Add("True");
//Data Adapter
dataAdapter = new ArrayAdapter<String>(context1, Android.Resource.Layout.SimpleSpinnerItem, showHeaderList);
dataAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
showHeaderSpinner.Adapter = dataAdapter;
//Mode Spinner Item Selected Listener
showHeaderSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) =>
{
String selectedItem = dataAdapter.GetItem(e.Position);
if (selectedItem.Equals("True"))
{
sfpicker.ShowHeader = true;
}
if (selectedItem.Equals("False"))
{
sfpicker.ShowHeader = false;
}
};
LinearLayout linearLayout = new LinearLayout(context1);
linearLayout.SetPadding(20, 40, 0, 40);
linearLayout.Orientation = Android.Widget.Orientation.Vertical;
linearLayout.AddView(showHeaderText);
linearLayout.AddView(showHeaderSpinner);
propertylayout.AddView(linearLayout);
}
private void showColumnHeaderLayout()
{
showColumnHeaderText = new TextView(context1);
showColumnHeaderText.TextSize = 20;
showColumnHeaderText.SetPadding(0, 0, 0, 10);
showColumnHeaderText.Text = "Show Column Header";
showColumnHeaderSpinner = new Spinner(context1, SpinnerMode.Dialog);
//View Mode List
List<String> showColumnHeaderList = new List<String>();
showColumnHeaderList.Add("False");
showColumnHeaderList.Add("True");
//Data Adapter
dataAdapter = new ArrayAdapter<String>(context1, Android.Resource.Layout.SimpleSpinnerItem, showColumnHeaderList);
dataAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
showColumnHeaderSpinner.Adapter = dataAdapter;
//Mode Spinner Item Selected Listener
showColumnHeaderSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) =>
{
String selectedItem = dataAdapter.GetItem(e.Position);
if (selectedItem.Equals("True"))
{
sfpicker.ShowColumnHeader = true;
}
if (selectedItem.Equals("False"))
{
sfpicker.ShowColumnHeader = false;
}
};
LinearLayout linearLayout = new LinearLayout(context1);
linearLayout.SetPadding(20, 40, 0, 40);
linearLayout.Orientation = Android.Widget.Orientation.Vertical;
linearLayout.AddView(showColumnHeaderText);
linearLayout.AddView(showColumnHeaderSpinner);
propertylayout.AddView(linearLayout);
}
private void HeaderTextLayout()
{
headerText = new TextView(context1);
headerText.TextSize = 20;
headerText.SetPadding(0,0,0,10);
headerText.Text = "Header Text";
headerTextView = new EditText(context1);
headerTextView.TextSize = 18;
headerTextView.Text = "PICK A COLOR";
headerTextView.TextChanged += (sender, e) => { sfpicker.HeaderText = e.Text.ToString(); };
LinearLayout linearLayout = new LinearLayout(context1);
linearLayout.SetPadding(20, 40, 0, 40);
linearLayout.Orientation = Android.Widget.Orientation.Vertical;
linearLayout.AddView(headerText);
linearLayout.AddView(headerTextView);
propertylayout.AddView(linearLayout);
}
}
}