Last active
August 29, 2015 14:15
-
-
Save sakapon/d692b7324fbc82d3fc00 to your computer and use it in GitHub Desktop.
Ink Gestures
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Window | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
x:Class="InkGestureWpf.MainWindow" | |
Title="Ink Gestures" Height="800" Width="1200" WindowState="Maximized" FontSize="48"> | |
<Grid> | |
<Grid.ColumnDefinitions> | |
<ColumnDefinition Width="600"/> | |
<ColumnDefinition/> | |
</Grid.ColumnDefinitions> | |
<ItemsControl x:Name="GestureResultsBox" Margin="48"/> | |
<Border Grid.Column="1" BorderBrush="#FF999999" BorderThickness="8,0,0,0"> | |
<InkCanvas x:Name="GestureCanvas" EditingMode="GestureOnly"/> | |
</Border> | |
</Grid> | |
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Collections.ObjectModel; | |
using System.Linq; | |
using System.Windows; | |
using System.Windows.Ink; | |
namespace InkGestureWpf | |
{ | |
public partial class MainWindow : Window | |
{ | |
public MainWindow() | |
{ | |
InitializeComponent(); | |
var gestureResults = new ObservableCollection<ApplicationGesture>(); | |
GestureResultsBox.ItemsSource = gestureResults; | |
GestureCanvas.Gesture += (o, e) => | |
{ | |
var result = e.GetGestureRecognitionResults() | |
// 信頼性 (RecognitionConfidence) を無視したほうがよさそうです。 | |
//.Where(r => r.RecognitionConfidence == RecognitionConfidence.Strong) | |
.FirstOrDefault(r => r.ApplicationGesture != ApplicationGesture.NoGesture); | |
if (result == null) return; | |
gestureResults.Insert(0, result.ApplicationGesture); | |
}; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment