Debian Codegraph @

Xpjproject/pjsip-apps/src/pjsua/winrt/gui/uwp/Voip/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 using VoipTasks.BackgroundOperations;
18 using VoipUI.Helpers;
19 using System.Diagnostics;
20
21 namespace VoipUI
22 {
23 /// <summary>
24 /// Provides application-specific behavior to supplement the default Application class.
25 /// </summary>
26 sealed partial class App : Application
27 {
28 /// <summary>
29 /// Initializes the singleton application object. This is the first line of authored code
30 /// executed, and as such is the logical equivalent of main() or WinMain().
31 /// </summary>
32 public App()
33 {
34 Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(
35 Microsoft.ApplicationInsights.WindowsCollectors.Metadata |
36 Microsoft.ApplicationInsights.WindowsCollectors.Session);
37 this.InitializeComponent();
38 this.Suspending += OnSuspending;
39 }
40
41 /// <summary>
42 /// Invoked when the application is launched normally by the end user. Other entry points
43 /// will be used such as when the application is launched to open a specific file.
44 /// </summary>
45 /// <param name="e">Details about the launch request and process.</param>
46 protected override void OnLaunched(LaunchActivatedEventArgs e)
47 {
48
49 #if DEBUG
50 if (System.Diagnostics.Debugger.IsAttached)
51 {
52 this.DebugSettings.EnableFrameRateCounter = true;
53 }
54 #endif
55
56 Frame rootFrame = Window.Current.Content as Frame;
57
58 // Do not repeat app initialization when the Window already has content,
59 // just ensure that the window is active
60 if (rootFrame == null)
61 {
62 // Create a Frame to act as the navigation context and navigate to the first page
63 rootFrame = new Frame();
64
65 rootFrame.NavigationFailed += OnNavigationFailed;
66
67 if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
68 {
69 //TODO: Load state from previously suspended application
70 }
71
72 // Place the frame in the current Window
73 Window.Current.Content = rootFrame;
74 }
75
76 if (rootFrame.Content == null)
77 {
78 // When the navigation stack isn't restored navigate to the first page,
79 // configuring the new page by passing required information as a navigation
80 // parameter
81 rootFrame.Navigate(typeof(MainPage), e.Arguments);
82 }
83
84 /* Start service. */
85 StartServiceAsync();
86
87 // Ensure the current window is active
88 Window.Current.Activate();
89 }
90
91 private async void GetAccountInfoAsync()
92 {
93 try
94 {
95 OperationResult result = await EndpointHelper.GetAccountInfo();
96 }
97 catch (Exception ex)
98 {
99 Debug.WriteLine(ex.Message);
100 }
101 }
102
103 private async void StartServiceAsync()
104 {
105 try
106 {
107 OperationResult result = await EndpointHelper.StartServiceAsync();
108 }
109 catch (Exception ex)
110 {
111 Debug.WriteLine(ex.Message);
112 }
113 }
114
115 /// <summary>
116 /// Invoked when Navigation to a certain page fails
117 /// </summary>
118 /// <param name="sender">The Frame which failed navigation</param>
119 /// <param name="e">Details about the navigation failure</param>
120 void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
121 {
122 throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
123 }
124
125 /// <summary>
126 /// Invoked when application execution is being suspended. Application state is saved
127 /// without knowing whether the application will be terminated or resumed with the contents
128 /// of memory still intact.
129 /// </summary>
130 /// <param name="sender">The source of the suspend request.</param>
131 /// <param name="e">Details about the suspend request.</param>
132 private void OnSuspending(object sender, SuspendingEventArgs e)
133 {
134 var deferral = e.SuspendingOperation.GetDeferral();
135 //TODO: Save application state and stop any background activity
136 deferral.Complete();
137 }
138 }
139 }