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.
19 using System.Collections.Generic;
21 namespace ElmSharp.Test
23 public class IndexTest2 : TestCaseBase
25 Dictionary<IndexItem, int> _indexTable = new Dictionary<IndexItem, int>();
27 public override string TestName => "IndexTest2";
28 public override string TestDescription => "To test basic operation of Index";
29 public override void Run(Window window)
31 Conformant conformant = new Conformant(window);
33 Box outterBox = new Box(window)
42 Scroller scroller = new Scroller(window)
48 ScrollBlock = ScrollBlock.Vertical,
49 HorizontalPageScrollLimit = 1,
51 scroller.SetPageSize(1.0, 1.0);
54 Box box = new Box(window)
63 scroller.SetContent(box);
65 Index index = new Index(window)
68 Style = "pagecontrol",
75 var rnd = new Random();
76 for (int i = 0; i < 10; i++)
78 int r = rnd.Next(255);
79 int g = rnd.Next(255);
80 int b = rnd.Next(255);
81 Color color = Color.FromRgb(r, g, b);
82 Rectangle colorBox = new Rectangle(window)
89 MinimumWidth = window.ScreenSize.Width,
92 Console.WriteLine("Height = {0}", colorBox.Geometry.Height);
93 box.PackEnd(colorBox);
94 var item = index.Append(string.Format("{0}", i));
95 item.Selected += (s, e) =>
97 scroller.ScrollTo(_indexTable[(IndexItem)s], 0, true);
99 _indexTable[item] = i;
102 conformant.SetContent(outterBox);
103 outterBox.PackEnd(scroller);
105 Button prev = new Button(window)
111 Button next = new Button(window)
117 prev.Clicked += (s, e) =>
119 scroller.ScrollTo(scroller.HorizontalPageIndex > 0 ? scroller.HorizontalPageIndex - 1 : 0, scroller.VerticalPageIndex, true);
121 next.Clicked += (s, e) =>
123 scroller.ScrollTo(scroller.HorizontalPageIndex + 1, scroller.VerticalPageIndex, true);
127 outterBox.PackEnd(prev);
128 outterBox.PackEnd(next);
129 outterBox.PackEnd(index);
131 scroller.DragStart += Scroller_DragStart;
132 scroller.DragStop += Scroller_DragStop;
135 private void Scroller_DragStop(object sender, EventArgs e)
137 Console.WriteLine("Drag stop");
140 private void Scroller_DragStart(object sender, EventArgs e)
142 Console.WriteLine("Drag start");