1 using System.Collections.Generic;
2 using Tizen.NUI.BaseComponents;
3 using Tizen.NUI.Components;
5 namespace Tizen.NUI.Samples
7 public class CheckBoxSample : IExample
12 private View leftbody;
13 private View rightbody;
15 private TextLabel[] createText = new TextLabel[2];
16 private TextLabel[] modeText = new TextLabel[4];
17 private TextLabel[] modeText2 = new TextLabel[4];
19 private CheckBox[] utilityCheckBox = new CheckBox[4];
20 private CheckBox[] familyCheckBox = new CheckBox[4];
21 private CheckBox[] foodCheckBox = new CheckBox[4];
22 private CheckBox[] kitchenCheckBox = new CheckBox[4];
23 private CheckBoxGroup[] group = new CheckBoxGroup[4];
25 private CheckBox[] utilityCheckBox2 = new CheckBox[4];
26 private CheckBox[] familyCheckBox2 = new CheckBox[4];
27 private CheckBox[] foodCheckBox2 = new CheckBox[4];
28 private CheckBox[] kitchenCheckBox2 = new CheckBox[4];
29 private CheckBoxGroup[] group2 = new CheckBoxGroup[4];
31 private static string[] mode = new string[]
38 public void Activate()
40 Window window = NUIApplication.GetDefaultWindow();
43 Size = new Size(1920, 1080),
44 BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f),
45 Padding = new Extents(40, 40, 40, 40),
46 Layout = new LinearLayout()
48 LinearOrientation = LinearLayout.Orientation.Horizontal,
49 CellPadding = new Size(40, 40),
50 LinearAlignment = LinearLayout.Alignment.Center,
55 ///////////////////////////////////////////////Create by Property//////////////////////////////////////////////////////////
58 Size = new Size(920, 800),
59 Layout = new LinearLayout()
61 LinearOrientation = LinearLayout.Orientation.Vertical,
65 //Create description text.
66 createText[0] = new TextLabel();
67 createText[0].Text = "Create CheckBox just by properties";
68 createText[0].TextColor = Color.White;
69 createText[0].Size = new Size(800, 100);
70 left.Add(createText[0]);
72 leftbody = new View();
73 leftbody.Layout = new GridLayout() { Columns = 4 };
75 for (int i = 0; i < num; i++)
77 group[i] = new CheckBoxGroup();
78 modeText[i] = new TextLabel();
79 modeText[i].Text = mode[i];
80 modeText[i].Size = new Size(200, 48);
81 modeText[i].HorizontalAlignment = HorizontalAlignment.Center;
82 modeText[i].VerticalAlignment = VerticalAlignment.Center;
83 leftbody.Add(modeText[i]);
86 for (int i = 0; i < num; i++)
88 //Create utility radio button.
89 utilityCheckBox[i] = new CheckBox();
90 var utilityStyle = utilityCheckBox[i].Style;
91 utilityStyle.Icon.Opacity = new Selector<float?>
96 DisabledSelected = 0.4f
98 utilityStyle.Icon.BackgroundImage = new Selector<string>
100 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
101 Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_on.png",
102 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
103 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_on.png",
105 utilityStyle.Icon.ResourceUrl = new Selector<string>
108 Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check.png",
110 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check.png",
112 utilityStyle.Icon.ImageShadow = new Selector<ImageShadow>
115 Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_shadow.png",
117 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_shadow.png",
119 utilityCheckBox[i].ApplyStyle(utilityStyle);
121 utilityCheckBox[i].Size = new Size(48, 48);
122 utilityCheckBox[i].Margin = new Extents(76, 76, 25, 25);
123 utilityCheckBox[i].ButtonIcon.Size = new Size(48, 48);
125 group[0].Add(utilityCheckBox[i]);
126 //Create family radio button.
127 familyCheckBox[i] = new CheckBox();
128 var familyStyle = familyCheckBox[i].Style;
129 familyStyle.Icon.Opacity = new Selector<float?>
134 DisabledSelected = 0.4f
136 familyStyle.Icon.BackgroundImage = "";
137 familyStyle.Icon.ResourceUrl = new Selector<string>
139 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
140 Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_24c447.png",
141 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
142 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_24c447.png",
144 familyCheckBox[i].ApplyStyle(familyStyle);
146 familyCheckBox[i].Size = new Size(48, 48);
147 familyCheckBox[i].Margin = new Extents(76, 76, 25, 25);
148 familyCheckBox[i].ButtonIcon.Size = new Size(48, 48);
149 group[1].Add(familyCheckBox[i]);
150 //Create food radio button.
151 foodCheckBox[i] = new CheckBox();
152 var foodStyle = foodCheckBox[i].Style;
153 foodStyle.Icon.Opacity = new Selector<float?>
158 DisabledSelected = 0.4f
160 foodStyle.Icon.BackgroundImage = "";
161 foodStyle.Icon.ResourceUrl = new Selector<string>
163 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
164 Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_ec7510.png",
165 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
166 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_ec7510.png",
168 foodCheckBox[i].ApplyStyle(foodStyle);
169 foodCheckBox[i].Size = new Size(48, 48);
170 familyCheckBox[i].Margin = new Extents(76, 76, 25, 25);
171 foodCheckBox[i].ButtonIcon.Size = new Size(48, 48);
173 group[2].Add(foodCheckBox[i]);
174 //Create kitchen radio button.
175 kitchenCheckBox[i] = new CheckBox();
176 var kitchenStyle = kitchenCheckBox[i].Style;
177 kitchenStyle.Icon.Opacity = new Selector<float?>
182 DisabledSelected = 0.4f
184 kitchenStyle.Icon.BackgroundImage = "";
185 kitchenStyle.Icon.ResourceUrl = new Selector<string>
187 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
188 Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_9762d9.png",
189 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
190 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_9762d9.png",
192 kitchenCheckBox[i].ApplyStyle(kitchenStyle);
193 kitchenCheckBox[i].WidthSpecification = 48;
194 kitchenCheckBox[i].HeightSpecification = 48;
195 kitchenCheckBox[i].Margin = new Extents(76, 76, 25, 25);
196 kitchenCheckBox[i].ButtonIcon.Size = new Size(48, 48);
198 group[3].Add(kitchenCheckBox[i]);
200 leftbody.Add(utilityCheckBox[i]);
201 leftbody.Add(familyCheckBox[i]);
202 leftbody.Add(foodCheckBox[i]);
203 leftbody.Add(kitchenCheckBox[i]);
205 /////////////////////////////////////////////Create by Attributes//////////////////////////////////////////////////////////
208 Size = new Size(920, 800),
209 Layout = new LinearLayout()
211 LinearOrientation = LinearLayout.Orientation.Vertical,
215 rightbody = new View();
216 rightbody.Layout = new GridLayout() { Columns = 4 };
218 //Create description text.
219 createText[1] = new TextLabel();
220 createText[1].Text = "Create CheckBox just by styles";
221 createText[1].TextColor = Color.White;
222 createText[1].Size = new Size(800, 100);
223 right.Add(createText[1]);
225 for (int i = 0; i < num; i++)
227 group2[i] = new CheckBoxGroup();
228 modeText2[i] = new TextLabel();
229 modeText2[i].Text = mode[i];
230 modeText2[i].Size = new Size(200, 48);
231 modeText2[i].HorizontalAlignment = HorizontalAlignment.Center;
232 modeText2[i].VerticalAlignment = VerticalAlignment.Center;
233 rightbody.Add(modeText2[i]);
235 //Create utility style of radio button.
236 ButtonStyle utilityStyle2 = new ButtonStyle
238 Icon = new ImageViewStyle
240 Size = new Size(48, 48),
241 Opacity = new Selector<float?>
246 DisabledSelected = 0.4f
248 BackgroundImage = new Selector<string>
250 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
251 Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_on.png",
252 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
253 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_on.png",
255 ResourceUrl = new Selector<string>
258 Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check.png",
260 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check.png",
262 ImageShadow = new Selector<ImageShadow>
265 Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_shadow.png",
267 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_shadow.png",
271 //Create family style of radio button.
272 ButtonStyle familyStyle2 = new ButtonStyle
274 Icon = new ImageViewStyle
276 Size = new Size(48, 48),
277 Opacity = new Selector<float?>
282 DisabledSelected = 0.4f
284 ResourceUrl = new Selector<string>
286 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
287 Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_24c447.png",
288 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
289 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_24c447.png",
293 //Create food style of radio button.
294 ButtonStyle foodStyle2 = new ButtonStyle
296 Icon = new ImageViewStyle
298 Size = new Size(48, 48),
299 Position = new Position(0, 0),
300 Opacity = new Selector<float?>
305 DisabledSelected = 0.4f
307 ResourceUrl = new Selector<string>
309 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
310 Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_ec7510.png",
311 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
312 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_ec7510.png",
316 //Create kitchen style of radio button.
317 ButtonStyle kitchenStyle2 = new ButtonStyle
319 Icon = new ImageViewStyle
321 Size = new Size(48, 48),
322 Position = new Position(0, 0),
323 Opacity = new Selector<float?>
328 DisabledSelected = 0.4f
330 ResourceUrl = new Selector<string>
332 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
333 Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_9762d9.png",
334 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
335 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_9762d9.png",
339 for (int i = 0; i < num; i++)
341 utilityCheckBox2[i] = new CheckBox(utilityStyle2);
342 utilityCheckBox2[i].Size = new Size(48, 48);
343 utilityCheckBox2[i].Margin = new Extents(76, 76, 25, 25);
344 group2[0].Add(utilityCheckBox2[i]);
346 familyCheckBox2[i] = new CheckBox(familyStyle2);
347 familyCheckBox2[i].Size = new Size(48, 48);
348 familyCheckBox2[i].Margin = new Extents(76, 76, 25, 25);
349 group2[1].Add(familyCheckBox2[i]);
351 foodCheckBox2[i] = new CheckBox(foodStyle2);
352 foodCheckBox2[i].Size = new Size(48, 48);
353 foodCheckBox2[i].Margin = new Extents(76, 76, 25, 25);
354 group2[2].Add(foodCheckBox2[i]);
356 kitchenCheckBox2[i] = new CheckBox(kitchenStyle2);
357 kitchenCheckBox2[i].Size = new Size(48, 48);
358 kitchenCheckBox2[i].Margin = new Extents(76, 76, 25, 25);
359 group2[3].Add(kitchenCheckBox2[i]);
361 rightbody.Add(utilityCheckBox2[i]);
362 rightbody.Add(familyCheckBox2[i]);
363 rightbody.Add(foodCheckBox2[i]);
364 rightbody.Add(kitchenCheckBox2[i]);
370 right.Add(rightbody);
372 utilityCheckBox[2].IsEnabled = false;
373 familyCheckBox[2].IsEnabled = false;
374 foodCheckBox[2].IsEnabled = false;
375 kitchenCheckBox[2].IsEnabled = false;
377 utilityCheckBox2[2].IsEnabled = false;
378 familyCheckBox2[2].IsEnabled = false;
379 foodCheckBox2[2].IsEnabled = false;
380 kitchenCheckBox2[2].IsEnabled = false;
382 utilityCheckBox[3].IsEnabled = false;
383 familyCheckBox[3].IsEnabled = false;
384 foodCheckBox[3].IsEnabled = false;
385 kitchenCheckBox[3].IsEnabled = false;
386 utilityCheckBox[3].IsSelected = true;
387 familyCheckBox[3].IsSelected = true;
388 foodCheckBox[3].IsSelected = true;
389 kitchenCheckBox[3].IsSelected = true;
391 utilityCheckBox2[3].IsEnabled = false;
392 familyCheckBox2[3].IsEnabled = false;
393 foodCheckBox2[3].IsEnabled = false;
394 kitchenCheckBox2[3].IsEnabled = false;
395 utilityCheckBox2[3].IsSelected = true;
396 familyCheckBox2[3].IsSelected = true;
397 foodCheckBox2[3].IsSelected = true;
398 kitchenCheckBox2[3].IsSelected = true;
401 public void Deactivate()
406 for (int i = 0; i < num; i++)
408 leftbody.Remove(utilityCheckBox[i]);
409 utilityCheckBox[i].Dispose();
410 utilityCheckBox[i] = null;
412 leftbody.Remove(familyCheckBox[i]);
413 familyCheckBox[i].Dispose();
414 familyCheckBox[i] = null;
416 leftbody.Remove(foodCheckBox[i]);
417 foodCheckBox[i].Dispose();
418 foodCheckBox[i] = null;
420 leftbody.Remove(kitchenCheckBox[i]);
421 kitchenCheckBox[i].Dispose();
422 kitchenCheckBox[i] = null;
424 leftbody.Remove(modeText[i]);
425 modeText[i].Dispose();
428 rightbody.Remove(utilityCheckBox2[i]);
429 utilityCheckBox2[i].Dispose();
430 utilityCheckBox2[i] = null;
432 rightbody.Remove(familyCheckBox2[i]);
433 familyCheckBox2[i].Dispose();
434 familyCheckBox2[i] = null;
436 rightbody.Remove(foodCheckBox2[i]);
437 foodCheckBox2[i].Dispose();
438 foodCheckBox2[i] = null;
440 rightbody.Remove(kitchenCheckBox2[i]);
441 kitchenCheckBox2[i].Dispose();
442 kitchenCheckBox2[i] = null;
444 rightbody.Remove(modeText2[i]);
445 modeText2[i].Dispose();
449 left.Remove(createText[0]);
450 createText[0].Dispose();
451 createText[0] = null;
452 left.Remove(leftbody);
455 right.Remove(createText[1]);
456 createText[1].Dispose();
457 createText[1] = null;
458 right.Remove(rightbody);
469 NUIApplication.GetDefaultWindow().Remove(root);