}
}
- internal class Application : BaseHandle, IResourcesProvider, IApplicationController, IElementConfiguration<Application>
+ internal class Application : BaseHandle, IResourcesProvider, IElementConfiguration<Application>
{
- static Application s_current;
- Task<IDictionary<string, object>> _propertiesTask;
- readonly Lazy<PlatformConfigurationRegistry<Application>> _platformConfigurationRegistry;
- IAppIndexingProvider _appIndexProvider;
+ static Application s_current;
ReadOnlyCollection<Element> _logicalChildren;
- Page _mainPage;
-
static SemaphoreSlim SaveSemaphore = new SemaphoreSlim(1, 1);
- public IAppLinks AppLinks
- {
- get
- {
- if (_appIndexProvider == null)
- throw new ArgumentException("No IAppIndexingProvider was provided");
- if (_appIndexProvider.AppLinks == null)
- throw new ArgumentException("No AppLinks implementation was found, if in Android make sure you installed the Xamarin.Forms.AppLinks");
- return _appIndexProvider.AppLinks;
- }
- }
-
[EditorBrowsable(EditorBrowsableState.Never)]
public static void SetCurrentApplication(Application value) => Current = value;
}
}
- public Page MainPage
- {
- get { return _mainPage; }
- set
- {
- if (value == null)
- throw new ArgumentNullException("value");
-
- if (_mainPage == value)
- return;
-
- OnPropertyChanging();
- if (_mainPage != null)
- {
- InternalChildren.Remove(_mainPage);
- _mainPage.Parent = null;
- }
-
- _mainPage = value;
-
- if (_mainPage != null)
- {
- _mainPage.Parent = this;
- _mainPage.NavigationProxy.Inner = NavigationProxy;
- InternalChildren.Add(_mainPage);
- }
- OnPropertyChanged();
- }
- }
-
- public IDictionary<string, object> Properties
- {
- get
- {
- if (_propertiesTask == null)
- {
- _propertiesTask = GetPropertiesAsync();
- }
-
- return _propertiesTask.Result;
- }
- }
-
internal override ReadOnlyCollection<Element> LogicalChildrenInternal
{
get { return _logicalChildren ?? (_logicalChildren = new ReadOnlyCollection<Element>(InternalChildren)); }
}
- [EditorBrowsable(EditorBrowsableState.Never)]
- public new NavigationProxy NavigationProxy { get; }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public int PanGestureId { get; set; }
-
internal IResourceDictionary SystemResources { get; }
ObservableCollection<Element> InternalChildren { get; } = new ObservableCollection<Element>();
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void SetAppIndexingProvider(IAppIndexingProvider provider)
- {
- _appIndexProvider = provider;
- }
-
ResourceDictionary _resources;
public bool IsResourcesCreated => _resources != null;
}
}
- public event EventHandler<ModalPoppedEventArgs> ModalPopped;
-
- public event EventHandler<ModalPoppingEventArgs> ModalPopping;
-
- public event EventHandler<ModalPushedEventArgs> ModalPushed;
-
- public event EventHandler<ModalPushingEventArgs> ModalPushing;
-
- public event EventHandler<Page> PageAppearing;
-
- public event EventHandler<Page> PageDisappearing;
-
-
- async void SaveProperties()
- {
- try
- {
- await SetPropertiesAsync();
- }
- catch (Exception exc)
- {
- Console.WriteLine(nameof(Application), $"Exception while saving Application Properties: {exc}");
- }
- }
-
- public async Task SavePropertiesAsync()
- {
- if (Device.IsInvokeRequired)
- {
- Device.BeginInvokeOnMainThread(SaveProperties);
- }
- else
- {
- await SetPropertiesAsync();
- }
- }
-
- // Don't use this unless there really is no better option
- internal void SavePropertiesAsFireAndForget()
- {
- if (Device.IsInvokeRequired)
- {
- Device.BeginInvokeOnMainThread(SaveProperties);
- }
- else
- {
- SaveProperties();
- }
- }
-
- public IPlatformElementConfiguration<T, Application> On<T>() where T : IConfigPlatform
- {
- return _platformConfigurationRegistry.Value.On<T>();
- }
-
- protected virtual void OnAppLinkRequestReceived(Uri uri)
- {
- }
-
protected override void OnParentSet()
{
throw new InvalidOperationException("Setting a Parent on Application is invalid.");
}
- protected virtual void OnResume()
- {
- }
-
- protected virtual void OnSleep()
- {
- }
-
- protected virtual void OnStart()
- {
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static void ClearCurrent()
- {
- s_current = null;
- }
-
[EditorBrowsable(EditorBrowsableState.Never)]
public static bool IsApplicationOrNull(Element element)
{
OnResourcesChanged(changedResources);
}
- internal event EventHandler PopCanceled;
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void SendOnAppLinkRequestReceived(Uri uri)
- {
- OnAppLinkRequestReceived(uri);
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void SendResume()
- {
- s_current = this;
- OnResume();
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void SendSleep()
- {
- OnSleep();
- SavePropertiesAsFireAndForget();
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Task SendSleepAsync()
- {
- OnSleep();
- return SavePropertiesAsync();
- }
-
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void SendStart()
- {
- OnStart();
- }
-
- async Task<IDictionary<string, object>> GetPropertiesAsync()
- {
- var deserializer = DependencyService.Get<IDeserializer>();
- if (deserializer == null)
- {
- Console.WriteLine("Startup", "No IDeserialzier was found registered");
- return new Dictionary<string, object>(4);
- }
-
- IDictionary<string, object> properties = await deserializer.DeserializePropertiesAsync().ConfigureAwait(false);
- if (properties == null)
- properties = new Dictionary<string, object>(4);
-
- return properties;
- }
-
- internal void OnPageAppearing(Page page)
- => PageAppearing?.Invoke(this, page);
-
- internal void OnPageDisappearing(Page page)
- => PageDisappearing?.Invoke(this, page);
-
- void OnModalPopped(Page modalPage)
- => ModalPopped?.Invoke(this, new ModalPoppedEventArgs(modalPage));
-
- bool OnModalPopping(Page modalPage)
- {
- var args = new ModalPoppingEventArgs(modalPage);
- ModalPopping?.Invoke(this, args);
- return args.Cancel;
- }
-
- void OnModalPushed(Page modalPage)
- => ModalPushed?.Invoke(this, new ModalPushedEventArgs(modalPage));
-
- void OnModalPushing(Page modalPage)
- => ModalPushing?.Invoke(this, new ModalPushingEventArgs(modalPage));
-
- void OnPopCanceled()
- => PopCanceled?.Invoke(this, EventArgs.Empty);
-
- async Task SetPropertiesAsync()
- {
- await SaveSemaphore.WaitAsync();
- try
- {
- await DependencyService.Get<IDeserializer>()?.SerializePropertiesAsync(Properties);
- }
- finally
- {
- SaveSemaphore.Release();
- }
-
- }
-
- class NavigationImpl : NavigationProxy
- {
- readonly Application _owner;
-
- public NavigationImpl(Application owner)
- {
- _owner = owner;
- }
-
- protected override async Task<Page> OnPopModal(bool animated)
- {
- Page modal = ModalStack[ModalStack.Count - 1];
- if (_owner.OnModalPopping(modal))
- {
- _owner.OnPopCanceled();
- return null;
- }
- Page result = await base.OnPopModal(animated);
- result.Parent = null;
- _owner.OnModalPopped(result);
- return result;
- }
-
- protected override async Task OnPushModal(Page modal, bool animated)
- {
- _owner.OnModalPushing(modal);
-
- modal.Parent = _owner;
-
- if (modal.NavigationProxy.ModalStack.Count == 0)
- {
- modal.NavigationProxy.Inner = this;
- await base.OnPushModal(modal, animated);
- }
- else
- {
- await base.OnPushModal(modal, animated);
- modal.NavigationProxy.Inner = this;
- }
-
- _owner.OnModalPushed(modal);
- }
- }
-
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
internal Application(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.Application_SWIGUpcast(cPtr), cMemoryOwn)
{
- NavigationProxy = new NavigationImpl(this);
SetCurrentApplication(this);
- _platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<Application>>(() => new PlatformConfigurationRegistry<Application>(this));
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
- SendResume();
+ s_current = this;
}
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Application obj)
if (swigCMemOwn)
{
swigCMemOwn = false;
- NDalicPINVOKE.delete_Application(swigCPtr);
+ Interop.Application.delete_Application(swigCPtr);
}
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
}
e.Application = this;
_applicationTerminateEventHandler.Invoke(this, e);
}
-
- Window.Instance.DisconnectNativeSignals();
+ if (Window.Instance)
+ {
+ Window.Instance.DisconnectNativeSignals();
+ }
}
/**
{
lock (this)
{
- NUIApplicationBatteryLowEventArgs e = new NUIApplicationBatteryLowEventArgs();
+ NUIApplicationBatteryLowEventArgs e = new NUIApplicationBatteryLowEventArgs();
- // Populate all members of "e" (NUIApplicationBatteryLowEventArgs) with real data
- e.BatteryStatus = status;
- _applicationBatteryLowEventHandler?.Invoke(this, e);
- }
+ // Populate all members of "e" (NUIApplicationBatteryLowEventArgs) with real data
+ e.BatteryStatus = status;
+ _applicationBatteryLowEventHandler?.Invoke(this, e);
+ }
}
/**
{
lock (this)
{
- NUIApplicationMemoryLowEventArgs e = new NUIApplicationMemoryLowEventArgs();
+ NUIApplicationMemoryLowEventArgs e = new NUIApplicationMemoryLowEventArgs();
- // Populate all members of "e" (NUIApplicationMemoryLowEventArgs) with real data
- e.MemoryStatus = status;
- _applicationMemoryLowEventHandler?.Invoke(this, e);
- }
+ // Populate all members of "e" (NUIApplicationMemoryLowEventArgs) with real data
+ e.MemoryStatus = status;
+ _applicationMemoryLowEventHandler?.Invoke(this, e);
+ }
}
/**
public bool AddIdle(System.Delegate func)
{
System.IntPtr ip = System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate<System.Delegate>(func);
- System.IntPtr ip2 = NDalicManualPINVOKE.MakeCallback(new System.Runtime.InteropServices.HandleRef(this, ip));
+ System.IntPtr ip2 = Interop.Application.MakeCallback(new System.Runtime.InteropServices.HandleRef(this, ip));
- bool ret = NDalicPINVOKE.Application_AddIdle(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip2));
+ bool ret = Interop.Application.Application_AddIdle(swigCPtr, new System.Runtime.InteropServices.HandleRef(this, ip2));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
*/
public static Application New()
{
- Application ret = new Application(NDalicPINVOKE.Application_New__SWIG_0(), true);
+ Application ret = new Application(Interop.Application.Application_New__SWIG_0(), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public static Application New(int argc)
{
- Application ret = new Application(NDalicPINVOKE.Application_New__SWIG_1(argc), true);
+ Application ret = new Application(Interop.Application.Application_New__SWIG_1(argc), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public static Application New(int argc, string stylesheet)
{
- Application ret = new Application(NDalicPINVOKE.Application_New__SWIG_2(argc, stylesheet), true);
+ Application ret = new Application(Interop.Application.Application_New__SWIG_2(argc, stylesheet), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public static Application New(int argc, string stylesheet, Application.WindowMode windowMode)
{
- Application ret = new Application(NDalicPINVOKE.Application_New__SWIG_3(argc, stylesheet, (int)windowMode), true);
+ Application ret = new Application(Interop.Application.Application_New__SWIG_3(argc, stylesheet, (int)windowMode), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- ret.SendResume();
+ s_current = ret;
return ret;
}
string argvStr = string.Join(" ", args);
Application ret = new Application(NDalicPINVOKE.Application_New__MANUAL_4(argc, argvStr, stylesheet, (int)windowMode), true);
+
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+
return ret;
}
public static Application New(int argc, string stylesheet, Application.WindowMode windowMode, Rectangle positionSize)
{
- Application ret = new Application(NDalicPINVOKE.Application_New__SWIG_4(argc, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
+ Application ret = new Application(Interop.Application.Application_New__SWIG_4(argc, stylesheet, (int)windowMode, Rectangle.getCPtr(positionSize)), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
- public Application() : this(NDalicPINVOKE.new_Application__SWIG_0(), true)
+ public Application() : this(Interop.Application.new_Application__SWIG_0(), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
- public Application(Application application) : this(NDalicPINVOKE.new_Application__SWIG_1(Application.getCPtr(application)), true)
+ public Application(Application application) : this(Interop.Application.new_Application__SWIG_1(Application.getCPtr(application)), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
public Application Assign(Application application)
{
- Application ret = new Application(NDalicPINVOKE.Application_Assign(swigCPtr, Application.getCPtr(application)), false);
+ Application ret = new Application(Interop.Application.Application_Assign(swigCPtr, Application.getCPtr(application)), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
internal void MainLoop(SWIGTYPE_p_Configuration__ContextLoss configuration)
{
- NDalicPINVOKE.Application_MainLoop__SWIG_1(swigCPtr, SWIGTYPE_p_Configuration__ContextLoss.getCPtr(configuration));
+ Interop.Application.Application_MainLoop__SWIG_1(swigCPtr, SWIGTYPE_p_Configuration__ContextLoss.getCPtr(configuration));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
public void Lower()
{
- NDalicPINVOKE.Application_Lower(swigCPtr);
+ Interop.Application.Application_Lower(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
public void Quit()
{
- NDalicPINVOKE.Application_Quit(swigCPtr);
+ Interop.Application.Application_Quit(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
internal bool AddIdle(SWIGTYPE_p_Dali__CallbackBase callback)
{
- bool ret = NDalicPINVOKE.Application_AddIdle(swigCPtr, SWIGTYPE_p_Dali__CallbackBase.getCPtr(callback));
+ bool ret = Interop.Application.Application_AddIdle(swigCPtr, SWIGTYPE_p_Dali__CallbackBase.getCPtr(callback));
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public Window GetWindow()
{
- Window ret = new Window(NDalicPINVOKE.Application_GetWindow(swigCPtr), true);
+ Window ret = new Window(Interop.Application.Application_GetWindow(swigCPtr), true);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public void ReplaceWindow(Rectangle windowPosition, string name)
{
- NDalicPINVOKE.Application_ReplaceWindow(swigCPtr, Rectangle.getCPtr(windowPosition), name);
+ Interop.Application.Application_ReplaceWindow(swigCPtr, Rectangle.getCPtr(windowPosition), name);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
public static string GetResourcePath()
{
- string ret = NDalicPINVOKE.Application_GetResourcePath();
+ string ret = Interop.Application.Application_GetResourcePath();
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public string GetLanguage()
{
- string ret = NDalicPINVOKE.Application_GetLanguage(swigCPtr);
+ string ret = Interop.Application.Application_GetLanguage(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
public string GetRegion()
{
- string ret = NDalicPINVOKE.Application_GetRegion(swigCPtr);
+ string ret = Interop.Application.Application_GetRegion(swigCPtr);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
+ internal List<Window> GetWindowList()
+ {
+ uint ListSize = Interop.Application.Application_GetWindowsListSize();
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+
+ List<Window> WindowList = new List<Window>();
+ for( uint i = 0; i < ListSize; ++i )
+ {
+ Window currWin = new Window(Interop.Application.Application_GetWindowsFromList(i), true);
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ WindowList.Add(currWin);
+ }
+ return WindowList;
+ }
internal ApplicationSignal InitSignal()
{