X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2FTizen.NUI%2Fsrc%2Finternal%2FNUIWidgetCoreBackend.cs;h=7798fd6226f5f93775760758f5f62029a99b08b0;hb=46b8a31f5c1c75a22b648ca394a4de8a50898513;hp=0f8ff84d7cbc758ee0cc6f842c32520d863f5211;hpb=35b5d151f00612ef6f3e09b6b0b0bbcc4d2854a7;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git diff --git a/src/Tizen.NUI/src/internal/NUIWidgetCoreBackend.cs b/src/Tizen.NUI/src/internal/NUIWidgetCoreBackend.cs index 0f8ff84..7798fd6 100755 --- a/src/Tizen.NUI/src/internal/NUIWidgetCoreBackend.cs +++ b/src/Tizen.NUI/src/internal/NUIWidgetCoreBackend.cs @@ -17,7 +17,6 @@ using System; using System.Collections.Generic; - using Tizen.Applications.CoreBackend; using Tizen.Applications; @@ -30,6 +29,7 @@ namespace Tizen.NUI /// protected WidgetApplication _application; private string _stylesheet = ""; + Dictionary _widgetInfo; /// /// Dictionary to contain each type of event callback. @@ -41,8 +41,6 @@ namespace Tizen.NUI /// public NUIWidgetCoreBackend() { - //Tizen.Log.Fatal("NUI", "### NUIWidgetCoreBackend called"); - //_application = WidgetApplication.NewWidgetApplication(); } /// @@ -51,7 +49,6 @@ namespace Tizen.NUI public NUIWidgetCoreBackend(string stylesheet) { _stylesheet = stylesheet; - //_application = WidgetApplication.NewWidgetApplication(stylesheet); } /// @@ -83,7 +80,6 @@ namespace Tizen.NUI /// public void Dispose() { - Tizen.Log.Fatal("NUI", "### NUIWidgetCoreBackend Dispose called"); if (_application != null) { _application.Dispose(); @@ -95,106 +91,142 @@ namespace Tizen.NUI /// public void Exit() { - Tizen.Log.Fatal("NUI", "### NUIWidgetCoreBackend Exit called"); if (_application != null) { _application.Quit(); } } + public void RegisterWidgetInfo(Dictionary widgetInfo) + { + _widgetInfo = widgetInfo; + } + /// /// Run Application. /// /// Arguments from commandline. public void Run(string[] args) { + TizenSynchronizationContext.Initialize(); + args[0] = Tizen.Applications.Application.Current.ApplicationInfo.ExecutablePath; _application = WidgetApplication.NewWidgetApplication(args, _stylesheet); + _application.RegisterWidgetInfo(_widgetInfo); - TizenSynchronizationContext.Initialize(); _application.BatteryLow += OnBatteryLow; _application.LanguageChanged += OnLanguageChanged; _application.MemoryLow += OnMemoryLow; _application.RegionChanged += OnRegionChanged; ; - - _application.Init += OnInit; - _application.Terminate += OnTerminate; + _application.Initialized += OnInitialized; + _application.Terminating += OnTerminated; _application.MainLoop(); } - private void OnInit(object sender, WidgetApplication.WidgetApplicationEventArgs e) + /// + /// The Initialized event callback function. + /// + /// The application instance. + /// The event argument for Initialized. + private void OnInitialized(object source, NUIApplicationInitEventArgs e) { - Log.Fatal("NUI", "NUIWidgetApplication OnPreCreated Called"); var preCreateHandler = Handlers[EventType.PreCreated] as Action; preCreateHandler?.Invoke(); - Log.Fatal("NUI", "NUIWidgetApplication OnCreate Called"); var createHandler = Handlers[EventType.Created] as Action; createHandler?.Invoke(); - + _application.RegisterWidgetCreatingFunction(); } - private void OnTerminate(object sender, WidgetApplication.WidgetApplicationEventArgs e) + /// + /// The Terminated event callback function. + /// + /// The application instance. + /// The event argument for Terminated. + private void OnTerminated(object source, NUIApplicationTerminatingEventArgs e) { - Log.Fatal("NUI", "NUIWidgetApplication OnTerminated Called"); var handler = Handlers[EventType.Terminated] as Action; handler?.Invoke(); } /// - /// Region changed event callback function. + /// The Region changed event callback function. /// - /// Application instance - /// Event argument for RegionChanged - private void OnRegionChanged(object sender, WidgetApplication.WidgetApplicationEventArgs e) + /// The application instance. + /// The event argument for RegionChanged. + private void OnRegionChanged(object source, NUIApplicationRegionChangedEventArgs e) { - Log.Fatal("NUI", "NUIWidgetApplication OnRegionChanged Called"); var handler = Handlers[EventType.RegionFormatChanged] as Action; - // Need to make new signal return in native to return right value. - handler?.Invoke(new RegionFormatChangedEventArgs("")); + handler?.Invoke(new RegionFormatChangedEventArgs(e.Application.GetRegion())); } /// - /// Memory Low event callback function. + /// The Language changed event callback function. /// - /// Application instance - /// Event argument for MemoryLow - private void OnMemoryLow(object sender, WidgetApplication.WidgetApplicationEventArgs e) + /// The application instance. + /// The event argument for LanguageChanged. + private void OnLanguageChanged(object source, NUIApplicationLanguageChangedEventArgs e) { - Log.Fatal("NUI", "NUIWidgetApplication OnMemoryLow Called"); - var handler = Handlers[EventType.LowMemory] as Action; - // Need to make new signal return in native to return right value. - handler?.Invoke(new LowMemoryEventArgs(LowMemoryStatus.None)); + var handler = Handlers[EventType.LocaleChanged] as Action; + handler?.Invoke(new LocaleChangedEventArgs(e.Application.GetLanguage())); } /// - /// Language changed event callback function. + /// The Memory Low event callback function. /// - /// Application instance - /// Event argument for LanguageChanged - private void OnLanguageChanged(object sender, WidgetApplication.WidgetApplicationEventArgs e) + /// The application instance. + /// The event argument for MemoryLow. + private void OnMemoryLow(object source, NUIApplicationMemoryLowEventArgs e) { + var handler = Handlers[EventType.LowMemory] as Action; - Log.Fatal("NUI", "NUIWidgetApplication OnLanguageChanged Called"); - var handler = Handlers[EventType.LocaleChanged] as Action; - // Need to make new signal return in native to return right value. - handler?.Invoke(new LocaleChangedEventArgs("")); - + switch (e.MemoryStatus) + { + case Application.MemoryStatus.Normal: + { + handler?.Invoke(new LowMemoryEventArgs(LowMemoryStatus.None)); + break; + } + case Application.MemoryStatus.Low: + { + handler?.Invoke(new LowMemoryEventArgs(LowMemoryStatus.SoftWarning)); + break; + } + case Application.MemoryStatus.CriticallyLow: + { + handler?.Invoke(new LowMemoryEventArgs(LowMemoryStatus.HardWarning)); + break; + } + } } /// - /// Battery low event callback function. + /// The Battery Low event callback function. /// - /// Application instance - /// Event argument for BatteryLow - private void OnBatteryLow(object sender, WidgetApplication.WidgetApplicationEventArgs e) + /// The application instance. + /// The event argument for BatteryLow. + private void OnBatteryLow(object source, NUIApplicationBatteryLowEventArgs e) { - Log.Fatal("NUI", "NUIWidgetApplication OnBatteryLow Called"); var handler = Handlers[EventType.LowBattery] as Action; - // Need to make new signal return in native to return right value. - handler?.Invoke(new LowBatteryEventArgs(LowBatteryStatus.None)); - + switch (e.BatteryStatus) + { + case Application.BatteryStatus.Normal: + { + handler?.Invoke(new LowBatteryEventArgs(LowBatteryStatus.None)); + break; + } + case Application.BatteryStatus.CriticallyLow: + { + handler?.Invoke(new LowBatteryEventArgs(LowBatteryStatus.CriticalLow)); + break; + } + case Application.BatteryStatus.PowerOff: + { + handler?.Invoke(new LowBatteryEventArgs(LowBatteryStatus.PowerOff)); + break; + } + } } internal WidgetApplication WidgetApplicationHandle