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
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 RadioButton[] utilityRadioButton = new RadioButton[4];
20 private RadioButton[] familyRadioButton = new RadioButton[4];
21 private RadioButton[] foodRadioButton = new RadioButton[4];
22 private RadioButton[] kitchenRadioButton = new RadioButton[4];
23 private RadioButtonGroup[] group = new RadioButtonGroup[4];
25 private RadioButton[] utilityRadioButton2 = new RadioButton[4];
26 private RadioButton[] familyRadioButton2 = new RadioButton[4];
27 private RadioButton[] foodRadioButton2 = new RadioButton[4];
28 private RadioButton[] kitchenRadioButton2 = new RadioButton[4];
29 private RadioButtonGroup[] group2 = new RadioButtonGroup[4];
31 private static string[] mode = new string[]
38 public void Activate()
40 Window window = NUIApplication.GetDefaultWindow();
45 Size = new Size(1920, 1080),
46 BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f),
47 Padding = new Extents(40, 40, 40, 40),
48 Layout = new LinearLayout()
50 LinearOrientation = LinearLayout.Orientation.Horizontal,
51 CellPadding = new Size(40, 40),
52 LinearAlignment = LinearLayout.Alignment.Center,
57 ///////////////////////////////////////////////Create by Property//////////////////////////////////////////////////////////
60 Size = new Size(920, 800),
61 Layout = new LinearLayout()
63 LinearOrientation = LinearLayout.Orientation.Vertical
67 //Create left description text.
68 createText[0] = new TextLabel();
69 createText[0].Text = "Create RadioButton just by properties";
70 createText[0].TextColor = Color.White;
71 createText[0].Size = new Size(800, 100);
72 left.Add(createText[0]);
74 leftbody = new View();
75 leftbody.Layout = new GridLayout() { Columns = 4 };
77 for (int i = 0; i < num; i++)
79 group[i] = new RadioButtonGroup();
80 modeText[i] = new TextLabel();
81 modeText[i].Text = mode[i];
82 modeText[i].Size = new Size(200, 48);
83 modeText[i].HorizontalAlignment = HorizontalAlignment.Center;
84 modeText[i].VerticalAlignment = VerticalAlignment.Center;
85 leftbody.Add(modeText[i]);
88 for (int i = 0; i < num; i++)
90 // create utility radio button.
91 utilityRadioButton[i] = new RadioButton();
92 var utilityStyle = utilityRadioButton[i].Style;
93 utilityStyle.Icon.Opacity = new Selector<float?>
98 DisabledSelected = 0.4f
100 utilityStyle.Icon.BackgroundImage = "";
101 utilityStyle.Icon.ResourceUrl = new Selector<string>
103 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
104 Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_on.png",
105 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
106 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_on.png",
108 utilityRadioButton[i].ApplyStyle(utilityStyle);
109 utilityRadioButton[i].Size = new Size(48, 48);
110 utilityRadioButton[i].Icon.Size = new Size(48, 48);
111 group[0].Add(utilityRadioButton[i]);
113 // create family radio button.
114 familyRadioButton[i] = new RadioButton();
115 var familyStyle = familyRadioButton[i].Style;
116 familyStyle.Icon.Opacity = new Selector<float?>
121 DisabledSelected = 0.4f
123 familyStyle.Icon.BackgroundImage = "";
124 familyStyle.Icon.ResourceUrl = new Selector<string>
126 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
127 Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_24c447.png",
128 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
129 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_24c447.png",
131 familyRadioButton[i].ApplyStyle(familyStyle);
132 familyRadioButton[i].Size = new Size(48, 48);
133 familyRadioButton[i].Icon.Size = new Size(48, 48);
135 group[1].Add(familyRadioButton[i]);
137 // create food radio button.
138 foodRadioButton[i] = new RadioButton();
139 var foodStyle = foodRadioButton[i].Style;
140 foodStyle.Icon.Opacity = new Selector<float?>
145 DisabledSelected = 0.4f
147 foodStyle.Icon.BackgroundImage = "";
148 foodStyle.Icon.ResourceUrl = new Selector<string>
150 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
151 Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_ec7510.png",
152 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
153 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_ec7510.png",
155 foodRadioButton[i].ApplyStyle(foodStyle);
156 foodRadioButton[i].Size = new Size(150, 48);
157 foodRadioButton[i].Icon.Size = new Size(48, 48);
159 group[2].Add(foodRadioButton[i]);
161 // create kitchen radio button.
162 kitchenRadioButton[i] = new RadioButton();
163 var kitchenStyle = kitchenRadioButton[i].Style;
164 kitchenStyle.Icon.Opacity = new Selector<float?>
169 DisabledSelected = 0.4f
171 kitchenStyle.Icon.BackgroundImage = "";
172 kitchenStyle.Icon.ResourceUrl = new Selector<string>
174 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
175 Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_9762d9.png",
176 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
177 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_9762d9.png",
179 kitchenRadioButton[i].ApplyStyle(kitchenStyle);
180 kitchenRadioButton[i].Size = new Size(48, 48);
181 kitchenRadioButton[i].Icon.Size = new Size(48, 48);
183 group[3].Add(kitchenRadioButton[i]);
185 leftbody.Add(utilityRadioButton[i]);
186 leftbody.Add(familyRadioButton[i]);
187 leftbody.Add(foodRadioButton[i]);
188 leftbody.Add(kitchenRadioButton[i]);
191 ///////////////////////////////////////////////Create by Attributes//////////////////////////////////////////////////////////
194 Size = new Size(920, 800),
195 Layout = new LinearLayout()
197 LinearOrientation = LinearLayout.Orientation.Vertical,
201 rightbody = new View();
202 rightbody.Layout = new GridLayout() { Columns = 4 };
203 createText[1] = new TextLabel();
204 createText[1].Text = "Create RadioButton just by styles";
205 createText[1].TextColor = Color.White;
206 createText[1].Size = new Size(800, 100);
207 right.Add(createText[1]);
209 for (int i = 0; i < num; i++)
211 group2[i] = new RadioButtonGroup();
212 modeText2[i] = new TextLabel();
213 modeText2[i].Text = mode[i];
214 modeText2[i].Size = new Size(200, 48);
215 modeText2[i].HorizontalAlignment = HorizontalAlignment.Center;
216 modeText2[i].VerticalAlignment = VerticalAlignment.Center;
217 rightbody.Add(modeText2[i]);
220 //Create utility style of radio button.
221 ButtonStyle utilityStyle2 = new ButtonStyle
223 Icon = new ImageViewStyle
225 Size = new Size(48, 48),
226 Opacity = new Selector<float?>
231 DisabledSelected = 0.4f
233 ResourceUrl = new Selector<string>
235 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
236 Selected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_on.png",
237 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
238 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_on.png",
242 //Create family style of radio button.
243 ButtonStyle familyStyle2 = new ButtonStyle
245 Icon = new ImageViewStyle
247 Size = new Size(48, 48),
248 Opacity = new Selector<float?>
253 DisabledSelected = 0.4f
255 ResourceUrl = new Selector<string>
257 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
258 Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_24c447.png",
259 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
260 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_24c447.png",
264 //Create food style of radio button.
265 ButtonStyle foodStyle2 = new ButtonStyle
267 Icon = new ImageViewStyle
269 Size = new Size(48, 48),
270 Opacity = new Selector<float?>
275 DisabledSelected = 0.4f
277 ResourceUrl = new Selector<string>
279 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
280 Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_ec7510.png",
281 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
282 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_ec7510.png",
286 //Create kitchen style of radio button.
287 ButtonStyle kitchenStyle2 = new ButtonStyle
289 Icon = new ImageViewStyle
291 Size = new Size(48, 48),
292 Opacity = new Selector<float?>
297 DisabledSelected = 0.4f
299 ResourceUrl = new Selector<string>
301 Normal = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
302 Selected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_9762d9.png",
303 Disabled = CommonResource.GetFHResourcePath() + "9. Controller/controller_btn_radio_off.png",
304 DisabledSelected = CommonResource.GetFHResourcePath() + "9. Controller/[Controller] App Primary Color/controller_btn_radio_on_9762d9.png",
308 for (int i = 0; i < num; i++)
310 utilityRadioButton2[i] = new RadioButton(utilityStyle2);
311 utilityRadioButton2[i].Size = new Size(48, 48);
312 group2[0].Add(utilityRadioButton2[i]);
314 familyRadioButton2[i] = new RadioButton(familyStyle2);
315 familyRadioButton2[i].Size = new Size(48, 48);
316 group2[1].Add(familyRadioButton2[i]);
318 foodRadioButton2[i] = new RadioButton(foodStyle2);
319 foodRadioButton2[i].Size = new Size(48, 48);
320 group2[2].Add(foodRadioButton2[i]);
322 kitchenRadioButton2[i] = new RadioButton(kitchenStyle2);
323 kitchenRadioButton2[i].Size = new Size(48, 48);
324 group2[3].Add(kitchenRadioButton2[i]);
326 rightbody.Add(utilityRadioButton2[i]);
327 rightbody.Add(familyRadioButton2[i]);
328 rightbody.Add(foodRadioButton2[i]);
329 rightbody.Add(kitchenRadioButton2[i]);
335 right.Add(rightbody);
337 utilityRadioButton[2].IsEnabled = false;
338 familyRadioButton[2].IsEnabled = false;
339 foodRadioButton[2].IsEnabled = false;
340 kitchenRadioButton[2].IsEnabled = false;
342 utilityRadioButton2[2].IsEnabled = false;
343 familyRadioButton2[2].IsEnabled = false;
344 foodRadioButton2[2].IsEnabled = false;
345 kitchenRadioButton2[2].IsEnabled = false;
347 utilityRadioButton[3].IsEnabled = false;
348 familyRadioButton[3].IsEnabled = false;
349 foodRadioButton[3].IsEnabled = false;
350 kitchenRadioButton[3].IsEnabled = false;
351 utilityRadioButton[3].IsSelected = true;
352 familyRadioButton[3].IsSelected = true;
353 foodRadioButton[3].IsSelected = true;
354 kitchenRadioButton[3].IsSelected = true;
356 utilityRadioButton2[3].IsEnabled = false;
357 familyRadioButton2[3].IsEnabled = false;
358 foodRadioButton2[3].IsEnabled = false;
359 kitchenRadioButton2[3].IsEnabled = false;
360 utilityRadioButton2[3].IsSelected = true;
361 familyRadioButton2[3].IsSelected = true;
362 foodRadioButton2[3].IsSelected = true;
363 kitchenRadioButton2[3].IsSelected = true;
366 public void Deactivate()
371 for (int i = 0; i < num; i++)
373 leftbody.Remove(utilityRadioButton[i]);
374 utilityRadioButton[i].Dispose();
375 utilityRadioButton[i] = null;
377 leftbody.Remove(familyRadioButton[i]);
378 familyRadioButton[i].Dispose();
379 familyRadioButton[i] = null;
381 leftbody.Remove(foodRadioButton[i]);
382 foodRadioButton[i].Dispose();
383 foodRadioButton[i] = null;
385 leftbody.Remove(kitchenRadioButton[i]);
386 kitchenRadioButton[i].Dispose();
387 kitchenRadioButton[i] = null;
389 leftbody.Remove(modeText[i]);
390 modeText[i].Dispose();
393 rightbody.Remove(utilityRadioButton2[i]);
394 utilityRadioButton2[i].Dispose();
395 utilityRadioButton2[i] = null;
397 rightbody.Remove(familyRadioButton2[i]);
398 familyRadioButton2[i].Dispose();
399 familyRadioButton2[i] = null;
401 rightbody.Remove(foodRadioButton2[i]);
402 foodRadioButton2[i].Dispose();
403 foodRadioButton2[i] = null;
405 rightbody.Remove(kitchenRadioButton2[i]);
406 kitchenRadioButton2[i].Dispose();
407 kitchenRadioButton2[i] = null;
409 rightbody.Remove(modeText2[i]);
410 modeText2[i].Dispose();
414 left.Remove(createText[0]);
415 createText[0].Dispose();
416 createText[0] = null;
417 left.Remove(leftbody);
420 right.Remove(createText[1]);
421 createText[1].Dispose();
422 createText[1] = null;
423 right.Remove(rightbody);
433 NUIApplication.GetDefaultWindow().Remove(root);