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
11 private TextLabel[] createText = new TextLabel[2];
13 private Tab tab = null;
14 private Tab tab2 = null;
16 private Button button = null;
17 private Button button2 = null;
18 private int index = 0;
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 = Window.Instance;
40 Size2D = new Size2D(1920, 1080),
44 ///////////////////////////////////////////////Create by Property//////////////////////////////////////////////////////////
45 createText[0] = new TextLabel();
46 createText[0].Text = "Create Tab just by properties";
47 createText[0].Size2D = new Size2D(450, 100);
48 createText[0].Position2D = new Position2D(200, 100);
49 createText[0].MultiLine = true;
50 root.Add(createText[0]);
53 tab.Size2D = new Size2D(700, 108);
54 tab.Position2D = new Position2D(100, 300);
55 tab.BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 0.5f);
56 //tab.IsNatureTextWidth = true;
59 //tab.RightSpace = 56;
61 //tab.BottomSpace = 0;
62 tab.Style.UnderLine.Size = new Size(1, 3);
63 tab.Style.UnderLine.BackgroundColor = color[0];
64 tab.Style.Text.PointSize = 25;
65 tab.Style.Text.TextColor = new Selector<Color>
70 tab.ItemChangedEvent += TabItemChangedEvent;
73 for (int i = 0; i < 3; i++)
75 Tab.TabItemData item = new Tab.TabItemData();
76 item.Text = "Tab " + i;
79 item.Text = "Long Tab " + i;
83 tab.SelectedItemIndex = 0;
85 ///////////////////////////////////////////////Create by Attributes//////////////////////////////////////////////////////////
86 createText[1] = new TextLabel();
87 createText[1].Text = "Create Tab just by Attributes";
88 createText[1].Size2D = new Size2D(450, 100);
89 createText[1].Position2D = new Position2D(1000, 100);
90 createText[1].MultiLine = true;
91 root.Add(createText[1]);
93 TabStyle attrs = new TabStyle
95 //IsNatureTextWidth = false,
96 ItemPadding = new Extents(56, 56, 1, 0),
97 UnderLine = new ViewStyle
99 Size = new Size(1, 3),
100 PositionUsesPivotPoint = true,
101 ParentOrigin = Tizen.NUI.ParentOrigin.BottomLeft,
102 PivotPoint = Tizen.NUI.PivotPoint.BottomLeft,
103 BackgroundColor = new Selector<Color> { All = color[0]},
105 Text = new TextLabelStyle
107 PointSize = new Selector<float?> { All = 25 },
108 TextColor = new Selector<Color>
110 Normal = Color.Black,
116 tab2 = new Tab(attrs);
117 tab2.Size2D = new Size2D(500, 108);
118 tab2.Position2D = new Position2D(900, 300);
119 tab2.BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 0.5f);
120 tab2.ItemChangedEvent += Tab2ItemChangedEvent;
123 for (int i = 0; i < 3; i++)
125 Tab.TabItemData item = new Tab.TabItemData();
126 item.Text = "Tab " + i;
129 tab2.SelectedItemIndex = 0;
131 button = new Button();
132 button.Style.BackgroundImage = CommonResource.GetTVResourcePath() + "component/c_buttonbasic/c_basic_button_white_bg_normal_9patch.png";
133 button.Style.BackgroundImageBorder = new Rectangle(4, 4, 5, 5);
134 button.Size2D = new Size2D(280, 80);
135 button.Position2D = new Position2D(400, 700);
136 button.Style.Text.Text = mode[index];
137 button.ClickEvent += ButtonClickEvent;
140 button2 = new Button();
141 button2.Style.BackgroundImage = CommonResource.GetTVResourcePath() + "component/c_buttonbasic/c_basic_button_white_bg_normal_9patch.png";
142 button2.Style.BackgroundImageBorder = new Rectangle(4, 4, 5, 5);
143 button2.Size2D = new Size2D(580, 80);
144 button2.Position2D = new Position2D(250, 500);
145 button2.Style.Text.Text = "LayoutDirection is left to right";
146 button2.ClickEvent += ButtonClickEvent2;
150 private void TabItemChangedEvent(object sender, Tab.ItemChangedEventArgs e)
152 createText[0].Text = "Create Tab just by properties, Selected index from " + e.PreviousIndex + " to " + e.CurrentIndex;
155 public void Deactivate()
168 root.Remove(button2);
186 if (createText[0] != null)
188 root.Remove(createText[0]);
189 createText[0].Dispose();
190 createText[0] = null;
192 if (createText[1] != null)
194 root.Remove(createText[1]);
195 createText[1].Dispose();
196 createText[1] = null;
199 Window.Instance.Remove(root);
205 private void Tab2ItemChangedEvent(object sender, Tab.ItemChangedEventArgs e)
207 createText[1].Text = "Create Tab just by Attributes, Selected index from " + e.PreviousIndex + " to " + e.CurrentIndex;
210 private void ButtonClickEvent(object sender, Button.ClickEventArgs e)
212 index = (index + 1) % 4;
213 button.Style.Text.Text = mode[index];
214 tab.Style.UnderLine.BackgroundColor = color[index];
215 tab.Style.Text.TextColor = new Selector<Color>
217 Normal = Color.Black,
218 Selected = color[index],
220 tab2.Style.UnderLine.BackgroundColor = color[index];
221 tab2.Style.Text.TextColor = new Selector<Color>
223 Normal = Color.Black,
224 Selected = color[index],
228 private void ButtonClickEvent2(object sender, Button.ClickEventArgs e)
230 if (tab.LayoutDirection == ViewLayoutDirectionType.LTR)
232 tab.LayoutDirection = ViewLayoutDirectionType.RTL;
233 tab2.LayoutDirection = ViewLayoutDirectionType.RTL;
234 button2.Style.Text.Text = "LayoutDirection is right to left";
238 tab.LayoutDirection = ViewLayoutDirectionType.LTR;
239 tab2.LayoutDirection = ViewLayoutDirectionType.LTR;
240 button2.Style.Text.Text = "LayoutDirection is left to right";