1 using System.Collections.Generic;
2 using Tizen.NUI.BaseComponents;
3 using Tizen.NUI.Components;
5 namespace Tizen.NUI.Samples
7 public class DropDownSample : IExample
13 private TextLabel[] createText = new TextLabel[2];
15 private DropDown dropDown = null;
16 private DropDown dropDown2 = null;
17 private ScrollBar scrollBar = null;
18 private ScrollBar scrollBar2 = null;
20 private static string[] mode = new string[]
27 private static Color[] color = new Color[]
29 new Color(0.05f, 0.63f, 0.9f, 1),//#ff0ea1e6 Utility
30 new Color(0.14f, 0.77f, 0.28f, 1),//#ff24c447 Family
31 new Color(0.75f, 0.46f, 0.06f, 1),//#ffec7510 Food
32 new Color(0.59f, 0.38f, 0.85f, 1),//#ff9762d9 Kitchen
34 public void Activate()
36 Window window = NUIApplication.GetDefaultWindow();
38 //Create root view with linear layout.
41 Size = new Size(1920, 1080),
42 BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f),
43 Layout = new LinearLayout()
45 LinearOrientation = LinearLayout.Orientation.Horizontal,
46 CellPadding = new Size(50, 50),
47 LinearAlignment = LinearLayout.Alignment.Center,
52 ///////////////////////////////////////////////Create by Property//////////////////////////////////////////////////////////
55 Size = new Size(900, 800),
56 Layout = new LinearLayout()
58 LinearOrientation = LinearLayout.Orientation.Vertical,
59 CellPadding = new Size(50, 50),
60 LinearAlignment = LinearLayout.Alignment.Top,
65 // Create a description text.
66 createText[0] = new TextLabel();
67 createText[0].Text = "Create DropDown just by properties";
68 createText[0].Size = new Size(800, 100);
69 createText[0].MultiLine = true;
70 parent1.Add(createText[0]);
72 //Create a dropdown by property.
73 #region CreateByProperty
74 dropDown = new DropDown();
75 var style = dropDown.Style;
76 style.Button.BackgroundImage = "";
77 style.Button.Icon.ResourceUrl = CommonResource.GetFHResourcePath() + "6. List/list_ic_dropdown.png";
78 style.Button.Text.PointSize = 20;
79 style.Button.Text.FontFamily = "SamsungOneUI 500";
80 style.Button.Text.TextColor = new Color(0, 0, 0, 1);
81 dropDown.ApplyStyle(style);
82 dropDown.Size = new Size(900, 108);
83 dropDown.HeaderText.Text = "TitleArea";
84 dropDown.HeaderText.TextColor = new Color(0, 0, 0, 1);
85 dropDown.HeaderText.PointSize = 28;
86 dropDown.HeaderText.FontFamily = "SamsungOneUI 500C";
87 dropDown.HeaderText.PositionX = 50;
88 dropDown.Button.TextLabel.Text = "DropDown Text";
89 dropDown.Button.Icon.Size = new Size(48, 48);
90 dropDown.Button.IconRelativeOrientation = Button.IconOrientation.Right;
91 dropDown.Button.ParentOrigin = ParentOrigin.CenterLeft;
92 dropDown.Button.PivotPoint = PivotPoint.CenterLeft;
93 dropDown.Button.PositionX = 56;
94 dropDown.SpaceBetweenButtonTextAndIcon = 8;
95 dropDown.ListBackgroundImage.ResourceUrl = CommonResource.GetFHResourcePath() + "10. Drop Down/dropdown_bg.png";
96 dropDown.ListBackgroundImage.Border = new Rectangle(51, 51, 51, 51);
97 dropDown.ListBackgroundImage.Size = new Size(360, 500);
98 dropDown.ListMargin.Start = 20;
99 dropDown.ListMargin.Top = 20;
100 dropDown.ListPadding = new Extents(4, 4, 4, 4);
101 dropDown.BackgroundColor = new Color(1, 1, 1, 1);
102 parent1.Add(dropDown);
103 for (int i = 0; i < 8; i++)
105 DropDown.DropDownDataItem item = new DropDown.DropDownDataItem();
106 item.Size = new Size(360, 96);
107 item.BackgroundColor= new Selector<Color>
109 Pressed = new Color(0, 0, 0, 0.4f),
110 Other = new Color(1, 1, 1, 0),
112 item.Text = "Normal list " + i;
114 item.FontFamily = "SamsungOne 500";
115 item.TextPosition = new Position(28, 0);
116 item.CheckImageSize = new Size(40, 40);
117 item.CheckImageResourceUrl = CommonResource.GetFHResourcePath() + "10. Drop Down/dropdown_checkbox_on.png";
118 item.CheckImageGapToBoundary = 16;
119 dropDown.AddItem(item);
122 dropDown.SelectedItemIndex = 3;
124 ////////Attach scrollbar///////////
125 scrollBar = new ScrollBar();
126 scrollBar.Direction = ScrollBar.DirectionType.Vertical;
127 scrollBar.Size = new Size(4, 446);
128 scrollBar.TrackColor = Color.Green;
129 scrollBar.ThumbSize = new Size(4, 30);
130 scrollBar.ThumbColor = Color.Yellow;
131 scrollBar.TrackImageURL = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png";
132 dropDown.AttachScrollBar(scrollBar);
135 ///////////////////////////////////////////////Create by Attributes//////////////////////////////////////////////////////////
138 Size = new Size(900, 800),
139 Layout = new LinearLayout()
141 LinearOrientation = LinearLayout.Orientation.Vertical,
142 CellPadding = new Size(50, 50),
143 LinearAlignment = LinearLayout.Alignment.Top,
148 // Create a description text.
149 createText[1] = new TextLabel();
150 createText[1].Text = "Create DropDown just by Attributes";
151 createText[1].Size = new Size(800, 100);
152 createText[1].MultiLine = true;
153 parent2.Add(createText[1]);
155 //Create a dropdown by style.
156 #region CreateByStyle
158 DropDownStyle dropDownStyle = new DropDownStyle
160 HeaderText = new TextLabelStyle
162 Text = new Selector<string> { All = "TitleArea" },
163 PointSize = new Selector<float?> { All = 28 },
164 TextColor = new Selector<Color> { All = new Color(0, 0, 0, 1) },
165 FontFamily = "SamsungOneUI 500C",
169 Button = new ButtonStyle
171 Text = new TextLabelStyle
173 Text = new Selector<string> { All = "DropDown Text" },
174 PointSize = new Selector<float?> { All = 20 },
175 TextColor = new Selector<Color> { All = new Color(0, 0, 0, 1) },
176 FontFamily = "SamsungOneUI 500",
178 Icon = new ImageViewStyle
180 Size = new Size(48, 48),
181 ResourceUrl = new Selector<string> { All = CommonResource.GetFHResourcePath() + "6. List/list_ic_dropdown.png" },
183 IconRelativeOrientation = Button.IconOrientation.Right,
185 BackgroundImage = "",
187 ListBackgroundImage = new ImageViewStyle
189 ResourceUrl = new Selector<string> { All = CommonResource.GetFHResourcePath() + "10. Drop Down/dropdown_bg.png" },
190 Border = new Selector<Rectangle> { All = new Rectangle(51, 51, 51, 51) },
191 Size = new Size(360, 500),
193 SpaceBetweenButtonTextAndIcon = 8,
194 ListMargin = new Extents(20, 0, 20, 0),
195 BackgroundColor = new Selector<Color> { All = new Color(1, 1, 1, 1) },
196 ListPadding = new Extents(4, 4, 4, 4),
199 dropDown2 = new DropDown(dropDownStyle);
200 dropDown2.Size = new Size(900, 108);
201 parent2.Add(dropDown2);
203 DropDownItemStyle itemStyle = new DropDownItemStyle
205 BackgroundColor = new Selector<Color>
207 Pressed = new Color(0, 0, 0, 0.4f),
208 Other = new Color(1, 1, 1, 0),
210 Text = new TextLabelStyle
212 PointSize = new Selector<float?> { All = 18 },
213 FontFamily = "SamsungOne 500",
214 Position = new Position(28, 0),
216 CheckImage = new ImageViewStyle
218 Size = new Size(40, 40),
219 ResourceUrl = new Selector<string> { All = CommonResource.GetFHResourcePath() + "10. Drop Down/dropdown_checkbox_on.png" },
221 CheckImageGapToBoundary = 16,
224 for (int i = 0; i < 8; i++)
226 DropDown.DropDownDataItem item = new DropDown.DropDownDataItem(itemStyle);
227 item.Size = new Size(360, 96);
228 item.Text = "Normal list " + i;
229 dropDown2.AddItem(item);
231 dropDown2.SelectedItemIndex = 0;
233 ////////Attach scrollbar///////////
234 scrollBar2 = new ScrollBar();
235 scrollBar2.Direction = ScrollBar.DirectionType.Vertical;
236 scrollBar2.Size = new Size(4, 446);
237 scrollBar2.TrackColor = Color.Green;
238 scrollBar2.ThumbSize = new Size(4, 30);
239 scrollBar2.ThumbColor = Color.Yellow;
240 scrollBar2.TrackImageURL = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png";
241 dropDown2.AttachScrollBar(scrollBar2);
244 //Add all views into root view.
249 public void Deactivate()
253 if (dropDown != null)
255 if (scrollBar != null)
257 dropDown.DetachScrollBar();
262 parent1.Remove(dropDown);
266 if (dropDown2 != null)
268 if (scrollBar2 != null)
270 dropDown2.DetachScrollBar();
271 scrollBar2.Dispose();
275 parent2.Remove(dropDown2);
280 if (createText[0] != null)
282 parent1.Remove(createText[0]);
283 createText[0].Dispose();
284 createText[0] = null;
286 if (createText[1] != null)
288 parent2.Remove(createText[1]);
289 createText[1].Dispose();
290 createText[1] = null;
293 root.Remove(parent1);
296 root.Remove(parent2);
300 NUIApplication.GetDefaultWindow().Remove(root);