123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- using ReactNative;
- using ReactNative.Modules.Launch;
- using System;
- using Windows.ApplicationModel;
- using Windows.ApplicationModel.Activation;
- using Windows.UI.Core;
- using Windows.UI.Xaml;
- using Windows.UI.Xaml.Controls;
- using Windows.UI.Xaml.Navigation;
-
- namespace ViewShotExample
- {
-
-
-
- sealed partial class App : Application
- {
- private readonly ReactPage _reactPage;
-
-
-
-
-
- public App()
- {
- this.InitializeComponent();
- this.Suspending += OnSuspending;
- this.Resuming += OnResuming;
-
- _reactPage = new MainPage();
- }
-
-
-
-
-
-
- protected override void OnLaunched(LaunchActivatedEventArgs e)
- {
- base.OnLaunched(e);
- OnCreate(e.Arguments);
- }
-
-
-
-
-
- protected override void OnActivated(IActivatedEventArgs args)
- {
- base.OnActivated(args);
-
- switch (args.Kind)
- {
- case ActivationKind.Protocol:
- case ActivationKind.ProtocolForResults:
- var protocolArgs = (IProtocolActivatedEventArgs)args;
- LauncherModule.SetActivatedUrl(protocolArgs.Uri.AbsoluteUri);
- break;
- }
-
- if (args.PreviousExecutionState != ApplicationExecutionState.Running &&
- args.PreviousExecutionState != ApplicationExecutionState.Suspended)
- {
- OnCreate(null);
- }
- }
-
-
-
-
-
- private void OnCreate(string arguments)
- {
- _reactPage.OnResume(Exit);
-
- #if DEBUG
- if (System.Diagnostics.Debugger.IsAttached)
- {
- this.DebugSettings.EnableFrameRateCounter = true;
- }
-
- SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
- AppViewBackButtonVisibility.Visible;
- #endif
-
- Frame rootFrame = Window.Current.Content as Frame;
-
-
-
- if (rootFrame == null)
- {
- _reactPage.OnCreate(arguments);
-
-
- rootFrame = new Frame();
-
- rootFrame.NavigationFailed += OnNavigationFailed;
-
-
- Window.Current.Content = rootFrame;
- }
-
- if (rootFrame.Content == null)
- {
-
-
-
- rootFrame.Content = _reactPage;
- }
-
-
- Window.Current.Activate();
- }
-
-
-
-
-
-
- private void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
- {
- throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
- }
-
-
-
-
-
-
-
-
- private void OnSuspending(object sender, SuspendingEventArgs e)
- {
- _reactPage.OnSuspend();
- }
-
-
-
-
-
-
- private void OnResuming(object sender, object e)
- {
- _reactPage.OnResume(Exit);
- }
- }
- }
|