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 NaviframeTest3 : TestCaseBase
24 public override string TestName => "NaviframeTest3";
25 public override string TestDescription => "Naviframe test";
30 public override void Run(Window window)
32 Conformant conformant = new Conformant(window);
35 Naviframe navi = new Naviframe(window)
37 PreserveContentOnPop = true,
38 DefaultBackButtonEnabled = true
42 navi.Popped += (s, e) =>
44 Console.WriteLine("----- Naviframe was popped {0:x} ", (int)(IntPtr)e.Content);
47 NaviItem item = navi.Push(CreatePage(window), "0 Page");
48 item.SetPartContent("title_left_btn", new Button(window) { Text = "LEFT" , Style = "naviframe/title_left"} );
49 item.SetPartContent("title_right_btn", new Button(window) { Text = "RIGHT", Style = "naviframe/title_right" });
51 conformant.SetContent(navi);
54 EvasObject CreatePage(Window parent)
56 Box box = new Box(parent);
59 Label label = new Label(parent) {
60 Text = string.Format("{0} Page", _sequence++),
64 Button push = new Button(parent) {
69 Button pop = new Button(parent) {
74 Button insertBeforeTop = new Button(parent) {
75 Text = "insertBeforeTop",
79 Button insertAfterTop = new Button(parent) {
80 Text = "insertAfterTop",
85 Button removeTop = new Button(parent)
92 Button barChange = new Button(parent)
94 Text = "TitleBarColor Change",
99 Button barColorDefault = new Button(parent)
101 Text = "TitleBarColor - Default",
109 insertBeforeTop.Show();
110 insertAfterTop.Show();
113 barColorDefault.Show();
115 push.Clicked += (s, e) =>
117 _navi.Push(CreatePage(parent), string.Format("{0} Page", _sequence-1));
120 pop.Clicked += (s, e) =>
122 var item = _navi.NavigationStack.LastOrDefault();
123 int nativePointer = (int)(IntPtr)(item.Content);
124 Console.WriteLine("----- Before Call _navi.Pop() {0:x} ", nativePointer);
126 Console.WriteLine("----- After Call _navi.Pop() {0:x} ", nativePointer);
129 insertBeforeTop.Clicked += (s, e) =>
131 _navi.InsertBefore(_navi.NavigationStack.LastOrDefault(), CreatePage(parent), string.Format("{0} Page", _sequence - 1));
134 insertAfterTop.Clicked += (s, e) =>
136 _navi.InsertAfter(_navi.NavigationStack.LastOrDefault(), CreatePage(parent), string.Format("{0} Page", _sequence - 1));
138 removeTop.Clicked += (s, e) =>
140 var item = _navi.NavigationStack.LastOrDefault();
141 int nativePointer = (int)(IntPtr)(item.Content);
142 Console.WriteLine("----- Before Call NaviItem.Delete() {0:x} ", nativePointer);
144 Console.WriteLine("----- After Call NaviItem.Delete() {0:x} ", nativePointer);
147 Random rand = new Random(DateTime.Now.Millisecond);
148 barChange.Clicked += (s, e) =>
150 int currentIndex = _navi.NavigationStack.Count - 1;
151 if (currentIndex >= 0)
153 _navi.NavigationStack[currentIndex].TitleBarBackgroundColor = Color.FromHex(string.Format("#{0:X8}", rand.Next()));
157 barColorDefault.Clicked += (s, e) =>
159 int currentIndex = _navi.NavigationStack.Count - 1;
160 if (currentIndex >= 0)
162 _navi.NavigationStack[currentIndex].TitleBarBackgroundColor = Color.Default;
169 box.PackEnd(insertBeforeTop);
170 box.PackEnd(insertAfterTop);
171 box.PackEnd(removeTop);
172 box.PackEnd(barChange);
173 box.PackEnd(barColorDefault);