Skip to content

Commit 7a7a9f4

Browse files
committed
Push the latest updates
1 parent 5868158 commit 7a7a9f4

17 files changed

+1099
-1128
lines changed
Lines changed: 60 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,60 @@
1-
---
2-
topic: sample
3-
languages:
4-
- csharp
5-
products:
6-
- uwp
7-
- windows
8-
- azure
9-
---
10-
11-
# Ink Recognizer Cognitive Service C# UWP Sample
12-
13-
![Build passing](https://img.shields.io/badge/build-passing-brightgreen.svg) ![License](https://img.shields.io/badge/license-MIT-green.svg)
14-
15-
Ink Recognizer Cognitive Service provides recognition of digital ink. It takes the digital ink stroke data as input and provides a document tree with individual recognition units as output. This project has sample code to demonstrate a few ways developers can take advantage of the service.
16-
17-
## Features
18-
19-
This project framework provides the following features:
20-
21-
* Capturing very basic inking input.
22-
* Creating the JSON payload using the JSON schema used by Ink Recognizer.
23-
* Calling the Ink Recognizer REST APIs with the JSON payload
24-
* Parsing the JSON response from the service, build the document tree and parse it.
25-
26-
## Contents
27-
28-
| File/folder | Description |
29-
|-------------|-------------|
30-
| `src` | Sample source code. |
31-
| `README.md` | This README file. |
32-
| `LICENSE` | The license for the sample. |
33-
34-
## Prerequisites
35-
36-
- Install [Visual Studio] (https://docs.microsoft.com/en-us/visualstudio/install/install-visual-studio)
37-
- Requires subscription key from [Azure Cognitive Services] (https://docs.microsoft.com/en-us/azure/cognitive-services/authentication)
38-
39-
## Build the sample
40-
41-
1. Clone or download this sample repository
42-
2. Start Visual Studio and select **File > Open > Project/Solution**
43-
3. Replace "[YOUR SUBSCRIPTION KEY]" in NoteTaker.xaml.cs with valid subscription key
44-
4. Press Ctrl+Shift+B, or select **Build > Build Solution**
45-
46-
## Run the sample
47-
48-
The next steps depend on whether you just want to deploy the sample or you want to both deploy and run it.
49-
50-
### Deploying the sample
51-
Select Build > Deploy Solution.
52-
53-
### Debugging and running the sample
54-
To debug the sample and then run it, press F5 or select Debug > Start Debugging. To run the sample without debugging, press Ctrl+F5 or select Debug > Start Without Debugging.
1+
---
2+
topic: sample
3+
languages:
4+
- C#
5+
products:
6+
- WPF
7+
- azure
8+
---
9+
10+
# Ink Recognizer Cognitive Service C# UWP Sample
11+
12+
![Build passing](https://img.shields.io/badge/build-passing-brightgreen.svg) ![License](https://img.shields.io/badge/license-MIT-green.svg)
13+
14+
Ink Recognizer Cognitive Service provides recognition of digital ink. It takes the digital ink stroke data as input and provides a document tree with individual recognition units as output. This project has sample code to demonstrate a few ways developers can take advantage of the service.
15+
16+
## Features
17+
18+
This sample provides the following features:
19+
20+
* Collect ink strokes
21+
* Create JSON request with Ink Recognizer Service's schema.
22+
* Call the Ink Recognizer REST APIs with the JSON payload
23+
* Parse the JSON response from the service and build the document tree.
24+
25+
## Contents
26+
27+
| File/folder | Description |
28+
|-------------|-------------|
29+
| `cs` | Sample source code. |
30+
| `README.md` | This README file. |
31+
| `LICENSE` | The license for the sample. |
32+
33+
## Prerequisites
34+
35+
- Install [Visual Studio](https://docs.microsoft.com/en-us/visualstudio/install/install-visual-studio)
36+
- Requires subscription key from [Azure Cognitive Services](https://docs.microsoft.com/en-us/azure/cognitive-services/authentication)
37+
38+
## Build the sample
39+
40+
1. Clone or download this sample repository
41+
2. Start Visual Studio and select **File > Open > Project/Solution**
42+
3. Replace "[YOUR SUBSCRIPTION KEY]" in NoteTaker.xaml.cs with a valid subscription key
43+
4. Select **Build > Build Solution**
44+
45+
## Run the sample
46+
47+
* To debug the sample, select Debug > Start Debugging. To run the sample without debugging, select Debug > Start Without Debugging
48+
* Write some text / Draw a shape on the inking area
49+
* After 1 second of inactivity, the ink will be recognized and the result will be displayed at the bottom of the app
50+
51+
## Resources
52+
53+
Additional resources related the project are located below
54+
55+
* [Learn more about Ink Recognizer](http://go.microsoft.com/fwlink/?LinkID=2084782)
56+
* [Ink Recognizer API Reference](http://go.microsoft.com/fwlink/?LinkID=2085147)
57+
* [Ink Recognizer JavaScript sample](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/tree/master/javascript/InkRecognition/javascript-app)
58+
* [Ink Recognizer WPF sample](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/tree/master/dotnet/InkRecognition/wpf-app)
59+
* [Ink Recognizer Java sample](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/tree/master/java/InkRecognition/android-sample-app)
60+
* [Ink Recognizer Swift sample](https://github.com/Azure-Samples/cognitive-services-REST-api-samples/tree/master/swift/InkRecognition)
Lines changed: 95 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,95 @@
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-
18-
namespace NoteTaker
19-
{
20-
/// <summary>
21-
/// Provides application-specific behavior to supplement the default Application class.
22-
/// </summary>
23-
sealed partial class App : Application
24-
{
25-
/// <summary>
26-
/// Initializes the singleton application object. This is the first line of authored code
27-
/// executed, and as such is the logical equivalent of main() or WinMain().
28-
/// </summary>
29-
public App()
30-
{
31-
this.InitializeComponent();
32-
this.Suspending += OnSuspending;
33-
}
34-
35-
/// <summary>
36-
/// Invoked when the application is launched normally by the end user. Other entry points
37-
/// will be used such as when the application is launched to open a specific file.
38-
/// </summary>
39-
/// <param name="e">Details about the launch request and process.</param>
40-
protected override void OnLaunched(LaunchActivatedEventArgs e)
41-
{
42-
Frame rootFrame = Window.Current.Content as Frame;
43-
44-
// Do not repeat app initialization when the Window already has content,
45-
// just ensure that the window is active
46-
if (rootFrame == null)
47-
{
48-
// Create a Frame to act as the navigation context and navigate to the first page
49-
rootFrame = new Frame();
50-
51-
rootFrame.NavigationFailed += OnNavigationFailed;
52-
53-
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
54-
{
55-
//TODO: Load state from previously suspended application
56-
}
57-
58-
// Place the frame in the current Window
59-
Window.Current.Content = rootFrame;
60-
}
61-
62-
if (e.PrelaunchActivated == false)
63-
{
64-
if (rootFrame.Content == null)
65-
{
66-
// When the navigation stack isn't restored navigate to the first page,
67-
// configuring the new page by passing required information as a navigation
68-
// parameter
69-
rootFrame.Navigate(typeof(NoteTaker), e.Arguments);
70-
}
71-
// Ensure the current window is active
72-
Window.Current.Activate();
73-
}
74-
}
75-
76-
/// <summary>
77-
/// Invoked when Navigation to a certain page fails
78-
/// </summary>
79-
/// <param name="sender">The Frame which failed navigation</param>
80-
/// <param name="e">Details about the navigation failure</param>
81-
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
82-
{
83-
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
84-
}
85-
86-
/// <summary>
87-
/// Invoked when application execution is being suspended. Application state is saved
88-
/// without knowing whether the application will be terminated or resumed with the contents
89-
/// of memory still intact.
90-
/// </summary>
91-
/// <param name="sender">The source of the suspend request.</param>
92-
/// <param name="e">Details about the suspend request.</param>
93-
private void OnSuspending(object sender, SuspendingEventArgs e)
94-
{
95-
var deferral = e.SuspendingOperation.GetDeferral();
96-
//TODO: Save application state and stop any background activity
97-
deferral.Complete();
98-
}
99-
}
100-
}
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+
18+
namespace NoteTaker
19+
{
20+
/// <summary>
21+
/// Provides application-specific behavior to supplement the default Application class.
22+
/// </summary>
23+
sealed partial class App : Application
24+
{
25+
/// <summary>
26+
/// Initializes the singleton application object. This is the first line of authored code
27+
/// executed, and as such is the logical equivalent of main() or WinMain().
28+
/// </summary>
29+
public App()
30+
{
31+
this.InitializeComponent();
32+
this.Suspending += OnSuspending;
33+
}
34+
35+
/// <summary>
36+
/// Invoked when the application is launched normally by the end user. Other entry points
37+
/// will be used such as when the application is launched to open a specific file.
38+
/// </summary>
39+
/// <param name="e">Details about the launch request and process.</param>
40+
protected override void OnLaunched(LaunchActivatedEventArgs e)
41+
{
42+
Frame rootFrame = Window.Current.Content as Frame;
43+
44+
// Do not repeat app initialization when the Window already has content,
45+
// just ensure that the window is active
46+
if (rootFrame == null)
47+
{
48+
// Create a Frame to act as the navigation context and navigate to the first page
49+
rootFrame = new Frame();
50+
51+
rootFrame.NavigationFailed += OnNavigationFailed;
52+
53+
54+
// Place the frame in the current Window
55+
Window.Current.Content = rootFrame;
56+
}
57+
58+
if (e.PrelaunchActivated == false)
59+
{
60+
if (rootFrame.Content == null)
61+
{
62+
// When the navigation stack isn't restored navigate to the first page,
63+
// configuring the new page by passing required information as a navigation
64+
// parameter
65+
rootFrame.Navigate(typeof(NoteTaker), e.Arguments);
66+
}
67+
// Ensure the current window is active
68+
Window.Current.Activate();
69+
}
70+
}
71+
72+
/// <summary>
73+
/// Invoked when Navigation to a certain page fails
74+
/// </summary>
75+
/// <param name="sender">The Frame which failed navigation</param>
76+
/// <param name="e">Details about the navigation failure</param>
77+
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
78+
{
79+
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
80+
}
81+
82+
/// <summary>
83+
/// Invoked when application execution is being suspended. Application state is saved
84+
/// without knowing whether the application will be terminated or resumed with the contents
85+
/// of memory still intact.
86+
/// </summary>
87+
/// <param name="sender">The source of the suspend request.</param>
88+
/// <param name="e">Details about the suspend request.</param>
89+
private void OnSuspending(object sender, SuspendingEventArgs e)
90+
{
91+
var deferral = e.SuspendingOperation.GetDeferral();
92+
deferral.Complete();
93+
}
94+
}
95+
}

0 commit comments

Comments
 (0)