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;
26 /// Represents an application that have UI screen. The NUIWidgetApplication class has a default stage.
28 /// <since_tizen> 4 </since_tizen>
29 public class NUIWidgetApplication : CoreApplication
32 /// The default constructor.
34 /// <remarks>Widget ID will be replaced as the application ID.</remarks>
35 /// <param name="widgetType">Derived widget class type.</param>
36 public NUIWidgetApplication( System.Type widgetType ) : base(new NUIWidgetCoreBackend())
38 NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend;
39 core?.RegisterWidgetInfo(new Dictionary<System.Type, string> { { widgetType, ApplicationInfo.ApplicationId } });
43 /// The constructor for multi widget class and instance.
45 /// <param name="widgetTypes">List of derived widget class type.</param>
46 public NUIWidgetApplication(Dictionary<System.Type, string> widgetTypes) : base(new NUIWidgetCoreBackend())
48 if( widgetTypes == null )
50 throw new InvalidOperationException("Dictionary is null");
54 NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend;
55 core?.RegisterWidgetInfo(widgetTypes);
60 /// The default constructor with stylesheet.
62 /// <remarks>Widget ID will be replaced as the application ID.</remarks>
63 /// <param name="widgetType">Derived widget class type.</param>
64 /// <param name="styleSheet">The styleSheet url.</param>
65 /// <since_tizen> 4 </since_tizen>
66 public NUIWidgetApplication(System.Type widgetType, string styleSheet) : base(new NUIWidgetCoreBackend(styleSheet))
68 NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend;
69 core?.RegisterWidgetInfo(new Dictionary<System.Type, string> { { widgetType, ApplicationInfo.ApplicationId } });
73 /// Add WidgetInfo in runtime
75 /// <param name="widgetType">Derived widget class type.</param>
76 [EditorBrowsable(EditorBrowsableState.Never)]
77 public void AddWidgetType( System.Type widgetType )
79 NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend;
80 core?.AddWidgetInfo(new Dictionary<System.Type, string> { { widgetType, ApplicationInfo.ApplicationId } });
84 /// Add WidgetInfo in runtime
86 /// <param name="widgetTypes">Derived widget class type.</param>
87 [EditorBrowsable(EditorBrowsableState.Never)]
88 public void AddWidgetType( Dictionary<System.Type, string> widgetTypes )
90 NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend;
91 core?.AddWidgetInfo(widgetTypes);
94 internal WidgetApplication ApplicationHandle
98 return ((NUIWidgetCoreBackend)this.Backend).WidgetApplicationHandle;
103 /// Run NUIWidgetApplication.
105 /// <param name="args">Arguments from commandline.</param>
106 /// <since_tizen> 4 </since_tizen>
107 public override void Run(string[] args)
109 Backend.AddEventHandler(EventType.PreCreated, OnPreCreate);
114 /// Exit NUIWidgetApplication.
116 /// <since_tizen> 4 </since_tizen>
117 public override void Exit()
119 Tizen.Log.Fatal("NUI", "### NUIWidgetApplication Exit called");
124 /// Overrides this method if want to handle OnLocaleChanged behavior.
126 /// <since_tizen> 4 </since_tizen>
127 protected override void OnLocaleChanged(LocaleChangedEventArgs e)
129 Log.Fatal("NUI", "OnLocaleChanged() is called!");
130 base.OnLocaleChanged(e);
134 /// Overrides this method if want to handle OnLowBattery behavior.
136 /// <since_tizen> 4 </since_tizen>
137 protected override void OnLowBattery(LowBatteryEventArgs e)
139 Log.Fatal("NUI", "OnLowBattery() is called!");
140 base.OnLowBattery(e);
144 /// Overrides this method if want to handle OnLowMemory behavior.
146 /// <since_tizen> 4 </since_tizen>
147 protected override void OnLowMemory(LowMemoryEventArgs e)
149 Log.Fatal("NUI", "OnLowMemory() is called!");
154 /// Overrides this method if want to handle OnRegionFormatChanged behavior.
156 /// <since_tizen> 4 </since_tizen>
157 protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
159 Log.Fatal("NUI", "OnRegionFormatChanged() is called!");
160 base.OnRegionFormatChanged(e);
164 /// Overrides this method if want to handle OnTerminate behavior.
166 /// <since_tizen> 4 </since_tizen>
167 protected override void OnTerminate()
169 Log.Fatal("NUI", "OnTerminate() is called!");
174 /// Overrides this method if want to handle OnPreCreate behavior.
176 /// <since_tizen> 4 </since_tizen>
177 protected virtual void OnPreCreate()
179 Log.Fatal("NUI", "OnPreCreate() is called!");
183 /// Overrides this method if want to handle OnCreate behavior.
185 /// <since_tizen> 4 </since_tizen>
186 protected override void OnCreate()
188 // This is also required to create DisposeQueue on main thread.
189 DisposeQueue disposeQ = DisposeQueue.Instance;
190 disposeQ.Initialize();
191 Log.Fatal("NUI","OnCreate() is called!");