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 class IndexTest1 : TestCaseBase
25 Dictionary<IndexItem, GenListItem> _indexTable = new Dictionary<IndexItem, GenListItem>();
26 public override string TestName => "IndexTest1";
27 public override string TestDescription => "To test group operation of Index";
28 public override void Run(Window window)
30 Conformant conformant = new Conformant(window);
32 Box box = new Box(window)
41 GenList list = new GenList(window)
50 Index index = new Index(window)
61 GenItemClass groupClass = new GenItemClass("group_index")
63 GetTextHandler = (obj, part) =>
65 return string.Format("{0} - {1}", (string)obj, part);
69 GenListItem[] groups = new GenListItem[10];
71 for (int i = 0; i < 10; i++)
73 groups[i] = list.Append(groupClass, string.Format("{0}", i), GenListItemType.Group);
74 var indexitem = index.Append(string.Format("{0}", i));
75 indexitem.Selected += (s, e) =>
77 Console.WriteLine("Index selected : {0}", ((IndexItem)s).Text);
78 list.ScrollTo(_indexTable[(IndexItem)s], ScrollToPosition.In, true);
80 _indexTable[indexitem] = groups[i];
83 GenItemClass defaultClass = new GenItemClass("default")
85 GetTextHandler = (obj, part) =>
87 return string.Format("{0} - {1}", (string)obj, part);
91 for (int j = 0; j < 10; j++)
93 for (int i = 0; i < 20; i++)
95 list.Append(defaultClass, string.Format("{0} Item", i), GenListItemType.Normal, groups[j]);
99 list.ItemSelected += List_ItemSelected;
103 box.SetLayoutCallback(() =>
105 list.Geometry = box.Geometry;
106 index.Geometry = box.Geometry;
108 conformant.SetContent(box);
111 private void List_ItemSelected(object sender, GenListItemEventArgs e)
113 Console.WriteLine("{0} Item was selected", (string)(e.Item.Data));