# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Application", "Tizen.Application\Tizen.Application.csproj", "{663C5A3D-E631-4987-AEE7-F498C56A40FC}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Applications", "Tizen.Applications\Tizen.Applications.csproj", "{663C5A3D-E631-4987-AEE7-F498C56A40FC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
+++ /dev/null
-using System;
-
-namespace Tizen.Application
-{
- public abstract class Actor
- {
- private enum State
- {
- None,
- Created,
- Started,
- Resumed,
- Pasued
- }
-
- private ApplicationContext _context;
- private State _state = State.None;
- private AppControl _appcontrol;
-
- protected Page MainPage { get; set; }
- protected AppControl ReceivedAppControl { get { return _appcontrol; } }
- protected ApplicationContext Context { get { return _context; } }
-
- protected virtual void OnCreate() { }
- protected virtual void OnStart() { }
- protected virtual void OnPause() { }
- protected virtual void OnResume() { }
- protected virtual void OnTerminate() { }
-
- internal void Create(ApplicationContext context)
- {
- if (_state != State.Created)
- {
- _context = context;
- OnCreate();
- _state = State.Created;
- }
- }
-
- internal void Start(AppControl appControl)
- {
- if (_state != State.Started)
- {
- _appcontrol = appControl;
- OnStart();
- _state = State.Started;
- }
- }
-
- internal void Pause()
- {
- if (_state != State.Pasued)
- {
- OnPause();
- _state = State.Pasued;
- }
- }
-
- internal void Resume()
- {
- if (_state != State.Resumed)
- {
- OnResume();
- _state = State.Resumed;
- }
- }
-
- internal void Terminate()
- {
- if (_state != State.None)
- {
- OnTerminate();
- _state = State.None;
- }
- }
-
- protected void StartActor(Type actorType, AppControl appControl)
- {
- _context.StartActor(actorType, appControl);
-
- }
-
- protected void StartActor(Actor actor, AppControl appControl)
- {
- _context.StartActor(actor, appControl);
- }
-
- protected void StartService(Type serviceType, AppControl appControl)
- {
- Application.StartService(serviceType, appControl);
- }
- protected void StopService(Type serviceType)
- {
- Application.StopService(serviceType);
- }
-
- public void Finish()
- {
- throw new NotImplementedException();
- }
- }
-}
+++ /dev/null
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Runtime.InteropServices;
-
-namespace Tizen.Application
-{
- public static class Application
- {
- private static Dictionary<AppControlFilter, Type> _filterMap = new Dictionary<AppControlFilter, Type>();
- private static List<ApplicationContext> _contextList = new List<ApplicationContext>();
- private static Window _window = null;
- private static ServiceManager _serviceManager = new ServiceManager();
-
- public static event EventHandler ApplicationInit;
- public static event EventHandler ApplicationExit;
-
- private static ApplicationContext CurrentContext { get { return _contextList.LastOrDefault(null); } }
-
- public static int Run(string[] args)
- {
- Interop.Application.UIAppLifecycleCallbacks ops;
- ops.OnCreate = (userData) =>
- {
- ApplicationInit(null, null);
- return true;
- };
- ops.OnPause = (userData) =>
- {
- if (CurrentContext != null)
- {
- CurrentContext.Pause();
- }
- };
- ops.OnResume = (userData) =>
- {
- if (CurrentContext != null)
- {
- CurrentContext.Resume();
- }
- };
- ops.OnAppControl = (appControlHandle, userData) =>
- {
- AppControl appControl = new AppControl(appControlHandle);
- if (appControl.isService)
- {
- _serviceManager.OnAppControl(appControl);
- } else {
- foreach (var item in _filterMap)
- {
- if (item.Key.IsMatch(appControl))
- {
- // Window was created when the first UI Actor was created
- if (_window == null)
- _window = new Window();
- if (CurrentContext == null || !appControl.IsLaunchOperation())
- {
- ApplicationContext ctx = new ApplicationContext();
- ctx.ReleaseContext += Ctx_ReleaseContext;
- _contextList.Add(ctx);
- Actor actor = ctx.StartActor(item.Value, appControl);
- if (!_window.Visible)
- {
- _window.Active();
- _window.Show();
- ctx.Resume();
- }
- }
- break;
- }
- }
- }
- };
- ops.OnTerminate = (userData) =>
- {
- Exit();
- };
-
- TizenSynchronizationContext.Initialize();
-
- int ret = Interop.Application.UIAppMain(args.Length, args, ref ops, IntPtr.Zero);
-
- return ret;
- }
-
- public static void Hide()
- {
- if (_window != null)
- _window.InActive();
- }
-
- public static void Exit()
- {
- ApplicationExit(null, null);
- throw new NotImplementedException();
- }
-
- private static void Ctx_ReleaseContext(object sender, EventArgs e)
- {
- var ctx = sender as ApplicationContext;
- if (ctx != null)
- {
- _contextList.Remove(ctx);
- if (_contextList.Count > 0)
- {
- Hide();
- } else
- {
- // TODO. If running service was existed, application should not terminated, but Send the message to AUL(UI App terminate)
- Exit();
- }
- }
- }
-
- public static void AddActor(Type clazz)
- {
- AddActor(clazz, new AppControlFilter[0] { });
- }
-
- public static void AddActor(Type clazz, AppControlFilter filter)
- {
- AddActor(clazz, new AppControlFilter[] { filter });
- }
-
- public static void AddActor(Type clazz, AppControlFilter[] filters)
- {
- if (!clazz.IsSubclassOf(typeof(Actor)))
- throw new ArgumentException(clazz.FullName + " is not a subclass of Actor.");
-
- foreach (var prop in clazz.GetProperties())
- {
- foreach (var attr in prop.GetCustomAttributes(false))
- {
- var filter = attr as AppControlFilter;
- if (filter != null)
- {
- _filterMap.Add(filter, clazz);
- }
- }
- }
- if (filters != null)
- {
- foreach (var filter in filters)
- {
- _filterMap.Add(filter, clazz);
- }
- }
- }
-
- public static void AddServiceHandler(Type clazz)
- {
- AddServiceHandler(clazz, new AppControlFilter[0] { });
- }
-
- public static void AddServiceHandler(Type clazz, AppControlFilter filter)
- {
- AddServiceHandler(clazz, new AppControlFilter[] { filter });
- }
-
- public static void AddServiceHandler(Type clazz, AppControlFilter[] filters)
- {
- _serviceManager.AddServiceHandler(clazz, filters);
- }
-
- internal static void StartService(Type clazz, AppControl appControl)
- {
- _serviceManager.StartService(clazz, appControl);
- }
- internal static void StopService(Type clazz)
- {
- _serviceManager.StopService(clazz);
- }
- }
-
-
-}
+++ /dev/null
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Tizen.Application
-{
- public class ApplicationContext
- {
- private List<Actor> _actorList;
-
- internal event EventHandler ReleaseContext;
-
- internal Actor TopActor { get { return _actorList.LastOrDefault(null); } }
-
- internal ApplicationContext()
- {
- _actorList = new List<Actor>();
- }
-
- internal Actor StartActor(Type actorType, AppControl appControl)
- {
- Actor newActor = (Actor)Activator.CreateInstance(actorType);
- _actorList.Add(newActor);
- newActor.Create(this);
- newActor.Start(appControl);
- return newActor;
- }
-
- internal Actor StartActor(Actor actor, AppControl appControl)
- {
- Actor found = _actorList.Find(s => s == actor);
- if (found == null)
- {
- throw new ArgumentException("Could not found the actor in current context.");
- }
- _actorList.Remove(found);
- _actorList.Add(found);
- found.Start(appControl);
- return found;
- }
-
- internal void FinishActor(Actor actor)
- {
- Actor found = _actorList.Find(s => s == actor);
- if (found == null)
- {
- throw new ArgumentException("Could not found the actor in current context.");
- }
-
- found.Pause();
- found.Terminate();
- _actorList.Remove(found);
-
- if (IsEmpty())
- {
- ReleaseContext(this, null);
- }
- }
-
- internal void Pause()
- {
- if (TopActor != null)
- {
- TopActor.Pause();
- }
- }
-
- internal void Resume()
- {
- if (TopActor != null)
- {
- TopActor.Resume();
- }
- }
-
- internal bool IsEmpty()
- {
- return _actorList.Count == 0;
- }
- }
-}
+++ /dev/null
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Tizen.Application
-{
- public class Page
- {
- }
-}
+++ /dev/null
-namespace Tizen.Application {
- public class Service {
- public Service() { }
-
- public void Terminate()
- {
- Application.StopService(GetType());
- }
-
- protected virtual void OnCreate() { }
- protected virtual void OnTerminate() { }
- protected virtual void OnAppControl(AppControl appControl) { }
-
- internal void DidCreate()
- {
- OnCreate();
- }
- internal void DidTerminate()
- {
- OnTerminate();
- }
- internal void DidAppControl(AppControl appControl)
- {
- OnAppControl(appControl);
- }
- }
-}
+++ /dev/null
-using System;
-using System.Collections.Generic;
-
-namespace Tizen.Application
-{
- public class ServiceManager
- {
- private Dictionary<AppControlFilter, Type> _filterMap = new Dictionary<AppControlFilter, Type>();
- private Dictionary<Type, Service> _runningService = new Dictionary<Type, Service>();
-
- public ServiceManager() { }
- internal void AddServiceHandler(Type clazz, AppControlFilter[] filters)
- {
- if (!clazz.IsSubclassOf(typeof(Service)))
- throw new ArgumentException(clazz.FullName + " is not a subclass of Service.");
-
- foreach (var prop in clazz.GetProperties())
- {
- foreach (var attr in prop.GetCustomAttributes(false))
- {
- var filter = attr as AppControlFilter;
- if (filter != null)
- {
- _filterMap.Add(filter, clazz);
- }
- }
- }
- if (filters != null)
- {
- foreach (var filter in filters)
- {
- _filterMap.Add(filter, clazz);
- }
- }
- }
- internal void OnAppControl(AppControl appControl)
- {
- foreach (var item in _filterMap)
- {
- if (item.Key.IsMatch(appControl))
- {
- StartService(item.Value, appControl);
- break;
- }
- }
- }
-
- internal void StartService(Type clazz, AppControl appControl)
- {
- lock (_runningService)
- {
- if (_runningService.ContainsKey(clazz))
- {
- _runningService[clazz].DidAppControl(appControl);
- } else
- {
- _runningService[clazz] = (Service)Activator.CreateInstance(clazz);
- _runningService[clazz].DidCreate();
- _runningService[clazz].DidAppControl(appControl);
- }
- }
- }
-
- internal void StopService(Type clazz)
- {
- lock (_runningService)
- {
- if (_runningService.ContainsKey(clazz))
- {
- _runningService[clazz].DidTerminate();
- _runningService.Remove(clazz);
- }
- }
- }
-
- internal bool ServiceAlived
- {
- get
- {
- lock (_runningService)
- {
- return _runningService.Count > 0;
- }
- }
- }
- }
-}
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
-[assembly: AssemblyTitle("Tizen.Application")]
+[assembly: AssemblyTitle("Tizen.Applications")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Samsung Electronics")]
-[assembly: AssemblyProduct("Tizen.Application")]
+[assembly: AssemblyProduct("Tizen.Applications")]
[assembly: AssemblyCopyright("Copyright (c) 2015 Samsung Electronics Co., Ltd")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
<ProjectGuid>{663C5A3D-E631-4987-AEE7-F498C56A40FC}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>Tizen.Application</RootNamespace>
- <AssemblyName>Tizen.Application</AssemblyName>
+ <RootNamespace></RootNamespace>
+ <AssemblyName>Tizen.Applications</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
- <AssemblyOriginatorKeyFile>Tizen.Application.snk</AssemblyOriginatorKeyFile>
+ <AssemblyOriginatorKeyFile>Tizen.Applications.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Compile Include="Interop\Interop.Libraries.cs" />
<Compile Include="Interop\Interop.Window.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
- <Compile Include="Tizen.Application\Actor.cs" />
- <Compile Include="Tizen.Application\AppControl.cs" />
- <Compile Include="Tizen.Application\AppControlFilter.cs" />
- <Compile Include="Tizen.Application\Application.cs" />
- <Compile Include="Tizen.Application\ApplicationContext.cs" />
- <Compile Include="Tizen.Application\CodeExample.cs" />
- <Compile Include="Tizen.Application\Page.cs" />
- <Compile Include="Tizen.Application\Service.cs" />
- <Compile Include="Tizen.Application\ServiceManager.cs" />
- <Compile Include="Tizen.Application\Window.cs" />
- <Compile Include="Tizen.Application\TizenSynchronizationContext.cs" />
+ <Compile Include="Tizen.Applications\Actor.cs" />
+ <Compile Include="Tizen.Applications\AppControl.cs" />
+ <Compile Include="Tizen.Applications\AppControlFilter.cs" />
+ <Compile Include="Tizen.Applications\Application.cs" />
+ <Compile Include="Tizen.Applications\CodeExample.cs" />
+ <Compile Include="Tizen.Applications\Context.cs" />
+ <Compile Include="Tizen.Applications\ContextGroup.cs" />
+ <Compile Include="Tizen.Applications\Service.cs" />
+ <Compile Include="Tizen.Applications\Window.cs" />
+ <Compile Include="Tizen.Applications\TizenSynchronizationContext.cs" />
</ItemGroup>
<ItemGroup>
- <None Include="Tizen.Application.snk" />
+ <None Include="Tizen.Applications.snk" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
--- /dev/null
+using System;
+
+namespace Tizen.Applications
+{
+ public abstract class Actor : Context
+ {
+ protected virtual void OnPaused() { }
+ protected virtual void OnResumed() { }
+
+ internal void Pause()
+ {
+ OnPaused();
+ }
+
+ internal void Resume()
+ {
+ OnResumed();
+ }
+
+ protected void StartActor(Actor actor, AppControl control)
+ {
+ Actor target = (Actor)CurrentGroup.MoveToTop(actor);
+ if (target != null)
+ {
+ Pause();
+ target.Start(control);
+ target.Resume();
+ }
+ }
+
+ protected override void StartActor(Type actorType, AppControl control)
+ {
+ Application.StartActor(CurrentGroup, actorType, control);
+ }
+
+ protected override void Finish()
+ {
+ Application.StopActor(CurrentGroup, this);
+ }
+
+ }
+}
+
using System.Collections.Generic;
using System.Runtime.InteropServices;
-namespace Tizen.Application
+namespace Tizen.Applications
{
public class AppControl
{
Interop.AppControl.GetUri(handle, out _uri);
}
- internal bool isService
+ internal bool IsService
{
- get {return false;}
+ get { return false; }
}
public AppControl(string operation, string mime, string uri)
using System;
using System.Text.RegularExpressions;
-namespace Tizen.Application
+namespace Tizen.Applications
{
[AttributeUsage(AttributeTargets.Class)]
public class AppControlFilter : Attribute
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Runtime.InteropServices;
+
+namespace Tizen.Applications
+{
+ public static class Application
+ {
+ private static Dictionary<AppControlFilter, Type> s_filterMap = new Dictionary<AppControlFilter, Type>();
+ private static ContextGroup s_serviceGroup = new ContextGroup();
+ private static List<ContextGroup> s_actorGroupList = new List<ContextGroup>();
+
+ private static Window s_window = null;
+
+ private static ContextGroup CurrentActorGroup
+ {
+ get
+ {
+ return s_actorGroupList.LastOrDefault(null);
+ }
+ }
+
+ public static event EventHandler Created = delegate { };
+ public static event EventHandler Exited = delegate { };
+
+ public static int Run(string[] args)
+ {
+ Interop.Application.UIAppLifecycleCallbacks ops;
+ ops.OnCreate = (userData) =>
+ {
+ Created(null, EventArgs.Empty);
+ return true;
+ };
+ ops.OnPause = (userData) =>
+ {
+ if (CurrentActorGroup != null && CurrentActorGroup.TopContext != null)
+ {
+ Actor actor = CurrentActorGroup.TopContext as Actor;
+ if (actor != null)
+ {
+ actor.Pause();
+ }
+ }
+ };
+ ops.OnResume = (userData) =>
+ {
+ if (CurrentActorGroup != null && CurrentActorGroup.TopContext != null)
+ {
+ Actor actor = CurrentActorGroup.TopContext as Actor;
+ if (actor != null)
+ {
+ actor.Resume();
+ }
+ }
+ };
+ ops.OnAppControl = (appControlHandle, userData) =>
+ {
+ AppControl appControl = new AppControl(appControlHandle);
+ if (appControl.IsService)
+ {
+ foreach (var item in s_filterMap)
+ {
+ if (item.Key.IsMatch(appControl) && item.Value.IsSubclassOf(typeof(Service)))
+ {
+ StartService(item.Value, appControl);
+ break;
+ }
+ }
+ }
+ else
+ {
+ foreach (var item in s_filterMap)
+ {
+ if (item.Key.IsMatch(appControl) && item.Value.IsSubclassOf(typeof(Actor)))
+ {
+ // Window was created when the first UI Actor was created
+ if (s_window == null)
+ {
+ s_window = new Window();
+ }
+
+ if (CurrentActorGroup == null || !appControl.IsLaunchOperation())
+ {
+ StartActor(null, item.Value, appControl);
+ }
+ break;
+ }
+ }
+ }
+ };
+ ops.OnTerminate = (userData) =>
+ {
+ Exit();
+ };
+
+ TizenSynchronizationContext.Initialize();
+
+ int ret = Interop.Application.UIAppMain(args.Length, args, ref ops, IntPtr.Zero);
+
+ return ret;
+ }
+
+ public static void Hide()
+ {
+ if (s_window != null)
+ s_window.InActive();
+ }
+
+ public static void Exit()
+ {
+ Exited(null, null);
+ throw new NotImplementedException();
+ }
+
+ public static void RegisterActor(Type clazz)
+ {
+ RegisterActor(clazz, new AppControlFilter[0] { });
+ }
+
+ public static void RegisterActor(Type clazz, AppControlFilter filter)
+ {
+ RegisterActor(clazz, new AppControlFilter[] { filter });
+ }
+
+ public static void RegisterActor(Type clazz, AppControlFilter[] filters)
+ {
+ if (!clazz.IsSubclassOf(typeof(Actor)))
+ throw new ArgumentException(clazz.FullName + " is not a subclass of Actor.");
+
+ RegisterContext(clazz, filters);
+ }
+
+ public static void RegisterService(Type clazz)
+ {
+ RegisterService(clazz, new AppControlFilter[0] { });
+ }
+
+ public static void RegisterService(Type clazz, AppControlFilter filter)
+ {
+ RegisterService(clazz, new AppControlFilter[] { filter });
+ }
+
+ public static void RegisterService(Type clazz, AppControlFilter[] filters)
+ {
+ if (!clazz.IsSubclassOf(typeof(Service)))
+ throw new ArgumentException(clazz.FullName + " is not a subclass of Service.");
+
+ RegisterContext(clazz, filters);
+ }
+
+ private static void RegisterContext(Type clazz, AppControlFilter[] filters)
+ {
+ foreach (var prop in clazz.GetProperties())
+ {
+ foreach (var attr in prop.GetCustomAttributes(false))
+ {
+ var filter = attr as AppControlFilter;
+ if (filter != null)
+ {
+ s_filterMap.Add(filter, clazz);
+ }
+ }
+ }
+ if (filters != null)
+ {
+ foreach (var filter in filters)
+ {
+ s_filterMap.Add(filter, clazz);
+ }
+ }
+ }
+
+ internal static void StartActor(ContextGroup group, Type actorType, AppControl control)
+ {
+ if (!actorType.IsSubclassOf(typeof(Actor)))
+ {
+ throw new ArgumentException(actorType.FullName + " is not a subclass of Actor.");
+ }
+
+ Actor actor = (Actor)Activator.CreateInstance(actorType);
+ ContextGroup ctxGroup = group;
+ if (ctxGroup == null)
+ {
+ ctxGroup = new ContextGroup();
+ s_actorGroupList.Add(ctxGroup);
+ }
+ ctxGroup.AddContext(actor);
+ actor.Create(ctxGroup);
+ actor.Start(control);
+
+ // TODO: consider resume operation
+ if (!s_window.Visible)
+ {
+ s_window.Active();
+ s_window.Show();
+ actor.Resume();
+ }
+ }
+
+ internal static void StopActor(ContextGroup group, Actor actor)
+ {
+ actor.Pause();
+ actor.Terminate();
+ group.RemoveContext(actor);
+ if (group.IsEmpty)
+ {
+ s_actorGroupList.Remove(group);
+ if (s_actorGroupList.Count == 0 && s_serviceGroup.IsEmpty)
+ {
+ Exit();
+ }
+ else
+ {
+ Hide();
+ }
+ }
+ else
+ {
+ Actor nextActor = group.TopContext as Actor;
+ if (nextActor != null)
+ {
+ nextActor.Resume();
+ }
+ }
+ }
+
+ internal static void StartService(Type serviceType, AppControl control)
+ {
+ if (!serviceType.IsSubclassOf(typeof(Service)))
+ {
+ throw new ArgumentException(serviceType.FullName + " is not a subclass of Service.");
+ }
+
+ Context ctx = s_serviceGroup.FindContext(serviceType);
+ if (ctx == null)
+ {
+ // Register ContextRemoved Handler once
+ ctx = (Service)Activator.CreateInstance(serviceType);
+ s_serviceGroup.AddContext(ctx);
+ ctx.Create(s_serviceGroup);
+ }
+ ctx.Start(control);
+ }
+
+ internal static void StopService(Type serviceType)
+ {
+ if (!serviceType.IsSubclassOf(typeof(Service)))
+ {
+ throw new ArgumentException(serviceType.FullName + " is not a subclass of Service.");
+ }
+
+ Context ctx = s_serviceGroup.FindContext(serviceType);
+ if (ctx != null)
+ {
+ ctx.Terminate();
+ s_serviceGroup.RemoveContext(ctx);
+ if (s_serviceGroup.IsEmpty)
+ {
+ if (s_actorGroupList.Count == 0)
+ {
+ Exit();
+ }
+ }
+ }
+ }
+ }
+}
using System.Text;
using System.Threading.Tasks;
-namespace Tizen.Application
+namespace Tizen.Applications
{
public class ViewActor : Actor
{
public string Type { get; set; }
- protected override void OnCreate()
+ protected override void OnCreated()
{
Console.WriteLine();
}
- protected override void OnStart()
+ protected override void OnStarted()
{
}
[AppControlFilter("http://tizen.org/appcontrol/operation/default")]
public class DefaultActor : Actor
{
- protected override void OnCreate()
+ protected override void OnCreated()
{
}
- protected override void OnStart()
+ protected override void OnStarted()
{
}
}
{
static void test(string[] args) // main
{
- Application.ApplicationInit += Application_Create;
- Application.ApplicationExit += Application_Terminate;
- Application.AddActor(typeof(DefaultActor));
- Application.AddActor(typeof(ViewActor), new AppControlFilter[] {
+ Application.Created += Application_Create;
+ Application.Exited += Application_Terminate;
+ Application.RegisterActor(typeof(DefaultActor));
+ Application.RegisterActor(typeof(ViewActor), new AppControlFilter[] {
new AppControlFilter("http://tizen.org/appcontrol/view", "image/*"),
new AppControlFilter("http://tizen.org/appcontrol/view", "text/*")
});
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tizen.Applications
+{
+ public abstract class Context
+ {
+ private ContextGroup _group;
+ private AppControl _control;
+
+ internal ContextGroup CurrentGroup
+ {
+ get
+ {
+ return _group;
+ }
+ }
+
+ protected AppControl ReceivedAppControl
+ {
+ get
+ {
+ return _control;
+ }
+ }
+
+ protected virtual void OnCreated() { }
+ protected virtual void OnStarted() { }
+ protected virtual void OnTerminated() { }
+
+ internal void Create(ContextGroup group)
+ {
+ _group = group;
+ OnCreated();
+ }
+
+ internal void Start(AppControl control)
+ {
+ _control = control;
+ OnStarted();
+ }
+
+ internal void Terminate()
+ {
+ OnTerminated();
+ }
+
+ protected abstract void StartActor(Type actorType, AppControl control);
+
+ protected void StartService(Type serviceType, AppControl control)
+ {
+ Application.StartService(serviceType, control);
+ }
+
+ protected void StopService(Type serviceType)
+ {
+ Application.StopService(serviceType);
+ }
+
+ protected abstract void Finish();
+
+ protected void SendAppControl(AppControl control, string destination)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tizen.Applications
+{
+ internal class ContextGroup
+ {
+ private List<Context> _contextList;
+
+ public bool IsEmpty
+ {
+ get
+ {
+ return _contextList.Count == 0;
+ }
+ }
+
+ public Context TopContext
+ {
+ get
+ {
+ return _contextList.LastOrDefault(null);
+ }
+ }
+
+ public ContextGroup()
+ {
+ _contextList = new List<Context>();
+ }
+
+ public void AddContext(Context ctx)
+ {
+ _contextList.Add(ctx);
+ }
+
+ public void RemoveContext(Context ctx)
+ {
+ _contextList.Remove(ctx);
+ }
+
+ public Context FindContext(Type type)
+ {
+ return _contextList.Find(s => s.GetType() == type);
+ }
+
+ public Context FindContext(Context ctx)
+ {
+ return _contextList.Find(s => s == ctx);
+ }
+
+ public Context MoveToTop(Context ctx)
+ {
+ var found = FindContext(ctx);
+ if (found != null)
+ {
+ _contextList.Remove(found);
+ _contextList.Add(found);
+ }
+ return found;
+ }
+ }
+}
--- /dev/null
+using System;
+
+namespace Tizen.Applications
+{
+ public abstract class Service : Context
+ {
+ protected override void StartActor(Type actorType, AppControl control)
+ {
+ Application.StartActor(null, actorType, control);
+ }
+
+ protected override void Finish()
+ {
+ Application.StopService(GetType());
+ }
+ }
+}
using System.Collections.Generic;
using System.Threading;
-namespace Tizen.Application
+namespace Tizen.Applications
{
internal class TizenSynchronizationContext : SynchronizationContext
{
using System;
-namespace Tizen.Application {
- class Window : IDisposable {
+namespace Tizen.Applications
+{
+ class Window : IDisposable
+ {
private IntPtr _native_window = IntPtr.Zero;
- public bool Visible {
- get {
+ public bool Visible
+ {
+ get
+ {
return _native_window != IntPtr.Zero ? Interop.Window.evas_object_visible_get(_native_window) : false;
}
}
- public Window() {
+ public Window()
+ {
_native_window = Interop.Window.elm_win_add(IntPtr.Zero, "Window", 0);
}
- ~Window() {
+ ~Window()
+ {
Dispose();
}
- public void Show() {
+ public void Show()
+ {
Interop.Window.evas_object_show(_native_window);
}
- public void Hide() {
+ public void Hide()
+ {
Interop.Window.evas_object_hide(_native_window);
}
- public void Active() {
+ public void Active()
+ {
Interop.Window.elm_win_activate(_native_window);
}
- public void InActive() {
+ public void InActive()
+ {
Interop.Window.elm_win_lower(_native_window);
}
- public void Dispose() {
- if (_native_window != IntPtr.Zero) {
+ public void Dispose()
+ {
+ if (_native_window != IntPtr.Zero)
+ {
Interop.Window.evas_object_unref(_native_window);
_native_window = IntPtr.Zero;
}
+%define _use_internal_dependency_generator 0
+
%define dllpath %{_libdir}/mono/tizen
-%define dllname Tizen.Application.dll
+%define dllname Tizen.Applications.dll
Name: csapi-application
Summary: Tizen Application API for C#
%build
# build dll
-mcs -target:library -out:%{dllname} -keyfile:Tizen.Application/Tizen.Application.snk \
- Tizen.Application/Properties/AssemblyInfo.cs \
- Tizen.Application/Tizen.Application/*.cs \
- Tizen.Application/Interop/*.cs
+mcs -target:library -out:%{dllname} -keyfile:Tizen.Applications/Tizen.Applications.snk \
+ Tizen.Applications/Properties/AssemblyInfo.cs \
+ Tizen.Applications/Tizen.Applications/*.cs \
+ Tizen.Applications/Interop/*.cs
# check p/invoke
if [ -x %{dllname} ]; then