2 using System.Collections.Generic;
4 using System.Reflection;
6 using System.Threading.Tasks;
8 using Tizen.NUI.BaseComponents;
10 namespace NuiCommonUiSamples
12 public class DaliDemo : Tizen.FH.NUI.FHNUIApplication
14 public DaliDemo() : base()
18 public DaliDemo(string styleSheet) : base(styleSheet)
22 private IExample curExample = null;
26 global::System.GC.Collect();
27 global::System.GC.WaitForPendingFinalizers();
28 global::System.GC.Collect();
31 private void DeleteDaliDemo()
33 Window.Instance.Remove(demo.mRootActor);
34 demo.mRootActor.Dispose();
40 private void CreateDaliDemo()
42 demo = new DaliTableView((string name) =>
47 Assembly assembly = this.GetType().Assembly;
49 Type exampleType = assembly.GetType("NuiCommonUiSamples.IExample");
51 foreach (Type type in assembly.GetTypes())
53 if (exampleType.IsAssignableFrom(type) && type.Name != "SampleMain" && this.GetType() != type && true == type.IsClass)
55 demo.AddExample(new Example(type.FullName, type.Name));
58 demo.SortAlphabetically(true);
62 Window.Instance.GetDefaultLayer().Add(demo.mRootActor);
65 private void OnBackNaviTouchEvent(object source, View.TouchEventArgs e)
67 if (e.Touch.GetState(0) == PointStateType.Up)
69 if (null != curExample)
75 if (backNavigation != null)
77 Window.Instance.GetDefaultLayer().Remove(backNavigation);
78 backNavigation.Dispose();
79 backNavigation = null;
89 private void RunSample(string name)
91 Assembly assembly = typeof(DaliDemo).Assembly;
93 Type exampleType = assembly?.GetType(name);
94 IExample example = assembly?.CreateInstance(name) as IExample;
96 curPageIndex = demo.GetCurrentPageIndex();
105 curExample = example;
107 backNavigation.Show();
108 backNavigation.RaiseToTop();
111 private int curPageIndex = -1;
113 private void ExitSample()
115 curExample?.Deactivate();
122 backNavigation.Hide();
124 if (0 <= curPageIndex)
126 demo.ScrollTo((uint)curPageIndex);
130 protected override void OnCreate()
136 backNavigation = new Tizen.FH.NUI.Controls.Navigation("Back");
137 backNavigation.PositionUsesPivotPoint = true;
138 backNavigation.PivotPoint = PivotPoint.BottomLeft;
139 backNavigation.ParentOrigin = ParentOrigin.BottomLeft;
140 backNavigation.ItemTouchEvent += OnBackNaviTouchEvent;
141 backNavigation.Hide();
143 Tizen.FH.NUI.Controls.Navigation.NavigationItemData backItem = new Tizen.FH.NUI.Controls.Navigation.NavigationItemData("WhiteBackItem");
144 backNavigation.AddItem(backItem);
146 Window.Instance.GetDefaultLayer().Add(backNavigation);
148 Window.Instance.KeyEvent += Instance_KeyEvent;
150 int id = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
152 timerForExit.Tick += TimerForExit_Tick;
155 private bool TimerForExit_Tick(object source, Timer.TickEventArgs e)
157 int id = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
158 backNavigation?.Dispose();
159 backNavigation = null;
164 timerForExit.Dispose();
168 private void Instance_KeyEvent(object sender, Window.KeyEventArgs e)
170 if (e.Key.State == Key.StateType.Up)
172 if (e.Key.KeyPressedName == "Escape" || e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "BackSpace")
174 if (null != curExample)
180 timerForExit.Start();
183 else if (e.Key.KeyPressedName == "1")
190 public void Deactivate()
195 private Tizen.NUI.Timer timerForExit = new Tizen.NUI.Timer(10);
196 private DaliTableView demo;
197 private Tizen.FH.NUI.Controls.Navigation backNavigation;