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() { LinearOrientation = LinearLayout.Orientation.Horizontal, LinearAlignment = LinearLayout.Alignment.Center, CellPadding = new Size2D(100, 0) };
56 root.Add(parentView[0]);
58 for (int i = 0; i < 2; i++)
60 createText[i] = new TextLabel();
61 createText[i].Size = new Size(500, 100);
62 createText[i].PointSize = 20.0f;
63 createText[i].BackgroundColor = Color.Magenta;
64 createText[i].HorizontalAlignment = HorizontalAlignment.Center;
65 createText[i].VerticalAlignment = VerticalAlignment.Center;
66 createText[i].MultiLine = true;
67 parentView[0].Add(createText[i]);
70 // Text of "Create Switch just by Properties"
71 createText[0].Text = "Create Tab just by Properties";
73 // Text of "Create Switch just by Style"
74 createText[1].Text = "Create Tab just by Style";
77 private void CreateTabView()
79 // Init parent of TabView
80 parentView[1] = new View();
81 parentView[1].Size = new Size(1920, 200);
82 parentView[1].Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, LinearAlignment = LinearLayout.Alignment.Center, CellPadding = new Size2D(100, 0) };
83 root.Add(parentView[1]);
85 ///////////////////////////////////////////////Create by Property//////////////////////////////////////////////////////////
87 tab.Size = new Size(700, 108);
88 tab.BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 0.5f);
89 tab.Underline.Size = new Size(1, 3);
90 tab.Underline.BackgroundColor = color[0];
92 tab.TextColorSelector = new ColorSelector
97 tab.ItemChangedEvent += TabItemChangedEvent;
98 parentView[1].Add(tab);
100 for (int i = 0; i < 3; i++)
102 Tab.TabItemData item = new Tab.TabItemData();
103 item.Text = "Tab " + i;
106 item.Text = "Long Tab " + i;
110 tab.SelectedItemIndex = 0;
112 ///////////////////////////////////////////////Create by Style//////////////////////////////////////////////////////////
113 TabStyle st = new TabStyle
115 //IsNatureTextWidth = false,
116 ItemPadding = new Extents(56, 56, 1, 0),
117 UnderLine = new ViewStyle
119 Size = new Size(1, 3),
120 PositionUsesPivotPoint = true,
121 ParentOrigin = Tizen.NUI.ParentOrigin.BottomLeft,
122 PivotPoint = Tizen.NUI.PivotPoint.BottomLeft,
123 BackgroundColor = new Selector<Color> { All = color[0] },
125 Text = new TextLabelStyle
127 PointSize = new Selector<float?> { All = 25 },
128 TextColor = new Selector<Color>
130 Normal = Color.Black,
137 tab2.Size = new Size(500, 108);
138 tab2.BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 0.5f);
139 tab2.ItemChangedEvent += Tab2ItemChangedEvent;
140 parentView[1].Add(tab2);
142 for (int i = 0; i < 3; i++)
144 Tab.TabItemData item = new Tab.TabItemData();
145 item.Text = "Tab " + i;
148 tab2.SelectedItemIndex = 0;
151 private void CreateButtonView()
153 // Init parent of ButtonView
154 parentView[2] = new View();
155 parentView[2].Size = new Size(1920, 200);
156 parentView[2].Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, LinearAlignment = LinearLayout.Alignment.Center, CellPadding = new Size2D(100, 0) };
157 root.Add(parentView[2]);
160 var buttonStyle = new ButtonStyle()
162 Size = new Size(300, 80),
163 Overlay = new ImageViewStyle()
165 ResourceUrl = new Selector<string>
167 Pressed = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_press_overlay.png",
170 Border = new Rectangle(5, 5, 5, 5)
172 Text = new TextLabelStyle()
174 TextColor = new Selector<Color>
176 Normal = new Color(0, 0, 0, 1),
177 Pressed = new Color(0, 0, 0, 0.7f),
178 Selected = new Color(0.058f, 0.631f, 0.92f, 1),
179 Disabled = new Color(0, 0, 0, 0.4f)
183 BackgroundImage = CommonResource.GetFHResourcePath() + "3. Button/rectangle_btn_normal.png",
184 BackgroundImageBorder = new Rectangle(5, 5, 5, 5),
187 // Button of switching mode
188 button = new Button(buttonStyle);
189 button.Size = new Size(500, 80);
190 button.TextLabel.Text = mode[index];
191 button.Clicked += ButtonClicked;
192 parentView[2].Add(button);
194 // Button of LayoutDirection
195 button2 = new Button(buttonStyle);
196 button2.Size = new Size(500, 80);
197 button2.TextLabel.Text = "LayoutDirection is left to right";
198 button2.Clicked += ButtonClicked2;
199 parentView[2].Add(button2);
202 private void TabItemChangedEvent(object sender, Tab.ItemChangedEventArgs e)
204 createText[0].Text = "Create Tab just by properties, Selected index from " + e.PreviousIndex + " to " + e.CurrentIndex;
207 public void Deactivate()
235 if (createText[0] != null)
237 createText[0].Dispose();
238 createText[0] = null;
241 if (createText[1] != null)
243 createText[1].Dispose();
244 createText[1] = null;
247 for (int j = 0; j < 3; j++)
249 if (parentView[j] != null)
251 parentView[j].Dispose();
252 parentView[j] = null;
256 NUIApplication.GetDefaultWindow().Remove(root);
262 private void Tab2ItemChangedEvent(object sender, Tab.ItemChangedEventArgs e)
264 createText[1].Text = "Create Tab just by Style, Selected index from " + e.PreviousIndex + " to " + e.CurrentIndex;
267 private void ButtonClicked(object sender, ClickedEventArgs e)
269 index = (index + 1) % 4;
270 button.TextLabel.Text = mode[index];
271 tab.Underline.BackgroundColor = color[index];
272 tab.TextColorSelector = new ColorSelector
274 Normal = Color.Black,
275 Selected = color[index],
277 tab2.Underline.BackgroundColor = color[index];
278 tab2.TextColorSelector = new ColorSelector
280 Normal = Color.Black,
281 Selected = color[index],
285 private void ButtonClicked2(object sender, ClickedEventArgs e)
287 if (tab.LayoutDirection == ViewLayoutDirectionType.LTR)
289 tab.LayoutDirection = ViewLayoutDirectionType.RTL;
290 tab2.LayoutDirection = ViewLayoutDirectionType.RTL;
291 button2.TextLabel.Text = "LayoutDirection is right to left";
295 tab.LayoutDirection = ViewLayoutDirectionType.LTR;
296 tab2.LayoutDirection = ViewLayoutDirectionType.LTR;
297 button2.TextLabel.Text = "LayoutDirection is left to right";