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++)
90 //Create utility radio button.
91 utilityCheckBox[i] = new CheckBox();
92 utilityCheckBox[i].SelectedChanged += (object sender, SelectedChangedEventArgs args) =>
94 global::System.Console.WriteLine($"Left {index}th Utility CheckBox's IsSelected is changed to {args.IsSelected}.");
96 var utilityStyle = utilityCheckBox[i].Style;
97 utilityStyle.Icon.Opacity = new Selector<float?>
102 DisabledSelected = 0.4f
104 utilityStyle.Icon.BackgroundImage = new Selector<string>
106 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
107 Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_on.png",
108 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
109 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_on.png",
111 utilityStyle.Icon.ResourceUrl = new Selector<string>
114 Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check.png",
116 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check.png",
118 utilityStyle.Icon.ImageShadow = new Selector<ImageShadow>
121 Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_shadow.png",
123 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_shadow.png",
125 utilityCheckBox[i].ApplyStyle(utilityStyle);
127 utilityCheckBox[i].Size = new Size(48, 48);
128 utilityCheckBox[i].Margin = new Extents(76, 76, 25, 25);
129 utilityCheckBox[i].Icon.Size = new Size(48, 48);
131 group[0].Add(utilityCheckBox[i]);
132 //Create family radio button.
133 familyCheckBox[i] = new CheckBox();
134 familyCheckBox[i].SelectedChanged += (object sender, SelectedChangedEventArgs args) =>
136 global::System.Console.WriteLine($"Left {index}th Family CheckBox's IsSelected is changed to {args.IsSelected}.");
138 var familyStyle = familyCheckBox[i].Style;
139 familyStyle.Icon.Opacity = new Selector<float?>
144 DisabledSelected = 0.4f
146 familyStyle.Icon.BackgroundImage = "";
147 familyStyle.Icon.ResourceUrl = new Selector<string>
149 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
150 Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_24c447.png",
151 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
152 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_24c447.png",
154 familyCheckBox[i].ApplyStyle(familyStyle);
156 familyCheckBox[i].Size = new Size(48, 48);
157 familyCheckBox[i].Margin = new Extents(76, 76, 25, 25);
158 familyCheckBox[i].Icon.Size = new Size(48, 48);
159 group[1].Add(familyCheckBox[i]);
160 //Create food radio button.
161 foodCheckBox[i] = new CheckBox();
162 foodCheckBox[i].SelectedChanged += (object sender, SelectedChangedEventArgs args) =>
164 global::System.Console.WriteLine($"Left {index}th Food CheckBox's IsSelected is changed to {args.IsSelected}.");
166 var foodStyle = foodCheckBox[i].Style;
167 foodStyle.Icon.Opacity = new Selector<float?>
172 DisabledSelected = 0.4f
174 foodStyle.Icon.BackgroundImage = "";
175 foodStyle.Icon.ResourceUrl = new Selector<string>
177 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
178 Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_ec7510.png",
179 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
180 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_ec7510.png",
182 foodCheckBox[i].ApplyStyle(foodStyle);
183 foodCheckBox[i].Size = new Size(48, 48);
184 familyCheckBox[i].Margin = new Extents(76, 76, 25, 25);
185 foodCheckBox[i].Icon.Size = new Size(48, 48);
187 group[2].Add(foodCheckBox[i]);
188 //Create kitchen radio button.
189 kitchenCheckBox[i] = new CheckBox();
190 kitchenCheckBox[i].SelectedChanged += (object sender, SelectedChangedEventArgs args) =>
192 global::System.Console.WriteLine($"Left {index}th Kitchen CheckBox's IsSelected is changed to {args.IsSelected}.");
194 var kitchenStyle = kitchenCheckBox[i].Style;
195 kitchenStyle.Icon.Opacity = new Selector<float?>
200 DisabledSelected = 0.4f
202 kitchenStyle.Icon.BackgroundImage = "";
203 kitchenStyle.Icon.ResourceUrl = new Selector<string>
205 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
206 Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_9762d9.png",
207 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
208 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_9762d9.png",
210 kitchenCheckBox[i].ApplyStyle(kitchenStyle);
211 kitchenCheckBox[i].WidthSpecification = 48;
212 kitchenCheckBox[i].HeightSpecification = 48;
213 kitchenCheckBox[i].Margin = new Extents(76, 76, 25, 25);
214 kitchenCheckBox[i].Icon.Size = new Size(48, 48);
216 group[3].Add(kitchenCheckBox[i]);
218 leftbody.Add(utilityCheckBox[i]);
219 leftbody.Add(familyCheckBox[i]);
220 leftbody.Add(foodCheckBox[i]);
221 leftbody.Add(kitchenCheckBox[i]);
223 /////////////////////////////////////////////Create by Attributes//////////////////////////////////////////////////////////
226 Size = new Size(920, 800),
227 Layout = new LinearLayout()
229 LinearOrientation = LinearLayout.Orientation.Vertical,
233 rightbody = new View();
234 rightbody.Layout = new GridLayout() { Columns = 4 };
236 //Create description text.
237 createText[1] = new TextLabel();
238 createText[1].Text = "Create CheckBox just by styles";
239 createText[1].TextColor = Color.White;
240 createText[1].Size = new Size(800, 100);
241 right.Add(createText[1]);
243 for (int i = 0; i < num; i++)
245 group2[i] = new CheckBoxGroup();
246 modeText2[i] = new TextLabel();
247 modeText2[i].Text = mode[i];
248 modeText2[i].Size = new Size(200, 48);
249 modeText2[i].HorizontalAlignment = HorizontalAlignment.Center;
250 modeText2[i].VerticalAlignment = VerticalAlignment.Center;
251 rightbody.Add(modeText2[i]);
253 //Create utility style of radio button.
254 ButtonStyle utilityStyle2 = new ButtonStyle
256 Icon = new ImageViewStyle
258 Size = new Size(48, 48),
259 Opacity = new Selector<float?>
264 DisabledSelected = 0.4f
266 BackgroundImage = new Selector<string>
268 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
269 Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_on.png",
270 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
271 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_on.png",
273 ResourceUrl = new Selector<string>
276 Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check.png",
278 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check.png",
280 ImageShadow = new Selector<ImageShadow>
283 Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_shadow.png",
285 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_shadow.png",
289 //Create family style of radio button.
290 ButtonStyle familyStyle2 = new ButtonStyle
292 Icon = new ImageViewStyle
294 Size = new Size(48, 48),
295 Opacity = new Selector<float?>
300 DisabledSelected = 0.4f
302 ResourceUrl = new Selector<string>
304 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
305 Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_24c447.png",
306 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
307 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_24c447.png",
311 //Create food style of radio button.
312 ButtonStyle foodStyle2 = new ButtonStyle
314 Icon = new ImageViewStyle
316 Size = new Size(48, 48),
317 Position = new Position(0, 0),
318 Opacity = new Selector<float?>
323 DisabledSelected = 0.4f
325 ResourceUrl = new Selector<string>
327 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
328 Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_ec7510.png",
329 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
330 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_ec7510.png",
334 //Create kitchen style of radio button.
335 ButtonStyle kitchenStyle2 = new ButtonStyle
337 Icon = new ImageViewStyle
339 Size = new Size(48, 48),
340 Position = new Position(0, 0),
341 Opacity = new Selector<float?>
346 DisabledSelected = 0.4f
348 ResourceUrl = new Selector<string>
350 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
351 Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_9762d9.png",
352 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_check_off.png",
353 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_check_on_9762d9.png",
357 for (int i = 0; i < num; i++)
361 utilityCheckBox2[i] = new CheckBox(utilityStyle2);
362 utilityCheckBox2[i].SelectedChanged += (object sender, SelectedChangedEventArgs args) =>
364 global::System.Console.WriteLine($"Right {index}th Utility CheckBox's IsSelected is changed to {args.IsSelected}.");
366 utilityCheckBox2[i].Size = new Size(48, 48);
367 utilityCheckBox2[i].Margin = new Extents(76, 76, 25, 25);
368 group2[0].Add(utilityCheckBox2[i]);
370 familyCheckBox2[i] = new CheckBox(familyStyle2);
371 familyCheckBox2[i].SelectedChanged += (object sender, SelectedChangedEventArgs args) =>
373 global::System.Console.WriteLine($"Right {index}th Family CheckBox's IsSelected is changed to {args.IsSelected}.");
375 familyCheckBox2[i].Size = new Size(48, 48);
376 familyCheckBox2[i].Margin = new Extents(76, 76, 25, 25);
377 group2[1].Add(familyCheckBox2[i]);
379 foodCheckBox2[i] = new CheckBox(foodStyle2);
380 foodCheckBox2[i].SelectedChanged += (object sender, SelectedChangedEventArgs args) =>
382 global::System.Console.WriteLine($"Right {index}th Food CheckBox's IsSelected is changed to {args.IsSelected}.");
384 foodCheckBox2[i].Size = new Size(48, 48);
385 foodCheckBox2[i].Margin = new Extents(76, 76, 25, 25);
386 group2[2].Add(foodCheckBox2[i]);
388 kitchenCheckBox2[i] = new CheckBox(kitchenStyle2);
389 kitchenCheckBox2[i].SelectedChanged += (object sender, SelectedChangedEventArgs args) =>
391 global::System.Console.WriteLine($"Right {index}th Kitchen CheckBox's IsSelected is changed to {args.IsSelected}.");
393 kitchenCheckBox2[i].Size = new Size(48, 48);
394 kitchenCheckBox2[i].Margin = new Extents(76, 76, 25, 25);
395 group2[3].Add(kitchenCheckBox2[i]);
397 rightbody.Add(utilityCheckBox2[i]);
398 rightbody.Add(familyCheckBox2[i]);
399 rightbody.Add(foodCheckBox2[i]);
400 rightbody.Add(kitchenCheckBox2[i]);
406 right.Add(rightbody);
408 utilityCheckBox[2].IsEnabled = false;
409 familyCheckBox[2].IsEnabled = false;
410 foodCheckBox[2].IsEnabled = false;
411 kitchenCheckBox[2].IsEnabled = false;
413 utilityCheckBox2[2].IsEnabled = false;
414 familyCheckBox2[2].IsEnabled = false;
415 foodCheckBox2[2].IsEnabled = false;
416 kitchenCheckBox2[2].IsEnabled = false;
418 utilityCheckBox[3].IsEnabled = false;
419 familyCheckBox[3].IsEnabled = false;
420 foodCheckBox[3].IsEnabled = false;
421 kitchenCheckBox[3].IsEnabled = false;
422 utilityCheckBox[3].IsSelected = true;
423 familyCheckBox[3].IsSelected = true;
424 foodCheckBox[3].IsSelected = true;
425 kitchenCheckBox[3].IsSelected = true;
427 utilityCheckBox2[3].IsEnabled = false;
428 familyCheckBox2[3].IsEnabled = false;
429 foodCheckBox2[3].IsEnabled = false;
430 kitchenCheckBox2[3].IsEnabled = false;
431 utilityCheckBox2[3].IsSelected = true;
432 familyCheckBox2[3].IsSelected = true;
433 foodCheckBox2[3].IsSelected = true;
434 kitchenCheckBox2[3].IsSelected = true;
437 public void Deactivate()
442 for (int i = 0; i < num; i++)
444 leftbody.Remove(utilityCheckBox[i]);
445 utilityCheckBox[i].Dispose();
446 utilityCheckBox[i] = null;
448 leftbody.Remove(familyCheckBox[i]);
449 familyCheckBox[i].Dispose();
450 familyCheckBox[i] = null;
452 leftbody.Remove(foodCheckBox[i]);
453 foodCheckBox[i].Dispose();
454 foodCheckBox[i] = null;
456 leftbody.Remove(kitchenCheckBox[i]);
457 kitchenCheckBox[i].Dispose();
458 kitchenCheckBox[i] = null;
460 leftbody.Remove(modeText[i]);
461 modeText[i].Dispose();
464 rightbody.Remove(utilityCheckBox2[i]);
465 utilityCheckBox2[i].Dispose();
466 utilityCheckBox2[i] = null;
468 rightbody.Remove(familyCheckBox2[i]);
469 familyCheckBox2[i].Dispose();
470 familyCheckBox2[i] = null;
472 rightbody.Remove(foodCheckBox2[i]);
473 foodCheckBox2[i].Dispose();
474 foodCheckBox2[i] = null;
476 rightbody.Remove(kitchenCheckBox2[i]);
477 kitchenCheckBox2[i].Dispose();
478 kitchenCheckBox2[i] = null;
480 rightbody.Remove(modeText2[i]);
481 modeText2[i].Dispose();
485 left.Remove(createText[0]);
486 createText[0].Dispose();
487 createText[0] = null;
488 left.Remove(leftbody);
491 right.Remove(createText[1]);
492 createText[1].Dispose();
493 createText[1] = null;
494 right.Remove(rightbody);
505 NUIApplication.GetDefaultWindow().Remove(root);