1
- // Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. See full license at the bottom of this file.
2
-
3
- using Office365StarterProject . ViewModels ;
4
- using System ;
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . IO ;
4
+ using System . Linq ;
5
+ using System . Runtime . InteropServices . WindowsRuntime ;
5
6
using Windows . ApplicationModel ;
6
7
using Windows . ApplicationModel . Activation ;
8
+ using Windows . Foundation ;
9
+ using Windows . Foundation . Collections ;
10
+ using Windows . UI . Core ;
7
11
using Windows . UI . Xaml ;
8
12
using Windows . UI . Xaml . Controls ;
13
+ using Windows . UI . Xaml . Controls . Primitives ;
14
+ using Windows . UI . Xaml . Data ;
15
+ using Windows . UI . Xaml . Input ;
16
+ using Windows . UI . Xaml . Media ;
9
17
using Windows . UI . Xaml . Navigation ;
10
18
11
- // The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=234227
12
- namespace Office365StarterProject
19
+ namespace HubApp2
13
20
{
14
21
/// <summary>
15
22
/// Provides application-specific behavior to supplement the default Application class.
16
23
/// </summary>
17
24
sealed partial class App : Application
18
25
{
19
- /// <summary>
20
- /// Represents the current user of the sample.
21
- /// </summary>
22
- private static UserViewModel _currentUser ;
23
- public static UserViewModel CurrentUser
24
- {
25
- get
26
- {
27
- if ( _currentUser == null )
28
- {
29
- _currentUser = new UserViewModel ( ) ;
30
- }
31
- return _currentUser ;
32
- }
33
- }
34
26
/// <summary>
35
27
/// Initializes the singleton application object. This is the first line of authored code
36
28
/// executed, and as such is the logical equivalent of main() or WinMain().
37
29
/// </summary>
38
30
public App ( )
39
31
{
32
+ Microsoft . ApplicationInsights . WindowsAppInitializer . InitializeAsync (
33
+ Microsoft . ApplicationInsights . WindowsCollectors . Metadata |
34
+ Microsoft . ApplicationInsights . WindowsCollectors . Session ) ;
40
35
this . InitializeComponent ( ) ;
41
36
this . Suspending += OnSuspending ;
42
37
}
@@ -46,14 +41,13 @@ public App()
46
41
/// will be used such as when the application is launched to open a specific file.
47
42
/// </summary>
48
43
/// <param name="e">Details about the launch request and process.</param>
49
- [ System . Diagnostics . CodeAnalysis . SuppressMessage ( "Microsoft.Design" , "CA1062:Validate arguments of public methods" , MessageId = "0" ) ]
50
44
protected override void OnLaunched ( LaunchActivatedEventArgs e )
51
45
{
52
46
53
47
#if DEBUG
54
48
if ( System . Diagnostics . Debugger . IsAttached )
55
49
{
56
- this . DebugSettings . EnableFrameRateCounter = false ;
50
+ this . DebugSettings . EnableFrameRateCounter = true ;
57
51
}
58
52
#endif
59
53
@@ -65,10 +59,9 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
65
59
{
66
60
// Create a Frame to act as the navigation context and navigate to the first page
67
61
rootFrame = new Frame ( ) ;
68
- // Set the default language
69
- rootFrame . Language = Windows . Globalization . ApplicationLanguages . Languages [ 0 ] ;
70
62
71
63
rootFrame . NavigationFailed += OnNavigationFailed ;
64
+ rootFrame . Navigated += OnNavigated ;
72
65
73
66
if ( e . PreviousExecutionState == ApplicationExecutionState . Terminated )
74
67
{
@@ -77,19 +70,50 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
77
70
78
71
// Place the frame in the current Window
79
72
Window . Current . Content = rootFrame ;
73
+ ResiterBackMethod ( rootFrame ) ;
80
74
}
81
75
82
76
if ( rootFrame . Content == null )
83
77
{
84
78
// When the navigation stack isn't restored navigate to the first page,
85
79
// configuring the new page by passing required information as a navigation
86
80
// parameter
87
- rootFrame . Navigate ( typeof ( MainPage ) , e . Arguments ) ;
81
+ rootFrame . Navigate ( typeof ( HubPage ) , e . Arguments ) ;
88
82
}
89
83
// Ensure the current window is active
90
84
Window . Current . Activate ( ) ;
91
85
}
92
86
87
+ /// <summary>
88
+ /// Invoked when the application is launched normally by the end user. Other entry points
89
+ /// will be used such as when the application is launched to open a specific file.
90
+ /// </summary>
91
+ /// <param name="e">Details about the launch request and process.</param>
92
+ private void ResiterBackMethod ( Frame rootFrame )
93
+ {
94
+ SystemNavigationManager . GetForCurrentView ( ) . BackRequested += ( s , a ) =>
95
+ {
96
+ if ( rootFrame . CanGoBack )
97
+ {
98
+ rootFrame . GoBack ( ) ;
99
+ a . Handled = true ;
100
+ }
101
+ } ;
102
+
103
+ SystemNavigationManager . GetForCurrentView ( ) . AppViewBackButtonVisibility =
104
+ rootFrame . CanGoBack ?
105
+ AppViewBackButtonVisibility . Visible :
106
+ AppViewBackButtonVisibility . Collapsed ;
107
+ }
108
+
109
+ private void OnNavigated ( object sender , NavigationEventArgs e )
110
+ {
111
+ SystemNavigationManager . GetForCurrentView ( ) . AppViewBackButtonVisibility =
112
+ ( ( Frame ) sender ) . CanGoBack ?
113
+ AppViewBackButtonVisibility . Visible :
114
+ AppViewBackButtonVisibility . Collapsed ;
115
+ }
116
+
93
117
/// <summary>
94
118
/// Invoked when Navigation to a certain page fails
95
119
/// </summary>
@@ -115,26 +139,3 @@ private void OnSuspending(object sender, SuspendingEventArgs e)
115
139
}
116
140
}
117
141
}
118
- //*********************************************************
119
- //
120
- // MIT License:
121
- // Permission is hereby granted, free of charge, to any person obtaining
122
- // a copy of this software and associated documentation files (the
123
- // ""Software""), to deal in the Software without restriction, including
124
- // without limitation the rights to use, copy, modify, merge, publish,
125
- // distribute, sublicense, and/or sell copies of the Software, and to
126
- // permit persons to whom the Software is furnished to do so, subject to
127
- // the following conditions:
128
-
129
- // The above copyright notice and this permission notice shall be
130
- // included in all copies or substantial portions of the Software.
131
-
132
- // THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND,
133
- // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
134
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
135
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
136
- // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
137
- // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
138
- // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
139
- //
140
- //*********************************************************
0 commit comments