1 using System.Collections.Generic;
2 using Tizen.NUI.BaseComponents;
3 using Tizen.NUI.Components;
5 namespace Tizen.NUI.Samples
7 public class RadioButtonSample : IExample
11 private TextLabel[] createText = new TextLabel[2];
12 private TextLabel[] modeText = new TextLabel[4];
13 private TextLabel[] modeText2 = new TextLabel[4];
15 private RadioButton[] utilityRadioButton = new RadioButton[4];
16 private RadioButton[] familyRadioButton = new RadioButton[4];
17 private RadioButton[] foodRadioButton = new RadioButton[4];
18 private RadioButton[] kitchenRadioButton = new RadioButton[4];
19 private RadioButtonGroup[] group = new RadioButtonGroup[4];
21 private RadioButton[] utilityRadioButton2 = new RadioButton[4];
22 private RadioButton[] familyRadioButton2 = new RadioButton[4];
23 private RadioButton[] foodRadioButton2 = new RadioButton[4];
24 private RadioButton[] kitchenRadioButton2 = new RadioButton[4];
25 private RadioButtonGroup[] group2 = new RadioButtonGroup[4];
27 private static string[] mode = new string[]
34 public void Activate()
36 Window window = Window.Instance;
40 Size2D = new Size2D(1920, 1080),
41 BackgroundColor = Color.White,
45 ///////////////////////////////////////////////Create by Property//////////////////////////////////////////////////////////
46 createText[0] = new TextLabel();
47 createText[0].Text = "Create RadioButton just by properties";
48 createText[0].TextColor = Color.White;
49 createText[0].Size2D = new Size2D(500, 100);
50 createText[0].Position2D = new Position2D(400, 100);
51 root.Add(createText[0]);
54 for (int i = 0; i < num; i++)
56 group[i] = new RadioButtonGroup();
57 modeText[i] = new TextLabel();
58 modeText[i].Text = mode[i];
59 modeText[i].Size2D = new Size2D(200, 48);
60 modeText[i].Position2D = new Position2D(300 + 200 * i, 200);
61 root.Add(modeText[i]);
64 for (int i = 0; i < num; i++)
66 utilityRadioButton[i] = new RadioButton();
67 utilityRadioButton[i].Size2D = new Size2D(48, 48);
68 utilityRadioButton[i].Position2D = new Position2D(300, 300 + i * 100);
69 utilityRadioButton[i].Style.Icon.Size = new Size(48, 48);
70 utilityRadioButton[i].Style.Icon.Padding.Start = 5;
71 utilityRadioButton[i].Style.Icon.Padding.End = 5;
72 utilityRadioButton[i].Style.Icon.Opacity = new Selector<float?>
77 DisabledSelected = 0.4f
79 utilityRadioButton[i].Style.Icon.ResourceUrl = new Selector<string>
81 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
82 Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_on.png",
83 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
84 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_on.png",
87 group[0].Add(utilityRadioButton[i]);
89 familyRadioButton[i] = new RadioButton();
90 familyRadioButton[i].Size2D = new Size2D(48, 48);
91 familyRadioButton[i].Position2D = new Position2D(500, 300 + i * 100);
92 familyRadioButton[i].Style.Icon.Size = new Size(48, 48);
93 familyRadioButton[i].Style.Icon.Padding.Start = 5;
94 familyRadioButton[i].Style.Icon.Padding.End = 5;
95 familyRadioButton[i].Style.Icon.Opacity = new Selector<float?>
100 DisabledSelected = 0.4f
102 familyRadioButton[i].Style.Icon.ResourceUrl = new Selector<string>
104 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
105 Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_24c447.png",
106 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
107 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_24c447.png",
110 group[1].Add(familyRadioButton[i]);
112 foodRadioButton[i] = new RadioButton();
113 foodRadioButton[i].Size2D = new Size2D(150, 48);
114 foodRadioButton[i].Position2D = new Position2D(700, 300 + i * 100);
115 foodRadioButton[i].Style.Icon.Size = new Size(48, 48);
116 foodRadioButton[i].Style.Icon.Padding.Start = 5;
117 foodRadioButton[i].Style.Icon.Padding.End = 5;
118 foodRadioButton[i].Style.Icon.Opacity = new Selector<float?>
123 DisabledSelected = 0.4f
125 foodRadioButton[i].Style.Icon.ResourceUrl = new Selector<string>
127 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
128 Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_ec7510.png",
129 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
130 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_ec7510.png",
133 //foodRadioButton[i].Text = "Radio" + i;
134 //foodRadioButton[i].TextAlignment = HorizontalAlignment.Begin;
135 //foodRadioButton[i].PointSize = 12;
136 //foodRadioButton[i].TextPaddingLeft = 70;
138 group[2].Add(foodRadioButton[i]);
140 kitchenRadioButton[i] = new RadioButton();
141 kitchenRadioButton[i].Size2D = new Size2D(48, 48);
142 kitchenRadioButton[i].Position2D = new Position2D(900, 300 + i * 100);
143 kitchenRadioButton[i].Style.Icon.Size = new Size(48, 48);
144 kitchenRadioButton[i].Style.Icon.Padding.Start = 5;
145 kitchenRadioButton[i].Style.Icon.Padding.End = 5;
146 kitchenRadioButton[i].Style.Icon.Opacity = new Selector<float?>
151 DisabledSelected = 0.4f
153 kitchenRadioButton[i].Style.Icon.ResourceUrl = new Selector<string>
155 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
156 Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_9762d9.png",
157 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
158 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_9762d9.png",
161 group[3].Add(kitchenRadioButton[i]);
163 root.Add(utilityRadioButton[i]);
164 root.Add(familyRadioButton[i]);
165 root.Add(foodRadioButton[i]);
166 root.Add(kitchenRadioButton[i]);
168 //foodRadioButton[0].LayoutDirection = ViewLayoutDirectionType.RTL;
169 ///////////////////////////////////////////////Create by Attributes//////////////////////////////////////////////////////////
170 createText[1] = new TextLabel();
171 createText[1].Text = "Create RadioButton just by Attributes";
172 createText[1].TextColor = Color.White;
173 createText[1].Size2D = new Size2D(500, 100);
174 createText[1].Position2D = new Position2D(1200, 100);
175 root.Add(createText[1]);
177 for (int i = 0; i < num; i++)
179 group2[i] = new RadioButtonGroup();
180 modeText2[i] = new TextLabel();
181 modeText2[i].Text = mode[i];
182 modeText2[i].Size2D = new Size2D(200, 48);
183 modeText2[i].Position2D = new Position2D(1100 + 200 * i, 200);
184 root.Add(modeText2[i]);
187 ButtonStyle utilityAttrs = new ButtonStyle
189 Icon = new ImageControlStyle
191 Size = new Size(48, 48),
192 Opacity = new Selector<float?>
197 DisabledSelected = 0.4f
199 ResourceUrl = new Selector<string>
201 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
202 Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_on.png",
203 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
204 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_on.png",
208 ButtonStyle familyAttrs = new ButtonStyle
210 Icon = new ImageControlStyle
212 Size = new Size(48, 48),
213 Opacity = new Selector<float?>
218 DisabledSelected = 0.4f
220 ResourceUrl = new Selector<string>
222 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
223 Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_24c447.png",
224 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
225 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_24c447.png",
229 ButtonStyle foodAttrs = new ButtonStyle
231 Icon = new ImageControlStyle
233 Size = new Size(48, 48),
234 Opacity = new Selector<float?>
239 DisabledSelected = 0.4f
241 ResourceUrl = new Selector<string>
243 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
244 Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_ec7510.png",
245 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
246 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_ec7510.png",
250 ButtonStyle kitchenAttrs = new ButtonStyle
252 Icon = new ImageControlStyle
254 Size = new Size(48, 48),
255 Opacity = new Selector<float?>
260 DisabledSelected = 0.4f
262 ResourceUrl = new Selector<string>
264 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
265 Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_9762d9.png",
266 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
267 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_9762d9.png",
271 for (int i = 0; i < num; i++)
273 utilityRadioButton2[i] = new RadioButton(utilityAttrs);
274 utilityRadioButton2[i].Size2D = new Size2D(48, 48);
275 utilityRadioButton2[i].Position2D = new Position2D(1100, 300 + i * 100);
276 group2[0].Add(utilityRadioButton2[i]);
278 familyRadioButton2[i] = new RadioButton(familyAttrs);
279 familyRadioButton2[i].Size2D = new Size2D(48, 48);
280 familyRadioButton2[i].Position2D = new Position2D(1300, 300 + i * 100);
281 group2[1].Add(familyRadioButton2[i]);
283 foodRadioButton2[i] = new RadioButton(foodAttrs);
284 foodRadioButton2[i].Size2D = new Size2D(48, 48);
285 foodRadioButton2[i].Position2D = new Position2D(1500, 300 + i * 100);
286 group2[2].Add(foodRadioButton2[i]);
288 kitchenRadioButton2[i] = new RadioButton(kitchenAttrs);
289 kitchenRadioButton2[i].Size2D = new Size2D(48, 48);
290 kitchenRadioButton2[i].Position2D = new Position2D(1700, 300 + i * 100);
291 group2[3].Add(kitchenRadioButton2[i]);
293 root.Add(utilityRadioButton2[i]);
294 root.Add(familyRadioButton2[i]);
295 root.Add(foodRadioButton2[i]);
296 root.Add(kitchenRadioButton2[i]);
299 utilityRadioButton[2].IsEnabled = false;
300 familyRadioButton[2].IsEnabled = false;
301 foodRadioButton[2].IsEnabled = false;
302 kitchenRadioButton[2].IsEnabled = false;
304 utilityRadioButton2[2].IsEnabled = false;
305 familyRadioButton2[2].IsEnabled = false;
306 foodRadioButton2[2].IsEnabled = false;
307 kitchenRadioButton2[2].IsEnabled = false;
309 utilityRadioButton[3].IsEnabled = false;
310 familyRadioButton[3].IsEnabled = false;
311 foodRadioButton[3].IsEnabled = false;
312 kitchenRadioButton[3].IsEnabled = false;
313 utilityRadioButton[3].IsSelected = true;
314 familyRadioButton[3].IsSelected = true;
315 foodRadioButton[3].IsSelected = true;
316 kitchenRadioButton[3].IsSelected = true;
318 utilityRadioButton2[3].IsEnabled = false;
319 familyRadioButton2[3].IsEnabled = false;
320 foodRadioButton2[3].IsEnabled = false;
321 kitchenRadioButton2[3].IsEnabled = false;
322 utilityRadioButton2[3].IsSelected = true;
323 familyRadioButton2[3].IsSelected = true;
324 foodRadioButton2[3].IsSelected = true;
325 kitchenRadioButton2[3].IsSelected = true;
328 public void Deactivate()
333 for (int i = 0; i < num; i++)
335 root.Remove(utilityRadioButton[i]);
336 utilityRadioButton[i].Dispose();
337 utilityRadioButton[i] = null;
339 root.Remove(familyRadioButton[i]);
340 familyRadioButton[i].Dispose();
341 familyRadioButton[i] = null;
343 root.Remove(foodRadioButton[i]);
344 foodRadioButton[i].Dispose();
345 foodRadioButton[i] = null;
347 root.Remove(kitchenRadioButton[i]);
348 kitchenRadioButton[i].Dispose();
349 kitchenRadioButton[i] = null;
351 root.Remove(modeText[i]);
352 modeText[i].Dispose();
355 root.Remove(utilityRadioButton2[i]);
356 utilityRadioButton2[i].Dispose();
357 utilityRadioButton2[i] = null;
359 root.Remove(familyRadioButton2[i]);
360 familyRadioButton2[i].Dispose();
361 familyRadioButton2[i] = null;
363 root.Remove(foodRadioButton2[i]);
364 foodRadioButton2[i].Dispose();
365 foodRadioButton2[i] = null;
367 root.Remove(kitchenRadioButton2[i]);
368 kitchenRadioButton2[i].Dispose();
369 kitchenRadioButton2[i] = null;
371 root.Remove(modeText2[i]);
372 modeText2[i].Dispose();
376 root.Remove(createText[0]);
377 createText[0].Dispose();
378 createText[0] = null;
379 root.Remove(createText[1]);
380 createText[1].Dispose();
381 createText[1] = null;
383 Window.Instance.Remove(root);