2 using Tizen.NUI.BaseComponents;
3 using Tizen.NUI.Components;
5 namespace Tizen.NUI.Samples
7 public class ScrollbarSample : IExample
9 private TextLabel text_nullstyle, text_style;
10 private Button[] button = new Button[4];
11 private ScrollBar[] scrollBar = new ScrollBar[3];
13 private View top_parent, bottom_parent, null_style_parent, style_parent;
15 public void Activate()
17 Window window = NUIApplication.GetDefaultWindow();
20 Size = new Size(1920, 1080),
21 BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f),
23 root.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical };
26 // TextLabel of Null style construction and Style construction
29 // Buttons for moving thumbnail
32 private void CreateTopView()
34 top_parent = new View() { Size = new Size(1920, 540) };
35 top_parent.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal };
37 CreateNullStylePart();
41 private void CreateNullStylePart()
43 null_style_parent = new View() { Size = new Size(960, 540) };
44 null_style_parent.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, LinearAlignment = LinearLayout.Alignment.Center, CellPadding = new Size2D(0, 50) };
45 top_parent.Add(null_style_parent);
47 // Add Textlabel of "Null style construction"
48 text_nullstyle = new TextLabel();
49 text_nullstyle.Size = new Size(400, 70);
50 text_nullstyle.PointSize = 20;
51 text_nullstyle.HorizontalAlignment = HorizontalAlignment.Center;
52 text_nullstyle.VerticalAlignment = VerticalAlignment.Center;
53 text_nullstyle.BackgroundColor = Color.Magenta;
54 text_nullstyle.Text = "Null style construction";
55 text_nullstyle.Focusable = true;
56 null_style_parent.Add(text_nullstyle);
58 // Add ScrollBar of Null style construction
59 scrollBar[0] = new ScrollBar();
60 scrollBar[0].Size = new Size(400, 4);
61 scrollBar[0].TrackColor = Color.Green;
62 scrollBar[0].MaxValue = (int)scrollBar[0].SizeWidth / 10;
63 scrollBar[0].MinValue = 0;
64 scrollBar[0].ThumbSize = new Size(30, 4);
65 scrollBar[0].CurrentValue = 0; //set after thumbsize
66 scrollBar[0].ThumbColor = Color.Black;
67 null_style_parent.Add(scrollBar[0]);
69 scrollBar[1] = new ScrollBar();
70 scrollBar[1].Size = new Size(400, 4);
71 scrollBar[1].TrackColor = Color.Green;
72 scrollBar[1].MaxValue = (int)scrollBar[1].SizeWidth / 10;
73 scrollBar[1].MinValue = 0;
74 scrollBar[1].ThumbSize = new Size(30, 4);
75 scrollBar[1].CurrentValue = 0;//set after thumbsize
76 scrollBar[1].ThumbColor = Color.Yellow;
77 scrollBar[1].TrackImageURL = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png";
78 null_style_parent.Add(scrollBar[1]);
81 private void CreateStylePart()
83 style_parent = new View() { Size = new Size(960, 540) };
84 style_parent.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Vertical, LinearAlignment = LinearLayout.Alignment.CenterVertical, CellPadding = new Size2D(0, 50) };
85 top_parent.Add(style_parent);
87 // Add Textlabel of "Style construction"
88 text_style = new TextLabel();
89 text_style.Size = new Size(400, 70);
90 text_style.PointSize = 20;
91 text_style.HorizontalAlignment = HorizontalAlignment.Center;
92 text_style.VerticalAlignment = VerticalAlignment.Center;
93 text_style.BackgroundColor = Color.Magenta;
94 text_style.Text = "Style construction";
95 text_style.Focusable = true;
96 style_parent.Add(text_style);
98 // Add ScrollBar of Style construction
99 ScrollBarStyle st = new ScrollBarStyle
101 Track = new ImageViewStyle
103 BackgroundColor = new Selector<Color>
105 All = new Color(0.43f, 0.43f, 0.43f, 0.1f),
108 Thumb = new ImageViewStyle
110 BackgroundColor = new Selector<Color>
112 All = new Color(1.0f, 0.0f, 0.0f, 0.2f),
116 scrollBar[2] = new ScrollBar(st);
117 scrollBar[2].Size = new Size(400, 4);
118 scrollBar[2].MaxValue = (int)scrollBar[2].SizeWidth / 10;
119 scrollBar[2].MinValue = 0;
120 scrollBar[2].ThumbSize = new Size(30, 4);
121 scrollBar[2].CurrentValue = 0;//set after thumbsize
122 style_parent.Add(scrollBar[2]);
125 private void CreateBottomView()
127 bottom_parent = new View() { Size = new Size(1920, 540) };
128 bottom_parent.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal, LinearAlignment = LinearLayout.Alignment.Center, CellPadding = new Size2D(50, 50) };
129 root.Add(bottom_parent);
137 for (int i = 0; i < 4; i++)
139 button[i] = new Button();
140 button[i].BackgroundColor = Color.Green;
141 button[i].Size = new Size(80, 50);
142 button[i].Focusable = true;
143 bottom_parent.Add(button[i]);
146 button[0].Text = "+";
147 button[0].ClickEvent += Scroll1Add;
149 button[1].Text = "-";
150 button[1].ClickEvent += Scroll1Minus;
152 button[2].Text = "+ / - 4";
153 button[2].ClickEvent += Scroll1_2move;
155 button[3].Text = "change direction";
156 button[3].ClickEvent += Scroll1_2Changed;
157 button[3].Size = new Size(180, 50);
159 // Set focus to Add Button
160 FocusManager.Instance.SetCurrentFocusView(button[0]);
163 private void Scroll1Add(object sender, global::System.EventArgs e)
165 scrollBar[0].CurrentValue++;
166 scrollBar[2].CurrentValue++;
168 private void Scroll1Minus(object sender, global::System.EventArgs e)
170 scrollBar[0].CurrentValue--;
171 scrollBar[2].CurrentValue--;
174 private void Scroll1_2Changed(object sender, global::System.EventArgs e)
176 if (scrollBar[1].LayoutDirection == ViewLayoutDirectionType.LTR)
178 scrollBar[1].LayoutDirection = ViewLayoutDirectionType.RTL;
182 scrollBar[1].LayoutDirection = ViewLayoutDirectionType.LTR;
186 private void Scroll1_2move(object sender, global::System.EventArgs e)
188 if (scrollBar[1].CurrentValue < scrollBar[1].MaxValue / 2)
190 scrollBar[1].SetCurrentValue(scrollBar[1].MaxValue - 2);
194 scrollBar[1].SetCurrentValue(2);
198 public void Deactivate()
202 NUIApplication.GetDefaultWindow().Remove(root);
203 if (text_nullstyle != null)
205 text_nullstyle.Dispose();
206 text_nullstyle = null;
209 if (text_style != null)
211 text_style.Dispose();
215 for (int i = 0; i < 4; i++)
217 if (button[i] != null)
224 for (int i = 0; i < 3; i++)
226 if (scrollBar[i] != null)
228 scrollBar[i].Dispose();
233 if (top_parent != null)
235 top_parent.Dispose();
239 if (bottom_parent != null)
241 bottom_parent.Dispose();
242 bottom_parent = null;
245 if (null_style_parent != null)
247 null_style_parent.Dispose();
248 null_style_parent = null;
251 if (style_parent != null)
253 style_parent.Dispose();