| 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 |
|
| 24 |
|
| 25 |
|
| 26 |
sealed partial class App : Application |
| 27 |
{ |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 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 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 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 |
|
| 59 |
|
| 60 |
if (rootFrame == null) |
| 61 |
{ |
| 62 |
|
| 63 |
rootFrame = new Frame(); |
| 64 |
|
| 65 |
rootFrame.NavigationFailed += OnNavigationFailed; |
| 66 |
|
| 67 |
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) |
| 68 |
{ |
| 69 |
|
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
Window.Current.Content = rootFrame; |
| 74 |
} |
| 75 |
|
| 76 |
if (rootFrame.Content == null) |
| 77 |
{ |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
rootFrame.Navigate(typeof(MainPage), e.Arguments); |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
StartServiceAsync(); |
| 86 |
|
| 87 |
|
| 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 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
void OnNavigationFailed(object sender, NavigationFailedEventArgs e) |
| 121 |
{ |
| 122 |
throw new Exception("Failed to load Page " + e.SourcePageType.FullName); |
| 123 |
} |
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
private void OnSuspending(object sender, SuspendingEventArgs e) |
| 133 |
{ |
| 134 |
var deferral = e.SuspendingOperation.GetDeferral(); |
| 135 |
|
| 136 |
deferral.Complete(); |
| 137 |
} |
| 138 |
} |
| 139 |
} |