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.
21 //------------------------------------------------------------------------------
22 // This file can only run on Tizen target. You should compile it with hello-test.cs, and
23 // add tizen c# application related library as reference.
24 //------------------------------------------------------------------------------
25 namespace Tizen.Applications
28 /// Represents an application that have UI screen. The NUIApplication class has a default stage.
30 public class NUIApplication : CoreUIApplication
33 /// The instance of the Dali Application.
36 /// This application is created before OnCreate() or created event. And the NUIApplication will be terminated when this application is closed.
38 protected Tizen.NUI.Application application;
41 /// The instance of the Dali Application extension.
43 internal Tizen.NUI.ApplicationExtensions applicationExt;
46 /// Store the stylesheet value.
48 protected string m_stylesheet;
51 /// Store the window mode value.
53 protected Tizen.NUI.Application.WINDOW_MODE m_windowMode;
56 /// Store the app mode value.
58 protected AppMode appMode;
61 /// The instance of the Dali Stage.
63 public Stage stage { get; private set; }
66 /// The default constructor.
68 public NUIApplication():base()
70 appMode = AppMode.Default;
74 /// The constructor with stylesheet.
76 public NUIApplication(string stylesheet):base()
78 //handle the stylesheet
79 appMode = AppMode.StyleSheetOnly;
80 m_stylesheet = stylesheet;
84 /// The constructor with stylesheet and window mode.
86 public NUIApplication(string stylesheet, Tizen.NUI.Application.WINDOW_MODE windowMode)
89 //handle the stylesheet and windowMode
90 appMode = AppMode.StyleSheetWithWindowMode;
91 m_stylesheet = stylesheet;
92 m_windowMode = windowMode;
96 /// Overrides this method if want to handle behavior before calling OnCreate().
97 /// stage property is initialized in this overrided method.
99 protected override void OnPreCreate()
103 case AppMode.Default:
104 application = Tizen.NUI.Application.NewApplication();
106 case AppMode.StyleSheetOnly:
107 application = Tizen.NUI.Application.NewApplication(m_stylesheet);
109 case AppMode.StyleSheetWithWindowMode:
110 application = Tizen.NUI.Application.NewApplication(m_stylesheet, m_windowMode);
116 applicationExt = new Tizen.NUI.ApplicationExtensions(application);
117 applicationExt.Init();
119 stage = Stage.GetCurrent();
120 stage.SetBackgroundColor( Color.White );
124 /// Overrides this method if want to handle behavior.
126 protected override void OnTerminate()
129 applicationExt.Terminate();
133 /// Overrides this method if want to handle behavior.
135 protected override void OnPause()
138 applicationExt.Pause();
142 /// Overrides this method if want to handle behavior.
144 protected override void OnResume()
147 applicationExt.Resume();
151 /// Overrides this method if want to handle behavior.
153 protected override void OnLocaleChanged(LocaleChangedEventArgs e)
155 base.OnLocaleChanged(e);
156 applicationExt.LanguageChange();
160 /// The mode of creating Dali application.
162 protected enum AppMode
166 StyleSheetWithWindowMode = 2