2 * Copyright (c) 2016 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.
17 using Tizen.Applications;
18 using Tizen.Applications.CoreBackend;
19 using System.Collections.Generic;
20 using System.ComponentModel;
25 /// Represents an application that have UI screen. The NUIWidgetApplication class has a default stage.
27 /// <since_tizen> 4 </since_tizen>
28 public class NUIWidgetApplication : CoreApplication
31 /// The default constructor.
33 /// <remarks>Widget ID will be replaced as the application ID.</remarks>
34 /// <param name="widgetType">Derived widget class type.</param>
35 public NUIWidgetApplication( System.Type widgetType ) : base(new NUIWidgetCoreBackend())
37 NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend;
38 core?.RegisterWidgetInfo(new Dictionary<System.Type, string> { { widgetType, ApplicationInfo.ApplicationId } });
42 /// The constructor for multi widget class and instance.
44 /// <param name="widgetTypes">List of derived widget class type.</param>
45 [EditorBrowsable(EditorBrowsableState.Never)]
46 public NUIWidgetApplication(Dictionary<System.Type, string> widgetTypes) : base(new NUIWidgetCoreBackend())
48 NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend;
49 core?.RegisterWidgetInfo(widgetTypes);
53 /// The default constructor with stylesheet.
55 /// <remarks>Widget ID will be replaced as the application ID.</remarks>
56 /// <param name="widgetType">Derived widget class type.</param>
57 /// <param name="styleSheet">The styleSheet url.</param>
58 /// <since_tizen> 4 </since_tizen>
59 public NUIWidgetApplication(System.Type widgetType, string styleSheet) : base(new NUIWidgetCoreBackend(styleSheet))
61 NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend;
62 core?.RegisterWidgetInfo(new Dictionary<System.Type, string> { { widgetType, ApplicationInfo.ApplicationId } });
65 internal WidgetApplication ApplicationHandle
69 return ((NUIWidgetCoreBackend)this.Backend).WidgetApplicationHandle;
74 /// Run NUIWidgetApplication.
76 /// <param name="args">Arguments from commandline.</param>
77 /// <since_tizen> 4 </since_tizen>
78 public override void Run(string[] args)
80 Backend.AddEventHandler(EventType.PreCreated, OnPreCreate);
85 /// Exit NUIWidgetApplication.
87 /// <since_tizen> 4 </since_tizen>
88 public override void Exit()
90 Tizen.Log.Fatal("NUI", "### NUIWidgetApplication Exit called");
95 /// Overrides this method if want to handle OnLocaleChanged behavior.
97 /// <since_tizen> 4 </since_tizen>
98 protected override void OnLocaleChanged(LocaleChangedEventArgs e)
100 Log.Fatal("NUI", "OnLocaleChanged() is called!");
101 base.OnLocaleChanged(e);
105 /// Overrides this method if want to handle OnLowBattery behavior.
107 /// <since_tizen> 4 </since_tizen>
108 protected override void OnLowBattery(LowBatteryEventArgs e)
110 Log.Fatal("NUI", "OnLowBattery() is called!");
111 base.OnLowBattery(e);
115 /// Overrides this method if want to handle OnLowMemory behavior.
117 /// <since_tizen> 4 </since_tizen>
118 protected override void OnLowMemory(LowMemoryEventArgs e)
120 Log.Fatal("NUI", "OnLowMemory() is called!");
125 /// Overrides this method if want to handle OnRegionFormatChanged behavior.
127 /// <since_tizen> 4 </since_tizen>
128 protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
130 Log.Fatal("NUI", "OnRegionFormatChanged() is called!");
131 base.OnRegionFormatChanged(e);
135 /// Overrides this method if want to handle OnTerminate behavior.
137 /// <since_tizen> 4 </since_tizen>
138 protected override void OnTerminate()
140 Log.Fatal("NUI", "OnTerminate() is called!");
145 /// Overrides this method if want to handle OnPreCreate behavior.
147 /// <since_tizen> 4 </since_tizen>
148 protected virtual void OnPreCreate()
150 Log.Fatal("NUI", "OnPreCreate() is called!");
154 /// Overrides this method if want to handle OnCreate behavior.
156 /// <since_tizen> 4 </since_tizen>
157 protected override void OnCreate()
159 // This is also required to create DisposeQueue on main thread.
160 DisposeQueue disposeQ = DisposeQueue.Instance;
161 disposeQ.Initialize();
162 Log.Fatal("NUI","OnCreate() is called!");