1 using System.Collections.Generic;
2 using Tizen.NUI.BaseComponents;
3 using Tizen.NUI.Components;
5 namespace Tizen.NUI.Samples
7 public class TabSample : IExample
10 private View[] parentView = new View[3];
12 private TextLabel[] createText = new TextLabel[2];
13 private Tab tab = null;
14 private Tab tab2 = null;
15 private Button button = null;
16 private Button button2 = null;
17 private int index = 0;
19 private static string[] mode = new string[]
26 private static Color[] color = new Color[]
28 new Color(0.05f, 0.63f, 0.9f, 1),//#ff0ea1e6 Utility
29 new Color(0.14f, 0.77f, 0.28f, 1),//#ff24c447 Family
30 new Color(0.75f, 0.46f, 0.06f, 1),//#ffec7510 Food
31 new Color(0.59f, 0.38f, 0.85f, 1),//#ff9762d9 Kitchen
34 public void Activate()
36 Window window = NUIApplication.GetDefaultWindow();
40 Size = new Size(1920, 1080),
41 BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f),
43 root.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical };
50 private void CreateTextView()
52 // Init parent of TextView
53 parentView[0] = new View();
54 parentView[0].Size = new Size(1920, 300);
55 parentView[0].Layout = new LinearLayout()
57 LinearOrientation = LinearLayout.Orientation.Horizontal,
58 HorizontalAlignment = HorizontalAlignment.Center,
59 VerticalAlignment = VerticalAlignment.Center,
60 CellPadding = new Size2D(100, 0)
62 root.Add(parentView[0]);
64 for (int i = 0; i < 2; i++)
66 createText[i] = new TextLabel();
67 createText[i].Size = new Size(500, 100);
68 createText[i].PointSize = 20.0f;
69 createText[i].BackgroundColor = Color.Magenta;
70 createText[i].HorizontalAlignment = HorizontalAlignment.Center;
71 createText[i].VerticalAlignment = VerticalAlignment.Center;
72 createText[i].MultiLine = true;
73 parentView[0].Add(createText[i]);
76 // Text of "Create Switch just by Properties"
77 createText[0].Text = "Create Tab just by Properties";
79 // Text of "Create Switch just by Style"
80 createText[1].Text = "Create Tab just by Style";
83 private void CreateTabView()
85 // Init parent of TabView
86 parentView[1] = new View();
87 parentView[1].Size = new Size(1920, 200);
88 parentView[1].Layout = new LinearLayout()
90 LinearOrientation = LinearLayout.Orientation.Horizontal,
91 HorizontalAlignment = HorizontalAlignment.Center,
92 VerticalAlignment = VerticalAlignment.Center,
93 CellPadding = new Size2D(100, 0)
95 root.Add(parentView[1]);
97 ///////////////////////////////////////////////Create by Property//////////////////////////////////////////////////////////
99 tab.Size = new Size(700, 108);
100 tab.BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 0.5f);
101 tab.Underline.Size = new Size(1, 3);
102 tab.Underline.BackgroundColor = color[0];
104 tab.TextColorSelector = new ColorSelector
106 Normal = Color.Black,
109 tab.ItemChangedEvent += TabItemChangedEvent;
110 parentView[1].Add(tab);
112 for (int i = 0; i < 3; i++)
114 Tab.TabItemData item = new Tab.TabItemData();
115 item.Text = "Tab " + i;
118 item.Text = "Long Tab " + i;
122 tab.SelectedItemIndex = 0;
124 ///////////////////////////////////////////////Create by Style//////////////////////////////////////////////////////////
125 TabStyle st = new TabStyle
127 //IsNatureTextWidth = false,
128 ItemPadding = new Extents(56, 56, 1, 0),
129 UnderLine = new ViewStyle
131 Size = new Size(1, 3),
132 PositionUsesPivotPoint = true,
133 ParentOrigin = Tizen.NUI.ParentOrigin.BottomLeft,
134 PivotPoint = Tizen.NUI.PivotPoint.BottomLeft,
135 BackgroundColor = new Selector<Color> { All = color[0] },
137 Text = new TextLabelStyle
139 PointSize = new Selector<float?> { All = 25 },
140 TextColor = new Selector<Color>
142 Normal = Color.Black,
149 tab2.Size = new Size(500, 108);
150 tab2.BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 0.5f);
151 tab2.ItemChangedEvent += Tab2ItemChangedEvent;
152 parentView[1].Add(tab2);
154 for (int i = 0; i < 3; i++)
156 Tab.TabItemData item = new Tab.TabItemData();
157 item.Text = "Tab " + i;
160 tab2.SelectedItemIndex = 0;
163 private void CreateButtonView()
165 // Init parent of ButtonView
166 parentView[2] = new View();
167 parentView[2].Size = new Size(1920, 200);
168 parentView[2].Layout = new LinearLayout()
170 LinearOrientation = LinearLayout.Orientation.Horizontal,
171 HorizontalAlignment = HorizontalAlignment.Center,
172 VerticalAlignment = VerticalAlignment.Center,
173 CellPadding = new Size2D(100, 0)
175 root.Add(parentView[2]);
178 var buttonStyle = new ButtonStyle()
180 Size = new Size(300, 80),
181 Overlay = new ImageViewStyle()
183 ResourceUrl = new Selector<string>
185 Pressed = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_press_overlay.png",
188 Border = new Rectangle(5, 5, 5, 5)
190 Text = new TextLabelStyle()
192 TextColor = new Selector<Color>
194 Normal = new Color(0, 0, 0, 1),
195 Pressed = new Color(0, 0, 0, 0.7f),
196 Selected = new Color(0.058f, 0.631f, 0.92f, 1),
197 Disabled = new Color(0, 0, 0, 0.4f)
201 BackgroundImage = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_normal.png",
202 BackgroundImageBorder = new Rectangle(5, 5, 5, 5),
205 // Button of switching mode
206 button = new Button(buttonStyle);
207 button.Size = new Size(500, 80);
208 button.TextLabel.Text = mode[index];
209 button.Clicked += ButtonClicked;
210 parentView[2].Add(button);
212 // Button of LayoutDirection
213 button2 = new Button(buttonStyle);
214 button2.Size = new Size(500, 80);
215 button2.TextLabel.Text = "LayoutDirection is left to right";
216 button2.Clicked += ButtonClicked2;
217 parentView[2].Add(button2);
220 private void TabItemChangedEvent(object sender, Tab.ItemChangedEventArgs e)
222 createText[0].Text = "Create Tab just by properties, Selected index from " + e.PreviousIndex + " to " + e.CurrentIndex;
225 public void Deactivate()
253 if (createText[0] != null)
255 createText[0].Dispose();
256 createText[0] = null;
259 if (createText[1] != null)
261 createText[1].Dispose();
262 createText[1] = null;
265 for (int j = 0; j < 3; j++)
267 if (parentView[j] != null)
269 parentView[j].Dispose();
270 parentView[j] = null;
274 NUIApplication.GetDefaultWindow().Remove(root);
280 private void Tab2ItemChangedEvent(object sender, Tab.ItemChangedEventArgs e)
282 createText[1].Text = "Create Tab just by Style, Selected index from " + e.PreviousIndex + " to " + e.CurrentIndex;
285 private void ButtonClicked(object sender, ClickedEventArgs e)
287 index = (index + 1) % 4;
288 button.TextLabel.Text = mode[index];
289 tab.Underline.BackgroundColor = color[index];
290 tab.TextColorSelector = new ColorSelector
292 Normal = Color.Black,
293 Selected = color[index],
295 tab2.Underline.BackgroundColor = color[index];
296 tab2.TextColorSelector = new ColorSelector
298 Normal = Color.Black,
299 Selected = color[index],
303 private void ButtonClicked2(object sender, ClickedEventArgs e)
305 if (tab.LayoutDirection == ViewLayoutDirectionType.LTR)
307 tab.LayoutDirection = ViewLayoutDirectionType.RTL;
308 tab2.LayoutDirection = ViewLayoutDirectionType.RTL;
309 button2.TextLabel.Text = "LayoutDirection is right to left";
313 tab.LayoutDirection = ViewLayoutDirectionType.LTR;
314 tab2.LayoutDirection = ViewLayoutDirectionType.LTR;
315 button2.TextLabel.Text = "LayoutDirection is left to right";