/* * 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 Tizen.Applications; using Tizen.Applications.CoreBackend; using System.Collections.Generic; using System.ComponentModel; namespace Tizen.NUI { /// /// Represents an application that have UI screen. The NUIWidgetApplication class has a default stage. /// /// 4 public class NUIWidgetApplication : CoreApplication { /// /// The default constructor. /// /// Widget ID will be replaced as the application ID. /// Derived widget class type. public NUIWidgetApplication( System.Type widgetType ) : base(new NUIWidgetCoreBackend()) { NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend; core?.RegisterWidgetInfo(new Dictionary { { widgetType, ApplicationInfo.ApplicationId } }); } /// /// The constructor for multi widget class and instance. /// /// List of derived widget class type. public NUIWidgetApplication(Dictionary widgetTypes) : base(new NUIWidgetCoreBackend()) { NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend; core?.RegisterWidgetInfo(widgetTypes); } /// /// The default constructor with stylesheet. /// /// Widget ID will be replaced as the application ID. /// Derived widget class type. /// The styleSheet url. /// 4 public NUIWidgetApplication(System.Type widgetType, string styleSheet) : base(new NUIWidgetCoreBackend(styleSheet)) { NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend; core?.RegisterWidgetInfo(new Dictionary { { widgetType, ApplicationInfo.ApplicationId } }); } /// /// Add WidgetInfo in runtime /// /// Derived widget class type. [EditorBrowsable(EditorBrowsableState.Never)] public void AddWidgetType( System.Type widgetType ) { NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend; core?.AddWidgetInfo(new Dictionary { { widgetType, ApplicationInfo.ApplicationId } }); } /// /// Add WidgetInfo in runtime /// /// Derived widget class type. [EditorBrowsable(EditorBrowsableState.Never)] public void AddWidgetType( Dictionary widgetTypes ) { NUIWidgetCoreBackend core = Backend as NUIWidgetCoreBackend; core?.AddWidgetInfo(widgetTypes); } internal WidgetApplication ApplicationHandle { get { return ((NUIWidgetCoreBackend)this.Backend).WidgetApplicationHandle; } } /// /// Run NUIWidgetApplication. /// /// Arguments from commandline. /// 4 public override void Run(string[] args) { Backend.AddEventHandler(EventType.PreCreated, OnPreCreate); base.Run(args); } /// /// Exit NUIWidgetApplication. /// /// 4 public override void Exit() { Tizen.Log.Fatal("NUI", "### NUIWidgetApplication Exit called"); base.Exit(); } /// /// Overrides this method if want to handle OnLocaleChanged behavior. /// /// 4 protected override void OnLocaleChanged(LocaleChangedEventArgs e) { Log.Fatal("NUI", "OnLocaleChanged() is called!"); base.OnLocaleChanged(e); } /// /// Overrides this method if want to handle OnLowBattery behavior. /// /// 4 protected override void OnLowBattery(LowBatteryEventArgs e) { Log.Fatal("NUI", "OnLowBattery() is called!"); base.OnLowBattery(e); } /// /// Overrides this method if want to handle OnLowMemory behavior. /// /// 4 protected override void OnLowMemory(LowMemoryEventArgs e) { Log.Fatal("NUI", "OnLowMemory() is called!"); base.OnLowMemory(e); } /// /// Overrides this method if want to handle OnRegionFormatChanged behavior. /// /// 4 protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e) { Log.Fatal("NUI", "OnRegionFormatChanged() is called!"); base.OnRegionFormatChanged(e); } /// /// Overrides this method if want to handle OnTerminate behavior. /// /// 4 protected override void OnTerminate() { Log.Fatal("NUI", "OnTerminate() is called!"); base.OnTerminate(); } /// /// Overrides this method if want to handle OnPreCreate behavior. /// /// 4 protected virtual void OnPreCreate() { Log.Fatal("NUI", "OnPreCreate() is called!"); } /// /// Overrides this method if want to handle OnCreate behavior. /// /// 4 protected override void OnCreate() { // This is also required to create DisposeQueue on main thread. DisposeQueue disposeQ = DisposeQueue.Instance; disposeQ.Initialize(); Log.Fatal("NUI","OnCreate() is called!"); base.OnCreate(); } } }