├── .nuget
├── NuGet.exe
├── NuGet.Config
└── NuGet.targets
├── WinPhoneOneNoteServiceSample
├── Assets
│ ├── Logo.jpg
│ ├── attachment.pdf
│ ├── AlignmentGrid.png
│ ├── ApplicationIcon.png
│ └── Tiles
│ │ ├── IconicTileSmall.png
│ │ ├── FlipCycleTileLarge.png
│ │ ├── FlipCycleTileMedium.png
│ │ ├── FlipCycleTileSmall.png
│ │ └── IconicTileMediumLarge.png
├── Fonts
│ └── LiveSymbol.ttf
├── Resources
│ ├── OneNote-MX-logo.png
│ ├── AppResources.Designer.cs
│ └── AppResources.resx
├── Properties
│ ├── AppManifest.xml
│ ├── WMAppManifest.xml
│ └── AssemblyInfo.cs
├── LocalizedStrings.cs
├── packages.config
├── CodeAnalysisRules.ruleset
├── App.xaml
├── StandardResponse.cs
├── MainPage.xaml
├── App.xaml.cs
├── WinPhoneOneNoteServiceSample.csproj
└── MainPage.xaml.cs
├── WinPhoneOneNoteServiceSample.sln
├── README.md
└── LICENSE.txt
/.nuget/NuGet.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneNoteDev/OneNoteAPISampleWinPhone/master/.nuget/NuGet.exe
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample/Assets/Logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneNoteDev/OneNoteAPISampleWinPhone/master/WinPhoneOneNoteServiceSample/Assets/Logo.jpg
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample/Assets/attachment.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneNoteDev/OneNoteAPISampleWinPhone/master/WinPhoneOneNoteServiceSample/Assets/attachment.pdf
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample/Fonts/LiveSymbol.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneNoteDev/OneNoteAPISampleWinPhone/master/WinPhoneOneNoteServiceSample/Fonts/LiveSymbol.ttf
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample/Assets/AlignmentGrid.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneNoteDev/OneNoteAPISampleWinPhone/master/WinPhoneOneNoteServiceSample/Assets/AlignmentGrid.png
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample/Assets/ApplicationIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneNoteDev/OneNoteAPISampleWinPhone/master/WinPhoneOneNoteServiceSample/Assets/ApplicationIcon.png
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample/Resources/OneNote-MX-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneNoteDev/OneNoteAPISampleWinPhone/master/WinPhoneOneNoteServiceSample/Resources/OneNote-MX-logo.png
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample/Assets/Tiles/IconicTileSmall.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneNoteDev/OneNoteAPISampleWinPhone/master/WinPhoneOneNoteServiceSample/Assets/Tiles/IconicTileSmall.png
--------------------------------------------------------------------------------
/.nuget/NuGet.Config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample/Assets/Tiles/FlipCycleTileLarge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneNoteDev/OneNoteAPISampleWinPhone/master/WinPhoneOneNoteServiceSample/Assets/Tiles/FlipCycleTileLarge.png
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample/Assets/Tiles/FlipCycleTileMedium.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneNoteDev/OneNoteAPISampleWinPhone/master/WinPhoneOneNoteServiceSample/Assets/Tiles/FlipCycleTileMedium.png
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample/Assets/Tiles/FlipCycleTileSmall.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneNoteDev/OneNoteAPISampleWinPhone/master/WinPhoneOneNoteServiceSample/Assets/Tiles/FlipCycleTileSmall.png
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample/Assets/Tiles/IconicTileMediumLarge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OneNoteDev/OneNoteAPISampleWinPhone/master/WinPhoneOneNoteServiceSample/Assets/Tiles/IconicTileMediumLarge.png
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample/Properties/AppManifest.xml:
--------------------------------------------------------------------------------
1 |
21 |
22 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample/LocalizedStrings.cs:
--------------------------------------------------------------------------------
1 | //*********************************************************
2 | // Copyright (c) Microsoft Corporation
3 | // All rights reserved.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the ""License"");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT
11 | // WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS
12 | // OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
13 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR
14 | // PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
15 | //
16 | // See the Apache Version 2.0 License for specific language
17 | // governing permissions and limitations under the License.
18 | //*********************************************************
19 |
20 | using WinPhoneOneNoteServiceSample.Resources;
21 |
22 | namespace WinPhoneOneNoteServiceSample
23 | {
24 | ///
25 | /// Provides access to string resources.
26 | ///
27 | public class LocalizedStrings
28 | {
29 | private static AppResources _localizedResources = new AppResources();
30 |
31 | public AppResources LocalizedResources { get { return _localizedResources; } }
32 | }
33 | }
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample/CodeAnalysisRules.ruleset:
--------------------------------------------------------------------------------
1 |
2 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample/App.xaml:
--------------------------------------------------------------------------------
1 |
21 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample/Properties/WMAppManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Assets\ApplicationIcon.png
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | Assets\Tiles\FlipCycleTileSmall.png
21 | 0
22 | Assets\Tiles\FlipCycleTileMedium.png
23 | WinPhoneOneNoteServiceSample
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2012
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinPhoneOneNoteServiceSample", "WinPhoneOneNoteServiceSample\WinPhoneOneNoteServiceSample.csproj", "{754B7B40-6677-44F6-A396-462677E6C394}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Any CPU = Debug|Any CPU
9 | Debug|ARM = Debug|ARM
10 | Debug|x86 = Debug|x86
11 | Release|Any CPU = Release|Any CPU
12 | Release|ARM = Release|ARM
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {754B7B40-6677-44F6-A396-462677E6C394}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {754B7B40-6677-44F6-A396-462677E6C394}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {754B7B40-6677-44F6-A396-462677E6C394}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
19 | {754B7B40-6677-44F6-A396-462677E6C394}.Debug|ARM.ActiveCfg = Debug|ARM
20 | {754B7B40-6677-44F6-A396-462677E6C394}.Debug|ARM.Build.0 = Debug|ARM
21 | {754B7B40-6677-44F6-A396-462677E6C394}.Debug|ARM.Deploy.0 = Debug|ARM
22 | {754B7B40-6677-44F6-A396-462677E6C394}.Debug|x86.ActiveCfg = Debug|x86
23 | {754B7B40-6677-44F6-A396-462677E6C394}.Debug|x86.Build.0 = Debug|x86
24 | {754B7B40-6677-44F6-A396-462677E6C394}.Debug|x86.Deploy.0 = Debug|x86
25 | {754B7B40-6677-44F6-A396-462677E6C394}.Release|Any CPU.ActiveCfg = Release|Any CPU
26 | {754B7B40-6677-44F6-A396-462677E6C394}.Release|Any CPU.Build.0 = Release|Any CPU
27 | {754B7B40-6677-44F6-A396-462677E6C394}.Release|Any CPU.Deploy.0 = Release|Any CPU
28 | {754B7B40-6677-44F6-A396-462677E6C394}.Release|ARM.ActiveCfg = Release|ARM
29 | {754B7B40-6677-44F6-A396-462677E6C394}.Release|ARM.Build.0 = Release|ARM
30 | {754B7B40-6677-44F6-A396-462677E6C394}.Release|ARM.Deploy.0 = Release|ARM
31 | {754B7B40-6677-44F6-A396-462677E6C394}.Release|x86.ActiveCfg = Release|x86
32 | {754B7B40-6677-44F6-A396-462677E6C394}.Release|x86.Build.0 = Release|x86
33 | {754B7B40-6677-44F6-A396-462677E6C394}.Release|x86.Deploy.0 = Release|x86
34 | EndGlobalSection
35 | GlobalSection(SolutionProperties) = preSolution
36 | HideSolutionNode = FALSE
37 | EndGlobalSection
38 | EndGlobal
39 |
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | //*********************************************************
2 | // Copyright (c) Microsoft Corporation
3 | // All rights reserved.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the ""License"");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT
11 | // WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS
12 | // OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
13 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR
14 | // PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
15 | //
16 | // See the Apache Version 2.0 License for specific language
17 | // governing permissions and limitations under the License.
18 | //*********************************************************
19 |
20 | using System.Reflection;
21 | using System.Runtime.CompilerServices;
22 | using System.Runtime.InteropServices;
23 | using System.Resources;
24 |
25 | // General Information about an assembly is controlled through the following
26 | // set of attributes. Change these attribute values to modify the information
27 | // associated with an assembly.
28 | [assembly: AssemblyTitle("WinPhoneOneNoteServiceSample")]
29 | [assembly: AssemblyDescription("")]
30 | [assembly: AssemblyConfiguration("")]
31 | [assembly: AssemblyCompany("")]
32 | [assembly: AssemblyProduct("WinPhoneOneNoteServiceSample")]
33 | [assembly: AssemblyCopyright("Copyright © 2013")]
34 | [assembly: AssemblyTrademark("")]
35 | [assembly: AssemblyCulture("")]
36 |
37 | // Setting ComVisible to false makes the types in this assembly not visible
38 | // to COM components. If you need to access a type in this assembly from
39 | // COM, set the ComVisible attribute to true on that type.
40 | [assembly: ComVisible(false)]
41 |
42 | // The following GUID is for the ID of the typelib if this project is exposed to COM
43 | [assembly: Guid("dfadc673-1389-4ee5-a542-e4180d8f1c57")]
44 |
45 | // Version information for an assembly consists of the following four values:
46 | //
47 | // Major Version
48 | // Minor Version
49 | // Build Number
50 | // Revision
51 | //
52 | // You can specify all the values or you can default the Revision and Build Numbers
53 | // by using the '*' as shown below:
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 | [assembly: NeutralResourcesLanguageAttribute("en-US")]
57 |
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample/StandardResponse.cs:
--------------------------------------------------------------------------------
1 | //*********************************************************
2 | // Copyright (c) Microsoft Corporation
3 | // All rights reserved.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the ""License"");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT
11 | // WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS
12 | // OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
13 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR
14 | // PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
15 | //
16 | // See the Apache Version 2.0 License for specific language
17 | // governing permissions and limitations under the License.
18 | //*********************************************************
19 |
20 | using System.Net;
21 |
22 | namespace WinPhoneOneNoteServiceSample
23 | {
24 | ///
25 | /// Base class representing a simplified response from a service call
26 | ///
27 | public abstract class StandardResponse
28 | {
29 | public HttpStatusCode StatusCode { get; set; }
30 |
31 | ///
32 | /// Per call identifier that can be logged to diagnose issues with Microsoft support
33 | ///
34 | public string CorrelationId { get; set; }
35 | }
36 |
37 | ///
38 | /// Class representing standard error from the service
39 | ///
40 | public class StandardErrorResponse : StandardResponse
41 | {
42 | ///
43 | /// Error message - intended for developer, not end user
44 | ///
45 | public string Message { get; set; }
46 |
47 | ///
48 | /// Constructor
49 | ///
50 | public StandardErrorResponse()
51 | {
52 | this.StatusCode = HttpStatusCode.InternalServerError;
53 | }
54 | }
55 |
56 | ///
57 | /// Class representing a successful create call from the service
58 | ///
59 | public class CreateSuccessResponse : StandardResponse
60 | {
61 | ///
62 | /// URL to launch OneNote rich client
63 | ///
64 | public string OneNoteClientUrl { get; set; }
65 |
66 | ///
67 | /// URL to launch OneNote web experience
68 | ///
69 | public string OneNoteWebUrl { get; set; }
70 | }
71 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## OneNote service API Windows Phone Sample README
2 |
3 | Created by Microsoft Corporation, 2014. Provided As-is without warranty. Trademarks mentioned here are the property of their owners.
4 |
5 |
6 | ### API functionality demonstrated in this sample
7 | ###The below code sample should be considered for legacy reasons only. For the most up to date Windows code samples, see the newer and more detailed [Windows Universal code sample](https://github.com/OneNoteDev/OneNoteAPISampleWinUniversal)
8 |
9 | The following aspects of the API are covered in this sample. You can
10 | find additional documentation at the links below.
11 |
12 | * [Log-in the user using the Live SDK](http://msdn.microsoft.com/EN-US/library/office/dn575435.aspx)
13 | * [POST simple HTML to a new OneNote QuickNotes page](http://msdn.microsoft.com/EN-US/library/office/dn575428.aspx)
14 | * [POST page in a specific section](http://msdn.microsoft.com/EN-US/library/office/dn672416.aspx)
15 | * [POST multi-part message with image data included in the request](http://msdn.microsoft.com/EN-US/library/office/dn575432.aspx)
16 | * [POST page with a URL rendered as an image](http://msdn.microsoft.com/EN-US/library/office/dn575431.aspx)
17 | * [POST page with a file attachment](http://msdn.microsoft.com/en-us/library/office/dn575436.aspx)
18 | * [POST page with a PDF file rendered and attached](http://msdn.microsoft.com/EN-US/library/office/dn655137.aspx)
19 | * [Extract the returned oneNoteClientURL and oneNoteWebURL links](http://msdn.microsoft.com/EN-US/library/office/dn575433.aspx)
20 |
21 | ### Prerequisites
22 |
23 | **Tools and Libraries** you will need to download, install, and configure for your development environment.
24 |
25 | * [Visual Studio 2012 or 2013](http://www.visualstudio.com/en-us/downloads).
26 |
27 | Be sure you enable the Windows Phone SDK when you install Visual Studio.
28 | If you don't, you will need to uninstall and re-install Visual Studio to get
29 | those features.
30 |
31 | **NuGet packages** used in the sample. These are handled using the package
32 | manager, as described in the setup instructions. These should update
33 | automatically at build time; if not, make sure your NuGet package manager
34 | is up-to-date. You can learn more about the packages we used at the links below.
35 |
36 | * [Newtonsoft Json.NET package](http://newtonsoft.com/) provides Json parsing utilities.
37 | * [Windows Live Connect SDK](https://github.com/liveservices/LiveSDK-for-Windows) provides the sign-in and authorization libraries
38 | * [.NET Http.client library](https://www.nuget.org/packages/Microsoft.Net.Http/) provides libraries that handle the HTTP request/responses.
39 | * [Microsoft BCL Build components](https://www.nuget.org/packages/Microsoft.Bcl.Build) provide build-infrastructure components.
40 | * [Microsoft BCL Portability Pack](https://www.nuget.org/packages/Microsoft.Bcl/) provides support for down-level data types.
41 |
42 | **Accounts**
43 |
44 | * As the developer, you'll need to [have a Microsoft account and get a client ID string](http://msdn.microsoft.com/EN-US/library/office/dn575426.aspx)
45 | so your app can authenticate with the Microsoft Live connect SDK.
46 |
47 | ### Using the sample
48 |
49 | After you've setup your development tools, and installed the prerequisites listed above,...
50 |
51 | 1. Download the repo as a ZIP file to your local computer, and extract the files. Or, clone the repository into a local copy of Git.
52 | 2. Open the project in Visual Studio.
53 | 3. Get a client ID string and copy it into the file .../MainPage.xaml.cs (~line 63).
54 | 4. Build and run the app (F5).
55 |
56 | (If your copy of NuGet is up-to-date, it should automatically
57 | update the packages. If you get package-not-found errors, update NuGet and rebuild, and that
58 | should fix it.)
59 |
60 | 5. Sign in to your Microsoft account in the running app.
61 | 6. Allow the app to create new pages in OneNote.
62 |
63 | ### Version Info
64 |
65 | This is the initial public release for this code sample.
66 |
67 | ### Learning More
68 |
69 | * Visit the [dev.onenote.com](http://dev.onenote.com) Dev Center
70 | * Contact us on [StackOverflow (tagged OneNote)](http://go.microsoft.com/fwlink/?LinkID=390182)
71 | * Follow us on [Twitter @onenotedev](http://www.twitter.com/onenotedev)
72 | * Read our [OneNote Developer blog](http://go.microsoft.com/fwlink/?LinkID=390183)
73 | * Explore the API using the [apigee.com interactive console](http://go.microsoft.com/fwlink/?LinkID=392871).
74 | Also, see the [short overview/tutorial](http://go.microsoft.com/fwlink/?LinkID=390179).
75 | * [API Reference](http://msdn.microsoft.com/en-us/library/office/dn575437.aspx) documentation
76 | * [Debugging / Troubleshooting](http://msdn.microsoft.com/EN-US/library/office/dn575430.aspx)
77 | * [Getting Started](http://go.microsoft.com/fwlink/?LinkID=331026) with the OneNote service API
78 |
79 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
80 |
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample/Resources/AppResources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.34003
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace WinPhoneOneNoteServiceSample.Resources {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | public class AppResources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal AppResources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | public static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WinPhoneOneNoteServiceSample.Resources.AppResources", typeof(AppResources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | public static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized string similar to add.
65 | ///
66 | public static string AppBarButtonText {
67 | get {
68 | return ResourceManager.GetString("AppBarButtonText", resourceCulture);
69 | }
70 | }
71 |
72 | ///
73 | /// Looks up a localized string similar to Menu Item.
74 | ///
75 | public static string AppBarMenuItemText {
76 | get {
77 | return ResourceManager.GetString("AppBarMenuItemText", resourceCulture);
78 | }
79 | }
80 |
81 | ///
82 | /// Looks up a localized string similar to MY APPLICATION.
83 | ///
84 | public static string ApplicationTitle {
85 | get {
86 | return ResourceManager.GetString("ApplicationTitle", resourceCulture);
87 | }
88 | }
89 |
90 | ///
91 | /// Looks up a localized resource of type System.Byte[].
92 | ///
93 | public static byte[] OneNote_MX_logo {
94 | get {
95 | object obj = ResourceManager.GetObject("OneNote_MX_logo", resourceCulture);
96 | return ((byte[])(obj));
97 | }
98 | }
99 |
100 | ///
101 | /// Looks up a localized string similar to LeftToRight.
102 | ///
103 | public static string ResourceFlowDirection {
104 | get {
105 | return ResourceManager.GetString("ResourceFlowDirection", resourceCulture);
106 | }
107 | }
108 |
109 | ///
110 | /// Looks up a localized string similar to en-US.
111 | ///
112 | public static string ResourceLanguage {
113 | get {
114 | return ResourceManager.GetString("ResourceLanguage", resourceCulture);
115 | }
116 | }
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
14 |
15 |
35 |
36 |
37 |
38 | Insert Your Client Id Here
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
74 |
75 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample/Resources/AppResources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | LeftToRight
122 | Controls the FlowDirection for all elements in the RootFrame. Set to the traditional direction of this resource file's language
123 |
124 |
125 | en-US
126 | Controls the Language and ensures that the font for all elements in the RootFrame aligns with the app's language. Set to the language code of this resource file's language.
127 |
128 |
129 | MY APPLICATION
130 |
131 |
132 | add
133 |
134 |
135 | Menu Item
136 |
137 |
138 |
139 | OneNote-MX-logo.png;System.Byte[], mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
140 |
141 |
--------------------------------------------------------------------------------
/.nuget/NuGet.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildProjectDirectory)\..\
5 |
6 |
7 | false
8 |
9 |
10 | false
11 |
12 |
13 | true
14 |
15 |
16 | false
17 |
18 |
19 |
20 |
21 |
22 |
26 |
27 |
28 |
29 |
30 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget"))
31 |
32 |
33 |
34 |
35 | $(SolutionDir).nuget
36 |
37 |
38 |
39 | packages.$(MSBuildProjectName.Replace(' ', '_')).config
40 |
41 |
42 |
43 |
44 |
45 | $(PackagesProjectConfig)
46 |
47 |
48 |
49 |
50 | packages.config
51 |
52 |
53 |
54 |
55 |
56 |
57 | $(NuGetToolsPath)\NuGet.exe
58 | @(PackageSource)
59 |
60 | "$(NuGetExePath)"
61 | mono --runtime=v4.0.30319 $(NuGetExePath)
62 |
63 | $(TargetDir.Trim('\\'))
64 |
65 | -RequireConsent
66 | -NonInteractive
67 |
68 | "$(SolutionDir) "
69 | "$(SolutionDir)"
70 |
71 |
72 | $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir)
73 | $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols
74 |
75 |
76 |
77 | RestorePackages;
78 | $(BuildDependsOn);
79 |
80 |
81 |
82 |
83 | $(BuildDependsOn);
84 | BuildPackage;
85 |
86 |
87 |
88 |
89 |
90 |
91 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
106 |
107 |
110 |
111 |
112 |
113 |
115 |
116 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
148 |
149 |
150 |
151 |
152 |
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample/App.xaml.cs:
--------------------------------------------------------------------------------
1 | //*********************************************************
2 | //
3 | // Copyright (c) Microsoft. All rights reserved.
4 | // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
5 | // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
6 | // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
7 | // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
8 | //
9 | //*********************************************************
10 |
11 | using System;
12 | using System.Diagnostics;
13 | using System.Resources;
14 | using System.Windows;
15 | using System.Windows.Markup;
16 | using System.Windows.Navigation;
17 | using Microsoft.Phone.Controls;
18 | using Microsoft.Phone.Shell;
19 | using WinPhoneOneNoteServiceSample.Resources;
20 |
21 | namespace WinPhoneOneNoteServiceSample
22 | {
23 | public partial class App : Application
24 | {
25 | ///
26 | /// Provides easy access to the root frame of the Phone Application.
27 | ///
28 | /// The root frame of the Phone Application.
29 | public static PhoneApplicationFrame RootFrame { get; private set; }
30 |
31 | ///
32 | /// Constructor for the Application object.
33 | ///
34 | public App()
35 | {
36 | // Global handler for uncaught exceptions.
37 | UnhandledException += Application_UnhandledException;
38 |
39 | // Standard XAML initialization
40 | InitializeComponent();
41 |
42 | // Phone-specific initialization
43 | InitializePhoneApplication();
44 |
45 | // Language display initialization
46 | InitializeLanguage();
47 |
48 | // Show graphics profiling information while debugging.
49 | if (Debugger.IsAttached)
50 | {
51 | // Display the current frame rate counters.
52 | Application.Current.Host.Settings.EnableFrameRateCounter = true;
53 |
54 | // Show the areas of the app that are being redrawn in each frame.
55 | //Application.Current.Host.Settings.EnableRedrawRegions = true;
56 |
57 | // Enable non-production analysis visualization mode,
58 | // which shows areas of a page that are handed off to GPU with a colored overlay.
59 | //Application.Current.Host.Settings.EnableCacheVisualization = true;
60 |
61 | // Prevent the screen from turning off while under the debugger by disabling
62 | // the application's idle detection.
63 | // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
64 | // and consume battery power when the user is not using the phone.
65 | PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
66 | }
67 |
68 | }
69 |
70 | // Code to execute when the application is launching (eg, from Start)
71 | // This code will not execute when the application is reactivated
72 | private void Application_Launching(object sender, LaunchingEventArgs e)
73 | {
74 | }
75 |
76 | // Code to execute when the application is activated (brought to foreground)
77 | // This code will not execute when the application is first launched
78 | private void Application_Activated(object sender, ActivatedEventArgs e)
79 | {
80 | }
81 |
82 | // Code to execute when the application is deactivated (sent to background)
83 | // This code will not execute when the application is closing
84 | private void Application_Deactivated(object sender, DeactivatedEventArgs e)
85 | {
86 | }
87 |
88 | // Code to execute when the application is closing (eg, user hit Back)
89 | // This code will not execute when the application is deactivated
90 | private void Application_Closing(object sender, ClosingEventArgs e)
91 | {
92 | }
93 |
94 | // Code to execute if a navigation fails
95 | private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
96 | {
97 | if (Debugger.IsAttached)
98 | {
99 | // A navigation has failed; break into the debugger
100 | Debugger.Break();
101 | }
102 | }
103 |
104 | // Code to execute on Unhandled Exceptions
105 | private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
106 | {
107 | if (Debugger.IsAttached)
108 | {
109 | // An unhandled exception has occurred; break into the debugger
110 | Debugger.Break();
111 | }
112 | }
113 |
114 | #region Phone application initialization
115 |
116 | // Avoid double-initialization
117 | private bool phoneApplicationInitialized = false;
118 |
119 | // Do not add any additional code to this method
120 | private void InitializePhoneApplication()
121 | {
122 | if (phoneApplicationInitialized)
123 | return;
124 |
125 | // Create the frame but don't set it as RootVisual yet; this allows the splash
126 | // screen to remain active until the application is ready to render.
127 | RootFrame = new PhoneApplicationFrame();
128 | RootFrame.Navigated += CompleteInitializePhoneApplication;
129 |
130 | // Handle navigation failures
131 | RootFrame.NavigationFailed += RootFrame_NavigationFailed;
132 |
133 | // Handle reset requests for clearing the backstack
134 | RootFrame.Navigated += CheckForResetNavigation;
135 |
136 | // Ensure we don't initialize again
137 | phoneApplicationInitialized = true;
138 | }
139 |
140 | // Do not add any additional code to this method
141 | private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
142 | {
143 | // Set the root visual to allow the application to render
144 | if (RootVisual != RootFrame)
145 | RootVisual = RootFrame;
146 |
147 | // Remove this handler since it is no longer needed
148 | RootFrame.Navigated -= CompleteInitializePhoneApplication;
149 | }
150 |
151 | private void CheckForResetNavigation(object sender, NavigationEventArgs e)
152 | {
153 | // If the app has received a 'reset' navigation, then we need to check
154 | // on the next navigation to see if the page stack should be reset
155 | if (e.NavigationMode == NavigationMode.Reset)
156 | RootFrame.Navigated += ClearBackStackAfterReset;
157 | }
158 |
159 | private void ClearBackStackAfterReset(object sender, NavigationEventArgs e)
160 | {
161 | // Unregister the event so it doesn't get called again
162 | RootFrame.Navigated -= ClearBackStackAfterReset;
163 |
164 | // Only clear the stack for 'new' (forward) and 'refresh' navigations
165 | if (e.NavigationMode != NavigationMode.New && e.NavigationMode != NavigationMode.Refresh)
166 | return;
167 |
168 | // For UI consistency, clear the entire page stack
169 | while (RootFrame.RemoveBackEntry() != null)
170 | {
171 | ; // do nothing
172 | }
173 | }
174 |
175 | #endregion
176 |
177 | // Initialize the app's font and flow direction as defined in its localized resource strings.
178 | //
179 | // To ensure that the font of your application is aligned with its supported languages and that the
180 | // FlowDirection for each of those languages follows its traditional direction, ResourceLanguage
181 | // and ResourceFlowDirection should be initialized in each resx file to match these values with that
182 | // file's culture. For example:
183 | //
184 | // AppResources.es-ES.resx
185 | // ResourceLanguage's value should be "es-ES"
186 | // ResourceFlowDirection's value should be "LeftToRight"
187 | //
188 | // AppResources.ar-SA.resx
189 | // ResourceLanguage's value should be "ar-SA"
190 | // ResourceFlowDirection's value should be "RightToLeft"
191 | //
192 | // For more info on localizing Windows Phone apps see http://go.microsoft.com/fwlink/?LinkId=262072.
193 | //
194 | private void InitializeLanguage()
195 | {
196 | try
197 | {
198 | // Set the font to match the display language defined by the
199 | // ResourceLanguage resource string for each supported language.
200 | //
201 | // Fall back to the font of the neutral language if the Display
202 | // language of the phone is not supported.
203 | //
204 | // If a compiler error is hit then ResourceLanguage is missing from
205 | // the resource file.
206 | RootFrame.Language = XmlLanguage.GetLanguage(AppResources.ResourceLanguage);
207 |
208 | // Set the FlowDirection of all elements under the root frame based
209 | // on the ResourceFlowDirection resource string for each
210 | // supported language.
211 | //
212 | // If a compiler error is hit then ResourceFlowDirection is missing from
213 | // the resource file.
214 | FlowDirection flow = (FlowDirection)Enum.Parse(typeof(FlowDirection), AppResources.ResourceFlowDirection);
215 | RootFrame.FlowDirection = flow;
216 | }
217 | catch
218 | {
219 | // If an exception is caught here it is most likely due to either
220 | // ResourceLangauge not being correctly set to a supported language
221 | // code or ResourceFlowDirection is set to a value other than LeftToRight
222 | // or RightToLeft.
223 |
224 | if (Debugger.IsAttached)
225 | {
226 | Debugger.Break();
227 | }
228 |
229 | throw;
230 | }
231 | }
232 | }
233 | }
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample/WinPhoneOneNoteServiceSample.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 10.0.20506
7 | 2.0
8 | {754B7B40-6677-44F6-A396-462677E6C394}
9 | {C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
10 | Library
11 | Properties
12 | WinPhoneOneNoteServiceSample
13 | WinPhoneOneNoteServiceSample
14 | WindowsPhone
15 | v8.0
16 | $(TargetFrameworkVersion)
17 | true
18 |
19 |
20 | true
21 | true
22 | WinPhoneOneNoteServiceSample_$(Configuration)_$(Platform).xap
23 | Properties\AppManifest.xml
24 | WinPhoneOneNoteServiceSample.App
25 | true
26 | 11.0
27 | true
28 | ..\
29 | true
30 |
31 |
32 | true
33 | full
34 | false
35 | Bin\Debug
36 | DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE
37 | true
38 | true
39 | prompt
40 | 4
41 |
42 |
43 | pdbonly
44 | true
45 | Bin\Release
46 | TRACE;SILVERLIGHT;WINDOWS_PHONE
47 | true
48 | true
49 | prompt
50 | 4
51 |
52 |
53 | true
54 | full
55 | false
56 | Bin\x86\Debug
57 | DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE
58 | true
59 | true
60 | prompt
61 | 4
62 |
63 |
64 | pdbonly
65 | true
66 | Bin\x86\Release
67 | TRACE;SILVERLIGHT;WINDOWS_PHONE
68 | true
69 | true
70 | prompt
71 | 4
72 |
73 |
74 | true
75 | full
76 | false
77 | Bin\ARM\Debug
78 | DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE
79 | true
80 | true
81 | prompt
82 | 4
83 |
84 |
85 | pdbonly
86 | true
87 | Bin\ARM\Release
88 | TRACE;SILVERLIGHT;WINDOWS_PHONE
89 | true
90 | true
91 | prompt
92 | 4
93 |
94 |
95 |
96 | App.xaml
97 |
98 |
99 |
100 | MainPage.xaml
101 |
102 |
103 |
104 | True
105 | True
106 | AppResources.resx
107 |
108 |
109 |
110 |
111 |
112 | Designer
113 | MSBuild:Compile
114 |
115 |
116 | Designer
117 | MSBuild:Compile
118 |
119 |
120 |
121 |
122 |
123 |
124 | Designer
125 |
126 |
127 |
128 | Designer
129 |
130 |
131 |
132 |
133 |
134 | PreserveNewest
135 |
136 |
137 |
138 | PreserveNewest
139 |
140 |
141 | PreserveNewest
142 |
143 |
144 | PreserveNewest
145 |
146 |
147 | PreserveNewest
148 |
149 |
150 | PreserveNewest
151 |
152 |
153 |
154 |
155 |
156 | PublicResXFileCodeGenerator
157 | AppResources.Designer.cs
158 |
159 |
160 |
161 |
162 | ..\packages\LiveSDK.5.5\lib\WindowsPhone8\Microsoft.Live.dll
163 |
164 |
165 | ..\packages\LiveSDK.5.5\lib\WindowsPhone8\Microsoft.Live.Controls.dll
166 |
167 |
168 | ..\packages\Newtonsoft.Json.5.0.8\lib\portable-net45+wp80+win8\Newtonsoft.Json.dll
169 |
170 |
171 | ..\packages\Microsoft.Net.Http.2.2.18\lib\sl4-windowsphone71\System.Net.Http.dll
172 |
173 |
174 | ..\packages\Microsoft.Net.Http.2.2.18\lib\sl4-windowsphone71\System.Net.Http.Extensions.dll
175 |
176 |
177 | ..\packages\Microsoft.Net.Http.2.2.18\lib\sl4-windowsphone71\System.Net.Http.Primitives.dll
178 |
179 |
180 |
181 |
182 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
--------------------------------------------------------------------------------
/WinPhoneOneNoteServiceSample/MainPage.xaml.cs:
--------------------------------------------------------------------------------
1 | //*********************************************************
2 | // Copyright (c) Microsoft Corporation
3 | // All rights reserved.
4 | //
5 | // Licensed under the Apache License, Version 2.0 (the ""License"");
6 | // you may not use this file except in compliance with the License.
7 | // You may obtain a copy of the License at
8 | // http://www.apache.org/licenses/LICENSE-2.0
9 | //
10 | // THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT
11 | // WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS
12 | // OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
13 | // WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR
14 | // PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
15 | //
16 | // See the Apache Version 2.0 License for specific language
17 | // governing permissions and limitations under the License.
18 | //*********************************************************
19 |
20 | using Microsoft.Live;
21 | using Newtonsoft.Json;
22 |
23 | using System;
24 | using System.Collections.Generic;
25 | using System.Globalization;
26 | using System.IO;
27 | using System.Linq;
28 | using System.Net;
29 | using System.Net.Http;
30 | using System.Net.Http.Headers;
31 | using System.Text.RegularExpressions;
32 | using System.Threading.Tasks;
33 | using System.Windows;
34 | using System.Windows.Resources;
35 |
36 | /********************************************************
37 | *
38 | * README
39 | *
40 | * 1. Before hitting F5, please ensure latest nuget update is installed and package restore is enabled in tools/options/package manager
41 | * 2. Before re-using the sample code in your app, please replace sample ClientId on MainPage.xaml with your own ClientId
42 | * 3. Accessing the OneNote Service APIs only requires the Office.onenote_* scopes. This sample app also contains the wl.offline_access wl.signin
43 | * scopes in order to demonstrate how to use a refresh token and re-authorize access tokens.
44 | * *****************************************************/
45 | namespace WinPhoneOneNoteServiceSample
46 | {
47 | public partial class MainPage
48 | {
49 | private string _accessToken;
50 | private DateTimeOffset _accessTokenExpiration;
51 | private string _refreshToken; // Refresh token (only applicable when the app uses the wl.offline_access wl.signin scopes)
52 | private StandardResponse _response;
53 | private string sectionName;
54 |
55 | public string PagesEndpoint
56 | {
57 | get
58 | {
59 | if (String.IsNullOrWhiteSpace(sectionName) || sectionName.Equals(SectionNameHint))
60 | {
61 | return PagesEndpointBaseUrl;
62 | }
63 | else
64 | {
65 | return string.Format("{0}/?sectionName={1}", PagesEndpointBaseUrl, sectionName);
66 | }
67 | }
68 | set
69 | {
70 | sectionName = value;
71 | }
72 | }
73 |
74 | // OneNote Service API v1.0 Endpoint
75 | private const string PagesEndpointBaseUrl = "https://www.onenote.com/api/v1.0/pages";
76 | private const string SectionNameHint = "Enter Section Name";
77 |
78 | // Collateral used to refresh access token (only applicable when the app uses the wl.offline_access wl.signin scopes)
79 | private const string MsaTokenRefreshUrl = "https://login.live.com/oauth20_token.srf";
80 | private const string TokenRefreshContentType = "application/x-www-form-urlencoded";
81 | private const string TokenRefreshRedirectUri = "https://login.live.com/oauth20_desktop.srf";
82 | private const string TokenRefreshRequestBody = "client_id={0}&redirect_uri={1}&grant_type=refresh_token&refresh_token={2}";
83 |
84 | // Constructor
85 | public MainPage()
86 | {
87 | InitializeComponent();
88 | this.sectionName = "";
89 | this.Loaded += CheckIfClientIdUpdated;
90 | this.textBox_sectionName.Text = SectionNameHint;
91 | }
92 |
93 | private void CheckIfClientIdUpdated(object sender, RoutedEventArgs e)
94 | {
95 | if ((string)Resources["ClientId"] == "Insert Your Client Id Here")
96 | {
97 | MessageBox.Show("Visit http://go.microsoft.com/fwlink/?LinkId=392537 for instructions on getting a Client Id. Please specify your client ID in the MainPage.xaml file and rebuild the application.");
98 | }
99 | }
100 |
101 | #region Send create page requests
102 |
103 | ///
104 | /// Send a create page request
105 | ///
106 | /// The HttpRequestMessage which contains the page information
107 | private async Task SendCreatePageRequest(HttpRequestMessage createMessage)
108 | {
109 | var httpClient = new HttpClient();
110 | _response = null;
111 |
112 | // Check if Auth token needs to be refreshed
113 | await RefreshAuthTokenIfNeeded();
114 |
115 | // Add Authorization header
116 | httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _accessToken);
117 | // Note: API only supports JSON return type.
118 | httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
119 |
120 | // Get and parse the HTTP response from the service
121 | HttpResponseMessage response = await httpClient.SendAsync(createMessage);
122 | _response = await ParseResponse(response);
123 |
124 | // Update the UI accordingly
125 | UpdateUIAfterRequest(response);
126 | }
127 |
128 | ///
129 | /// Create a page with simple html content
130 | ///
131 | private async void btn_CreateSimple_Click(object sender, RoutedEventArgs e)
132 | {
133 | string date = GetDate();
134 |
135 | string simpleHtml = "" +
136 | "
" +
137 | "A page created from basic HTML-formatted text (WinPhone8 Sample) " +
138 | " " +
139 | "" +
140 | "" +
141 | "This is a page that just contains some simple formatted text
" +
142 | "" +
143 | "";
144 |
145 | // Create the request message, which is a text/html single part in this case
146 | // The Service also supports content type multipart/form-data for more complex scenarios
147 | var createMessage = new HttpRequestMessage(HttpMethod.Post, PagesEndpoint)
148 | {
149 | Content = new StringContent(simpleHtml, System.Text.Encoding.UTF8, "text/html")
150 | };
151 |
152 | await SendCreatePageRequest(createMessage);
153 | }
154 |
155 | ///
156 | /// Create page with image
157 | ///
158 | private async void btn_CreateWithImage_Click(object sender, RoutedEventArgs e)
159 | {
160 | const string imagePartName = "image1";
161 |
162 | string date = GetDate();
163 | string simpleHtml = "" +
164 | "" +
165 | "A page with an image on it (WinPhone8 Sample) " +
166 | " " +
167 | "" +
168 | "" +
169 | "This is a page with an image on it " +
170 | " " +
171 | "" +
172 | "";
173 |
174 | // Create the image part - make sure it is disposed after we've sent the message in order to close the stream.
175 | Stream imageStream = GetAssetFileStream("assets\\Logo.jpg");
176 | using (var imageContent = new StreamContent(imageStream))
177 | {
178 | imageContent.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg");
179 | HttpRequestMessage createMessage = new HttpRequestMessage(HttpMethod.Post, PagesEndpoint)
180 | {
181 | // Create a multipart/form data request in this case
182 | // The Service also supports single part text/html content for simple scenarios
183 | Content = new MultipartFormDataContent
184 | {
185 | {new StringContent(simpleHtml, System.Text.Encoding.UTF8, "text/html"), "Presentation"},
186 | {imageContent, imagePartName}
187 | }
188 | };
189 |
190 | // Must send the request within the using block, or the image stream will have been disposed.
191 | await SendCreatePageRequest(createMessage);
192 | }
193 | }
194 |
195 | ///
196 | /// Create page with URL snapshot
197 | ///
198 | private async void btn_CreateWithUrl_Click(object sender, RoutedEventArgs e)
199 | {
200 | string date = GetDate();
201 | string simpleHtml = @"" +
202 | "" +
203 | "A Page Created With a URL Snapshot on it (WinPhone8 Sample) " +
204 | " " +
205 | "" +
206 | "" +
207 | "This is a page with an image of an html page rendered from a URL on it.
" +
208 | " " +
209 | "" +
210 | "";
211 |
212 | // Create the request message, which is a text/html single part in this case
213 | // The Service also supports content type multipart/form-data for more complex scenarios
214 | var createMessage = new HttpRequestMessage(HttpMethod.Post, PagesEndpoint)
215 | {
216 | Content = new StringContent(simpleHtml, System.Text.Encoding.UTF8, "text/html")
217 | };
218 |
219 | await SendCreatePageRequest(createMessage);
220 | }
221 |
222 | ///
223 | /// Create page with HTML snapshot
224 | ///
225 | private async void btn_CreateWithHtml_Click(object sender, RoutedEventArgs e)
226 | {
227 | const string embeddedPartName = "embedded1";
228 | const string embeddedWebPage =
229 | "" +
230 | "" +
231 | "Embedded HTML " +
232 | "" +
233 | "" +
234 | "This is a screen grab of a web page " +
235 | "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam vehicula magna quis mauris accumsan, nec imperdiet nisi tempus. Suspendisse potenti. " +
236 | "Duis vel nulla sit amet turpis venenatis elementum. Cras laoreet quis nisi et sagittis. Donec euismod at tortor ut porta. Duis libero urna, viverra id " +
237 | "aliquam in, ornare sed orci. Pellentesque condimentum gravida felis, sed pulvinar erat suscipit sit amet. Nulla id felis quis sem blandit dapibus. Ut " +
238 | "viverra auctor nisi ac egestas. Quisque ac neque nec velit fringilla sagittis porttitor sit amet quam.
" +
239 | "" +
240 | "";
241 |
242 | string date = GetDate();
243 |
244 | string simpleHtml = "" +
245 | "" +
246 | "A Page Created With Snapshot of Webpage in it (WinPhone8 Sample) " +
247 | " " +
248 | "" +
249 | "" +
250 | "This is a page with an image of an html page on it. " +
251 | " " +
252 | "" +
253 | "";
254 |
255 | var createMessage = new HttpRequestMessage(HttpMethod.Post, PagesEndpoint)
256 | {
257 | // Create a multipart/form data request in this case
258 | // The Service also supports single part text/html for more simpler scenarios
259 | Content = new MultipartFormDataContent
260 | {
261 | {new StringContent(simpleHtml, System.Text.Encoding.UTF8, "text/html"), "Presentation"},
262 | {new StringContent(embeddedWebPage, System.Text.Encoding.UTF8, "text/html"), embeddedPartName}
263 | }
264 | };
265 |
266 | await SendCreatePageRequest(createMessage);
267 | }
268 |
269 | ///
270 | /// Creates a OneNote page with a PDF document attached and rendered
271 | ///
272 | private async void btn_CreateWithAttachmentAndPdfRendering_Click(object sender, RoutedEventArgs e)
273 | {
274 | const string attachmentPartName = "pdfattachment1";
275 | string date = GetDate();
276 | string attachmentHtml = "" +
277 | "" +
278 | "A page created with a file attachment (WinPhone8 Sample) " +
279 | " " +
280 | "" +
281 | "" +
282 | "This is a page with a PDF file attachment " +
283 | " " +
284 | "Here's the Content of the PDF document :
" +
285 | " " +
286 | "" +
287 | "";
288 | // Create the attachment part - make sure it is disposed after we've sent the message in order to close the stream.
289 | Stream attachmentStream = GetAssetFileStream("Assets\\attachment.pdf");
290 | using (var attachmentContent = new StreamContent(attachmentStream))
291 | {
292 | attachmentContent.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
293 | HttpRequestMessage createMessage = new HttpRequestMessage(HttpMethod.Post, PagesEndpoint)
294 | {
295 | Content = new MultipartFormDataContent
296 | {
297 | {new StringContent(attachmentHtml, System.Text.Encoding.UTF8, "text/html"), "Presentation"},
298 | {attachmentContent, attachmentPartName}
299 | }
300 | };
301 | // Must send the request within the using block, or the attachment file stream will have been disposed.
302 | await SendCreatePageRequest(createMessage);
303 | }
304 | }
305 |
306 | #endregion
307 |
308 | #region Open OneNote Hyperlink
309 |
310 | ///
311 | /// Open the created page in the OneNote app
312 | ///
313 | private async void HyperlinkButton_Click(object sender, RoutedEventArgs e)
314 | {
315 | if (_response as CreateSuccessResponse != null)
316 | {
317 | CreateSuccessResponse successResponse = (CreateSuccessResponse)_response;
318 | await Windows.System.Launcher.LaunchUriAsync(FormulatePageUri(successResponse.OneNoteClientUrl));
319 | }
320 | }
321 |
322 | ///
323 | /// Formulate the OneNoteClientUrl so that we can open the OneNote app directly
324 | ///
325 | /// The OneNoteClientUrl received in the API JSON response
326 | private static Uri FormulatePageUri(string oneNoteClientUrl)
327 | {
328 | // Regular expression for identifying GUIDs in the URL returned by the server.
329 | // We need to wrap such GUIDs in curly braces before sending them to OneNote.
330 | Regex guidRegex = new Regex(@"=([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})&",
331 | RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
332 | if (!String.IsNullOrEmpty(oneNoteClientUrl))
333 | {
334 | var matches = guidRegex.Matches(oneNoteClientUrl);
335 | if (matches.Count == 2)
336 | {
337 | oneNoteClientUrl =
338 | oneNoteClientUrl.Replace(matches[0].Groups[1].Value, "{" + matches[0].Groups[1].Value + "}")
339 | .Replace(matches[1].Groups[1].Value, "{" + matches[1].Groups[1].Value + "}");
340 | }
341 | return new Uri(oneNoteClientUrl);
342 | }
343 | return null;
344 | }
345 |
346 | #endregion
347 |
348 | #region LiveSDK authentication/token refresh
349 |
350 | ///
351 | /// This method is called when the Live session status changes
352 | ///
353 | private void OnSessionChanged(object sender, Microsoft.Live.Controls.LiveConnectSessionChangedEventArgs e)
354 | {
355 | switch (e.Status)
356 | {
357 | case LiveConnectSessionStatus.Connected:
358 | _accessToken = e.Session.AccessToken;
359 | _accessTokenExpiration = e.Session.Expires;
360 | _refreshToken = e.Session.RefreshToken;
361 |
362 | SetCreateButtonsEnabled(true);
363 | infoTextBlock.Text = "Authentication successful";
364 | break;
365 | case LiveConnectSessionStatus.NotConnected:
366 | SetCreateButtonsEnabled(false);
367 | infoTextBlock.Text = "Authentication failed.";
368 | break;
369 | default:
370 | SetCreateButtonsEnabled(false);
371 | infoTextBlock.Text = "Not Authenticated";
372 | break;
373 | }
374 | }
375 |
376 | ///
377 | /// This method tries to refresh the token if it expires. The authentication token needs to be
378 | /// refreshed continuosly, so that the user is not prompted to sign in again
379 | ///
380 | ///
381 | private async Task AttemptAccessTokenRefresh()
382 | {
383 | var createMessage = new HttpRequestMessage(HttpMethod.Post, MsaTokenRefreshUrl)
384 | {
385 | Content = new StringContent(
386 | String.Format(CultureInfo.InvariantCulture, TokenRefreshRequestBody,
387 | Resources["ClientId"],
388 | TokenRefreshRedirectUri,
389 | _refreshToken),
390 | System.Text.Encoding.UTF8,
391 | TokenRefreshContentType)
392 | };
393 |
394 | HttpClient httpClient = new HttpClient();
395 | HttpResponseMessage response = await httpClient.SendAsync(createMessage);
396 | await ParseRefreshTokenResponse(response);
397 | }
398 |
399 | ///
400 | /// Handle the RegreshToken response
401 | ///
402 | /// The HttpResponseMessage from the TokenRefresh request
403 | private async Task ParseRefreshTokenResponse(HttpResponseMessage response)
404 | {
405 | if (response.StatusCode == HttpStatusCode.OK)
406 | {
407 | dynamic responseObject = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync());
408 | _accessToken = responseObject.access_token;
409 | _accessTokenExpiration = _accessTokenExpiration.AddSeconds((double)responseObject.expires_in);
410 | _refreshToken = responseObject.refresh_token;
411 | }
412 | }
413 |
414 | #endregion
415 |
416 | #region Helper functions
417 |
418 | ///
419 | /// Get date in ISO8601 format with local timezone offset
420 | ///
421 | /// Date as ISO8601 string
422 | private static string GetDate()
423 | {
424 | return DateTime.Now.ToString("o");
425 | }
426 |
427 | ///
428 | /// Get an asset file packaged with the application and return it as a managed stream
429 | ///
430 | /// The path name of an asset relative to the application package root
431 | /// A managed stream of the asset file data, opened for read
432 | private static Stream GetAssetFileStream(string assetFile)
433 | {
434 | StreamResourceInfo resource = Application.GetResourceStream(new Uri(assetFile, UriKind.Relative));
435 | return resource.Stream;
436 | }
437 |
438 | ///
439 | /// Refreshes the live authentication token if it has expired
440 | ///
441 | private async Task RefreshAuthTokenIfNeeded()
442 | {
443 | if (_accessTokenExpiration.CompareTo(DateTimeOffset.UtcNow) <= 0)
444 | {
445 | infoTextBlock.Text = "Access token needs to be refreshed";
446 | await AttemptAccessTokenRefresh();
447 | }
448 | infoTextBlock.Text = "Sending Request...";
449 | hyperlinkCreatedPage.Visibility = Visibility.Collapsed;
450 | }
451 |
452 | ///
453 | /// Update the UI after a create page request, depending on if it was
454 | /// successful or not
455 | ///
456 | /// The HttpResponseMessage from the create page request
457 | private void UpdateUIAfterRequest(HttpResponseMessage response)
458 | {
459 | if (response.StatusCode == HttpStatusCode.Created)
460 | {
461 | infoTextBlock.Text = "Page successfully created.";
462 | hyperlinkCreatedPage.Visibility = Visibility.Visible;
463 | }
464 | else
465 | {
466 | infoTextBlock.Text = "Page creation failed with error code: " + response.StatusCode;
467 | hyperlinkCreatedPage.Visibility = Visibility.Collapsed;
468 | }
469 | }
470 |
471 | ///
472 | /// Parse the OneNote Service API create page response
473 | ///
474 | /// The HttpResponseMessage from the create page request
475 | private async static Task ParseResponse(HttpResponseMessage response)
476 | {
477 | StandardResponse standardResponse;
478 | if (response.StatusCode == HttpStatusCode.Created)
479 | {
480 | dynamic responseObject = JsonConvert.DeserializeObject(await response.Content.ReadAsStringAsync());
481 | standardResponse = new CreateSuccessResponse
482 | {
483 | StatusCode = response.StatusCode,
484 | OneNoteClientUrl = responseObject.links.oneNoteClientUrl.href,
485 | OneNoteWebUrl = responseObject.links.oneNoteWebUrl.href
486 | };
487 | }
488 | else
489 | {
490 | standardResponse = new StandardErrorResponse
491 | {
492 | StatusCode = response.StatusCode,
493 | Message = await response.Content.ReadAsStringAsync()
494 | };
495 | }
496 |
497 | // Extract the correlation id. Apps should log this if they want to collect data to diagnose failures with Microsoft support
498 | IEnumerable correlationValues;
499 | if (response.Headers.TryGetValues("X-CorrelationId", out correlationValues))
500 | {
501 | standardResponse.CorrelationId = correlationValues.FirstOrDefault();
502 | }
503 |
504 | return standardResponse;
505 | }
506 |
507 | ///
508 | /// Change "create page" buttons to enabled/disabled
509 | ///
510 | /// A bool value indicating if the buttons should be enabled
511 | private void SetCreateButtonsEnabled(bool shouldBeEnabled)
512 | {
513 | btn_CreateSimple.IsEnabled = shouldBeEnabled;
514 | btn_CreateWithHtml.IsEnabled = shouldBeEnabled;
515 | btn_CreateWithImage.IsEnabled = shouldBeEnabled;
516 | btn_CreateWithUrl.IsEnabled = shouldBeEnabled;
517 | btn_CreateWithAttachmentAndPdfRendering.IsEnabled = shouldBeEnabled;
518 | }
519 |
520 | #endregion
521 |
522 | private void sectionName_GotFocus(object sender, RoutedEventArgs e)
523 | {
524 | string currentFieldValue = textBox_sectionName.Text;
525 | if (SectionNameHint.Equals(currentFieldValue))
526 | {
527 | textBox_sectionName.Text = string.Empty;
528 | }
529 | }
530 |
531 | private void sectionName_Change(object sender, System.Windows.Controls.TextChangedEventArgs e)
532 | {
533 | sectionName = textBox_sectionName.Text;
534 | }
535 |
536 | private void sectionName_LostFocus(object sender, RoutedEventArgs e)
537 | {
538 | string newValue = textBox_sectionName.Text;
539 | if (String.IsNullOrWhiteSpace(newValue))
540 | {
541 | sectionName = string.Empty;
542 | textBox_sectionName.Text = SectionNameHint;
543 | }
544 | else
545 | {
546 | sectionName = newValue;
547 | }
548 | }
549 | }
550 | }
--------------------------------------------------------------------------------