2 * Copyright(c) 2021 Samsung Electronics Co., Ltd.
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.
18 using System.Collections.Generic;
20 using Tizen.NUI.BaseComponents;
21 using Tizen.NUI.Components;
24 namespace NUITizenGallery
26 public partial class IndicatorViewTest2Page : ContentPage
28 private readonly string ResourcePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/images/";
29 private readonly int PagesCount = 5;
30 private List<Position> IndicatorPositions;
32 public IndicatorViewTest2Page()
34 InitializeComponent();
35 Scroller.ScrollAnimationEnded += OnScrollAnimationEnded;
37 PaginationStyle paginationStyle = new PaginationStyle()
39 IndicatorSize = new Size(26, 26),
43 Index.ApplyStyle(paginationStyle);
44 Index.IndicatorCount = PagesCount;
45 Index.SelectedIndex = 0;
46 Index.BackgroundColor = Tizen.NUI.Color.Gray;
47 Index.TouchEvent += OnIndexTouchEvent;
49 IndicatorPositions = new List<Position>();
50 for (int i = 0; i < PagesCount; ++i)
52 IndicatorPositions.Add(Index.GetIndicatorPosition(i));
56 private bool OnIndexTouchEvent(object sender, TouchEventArgs args)
58 if (args.Touch.GetState(0) == Tizen.NUI.PointStateType.Finished)
60 for (int i = PagesCount -1 ; i >= 0; i--)
62 if (args.Touch.GetLocalPosition(0).X >= IndicatorPositions[i].X)
64 Scroller.ScrollToIndex(i);
73 private void OnScrollAnimationEnded(object sender, ScrollEventArgs args)
75 Index.SelectedIndex = Scroller.CurrentPage;