Revert "[Tizen] Add obsolete attribute for Window property of NUIApplication, backwar...
[platform/core/csapi/nui.git] / Tizen.NUI / src / public / NUIApplication.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 using System;
19 using Tizen.Applications;
20 using Tizen.Applications.CoreBackend;
21 using Tizen.NUI;
22
23 namespace Tizen.NUI
24 {
25
26     /// <summary>
27     /// Represents an application that have UI screen. The NUIApplication class has a default stage.
28     /// </summary>
29     public class NUIApplication : CoreApplication
30     {
31         /// <summary>
32         /// The instance of ResourceManager.
33         /// </summary>
34         private static System.Resources.ResourceManager resourceManager = null;
35         /// <summary>
36         /// The default constructor.
37         /// </summary>
38         public NUIApplication() : base(new NUICoreBackend())
39         {
40         }
41
42         /// <summary>
43         /// The constructor with stylesheet.
44         /// </summary>
45         public NUIApplication(string stylesheet) : base(new NUICoreBackend(stylesheet))
46         {
47         }
48
49         /// <summary>
50         /// The constructor with stylesheet and window mode.
51         /// </summary>
52         public NUIApplication(string stylesheet, WindowMode windowMode) : base(new NUICoreBackend(stylesheet,windowMode))
53         {
54         }
55
56         /// <summary>
57         /// Overrides this method if want to handle behavior.
58         /// </summary>
59         protected override void OnLocaleChanged(LocaleChangedEventArgs e)
60         {
61         }
62
63         /// <summary>
64         /// Overrides this method if want to handle behavior.
65         /// </summary>
66         protected override void OnLowBattery(LowBatteryEventArgs e)
67         {
68             Log.Debug("NUI", "OnLowBattery() is called!");
69         }
70
71         /// <summary>
72         /// Overrides this method if want to handle behavior.
73         /// </summary>
74         protected override void OnLowMemory(LowMemoryEventArgs e)
75         {
76             Log.Debug("NUI", "OnLowMemory() is called!");
77         }
78
79         /// <summary>
80         /// Overrides this method if want to handle behavior.
81         /// </summary>
82         protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
83         {
84             Log.Debug("NUI", "OnRegionFormatChanged() is called!");
85         }
86
87         /// <summary>
88         /// Overrides this method if want to handle behavior.
89         /// </summary>
90         protected override void OnTerminate()
91         {
92             Log.Debug("NUI", "OnTerminate() is called!");
93         }
94
95         /// <summary>
96         /// Overrides this method if want to handle behavior.
97         /// </summary>
98         protected virtual void OnPause()
99         {
100         }
101
102         /// <summary>
103         /// Overrides this method if want to handle behavior.
104         /// </summary>
105         protected virtual void OnResume()
106         {
107         }
108
109         /// <summary>
110         /// Overrides this method if want to handle behavior.
111         /// </summary>
112         protected virtual void OnPreCreate()
113         {
114         }
115
116         /// <summary>
117         /// Overrides this method if want to handle behavior.
118         /// </summary>
119         protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
120         {
121             Log.Debug("NUI", "OnAppControlReceived() is called!");
122             if (e != null)
123             {
124                 Log.Debug("NUI", "OnAppControlReceived() is called! ApplicationId=" + e.ReceivedAppControl.ApplicationId);
125                 Log.Debug("NUI", "CallerApplicationId=" + e.ReceivedAppControl.CallerApplicationId + "   IsReplyRequest=" + e.ReceivedAppControl.IsReplyRequest);
126             }
127         }
128
129         /// <summary>
130         /// Overrides this method if want to handle behavior.
131         /// </summary>
132         protected override void OnCreate()
133         {
134             // This is also required to create DisposeQueue on main thread.
135             DisposeQueue disposeQ = DisposeQueue.Instance;
136             disposeQ.Initialize();
137             Log.Debug("NUI","OnCreate() is called!");
138         }
139
140         /// <summary>
141         /// Run NUIApplication.
142         /// </summary>
143         /// <param name="args">Arguments from commandline.</param>
144         public override void Run(string[] args)
145         {
146             string[] argsClone = null;
147
148             if (args == null)
149             {
150                 argsClone = new string[1];
151             }
152             else
153             {
154                 argsClone = new string[args.Length + 1];
155                 args.CopyTo(argsClone, 1);
156             }
157             argsClone[0] = string.Empty;
158
159             Backend.AddEventHandler(EventType.PreCreated, OnPreCreate);
160             Backend.AddEventHandler(EventType.Created, OnCreate);
161             Backend.AddEventHandler<AppControlReceivedEventArgs>(EventType.AppControlReceived, OnAppControlReceived);
162             Backend.AddEventHandler(EventType.Resumed, OnResume);
163             Backend.AddEventHandler(EventType.Paused, OnPause);
164             Backend.AddEventHandler(EventType.Terminated, OnTerminate);
165             Backend.AddEventHandler<RegionFormatChangedEventArgs>(EventType.RegionFormatChanged, OnRegionFormatChanged);
166             Backend.AddEventHandler<LowMemoryEventArgs>(EventType.LowMemory, OnLowMemory);
167             Backend.AddEventHandler<LowBatteryEventArgs>(EventType.LowBattery, OnLowBattery);
168             Backend.AddEventHandler<LocaleChangedEventArgs>(EventType.LocaleChanged, OnLocaleChanged);
169
170             Backend.Run(argsClone);
171         }
172
173         /// <summary>
174         /// Exit NUIApplication.
175         /// </summary>
176         public override void Exit()
177         {
178             Backend.Exit();
179         }
180
181         /// <summary>
182         /// Enumeration for deciding whether a NUI application window is opaque or transparent.
183         /// </summary>
184         public enum WindowMode
185         {
186             Opaque = 0,
187             Transparent = 1
188         }
189
190
191         internal Application ApplicationHandle
192         {
193             get
194             {
195                 return ((NUICoreBackend)this.Backend).ApplicationHandle;
196             }
197         }
198
199         /// <summary>
200         /// ResourceManager to handle multilingual
201         /// </summary>
202         public static System.Resources.ResourceManager MultilingualResourceManager
203         {
204             get
205             {
206                 return resourceManager;
207             }
208             set
209             {
210                 resourceManager = value;
211             }
212         }
213     }
214 }