2 using Tizen.NUI.BaseComponents;
3 using Tizen.NUI.Components;
5 namespace Tizen.NUI.Samples
7 public class ScrollbarSample : IExample
9 private TextLabel board1, board2, board;
10 private Button button1, button2, button3, button4, button5;
11 private ScrollBar scrollBar1_1, scrollBar1_2, scrollBar2_1, scrollBar2_2; //1-null para 2-attributes; X_1-color; X_2 image track
14 public void Activate()
16 Window window = Window.Instance;
20 Size2D = new Size2D(1920, 1080),
23 CreateBoardAndButtons();
25 scrollBar1_1 = new ScrollBar();
26 scrollBar1_1.Position2D = new Position2D(50, 300);
27 scrollBar1_1.Size2D = new Size2D(300, 4);
28 scrollBar1_1.Style.Track.BackgroundColor = Color.Green;
29 scrollBar1_1.MaxValue = (int)scrollBar1_1.SizeWidth / 10;
30 scrollBar1_1.MinValue = 0;
31 scrollBar1_1.Style.Thumb.Size = new Size(30, 4);
32 scrollBar1_1.CurrentValue = 0; //set after thumbsize
33 scrollBar1_1.Style.Thumb.BackgroundColor = Color.Black;
34 root.Add(scrollBar1_1);
36 scrollBar1_2 = new ScrollBar();
37 scrollBar1_2.Position2D = new Position2D(50, 400);
38 scrollBar1_2.Size2D = new Size2D(300, 4);
39 scrollBar1_2.Style.Track.BackgroundColor = Color.Green;
40 scrollBar1_2.MaxValue = (int)scrollBar1_2.SizeWidth / 10;
41 scrollBar1_2.MinValue = 0;
42 scrollBar1_2.Style.Thumb.Size = new Size(30, 4);
43 scrollBar1_2.CurrentValue = 0;//set after thumbsize
44 scrollBar1_2.Style.Thumb.BackgroundColor = Color.Yellow;
45 scrollBar1_2.Style.Track.ResourceUrl = CommonResource.GetTVResourcePath() + "component/c_progressbar/c_progressbar_white_buffering.png";
47 root.Add(scrollBar1_2);
49 ScrollBarStyle attr = new ScrollBarStyle
51 Track = new ImageViewStyle
53 BackgroundColor = new Selector<Color>
55 All = new Color(0.43f, 0.43f, 0.43f, 0.1f),
58 Thumb = new ImageViewStyle
60 BackgroundColor = new Selector<Color>
62 All = new Color(1.0f, 0.0f, 0.0f, 0.2f),
67 scrollBar2_1 = new ScrollBar(attr);
68 scrollBar2_1.Position2D = new Position2D(500, 300);
69 scrollBar2_1.Size2D = new Size2D(300, 4);
70 scrollBar2_1.MaxValue = (int)scrollBar2_1.SizeWidth / 10;
71 scrollBar2_1.MinValue = 0;
72 scrollBar2_1.Style.Thumb.Size = new Size(30, 4);
73 scrollBar2_1.CurrentValue = 0; //set after thumbsize
74 root.Add(scrollBar2_1);
76 board.UpFocusableView = button1;
80 FocusManager.Instance.SetCurrentFocusView(button1);
83 void CreateBoardAndButtons()
86 board = new TextLabel();
87 board.Size2D = new Size2D(1000, 100);
88 board.Position2D = new Position2D(430, 900);
90 board.HorizontalAlignment = HorizontalAlignment.Center;
91 board.VerticalAlignment = VerticalAlignment.Center;
92 board.BackgroundColor = Color.Magenta;
93 board.Text = "log pad";
95 board.Focusable = true;
96 board.FocusGained += Board_FocusGained;
97 board.FocusLost += Board_FocusLost;
99 board1 = new TextLabel();
100 board1.Size2D = new Size2D(300, 70);
101 board1.Position2D = new Position2D(50, 150);
102 board1.PointSize = 20;
103 board1.HorizontalAlignment = HorizontalAlignment.Center;
104 board1.VerticalAlignment = VerticalAlignment.Center;
105 board1.BackgroundColor = Color.Magenta;
106 board1.Text = "NULL parameter construction";
108 board1.Focusable = true;
109 board1.FocusGained += Board_FocusGained;
110 board1.FocusLost += Board_FocusLost;
112 board2 = new TextLabel();
113 board2.Size2D = new Size2D(300, 70);
114 board2.Position2D = new Position2D(500, 150);
115 board2.PointSize = 20;
116 board2.HorizontalAlignment = HorizontalAlignment.Center;
117 board2.VerticalAlignment = VerticalAlignment.Center;
118 board2.BackgroundColor = Color.Magenta;
119 board2.Text = "Attribute construction";
121 board2.Focusable = true;
122 board2.FocusGained += Board_FocusGained;
123 board2.FocusLost += Board_FocusLost;
125 button1 = new Button();
126 button1.BackgroundColor = Color.Green;
127 button1.Position2D = new Position2D(100, 700);
128 button1.Size2D = new Size2D(80, 50);
129 button1.Style.Text.Text = "+";
131 button1.Focusable = true;
132 button1.ClickEvent += Scroll1Add;
134 button2 = new Button();
135 button2.BackgroundColor = Color.Green;
136 button2.Position2D = new Position2D(200, 700);
137 button2.Size2D = new Size2D(80, 50);
138 button2.Style.Text.Text = "-";
140 button2.Focusable = true;
141 button2.ClickEvent += Scroll1Minus;
143 button5 = new Button();
144 button5.BackgroundColor = Color.Green;
145 button5.Position2D = new Position2D(400, 800);
146 button5.Size2D = new Size2D(100, 50);
147 button5.Style.Text.Text = "+ / - 4";
149 button5.Focusable = true;
150 button5.ClickEvent += Scroll1_2move;
152 Button button22 = new Button();
153 button22.BackgroundColor = Color.Green;
154 button22.Position2D = new Position2D(100, 800);
155 button22.Size2D = new Size2D(200, 50);
156 button22.Style.Text.Text = "change direction";
158 button22.Focusable = true;
159 button22.ClickEvent += Scroll1_2Changed;
161 button3 = new Button();
162 button3.BackgroundColor = Color.Green;
163 button3.Position2D = new Position2D(450, 700);
164 button3.Size2D = new Size2D(80, 50);
165 button3.Style.Text.Text = "+";
167 button3.Focusable = true;
168 button3.ClickEvent += Scroll2Add;
170 button4 = new Button();
171 button4.BackgroundColor = Color.Green;
172 button4.Position2D = new Position2D(550, 700);
173 button4.Size2D = new Size2D(80, 50);
174 button4.Style.Text.Text = "-";
176 button4.Focusable = true;
177 button4.ClickEvent += Scroll2Minus;
180 private void Board_FocusLost(object sender, global::System.EventArgs e)
182 board.BackgroundColor = Color.Magenta;
185 private void Board_FocusGained(object sender, global::System.EventArgs e)
187 board.BackgroundColor = Color.Cyan;
190 private void Scroll1Add(object sender, global::System.EventArgs e)
192 scrollBar1_1.CurrentValue++;
194 private void Scroll1Minus(object sender, global::System.EventArgs e)
196 scrollBar1_1.CurrentValue--;
198 private void Scroll2Add(object sender, global::System.EventArgs e)
200 scrollBar2_1.CurrentValue++;
202 private void Scroll2Minus(object sender, global::System.EventArgs e)
204 scrollBar2_1.CurrentValue--;
207 private void Scroll1_2Changed(object sender, global::System.EventArgs e)
209 if(scrollBar1_2.LayoutDirection == ViewLayoutDirectionType.LTR)
210 scrollBar1_2.LayoutDirection= ViewLayoutDirectionType.RTL;
212 scrollBar1_2.LayoutDirection = ViewLayoutDirectionType.LTR;
215 private void Scroll1_2move(object sender, global::System.EventArgs e)
217 if (scrollBar1_2.CurrentValue < scrollBar1_2.MaxValue / 2)
219 scrollBar1_2.SetCurrentValue(scrollBar1_2.MaxValue - 2);
223 scrollBar1_2.SetCurrentValue(2);
227 private void ScrollPan(object sender, global::System.EventArgs e)
229 board.Text = board.Text + " 1";
230 if (board.Text.Length > 20)
234 public void Deactivate()
238 Window.Instance.Remove(root);