Debian Codegraph @

Xpjproject/pjsip-apps/src/pjsua/winrt/cli/uwp/App.xaml.cs

raw symbols SCIP
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 /// <summary>
21 /// Provides application-specific behavior to supplement the default Application class.
22 /// </summary>
23 sealed partial class App : Application
24 {
25 /// <summary>
26 /// Initializes the singleton application object. This is the first line of authored code
27 /// executed, and as such is the logical equivalent of main() or WinMain().
28 /// </summary>
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 /// <summary>
39 /// Invoked when the application is launched normally by the end user. Other entry points
40 /// will be used such as when the application is launched to open a specific file.
41 /// </summary>
42 /// <param name="e">Details about the launch request and process.</param>
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 // Do not repeat app initialization when the Window already has content,
56 // just ensure that the window is active
57 if (rootFrame == null)
58 {
59 // Create a Frame to act as the navigation context and navigate to the first page
60 rootFrame = new Frame();
61
62 rootFrame.NavigationFailed += OnNavigationFailed;
63
64 if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
65 {
66 //TODO: Load state from previously suspended application
67 }
68
69 // Place the frame in the current Window
70 Window.Current.Content = rootFrame;
71 }
72
73 if (rootFrame.Content == null)
74 {
75 // When the navigation stack isn't restored navigate to the first page,
76 // configuring the new page by passing required information as a navigation
77 // parameter
78 rootFrame.Navigate(typeof(MainPage), e.Arguments);
79 }
80 // Ensure the current window is active
81 Window.Current.Activate();
82 }
83
84 /// <summary>
85 /// Invoked when Navigation to a certain page fails
86 /// </summary>
87 /// <param name="sender">The Frame which failed navigation</param>
88 /// <param name="e">Details about the navigation failure</param>
89 void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
90 {
91 throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
92 }
93
94 /// <summary>
95 /// Invoked when application execution is being suspended. Application state is saved
96 /// without knowing whether the application will be terminated or resumed with the contents
97 /// of memory still intact.
98 /// </summary>
99 /// <param name="sender">The source of the suspend request.</param>
100 /// <param name="e">Details about the suspend request.</param>
101 private void OnSuspending(object sender, SuspendingEventArgs e)
102 {
103 var deferral = e.SuspendingOperation.GetDeferral();
104 //TODO: Save application state and stop any background activity
105 deferral.Complete();
106 }
107 }
108 }