2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 namespace ElmSharp.Test
22 public class ScrollerTest3 : TestCaseBase
24 public override string TestName => "ScrollerTest3";
25 public override string TestDescription => "To test ScrollTo operation of Scroller";
28 public override void Run(Window window)
30 Conformant conformant = new Conformant(window);
32 Box outterBox = new Box(window)
34 BackgroundColor = Color.Gray,
42 _scroller = new Scroller(window)
48 HorizontalPageScrollLimit = 1,
50 _scroller.SetPageSize(1.0, 1.0);
53 Box box = new Box(window)
61 _scroller.SetContent(box);
63 for (int i = 0; i < 150; i++)
65 Label addlabel = new Label(window)
67 Text = i + " Label Test",
74 box.PackEnd(addlabel);
77 conformant.SetContent(outterBox);
78 outterBox.PackEnd(_scroller);
80 Button prev = new Button(window)
86 Button next = new Button(window)
95 prev.Clicked += (s, e) =>
97 Rect region = new Rect(0, _scroller.Geometry.Height * --index, _scroller.Geometry.Width * index, _scroller.Geometry.Height);
98 Console.WriteLine("index : {0} [{1}, {2}]\n", index, _scroller.Geometry.Width, _scroller.Geometry.Height);
99 _scroller.ScrollTo(region, false);
102 next.Clicked += (s, e) =>
104 Rect region = new Rect(0, _scroller.Geometry.Height * ++index, _scroller.Geometry.Width, _scroller.Geometry.Height);
105 Console.WriteLine("index : {0} [{1}, {2}]\n", index, _scroller.Geometry.Width, _scroller.Geometry.Height);
106 _scroller.ScrollTo(region, false);
111 Button prev2 = new Button(window)
115 Text = "animation Prev"
117 Button next2 = new Button(window)
121 Text = "animation next"
124 prev2.Clicked += (s, e) =>
126 Rect region = new Rect(0, _scroller.Geometry.Height * --index, _scroller.Geometry.Width * index, _scroller.Geometry.Height);
127 Console.WriteLine("animation index : {0} [{1}, {2}]\n", index, _scroller.Geometry.Width, _scroller.Geometry.Height);
128 _scroller.ScrollTo(region, true);
131 next2.Clicked += (s, e) =>
133 Rect region = new Rect(0, _scroller.Geometry.Height * ++index, _scroller.Geometry.Width, _scroller.Geometry.Height);
134 Console.WriteLine("animation index : {0} [{1}, {2}]\n", index, _scroller.Geometry.Width, _scroller.Geometry.Height);
135 _scroller.ScrollTo(region, true);
140 outterBox.PackEnd(prev);
141 outterBox.PackEnd(next);
142 outterBox.PackEnd(prev2);
143 outterBox.PackEnd(next2);
145 _scroller.DragStart += Scroller_DragStart;
146 _scroller.DragStop += Scroller_DragStop;
147 _scroller.ScrollAnimationStarted += Scroller_ScrollStart;
148 _scroller.ScrollAnimationStopped += Scroller_ScrollStop;
149 _scroller.Scrolled += Scroller_Scrolled;
152 private void Scroller_Scrolled(object sender, EventArgs e)
154 Console.WriteLine($"scrolled : {_scroller.CurrentRegion}");
157 private void Scroller_ScrollStop(object sender, EventArgs e)
159 Console.WriteLine("scroll animation stop");
162 private void Scroller_ScrollStart(object sender, EventArgs e)
164 Console.WriteLine("scroll animation start");
167 private void Scroller_DragStop(object sender, EventArgs e)
169 Console.WriteLine("Drag stop");
172 private void Scroller_DragStart(object sender, EventArgs e)
174 Console.WriteLine("Drag start");