From cdf3e138042309d841501edd7092717f98e21f45 Mon Sep 17 00:00:00 2001 From: WonYoung Choi Date: Wed, 16 Mar 2016 13:48:04 +0900 Subject: [PATCH] Refactor Lifecycles - Rename Actor to UIController - Rename Service to ServiceController Change-Id: I19f5365dd8fa80626c4c376324d3936dfaecdc5d --- Tizen.Applications/Interop/Interop.AppControl.cs | 2 +- Tizen.Applications/Tizen.Applications.csproj | 8 +- Tizen.Applications/Tizen.Applications/Actor.cs | 127 ------- .../Tizen.Applications/AppControlFilter.cs | 2 +- .../Tizen.Applications/Application.cs | 398 +++++++++------------ Tizen.Applications/Tizen.Applications/Context.cs | 91 ++--- .../Tizen.Applications/Controller.cs | 117 ++++++ Tizen.Applications/Tizen.Applications/Service.cs | 59 --- .../Tizen.Applications/ServiceController.cs | 20 ++ .../Tizen.Applications/UIController.cs | 101 ++++++ Tizen.Applications/Tizen.UI/IUIContext.cs | 26 ++ Tizen.Applications/Tizen.UI/Window.cs | 2 +- Tizen.UI/Properties/AssemblyInfo.cs | 36 ++ Tizen.UI/Tizen.UI.csproj | 55 +++ Tizen.UI/Tizen.UI/Window.cs | 12 + 15 files changed, 562 insertions(+), 494 deletions(-) delete mode 100755 Tizen.Applications/Tizen.Applications/Actor.cs create mode 100755 Tizen.Applications/Tizen.Applications/Controller.cs delete mode 100755 Tizen.Applications/Tizen.Applications/Service.cs create mode 100755 Tizen.Applications/Tizen.Applications/ServiceController.cs create mode 100755 Tizen.Applications/Tizen.Applications/UIController.cs create mode 100755 Tizen.Applications/Tizen.UI/IUIContext.cs create mode 100755 Tizen.UI/Properties/AssemblyInfo.cs create mode 100755 Tizen.UI/Tizen.UI.csproj create mode 100755 Tizen.UI/Tizen.UI/Window.cs diff --git a/Tizen.Applications/Interop/Interop.AppControl.cs b/Tizen.Applications/Interop/Interop.AppControl.cs index 69f10d0..84ff6c9 100755 --- a/Tizen.Applications/Interop/Interop.AppControl.cs +++ b/Tizen.Applications/Interop/Interop.AppControl.cs @@ -14,7 +14,7 @@ internal static partial class Interop { internal static partial class AppControl { - [DllImport(Libraries.Application, EntryPoint = "app_control_create", CallingConvention = CallingConvention.Cdecl)] + [DllImport(Libraries.Application, EntryPoint = "app_control_create")] internal static extern int Create(out SafeAppControlHandle handle); [DllImport(Libraries.Application, EntryPoint = "app_control_get_app_id", CallingConvention = CallingConvention.Cdecl)] diff --git a/Tizen.Applications/Tizen.Applications.csproj b/Tizen.Applications/Tizen.Applications.csproj index 489d94d..8e471b3 100755 --- a/Tizen.Applications/Tizen.Applications.csproj +++ b/Tizen.Applications/Tizen.Applications.csproj @@ -56,13 +56,15 @@ - + + - - + + + diff --git a/Tizen.Applications/Tizen.Applications/Actor.cs b/Tizen.Applications/Tizen.Applications/Actor.cs deleted file mode 100755 index fe4b8a1..0000000 --- a/Tizen.Applications/Tizen.Applications/Actor.cs +++ /dev/null @@ -1,127 +0,0 @@ -/// Copyright 2016 by Samsung Electronics, Inc., -/// -/// This software is the confidential and proprietary information -/// of Samsung Electronics, Inc. ("Confidential Information"). You -/// shall not disclose such Confidential Information and shall use -/// it only in accordance with the terms of the license agreement -/// you entered into with Samsung. - - -using System; -using Tizen.UI; - -namespace Tizen.Applications -{ - /// - /// - /// - public abstract class Actor : Context - { - private ActorState _state = ActorState.None; - - /// - /// - /// - public event EventHandler Created; - - /// - /// - /// - public event EventHandler Started; - - /// - /// - /// - public event EventHandler Resumed; - - /// - /// - /// - public event EventHandler Paused; - - /// - /// - /// - public event EventHandler Destroyed; - - private enum ActorState - { - None = 0, - Created = 1, - Started = 2, - Resumed = 3, - Pasued = 4 - } - - internal Guid TaskId { get; set; } - - /// - /// - /// - internal protected Page MainPage { get; set; } - - internal void OnCreate(Guid taskId, AppControl control) - { - if (_state != ActorState.Created) - { - TaskId = taskId; - _control = control; - _state = ActorState.Created; - if (Created != null) - { - Created(this, EventArgs.Empty); - } - } - } - - internal void OnStart() - { - if (_state != ActorState.Started) - { - _state = ActorState.Started; - if (Started != null) - { - Started(this, EventArgs.Empty); - } - } - } - - internal void OnPause() - { - if (_state != ActorState.Pasued) - { - _state = ActorState.Pasued; - if (Paused != null) - { - Paused(this, EventArgs.Empty); - } - } - } - - internal void OnResume() - { - if (_state != ActorState.Resumed) - { - _state = ActorState.Resumed; - if (Resumed != null) - { - Resumed(this, EventArgs.Empty); - } - MainPage.Show(); - } - } - - internal void OnDestroy() - { - if (_state != ActorState.None) - { - _state = ActorState.None; - if (Destroyed != null) - { - Destroyed(this, EventArgs.Empty); - } - } - } - } -} - diff --git a/Tizen.Applications/Tizen.Applications/AppControlFilter.cs b/Tizen.Applications/Tizen.Applications/AppControlFilter.cs index 3b2ded9..01e5c6a 100755 --- a/Tizen.Applications/Tizen.Applications/AppControlFilter.cs +++ b/Tizen.Applications/Tizen.Applications/AppControlFilter.cs @@ -59,7 +59,7 @@ namespace Tizen.Applications { AppControlFilter f = obj as AppControlFilter; if (f == null) return false; - + return (_operation == f._operation) & (_mime == f._mime) & (_uri == f._uri); } diff --git a/Tizen.Applications/Tizen.Applications/Application.cs b/Tizen.Applications/Tizen.Applications/Application.cs index 0f1559e..a926fb3 100755 --- a/Tizen.Applications/Tizen.Applications/Application.cs +++ b/Tizen.Applications/Tizen.Applications/Application.cs @@ -22,9 +22,9 @@ namespace Tizen.Applications public static class Application { private static readonly Dictionary s_filterMap = new Dictionary(); - private static readonly List s_serviceList = new List(); - private static readonly ActorStack s_actorStack = new ActorStack(); - private static Window s_window = null; + private static readonly List s_serviceControllerList = new List(); + private static readonly UIControllerStack s_uiControllerStack = new UIControllerStack(); + private static Window s_defaultWindow = null; /// /// Occurs when the application starts. @@ -36,11 +36,11 @@ namespace Tizen.Applications /// public static event EventHandler Exited = delegate { }; - private static Actor ForegroundActor + private static UIController Foreground { get { - return s_actorStack.Peek(); + return s_uiControllerStack.Peek(); } } @@ -58,37 +58,22 @@ namespace Tizen.Applications }; ops.OnPause = (userData) => { - if (ForegroundActor != null) + if (Foreground != null) { - ForegroundActor.OnPause(); + Foreground.SendPause(); } }; ops.OnResume = (userData) => { - if (ForegroundActor != null) + if (Foreground != null) { - ForegroundActor.OnResume(); + Foreground.SendResume(); } }; ops.OnAppControl = (appControlHandle, userData) => { AppControl control = new AppControl(appControlHandle); - if (control.IsService) - { - Type found = FindServiceInFilters(control); - if (found != null) - { - StartService(found, control); - } - } - else - { - Type found = FindActorInFilters(control); - if (found != null) - { - StartActor(null, found, Context.ActorFlags.NewInstance, control); - } - } + StartController(null, null, control, Controller.ControlFlags.NewInstance); }; ops.OnTerminate = (userData) => { @@ -112,332 +97,279 @@ namespace Tizen.Applications } /// - /// Registers an Actor class type. - /// - /// The type of Actor class. - public static void RegisterActor(Type actorType) - { - RegisterActor(actorType, new AppControlFilter[0] { }); - } - - /// - /// Registers an Actor class type. - /// - /// The type of Actor class. - /// The filter to match Actor and AppControl. - public static void RegisterActor(Type actorType, AppControlFilter filter) - { - RegisterActor(actorType, new AppControlFilter[] { filter }); - } - - /// - /// Registers an Actor class type. + /// /// - /// The type of Actor class. - /// The array of filters to match Actor and AppControl. - public static void RegisterActor(Type actorType, AppControlFilter[] filters) + /// + public static void RegisterController(Type controllerType) { - if (!actorType.IsSubclassOf(typeof(Actor))) - throw new ArgumentException(actorType.FullName + " is not a subclass of Actor."); - - RegisterContext(actorType, filters); + RegisterController(controllerType, new AppControlFilter[0] { }); } /// - /// Registers an Service class type. + /// /// - /// The type of Service class. - public static void RegisterService(Type serviceType) + /// + /// + public static void RegisterController(Type controllerType, AppControlFilter filter) { - RegisterService(serviceType, new AppControlFilter[0] { }); + RegisterController(controllerType, new AppControlFilter[] { filter }); } /// - /// Registers an Service class type. + /// /// - /// The type of Service class. - /// The filter to match Service and AppControl. - public static void RegisterService(Type serviceType, AppControlFilter filter) + /// + /// + public static void RegisterController(Type controllerType, AppControlFilter[] filters) { - RegisterService(serviceType, new AppControlFilter[] { filter }); - } - - /// - /// Registers an Service class type. - /// - /// The type of Service class. - /// The array of filters to match Service and AppControl. - public static void RegisterService(Type serviceType, AppControlFilter[] filters) - { - if (!serviceType.IsSubclassOf(typeof(Service))) - throw new ArgumentException(serviceType.FullName + " is not a subclass of Service."); - - RegisterContext(serviceType, filters); - } - - internal static void StartActor(Context caller, Type actorType, Context.ActorFlags flags, AppControl control) - { - if (caller == null && actorType == null) + if (controllerType == null) { - throw new ArgumentNullException("actorType"); + throw new ArgumentNullException("controllerType"); } - Actor targetActor = null; - - Actor callerActor = caller as Actor; - if (callerActor != null && ForegroundActor != callerActor) - { - throw new InvalidOperationException("StartActor() should be called from the foreground Actor."); + if (!controllerType.IsSubclassOf(typeof(UIController)) || !controllerType.IsSubclassOf(typeof(ServiceController))) + { + throw new ArgumentException(controllerType.FullName + " is not a sub class of UIController or ServiceController.", "controllerType"); } - if (actorType == null) + foreach (var prop in controllerType.GetProperties()) { - actorType = FindActorInFilters(control); - if (actorType == null) + foreach (var attr in prop.GetCustomAttributes(false)) { - throw new ArgumentException("Could not find the matched Actor.", "control"); + var filter = attr as AppControlFilter; + if (filter != null) + { + s_filterMap.Add(filter, controllerType); + } } } - - if (callerActor != null && !IsFlagSet(flags, Context.ActorFlags.NewInstance)) + if (filters != null) { - targetActor = s_actorStack.FindInForegroundTask(actorType); + foreach (var filter in filters) + { + s_filterMap.Add(filter, controllerType); + } } - - if (s_window == null) + } + + internal static void StartController(Controller caller, Type controllerType, AppControl control, Controller.ControlFlags flags) + { + if (control == null) { - s_window = new Window(); + throw new ArgumentNullException("control"); } - if (!s_window.Visible) + if (controllerType == null) { - s_window.Active(); - s_window.Show(); + controllerType = FindControllerInFilterMap(control); + if (controllerType == null) + { + throw new ArgumentException("Could not find any matched controller.", "controllerType"); + } } - if (targetActor == null) - { - targetActor = (Actor)Activator.CreateInstance(actorType); - targetActor.OnCreate(callerActor != null ? callerActor.TaskId : Guid.NewGuid(), control); - s_actorStack.Push(targetActor); - } - else + if (controllerType.IsSubclassOf(typeof(UIController))) { - if (IsFlagSet(flags, Context.ActorFlags.ClearTop)) + UIController target = null; + UIController uiCaller = caller as UIController; + if (uiCaller != null && uiCaller != Foreground) { - while (targetActor != ForegroundActor) - { - Actor popped = s_actorStack.Pop(); - popped.OnPause(); - popped.OnDestroy(); - } + throw new InvalidOperationException("Starting UIController should be called from the foreground."); } - else if (IsFlagSet(flags, Context.ActorFlags.MoveToTop)) + if (uiCaller != null && !IsFlagSet(flags, Controller.ControlFlags.NewInstance)) { - if (ForegroundActor != targetActor) - { - ForegroundActor.OnPause(); - s_actorStack.MoveToTop(targetActor); - } + target = s_uiControllerStack.FindInForegroundTask(controllerType); } - } - ForegroundActor.OnStart(); - ForegroundActor.OnResume(); - } - internal static void StopActor(Actor actor) - { - if (ForegroundActor == null) - { - throw new InvalidOperationException("The Actor stack is empty."); - } - Guid prevForegroundTaskId = ForegroundActor.TaskId; + if (s_defaultWindow == null) + { + s_defaultWindow = new Window(); + } - s_actorStack.Remove(actor); - actor.OnPause(); - actor.OnDestroy(); + if (!s_defaultWindow.Visible) + { + s_defaultWindow.Active(); + s_defaultWindow.Show(); + } - if (actor.TaskId == prevForegroundTaskId) - { - if (ForegroundActor.TaskId == actor.TaskId) + if (target == null) { - ForegroundActor.OnResume(); + target = (UIController)Activator.CreateInstance(controllerType); + target.TaskId = uiCaller == null ? Guid.NewGuid() : uiCaller.TaskId; + target.Window = s_defaultWindow; + target.SendCreate(); + s_uiControllerStack.Push(target); } else { - if (s_actorStack.Count == 0 && s_serviceList.Count == 0) + if (IsFlagSet(flags, Controller.ControlFlags.ClearTop)) { - Exit(); + while (target != Foreground) + { + UIController popped = s_uiControllerStack.Pop(); + popped.SendPause(); + popped.SendDestroy(); + } } - else + else if (IsFlagSet(flags, Controller.ControlFlags.MoveToTop)) { - s_window.Hide(); + if (Foreground != target) + { + Foreground.SendPause(); + s_uiControllerStack.MoveToTop(target); + } } } + Foreground.SendStart(control); + Foreground.SendResume(); } - } - - internal static void StartService(Type serviceType, AppControl control) - { - if (serviceType == null) + else if (controllerType.IsSubclassOf(typeof(ServiceController))) { - serviceType = FindServiceInFilters(control); - if (serviceType == null) + ServiceController svc = s_serviceControllerList.Find(s => s.GetType() == controllerType); + if (svc == null) { - throw new ArgumentException("Could not find the matched Service.", "control"); + svc = (ServiceController)Activator.CreateInstance(controllerType); + s_serviceControllerList.Add(svc); + svc.SendCreate(); } + svc.SendStart(control); } else { - if (!serviceType.IsSubclassOf(typeof(Service))) - { - throw new ArgumentException(serviceType.FullName + " is not a subclass of Service.", "serviceType"); - } + throw new ArgumentException("Invalid controller type.", "controllerType"); } - - Service svc = s_serviceList.Find(s => s.GetType() == serviceType); - if (svc == null) - { - svc = (Service)Activator.CreateInstance(serviceType); - s_serviceList.Add(svc); - svc.OnCreate(control); - } - svc.OnStart(); } - internal static void StopService(Type serviceType) + internal static void StopController(UIController target) { - if (!serviceType.IsSubclassOf(typeof(Service))) + if (Foreground == null) { - throw new ArgumentException(serviceType.FullName + " is not a subclass of Service."); + throw new InvalidOperationException("The UIController stack is empty."); } - Service svc = s_serviceList.Find(s => s.GetType() == serviceType); - if (svc != null) + Guid prevForegroundTaskId = Foreground.TaskId; + + s_uiControllerStack.Remove(target); + target.SendPause(); + target.SendDestroy(); + if (target.TaskId == prevForegroundTaskId) { - svc.OnDestroy(); - s_serviceList.Remove(svc); - if (ForegroundActor == null && s_serviceList.Count == 0) + if (Foreground.TaskId == target.TaskId) { - Exit(); + Foreground.SendResume(); } - } - } - - internal static void Finish(Context caller) - { - if (caller is Actor) - { - StopActor(caller as Actor); - } - else if (caller is Service) - { - // TODO: check the value of GetType() - StopService(caller.GetType()); - } - } - - private static Type FindActorInFilters(AppControl control) - { - foreach (var item in s_filterMap) - { - if (item.Key.IsMatch(control) && item.Value.IsSubclassOf(typeof(Actor))) + else { - return item.Value; + if (s_uiControllerStack.Count == 0 && s_serviceControllerList.Count == 0) + { + Exit(); + } + else + { + s_defaultWindow.Hide(); + } } } - return null; } - private static Type FindServiceInFilters(AppControl control) + internal static void StopController(Type controllerType) { - foreach (var item in s_filterMap) - { - if (item.Key.IsMatch(control) && item.Value.IsSubclassOf(typeof(Service))) + if (controllerType.IsSubclassOf(typeof(UIController))) + { + UIController target = s_uiControllerStack.Find(controllerType); + if (target == null) { - return item.Value; + throw new InvalidOperationException("Could not find the UIController to stop."); } + StopController(target); } - return null; - } - - private static void RegisterContext(Type contextType, AppControlFilter[] filters) - { - foreach (var prop in contextType.GetProperties()) + else if (controllerType.IsSubclassOf(typeof(ServiceController))) { - foreach (var attr in prop.GetCustomAttributes(false)) + ServiceController svc = s_serviceControllerList.Find(s => s.GetType() == controllerType); + if (svc != null) { - var filter = attr as AppControlFilter; - if (filter != null) + svc.SendDestroy(); + s_serviceControllerList.Remove(svc); + if (s_uiControllerStack.Count == 0 && s_serviceControllerList.Count == 0) { - s_filterMap.Add(filter, contextType); + Exit(); } } } - if (filters != null) + } + + private static Type FindControllerInFilterMap(AppControl control) + { + foreach (var item in s_filterMap) { - foreach (var filter in filters) + if (item.Key.IsMatch(control)) { - s_filterMap.Add(filter, contextType); + return item.Value; } } + return null; } - - private static bool IsFlagSet(Context.ActorFlags flags, Context.ActorFlags values) + + private static bool IsFlagSet(Controller.ControlFlags flags, Controller.ControlFlags values) { return (values & flags) == values; } - private class ActorStack + private class UIControllerStack { - private readonly List _actorList; + private readonly List _uiControllerList; public int Count { get { - return _actorList.Count; + return _uiControllerList.Count; } } - public ActorStack() + public UIControllerStack() { - _actorList = new List(); + _uiControllerList = new List(); } - public Actor Peek() + public UIController Peek() { - return _actorList.LastOrDefault(null); + return _uiControllerList.LastOrDefault(null); } - public void Push(Actor item) + public void Push(UIController item) { - _actorList.Add(item); + _uiControllerList.Add(item); } - public Actor Pop() + public UIController Pop() { - Actor last = Peek(); - _actorList.Remove(last); + UIController last = Peek(); + _uiControllerList.Remove(last); return last; } - public void Remove(Actor actor) + public void Remove(UIController actor) + { + _uiControllerList.Remove(actor); + } + + public UIController Find(Type controllerType) { - _actorList.Remove(actor); + return _uiControllerList.Find(s => s.GetType() == controllerType); } - public Actor FindInForegroundTask(Type actorType) + public UIController FindInForegroundTask(Type controllerType) { - return _actorList.Find(s => s.GetType() == actorType && s.TaskId == Peek().TaskId); + return _uiControllerList.Find(s => s.GetType() == controllerType && s.TaskId == Peek().TaskId); } - public void MoveToTop(Actor actor) + public void MoveToTop(UIController actor) { - _actorList.Remove(actor); - _actorList.Add(actor); + _uiControllerList.Remove(actor); + _uiControllerList.Add(actor); } } } diff --git a/Tizen.Applications/Tizen.Applications/Context.cs b/Tizen.Applications/Tizen.Applications/Context.cs index 7e0a786..2e28752 100755 --- a/Tizen.Applications/Tizen.Applications/Context.cs +++ b/Tizen.Applications/Tizen.Applications/Context.cs @@ -1,13 +1,9 @@ -/// Copyright 2016 by Samsung Electronics, Inc., -/// -/// This software is the confidential and proprietary information -/// of Samsung Electronics, Inc. ("Confidential Information"). You -/// shall not disclose such Confidential Information and shall use -/// it only in accordance with the terms of the license agreement -/// you entered into with Samsung. - - using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.IO; namespace Tizen.Applications { @@ -16,91 +12,48 @@ namespace Tizen.Applications /// public abstract class Context { - internal AppControl _control; - - [Flags] - public enum ActorFlags - { - NewInstance = 1, - ClearTop = 2, - MoveToTop = 4, - } - /// /// /// - protected AppControl AppControl + public string ApplicationId { get { - return _control; + throw new NotImplementedException(); } } /// /// /// - /// - /// - protected void StartActor(Type actorType, AppControl control, ActorFlags flags = ActorFlags.NewInstance) - { - Application.StartActor(this, actorType, ActorFlags.NewInstance, control); - } - - /// - /// - /// - /// - /// - protected void StartActor(AppControl control, ActorFlags flags = ActorFlags.NewInstance) - { - Application.StartActor(this, null, ActorFlags.NewInstance, control); - } - - /// - /// - /// - /// - /// - protected void StartService(Type serviceType, AppControl control) - { - Application.StartService(serviceType, control); - } - - /// - /// - /// - /// - protected void StartService(AppControl control) - { - Application.StartService(null, control); - } - - /// - /// - /// - /// - protected void StopService(Type serviceType) + public string ApplicationName { - Application.StopService(serviceType); + get + { + throw new NotImplementedException(); + } } /// /// /// - protected void Finish() + public string ApplicationVersion { - Application.Finish(this); + get + { + throw new NotImplementedException(); + } } /// /// /// - /// - /// - protected void SendAppControl(AppControl control, string destination) + public IReadOnlyDictionary ApplicationPath { - throw new NotImplementedException(); + get + { + throw new NotImplementedException(); + } } } } diff --git a/Tizen.Applications/Tizen.Applications/Controller.cs b/Tizen.Applications/Tizen.Applications/Controller.cs new file mode 100755 index 0000000..6319dc0 --- /dev/null +++ b/Tizen.Applications/Tizen.Applications/Controller.cs @@ -0,0 +1,117 @@ +/// Copyright 2016 by Samsung Electronics, Inc., +/// +/// This software is the confidential and proprietary information +/// of Samsung Electronics, Inc. ("Confidential Information"). You +/// shall not disclose such Confidential Information and shall use +/// it only in accordance with the terms of the license agreement +/// you entered into with Samsung. + + +using System; + +namespace Tizen.Applications +{ + /// + /// + /// + public abstract class Controller : Context + { + /// + /// + /// + [Flags] + public enum ControlFlags + { + NewInstance = 1, + ClearTop = 2, + MoveToTop = 4, + } + + /// + /// + /// + protected AppControl AppControl { get; private set; } + + internal virtual void SendCreate() + { + AppControl = null; + OnCreate(); + } + + internal virtual void SendStart(AppControl control) + { + AppControl = control; + OnStart(); + } + + internal virtual void SendDestroy() + { + OnDestroy(); + } + + /// + /// + /// + protected virtual void OnCreate() + { + } + + /// + /// + /// + protected virtual void OnStart() + { + } + + /// + /// + /// + protected virtual void OnDestroy() + { + } + + /// + /// + /// + /// + /// + protected void StartController(AppControl control, ControlFlags flags = ControlFlags.NewInstance) + { + Application.StartController(this, null, control, flags); + } + + /// + /// + /// + /// + /// + /// + protected void StartController(Type controllerType, AppControl control, ControlFlags flags = ControlFlags.NewInstance) + { + Application.StartController(this, controllerType, control, flags); + } + + protected void StopController(Type controllerType) + { + Application.StopController(controllerType); + } + + /// + /// + /// + protected virtual void Finish() + { + Application.StopController(GetType()); + } + + /// + /// + /// + /// + /// + protected void SendAppControl(AppControl control, string destination) + { + throw new NotImplementedException(); + } + } +} diff --git a/Tizen.Applications/Tizen.Applications/Service.cs b/Tizen.Applications/Tizen.Applications/Service.cs deleted file mode 100755 index de274c8..0000000 --- a/Tizen.Applications/Tizen.Applications/Service.cs +++ /dev/null @@ -1,59 +0,0 @@ -/// Copyright 2016 by Samsung Electronics, Inc., -/// -/// This software is the confidential and proprietary information -/// of Samsung Electronics, Inc. ("Confidential Information"). You -/// shall not disclose such Confidential Information and shall use -/// it only in accordance with the terms of the license agreement -/// you entered into with Samsung. - - -using System; - -namespace Tizen.Applications -{ - /// - /// - /// - public abstract class Service : Context - { - /// - /// - /// - public event EventHandler Created; - - /// - /// - /// - public event EventHandler Started; - - /// - /// - /// - public event EventHandler Destroyed; - - internal void OnCreate(AppControl control) - { - _control = control; - if (Created != null) - { - Created(this, EventArgs.Empty); - } - } - - internal void OnStart() - { - if (Started != null) - { - Started(this, EventArgs.Empty); - } - } - - internal void OnDestroy() - { - if (Destroyed != null) - { - Destroyed(this, EventArgs.Empty); - } - } - } -} diff --git a/Tizen.Applications/Tizen.Applications/ServiceController.cs b/Tizen.Applications/Tizen.Applications/ServiceController.cs new file mode 100755 index 0000000..906de6e --- /dev/null +++ b/Tizen.Applications/Tizen.Applications/ServiceController.cs @@ -0,0 +1,20 @@ +/// Copyright 2016 by Samsung Electronics, Inc., +/// +/// This software is the confidential and proprietary information +/// of Samsung Electronics, Inc. ("Confidential Information"). You +/// shall not disclose such Confidential Information and shall use +/// it only in accordance with the terms of the license agreement +/// you entered into with Samsung. + + +using System; + +namespace Tizen.Applications +{ + /// + /// + /// + public abstract class ServiceController : Controller + { + } +} diff --git a/Tizen.Applications/Tizen.Applications/UIController.cs b/Tizen.Applications/Tizen.Applications/UIController.cs new file mode 100755 index 0000000..a7f56c3 --- /dev/null +++ b/Tizen.Applications/Tizen.Applications/UIController.cs @@ -0,0 +1,101 @@ +/// Copyright 2016 by Samsung Electronics, Inc., +/// +/// This software is the confidential and proprietary information +/// of Samsung Electronics, Inc. ("Confidential Information"). You +/// shall not disclose such Confidential Information and shall use +/// it only in accordance with the terms of the license agreement +/// you entered into with Samsung. + + +using System; +using Tizen.UI; + +namespace Tizen.Applications +{ + /// + /// + /// + public abstract class UIController : Controller, IUIContext + { + private bool _isResumed = false; + + /// + /// + /// + public event EventHandler Resumed; + + /// + /// + /// + public event EventHandler Paused; + + /// + /// + /// + public Window Window { get; internal set; } + + internal Guid TaskId { get; set; } + + /// + /// + /// + protected internal Page MainPage { get; set; } + + public string ResolveResourcePath(string res) + { + throw new NotImplementedException(); + } + + internal override void SendCreate() + { + Window = OnPrepareWindow(); + base.SendCreate(); + } + + internal void SendPause() + { + if (_isResumed) + { + if (Paused != null) + { + OnPause(); + Paused(this, EventArgs.Empty); + } + _isResumed = false; + } + } + + internal void SendResume() + { + if (!_isResumed) + { + if (Resumed != null) + { + OnResume(); + Resumed(this, EventArgs.Empty); + } + _isResumed = true; + MainPage.Show(); + } + } + + protected virtual Window OnPrepareWindow() + { + return Window; + } + + protected virtual void OnResume() + { + } + + protected virtual void OnPause() + { + } + + protected override void Finish() + { + Application.StopController(this); + } + } +} + diff --git a/Tizen.Applications/Tizen.UI/IUIContext.cs b/Tizen.Applications/Tizen.UI/IUIContext.cs new file mode 100755 index 0000000..c676f6a --- /dev/null +++ b/Tizen.Applications/Tizen.UI/IUIContext.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tizen.UI +{ + /// + /// + /// + interface IUIContext + { + /// + /// + /// + Window Window { get; } + + /// + /// + /// + /// + /// + string ResolveResourcePath(string res); + } +} diff --git a/Tizen.Applications/Tizen.UI/Window.cs b/Tizen.Applications/Tizen.UI/Window.cs index e2e134b..3fd9a20 100755 --- a/Tizen.Applications/Tizen.UI/Window.cs +++ b/Tizen.Applications/Tizen.UI/Window.cs @@ -11,7 +11,7 @@ using System; namespace Tizen.UI { - internal class Window : IDisposable + public class Window : IDisposable { private IntPtr _native_window = IntPtr.Zero; diff --git a/Tizen.UI/Properties/AssemblyInfo.cs b/Tizen.UI/Properties/AssemblyInfo.cs new file mode 100755 index 0000000..5c1dc2b --- /dev/null +++ b/Tizen.UI/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 +// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 +// 이러한 특성 값을 변경하세요. +[assembly: AssemblyTitle("Tizen.UI")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Tizen.UI")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("729a2031-f2bd-4784-9ba1-ebd057add72c")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호가 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Tizen.UI/Tizen.UI.csproj b/Tizen.UI/Tizen.UI.csproj new file mode 100755 index 0000000..3f0415a --- /dev/null +++ b/Tizen.UI/Tizen.UI.csproj @@ -0,0 +1,55 @@ + + + + + Debug + AnyCPU + {729A2031-F2BD-4784-9BA1-EBD057ADD72C} + Library + Properties + Tizen.UI + Tizen.UI + v4.5.2 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Tizen.UI/Tizen.UI/Window.cs b/Tizen.UI/Tizen.UI/Window.cs new file mode 100755 index 0000000..d23339f --- /dev/null +++ b/Tizen.UI/Tizen.UI/Window.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tizen.UI +{ + public class Window : Tizen.Applications.IWindow + { + } +} -- 2.7.4