| 1 |
using System; |
| 2 |
using System.Collections.Generic; |
| 3 |
using System.IO; |
| 4 |
using System.Linq; |
| 5 |
using System.Runtime.InteropServices.WindowsRuntime; |
| 6 |
using Windows.ApplicationModel; |
| 7 |
using Windows.ApplicationModel.Activation; |
| 8 |
using Windows.Foundation; |
| 9 |
using Windows.Foundation.Collections; |
| 10 |
using Windows.UI.Xaml; |
| 11 |
using Windows.UI.Xaml.Controls; |
| 12 |
using Windows.UI.Xaml.Controls.Primitives; |
| 13 |
using Windows.UI.Xaml.Data; |
| 14 |
using Windows.UI.Xaml.Input; |
| 15 |
using Windows.UI.Xaml.Media; |
| 16 |
using Windows.UI.Xaml.Navigation; |
| 17 |
|
| 18 |
namespace PjsuaCLI.UI |
| 19 |
{ |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
sealed partial class App : Application |
| 24 |
{ |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
public App() |
| 30 |
{ |
| 31 |
Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync( |
| 32 |
Microsoft.ApplicationInsights.WindowsCollectors.Metadata | |
| 33 |
Microsoft.ApplicationInsights.WindowsCollectors.Session); |
| 34 |
this.InitializeComponent(); |
| 35 |
this.Suspending += OnSuspending; |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
protected override void OnLaunched(LaunchActivatedEventArgs e) |
| 44 |
{ |
| 45 |
|
| 46 |
#if DEBUG |
| 47 |
if (System.Diagnostics.Debugger.IsAttached) |
| 48 |
{ |
| 49 |
this.DebugSettings.EnableFrameRateCounter = true; |
| 50 |
} |
| 51 |
#endif |
| 52 |
|
| 53 |
Frame rootFrame = Window.Current.Content as Frame; |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
if (rootFrame == null) |
| 58 |
{ |
| 59 |
|
| 60 |
rootFrame = new Frame(); |
| 61 |
|
| 62 |
rootFrame.NavigationFailed += OnNavigationFailed; |
| 63 |
|
| 64 |
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) |
| 65 |
{ |
| 66 |
|
| 67 |
} |
| 68 |
|
| 69 |
|
| 70 |
Window.Current.Content = rootFrame; |
| 71 |
} |
| 72 |
|
| 73 |
if (rootFrame.Content == null) |
| 74 |
{ |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
rootFrame.Navigate(typeof(MainPage), e.Arguments); |
| 79 |
} |
| 80 |
|
| 81 |
Window.Current.Activate(); |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
void OnNavigationFailed(object sender, NavigationFailedEventArgs e) |
| 90 |
{ |
| 91 |
throw new Exception("Failed to load Page " + e.SourcePageType.FullName); |
| 92 |
} |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
private void OnSuspending(object sender, SuspendingEventArgs e) |
| 102 |
{ |
| 103 |
var deferral = e.SuspendingOperation.GetDeferral(); |
| 104 |
|
| 105 |
deferral.Complete(); |
| 106 |
} |
| 107 |
} |
| 108 |
} |