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
11 private TextLabel[] createText = new TextLabel[2];
13 private DropDown dropDown = null;
14 private DropDown dropDown2 = null;
15 private ScrollBar scrollBar = null;
16 private ScrollBar scrollBar2 = null;
18 private static string[] mode = new string[]
25 private static Color[] color = new Color[]
27 new Color(0.05f, 0.63f, 0.9f, 1),//#ff0ea1e6 Utility
28 new Color(0.14f, 0.77f, 0.28f, 1),//#ff24c447 Family
29 new Color(0.75f, 0.46f, 0.06f, 1),//#ffec7510 Food
30 new Color(0.59f, 0.38f, 0.85f, 1),//#ff9762d9 Kitchen
32 public void Activate()
34 Window window = Window.Instance;
38 Size2D = new Size2D(1920, 1080),
39 BackgroundColor = Color.White,
43 ///////////////////////////////////////////////Create by Property//////////////////////////////////////////////////////////
44 createText[0] = new TextLabel();
45 createText[0].Text = "Create DropDown just by properties";
46 createText[0].Size2D = new Size2D(450, 100);
47 createText[0].Position2D = new Position2D(200, 100);
48 createText[0].MultiLine = true;
49 root.Add(createText[0]);
51 #region CreateByProperty
52 dropDown = new DropDown();
53 dropDown.Size2D = new Size2D(900, 108);
54 dropDown.Position2D = new Position2D(50, 300);
55 dropDown.Style.HeaderText.Text = "TitleArea";
56 dropDown.Style.HeaderText.TextColor = new Color(0, 0, 0, 1);
57 dropDown.Style.HeaderText.PointSize = 28;
58 dropDown.Style.HeaderText.FontFamily = "SamsungOneUI 500C";
59 dropDown.Style.Button.Text.Text = "DropDown Text";
60 dropDown.Style.Button.Text.TextColor = new Color(0, 0, 0, 1);
61 dropDown.Style.Button.Text.PointSize = 20;
62 dropDown.Style.Button.Text.FontFamily = "SamsungOneUI 500";
63 dropDown.Style.Button.Icon.ResourceUrl = CommonResource.GetFHResourcePath() + "6. List/list_ic_dropdown.png";
64 dropDown.Style.Button.Icon.Size = new Size(48, 48);
65 dropDown.Style.Button.IconRelativeOrientation = Button.IconOrientation.Right;
66 dropDown.Style.Button.PositionX = 56;
67 dropDown.SpaceBetweenButtonTextAndIcon = 8;
68 dropDown.Style.ListBackgroundImage.ResourceUrl = CommonResource.GetFHResourcePath() + "10. Drop Down/dropdown_bg.png";
69 dropDown.Style.ListBackgroundImage.Border = new Rectangle(51, 51, 51, 51);
70 dropDown.Style.ListBackgroundImage.Size = new Size(360, 500);
71 dropDown.ListMargin.Start = 20;
72 dropDown.ListMargin.Top = 20;
73 dropDown.ListPadding = new Extents(4, 4, 4, 4);
76 for (int i = 0; i < 8; i++)
78 DropDown.DropDownDataItem item = new DropDown.DropDownDataItem();
79 item.Size = new Size(360, 96);
80 item.BackgroundColor= new Selector<Color>
82 Pressed = new Color(0, 0, 0, 0.4f),
83 Other = new Color(1, 1, 1, 0),
85 item.Text = "Normal list " + i;
87 item.FontFamily = "SamsungOne 500";
88 item.TextPosition = new Position(28, 0);
89 item.CheckImageSize = new Size(40, 40);
90 item.CheckImageResourceUrl = CommonResource.GetFHResourcePath() + "10. Drop Down/dropdown_checkbox_on.png";
91 item.CheckImageGapToBoundary = 16;
92 dropDown.AddItem(item);
95 dropDown.SelectedItemIndex = 3;
96 //dropDown.DeleteItem(1);
98 //DropDown.DropDownItemData insertItem = new DropDown.DropDownItemData();
99 //insertItem.Size2D = new Size2D(360, 96);
100 //insertItem.BackgroundColorSelector = new Selector<Color>
102 // Pressed = new Color(0, 0, 0, 0.4f),
103 // Other = new Color(1, 1, 1, 0),
105 //insertItem.Text = "Insert Normal list ";
106 //insertItem.PointSize = 18;
107 //insertItem.FontFamily = "SamsungOne 500";
108 //insertItem.TextPosition2D = new Position2D(28, 0);
109 //insertItem.CheckImageSize = new Size2D(40, 40);
110 //insertItem.CheckImageResourceUrl = CommonReosurce.GetFHResourcePath() + "10. Drop Down/dropdown_checkbox_on.png";
111 //insertItem.CheckImageRightSpace = 16;
112 //dropDown.InsertItem(insertItem, 1);
113 ////////Attach scrollbar///////////
114 scrollBar = new ScrollBar();
115 scrollBar.Direction = ScrollBar.DirectionType.Vertical;
116 scrollBar.Position2D = new Position2D(394, 2);
117 scrollBar.Size2D = new Size2D(4, 446);
118 scrollBar.Style.Track.BackgroundColor = Color.Green;
119 scrollBar.Style.Thumb.Size = new Size(4, 30);
120 scrollBar.Style.Thumb.BackgroundColor = Color.Yellow;
121 scrollBar.Style.Track.ResourceUrl = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png";
122 dropDown.AttachScrollBar(scrollBar);
125 ///////////////////////////////////////////////Create by Attributes//////////////////////////////////////////////////////////
126 createText[1] = new TextLabel();
127 createText[1].Text = "Create DropDown just by Attributes";
128 createText[1].Size2D = new Size2D(450, 100);
129 createText[1].Position2D = new Position2D(1000, 100);
130 createText[1].MultiLine = true;
131 root.Add(createText[1]);
133 #region CreateByAttributes
135 DropDownStyle attrs = new DropDownStyle
137 HeaderText = new TextLabelStyle
139 Text = new Selector<string> { All = "TitleArea" },
140 PointSize = new Selector<float?> { All = 28 },
141 TextColor = new Selector<Color> { All = new Color(0, 0, 0, 1) },
142 FontFamily = "SamsungOneUI 500C",
145 Button = new ButtonStyle
147 Text = new TextLabelStyle
149 Text = new Selector<string> { All = "DropDown Text" },
150 PointSize = new Selector<float?> { All = 20 },
151 TextColor = new Selector<Color> { All = new Color(0, 0, 0, 1) },
152 FontFamily = "SamsungOneUI 500",
154 Icon = new ImageViewStyle
156 Size = new Size(48, 48),
157 ResourceUrl = new Selector<string> { All = CommonResource.GetFHResourcePath() + "6. List/list_ic_dropdown.png" },
159 IconRelativeOrientation = Button.IconOrientation.Right,
162 ListBackgroundImage = new ImageViewStyle
164 ResourceUrl = new Selector<string> { All = CommonResource.GetFHResourcePath() + "10. Drop Down/dropdown_bg.png" },
165 Border = new Selector<Rectangle> { All = new Rectangle(51, 51, 51, 51) },
166 Size = new Size(360, 500),
168 SpaceBetweenButtonTextAndIcon = 8,
169 ListMargin = new Extents(20, 0, 20, 0),
170 BackgroundColor = new Selector<Color> { All = new Color(1, 1, 1, 1) },
171 ListPadding = new Extents(4, 4, 4, 4),
174 dropDown2 = new DropDown(attrs);
175 dropDown2.Size2D = new Size2D(900, 108);
176 dropDown2.Position2D = new Position2D(1000, 300);
179 DropDownItemStyle itemAttrs = new DropDownItemStyle
181 BackgroundColor = new Selector<Color>
183 Pressed = new Color(0, 0, 0, 0.4f),
184 Other = new Color(1, 1, 1, 0),
186 Text = new TextLabelStyle
188 PointSize = new Selector<float?> { All = 18 },
189 FontFamily = "SamsungOne 500",
190 Position = new Position(28, 0),
192 CheckImage = new ImageViewStyle
194 Size = new Size(40, 40),
195 ResourceUrl = new Selector<string> { All = CommonResource.GetFHResourcePath() + "10. Drop Down/dropdown_checkbox_on.png" },
197 CheckImageGapToBoundary = 16,
200 for (int i = 0; i < 8; i++)
202 DropDown.DropDownDataItem item = new DropDown.DropDownDataItem(itemAttrs);
203 item.Size = new Size(360, 96);
204 item.Text = "Normal list " + i;
205 dropDown2.AddItem(item);
207 dropDown2.SelectedItemIndex = 0;
209 ////////Attach scrollbar///////////
210 scrollBar2 = new ScrollBar();
211 scrollBar2.Direction = ScrollBar.DirectionType.Vertical;
212 scrollBar2.Position2D = new Position2D(394, 2);
213 scrollBar2.Size2D = new Size2D(4, 446);
214 scrollBar2.Style.Track.BackgroundColor = Color.Green;
215 scrollBar2.Style.Thumb.Size = new Size(4, 30);
216 scrollBar2.Style.Thumb.BackgroundColor = Color.Yellow;
217 scrollBar2.Style.Track.ResourceUrl = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png";
218 dropDown2.AttachScrollBar(scrollBar2);
223 public void Deactivate()
227 if (dropDown != null)
229 if (scrollBar != null)
231 dropDown.DetachScrollBar();
236 root.Remove(dropDown);
240 if (dropDown2 != null)
242 if (scrollBar2 != null)
244 dropDown2.DetachScrollBar();
245 scrollBar2.Dispose();
249 root.Remove(dropDown2);
254 if (createText[0] != null)
256 root.Remove(createText[0]);
257 createText[0].Dispose();
258 createText[0] = null;
260 if (createText[1] != null)
262 root.Remove(createText[1]);
263 createText[1].Dispose();
264 createText[1] = null;
267 Window.Instance.Remove(root);