Skip to content
This repository was archived by the owner on Jun 17, 2024. It is now read-only.

Commit 813a0f2

Browse files
committed
Merge branch 'o365-work' into origin365
Conflicts: README.md
2 parents f00fb83 + e8e87cd commit 813a0f2

38 files changed

+1682
-801
lines changed

OneNoteServiceSamplesWinUniversal.Shared/App.xaml.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,20 @@ public App()
4040
this.Suspending += this.OnSuspending;
4141
}
4242

43+
protected async override void OnActivated(IActivatedEventArgs e)
44+
{
45+
#if WINDOWS_PHONE_APP
46+
var rootFrame = Window.Current.Content as Frame;
47+
48+
var wabPage = rootFrame.Content as IWebAuthenticationContinuable;
49+
if (wabPage != null)
50+
{
51+
wabPage.ContinueWebAuthentication(e as WebAuthenticationBrokerContinuationEventArgs);
52+
}
53+
#endif
54+
Window.Current.Activate();
55+
}
56+
4357
/// <summary>
4458
/// Invoked when the application is launched normally by the end user. Other entry points
4559
/// will be used when the application is launched to open a specific file, to display
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using Windows.Storage;
5+
6+
namespace OneNoteServiceSamplesWinUniversal.Common
7+
{
8+
public static class AppSettings
9+
{
10+
public static bool GetProviderO365()
11+
{
12+
object result = false;
13+
ApplicationData.Current.LocalSettings.Values.TryGetValue("ProviderO365", out result);
14+
return (bool)(result ?? false);
15+
}
16+
public static void SetProviderO365(bool isO365)
17+
{
18+
ApplicationData.Current.LocalSettings.Values["ProviderO365"] = isO365;
19+
}
20+
21+
public static bool GetUseBeta()
22+
{
23+
object result = false;
24+
ApplicationData.Current.LocalSettings.Values.TryGetValue("UseBeta", out result);
25+
return (bool)(result ?? true); // default to true
26+
}
27+
public static void SetUseBeta(bool useBeta)
28+
{
29+
ApplicationData.Current.LocalSettings.Values["UseBeta"] = useBeta;
30+
}
31+
}
32+
}

OneNoteServiceSamplesWinUniversal.Shared/Common/NavigationHelper.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Windows.UI.Xaml;
1010
using Windows.UI.Xaml.Controls;
1111
using Windows.UI.Xaml.Navigation;
12+
using OneNoteServiceSamplesWinUniversal.OneNoteApi;
1213

1314
namespace OneNoteServiceSamplesWinUniversal.Common
1415
{
@@ -307,14 +308,14 @@ private void CoreWindow_PointerPressed(CoreWindow sender,
307308
/// </summary>
308309
public event SaveStateEventHandler SaveState;
309310

310-
/// <summary>
311-
/// Invoked when this page is about to be displayed in a Frame.
312-
/// This method calls <see cref="LoadState"/>, where all page specific
313-
/// navigation and process lifetime management logic should be placed.
314-
/// </summary>
315-
/// <param name="e">Event data that describes how this page was reached. The Parameter
316-
/// property provides the group to be displayed.</param>
317-
public void OnNavigatedTo(NavigationEventArgs e)
311+
/// <summary>
312+
/// Invoked when this page is about to be displayed in a Frame.
313+
/// This method calls <see cref="LoadState"/>, where all page specific
314+
/// navigation and process lifetime management logic should be placed.
315+
/// </summary>
316+
/// <param name="e">Event data that describes how this page was reached. The Parameter
317+
/// property provides the group to be displayed.</param>
318+
public void OnNavigatedTo(NavigationEventArgs e)
318319
{
319320
var frameState = SuspensionManager.SessionStateForFrame(this.Frame);
320321
this._pageKey = "Page-" + this.Frame.BackStackDepth;

OneNoteServiceSamplesWinUniversal.Shared/DataModel/ItemPageModel.cs

Lines changed: 55 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ namespace OneNoteServiceSamplesWinUniversal.DataModel
1111
{
1212
public class ItemPageModel : INotifyPropertyChanged
1313
{
14-
private string _authUserName = null; // Logged in user name
15-
private SampleDataItem _item = null; // Info about the current item
16-
private object _apiResponse = null; // Response from an API request - Either a ApiBaseResponse or a List<ApiBaseResponse>
17-
private ApiBaseResponse _selectedResponse = null; // Holds a reference to the currently selected response
14+
private string _authUserName = null; // Logged in user name
15+
private SampleDataItem _item = null; // Info about the current item
16+
private HubContext _userData = null;
17+
private object _apiResponse = null;
18+
// Response from an API request - Either a ApiBaseResponse or a List<ApiBaseResponse>
1819

19-
public event PropertyChangedEventHandler PropertyChanged; // Implements INotifyPropertyChanged for notifying the binding engine when an attribute changes
20+
private ApiBaseResponse _selectedResponse = null; // Holds a reference to the currently selected response
21+
22+
public event PropertyChangedEventHandler PropertyChanged;
23+
// Implements INotifyPropertyChanged for notifying the binding engine when an attribute changes
2024

2125
/// <summary>
2226
// NotifyPropertyChanged will fire the PropertyChanged event,
@@ -32,10 +36,7 @@ public void NotifyPropertyChanged(string propertyName)
3236

3337
public string AuthUserName
3438
{
35-
get
36-
{
37-
return _authUserName;
38-
}
39+
get { return _authUserName; }
3940

4041
set
4142
{
@@ -45,27 +46,9 @@ public string AuthUserName
4546
}
4647
}
4748

48-
public string SignInButtonTitle
49-
{
50-
get
51-
{
52-
string title = "Sign In";
53-
54-
if (Auth.IsSignedIn)
55-
{
56-
title = "Sign Out";
57-
}
58-
59-
return title;
60-
}
61-
}
62-
6349
public SampleDataItem Item
6450
{
65-
get
66-
{
67-
return _item;
68-
}
51+
get { return _item; }
6952

7053
set
7154
{
@@ -76,6 +59,7 @@ public SampleDataItem Item
7659

7760
public object ApiResponse
7861
{
62+
get { return _apiResponse as ApiBaseResponse; }
7963
set
8064
{
8165
_apiResponse = value;
@@ -85,14 +69,18 @@ public object ApiResponse
8569

8670
if (_apiResponse != null)
8771
{
88-
if (_apiResponse is ApiBaseResponse)
72+
var response = _apiResponse as ApiBaseResponse;
73+
if (response != null)
8974
{
90-
selectedResponse = _apiResponse as ApiBaseResponse;
75+
selectedResponse = response;
9176
}
9277
else
9378
{
94-
List<ApiBaseResponse> multipleResponses = _apiResponse as List<ApiBaseResponse>;
95-
selectedResponse = multipleResponses[0];
79+
var multipleResponses = _apiResponse as List<ApiBaseResponse>;
80+
if (multipleResponses != null)
81+
{
82+
selectedResponse = multipleResponses[0];
83+
}
9684
}
9785
}
9886

@@ -105,15 +93,13 @@ public object ApiResponse
10593
NotifyPropertyChanged("IsClientUrlAvailable");
10694
NotifyPropertyChanged("ResponseList");
10795
NotifyPropertyChanged("SelectedResponse");
96+
NotifyPropertyChanged("CorrelationId");
10897
}
10998
}
11099

111100
public ApiBaseResponse SelectedResponse
112101
{
113-
get
114-
{
115-
return _selectedResponse;
116-
}
102+
get { return _selectedResponse; }
117103

118104
set
119105
{
@@ -123,6 +109,17 @@ public ApiBaseResponse SelectedResponse
123109
}
124110
}
125111

112+
public HubContext UserData
113+
{
114+
get { return _userData; }
115+
116+
set
117+
{
118+
_userData = value;
119+
NotifyPropertyChanged("TimeStamp");
120+
}
121+
}
122+
126123
public string StatusCode
127124
{
128125
get
@@ -135,7 +132,7 @@ public string StatusCode
135132

136133
if (statusCode != 0)
137134
{
138-
statusCodeString = string.Format("{0}-{1}", (int)statusCode, statusCode.ToString());
135+
statusCodeString = string.Format("{0}-{1}", (int) statusCode, statusCode.ToString());
139136
}
140137
}
141138

@@ -149,7 +146,7 @@ public string Body
149146
{
150147
string body = string.Empty;
151148

152-
if (_selectedResponse != null)
149+
if (_selectedResponse != null && _selectedResponse.Body != null)
153150
{
154151
body = _selectedResponse.Body;
155152
}
@@ -175,10 +172,7 @@ public Thickness BodyBorderThikness
175172

176173
public bool IsResponseAvailable
177174
{
178-
get
179-
{
180-
return _apiResponse != null;
181-
}
175+
get { return _apiResponse != null; }
182176
}
183177

184178
public Visibility IsResponseListAvailable
@@ -198,10 +192,7 @@ public Visibility IsResponseListAvailable
198192

199193
public List<ApiBaseResponse> ResponseList
200194
{
201-
get
202-
{
203-
return _apiResponse as List<ApiBaseResponse>;
204-
}
195+
get { return _apiResponse as List<ApiBaseResponse>; }
205196
}
206197

207198
public Visibility IsClientUrlAvailable
@@ -248,5 +239,23 @@ public string OneNoteWebUrl
248239
return webUrl;
249240
}
250241
}
242+
243+
public string CorrelationId
244+
{
245+
get
246+
{
247+
return _selectedResponse != null && !string.IsNullOrEmpty(_selectedResponse.CorrelationId)
248+
? _selectedResponse.CorrelationId
249+
: string.Empty;
250+
}
251+
}
252+
253+
public string TimeStamp
254+
{
255+
get
256+
{
257+
return _userData != null ? _userData.TimeStamp.ToString() : string.Empty;
258+
}
259+
}
251260
}
252261
}

0 commit comments

Comments
 (0)