/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
using System;
using Dali;
//------------------------------------------------------------------------------
// This file can only run on Tizen target. You should compile it with hello-test.cs, and
// add tizen c# application related library as reference.
//------------------------------------------------------------------------------
namespace Tizen.Applications
{
///
/// Represents an application that have UI screen. The DaliApplication class has a default stage.
///
public class DaliApplication : CoreUIApplication
{
///
/// The instance of the Dali Application.
///
///
/// This application is created before OnCreate() or created event. And the DaliApplication will be terminated when this application is closed.
///
protected Dali.Application application;
///
/// The instance of the Dali Application extension.
///
protected Dali.ApplicationExtensions applicationExt;
///
/// Store the stylesheet value.
///
protected string m_stylesheet;
///
/// Store the window mode value.
///
protected Dali.Application.WINDOW_MODE m_windowMode;
///
/// Store the app mode value.
///
protected APP_MODE appMode;
///
/// The instance of the Dali Stage.
///
public Stage stage { get; private set; }
///
/// The default constructor.
///
public DaliApplication():base()
{
appMode = APP_MODE.DEFAULT;
}
///
/// The constructor with stylesheet.
///
public DaliApplication(string stylesheet):base()
{
//handle the stylesheet
appMode = APP_MODE.STYLESHEETONLY;
m_stylesheet = stylesheet;
}
///
/// The constructor with stylesheet and window mode.
///
public DaliApplication(string stylesheet, Dali.Application.WINDOW_MODE windowMode)
: base()
{
//handle the stylesheet and windowMode
appMode = APP_MODE.STYLESHEETWITHWINDOWMODE;
m_stylesheet = stylesheet;
m_windowMode = windowMode;
}
///
/// Overrides this method if want to handle behavior before calling OnCreate().
/// stage property is initialized in this overrided method.
///
protected override void OnPreCreate()
{
switch(appMode)
{
case APP_MODE.DEFAULT:
application = Dali.Application.NewApplication();
break;
case APP_MODE.STYLESHEETONLY:
application = Dali.Application.NewApplication(m_stylesheet);
break;
case APP_MODE.STYLESHEETWITHWINDOWMODE:
application = Dali.Application.NewApplication(m_stylesheet, m_windowMode);
break;
default:
break;
}
applicationExt = new Dali.ApplicationExtensions(application);
applicationExt.Init();
stage = Stage.GetCurrent();
stage.SetBackgroundColor( NDalic.WHITE );
}
///
/// Overrides this method if want to handle behavior.
///
protected override void OnTerminate()
{
base.OnTerminate();
applicationExt.Terminate();
}
///
/// Overrides this method if want to handle behavior.
///
protected override void OnPause()
{
base.OnPause();
applicationExt.Pause();
}
///
/// Overrides this method if want to handle behavior.
///
protected override void OnResume()
{
base.OnResume();
applicationExt.Resume();
}
///
/// Overrides this method if want to handle behavior.
///
protected override void OnLocaleChanged(LocaleChangedEventArgs e)
{
base.OnLocaleChanged(e);
applicationExt.LanguageChange();
}
///
/// The mode of creating Dali application.
///
protected enum APP_MODE
{
DEFAULT = 0,
STYLESHEETONLY = 1,
STYLESHEETWITHWINDOWMODE = 2
}
}
}