1 using Tizen.NUI.Components;
2 using Tizen.NUI.BaseComponents;
4 namespace Tizen.NUI.Samples
6 public class PaginationSample : IExample
8 private TextLabel[] board = new TextLabel[2];
9 private Pagination[] pagination = new Pagination[2];
10 private View[] layout = new View[3];
12 private readonly int PAGE_COUNT = 5;
14 public void Activate()
16 Window window = NUIApplication.GetDefaultWindow();
19 layout[0] = new View()
21 Size = new Size(1920, 1080),
22 BackgroundColor = new Color(0.7f, 0.9f, 0.8f, 1.0f),
24 layout[0].Layout = new LinearLayout()
26 LinearOrientation = LinearLayout.Orientation.Vertical,
27 LinearAlignment = LinearLayout.Alignment.Center,
28 CellPadding = new Size(20, 50)
30 window.Add(layout[0]);
31 window.KeyEvent += Window_KeyEvent;
33 // A pagination sample created by properties will be added to this layout.
36 Size = new Size(700, 70),
37 Layout = new LinearLayout()
39 LinearOrientation = LinearLayout.Orientation.Horizontal,
40 LinearAlignment = LinearLayout.Alignment.Center,
41 CellPadding = new Size(20, 50)
44 layout[0].Add(layout[1]);
46 // A pagination sample created by attributes will be added to this layout.
47 layout[2] = new View()
49 Size = new Size(700, 70),
50 Layout = new LinearLayout()
52 LinearOrientation = LinearLayout.Orientation.Horizontal,
53 LinearAlignment = LinearLayout.Alignment.Center,
54 CellPadding = new Size(20, 50)
57 layout[0].Add(layout[2]);
61 ///////////////////////////////////////////////Create by Properties//////////////////////////////////////////////////////////
62 pagination[0] = new Pagination();
63 var indicatorImageUrlStyle = new PaginationStyle()
65 IndicatorSize = new Size(26, 26),
67 IndicatorImageUrl = new Selector<string>
69 Normal = CommonResource.GetFHResourcePath() + "9. Controller/pagination_ic_nor.png",
70 Selected = CommonResource.GetFHResourcePath() + "9. Controller/pagination_ic_sel.png"
73 pagination[0].ApplyStyle(indicatorImageUrlStyle);
74 pagination[0].Name = "Pagination1";
75 pagination[0].Size = new Size(300, 50);
76 pagination[0].BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 0.6f);
77 pagination[0].IndicatorCount = PAGE_COUNT;
78 pagination[0].SelectedIndex = 0;
79 layout[1].Add(pagination[0]);
81 ///////////////////////////////////////////////Create by Attributes//////////////////////////////////////////////////////////
82 PaginationStyle style = new PaginationStyle()
84 IndicatorSize = new Size(15, 15),
85 IndicatorSpacing = 20,
86 IndicatorImageUrl = new Selector<string>
88 Normal = CommonResource.GetFHResourcePath() + "9. Controller/pagination_ic_nor.png",
89 Selected = CommonResource.GetFHResourcePath() + "9. Controller/pagination_ic_sel.png"
92 pagination[1] = new Pagination(style);
93 pagination[1].Name = "Pagination2";
94 pagination[1].Size = new Size(300, 50);
95 pagination[1].BackgroundColor = new Color(1.0f, 1.0f, 1.0f, 0.6f);
96 pagination[1].IndicatorCount = PAGE_COUNT;
97 pagination[1].SelectedIndex = 0;
98 layout[2].Add(pagination[1]);
103 board[0] = new TextLabel();
104 board[0].Size = new Size(300, 50);
105 board[0].PointSize = 15;
106 board[0].HorizontalAlignment = HorizontalAlignment.Center;
107 board[0].VerticalAlignment = VerticalAlignment.Center;
108 board[0].BackgroundColor = Color.Magenta;
109 board[0].Text = "Property construction";
110 layout[1].Add(board[0]);
112 board[1] = new TextLabel();
113 board[1].Size = new Size(300, 50);
114 board[1].PointSize = 15;
115 board[1].HorizontalAlignment = HorizontalAlignment.Center;
116 board[1].VerticalAlignment = VerticalAlignment.Center;
117 board[1].BackgroundColor = Color.Magenta;
118 board[1].Text = "Attribute construction";
119 layout[2].Add(board[1]);
122 private void Window_KeyEvent(object sender, Window.KeyEventArgs e)
124 if (e.Key.State == Key.StateType.Down)
126 if (e.Key.KeyPressedName == "Left")
128 if (pagination[0].SelectedIndex > 0)
130 pagination[0].SelectedIndex = pagination[0].SelectedIndex - 1;
132 if (pagination[1].SelectedIndex > 0)
134 pagination[1].SelectedIndex = pagination[1].SelectedIndex - 1;
137 else if (e.Key.KeyPressedName == "Right")
139 if (pagination[0].SelectedIndex < pagination[0].IndicatorCount - 1)
141 pagination[0].SelectedIndex = pagination[0].SelectedIndex + 1;
143 if (pagination[1].SelectedIndex < pagination[1].IndicatorCount - 1)
145 pagination[1].SelectedIndex = pagination[1].SelectedIndex + 1;
151 public void Deactivate()
153 Window window = NUIApplication.GetDefaultWindow();
154 window.KeyEvent -= Window_KeyEvent;
156 if (layout[0] != null)
158 layout[1].Remove(board[0]);
162 layout[1].Remove(pagination[0]);
163 pagination[0].Dispose();
164 pagination[0] = null;
166 layout[0].Remove(layout[1]);
170 layout[2].Remove(board[1]);
174 layout[2].Remove(pagination[1]);
175 pagination[1].Dispose();
176 pagination[1] = null;
178 layout[0].Remove(layout[2]);
182 window.Remove(layout[0]);