본문 바로가기

Programing (프로그래밍)/WPF & C# (C Sharp)

WPF & C# - Inkcanvas Gesture Event ( 잉크캔버스 제스처 제스쳐 이벤트 등록)

728x90
반응형


 WPF & C# - Inkcanvas Gesture Event ( 잉크캔버스 제스처 제스쳐 이벤트 등록)



MainWindow.xaml.cs


using System.Collections.ObjectModel;
using System.Windows.Ink;
using System.Windows.Controls;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
void initUI()
{
    // inckCanvas1 에 제스처 이벤트 등록하기
    inkCanvas1.EditingMode = InkCanvasEditingMode.InkAndGesture;
    inkCanvas1.Gesture += new InkCanvasGestureEventHandler(inkCanvas1_Gesture);
    inkCanvas1.SetEnabledGestures(new ApplicationGesture[]
    {
        ApplicationGesture.Down,
        ApplicationGesture.Circle,
        ApplicationGesture.Triangle
    });
}
 
// inkCanvas1 Gesture Event
void inkCanvas1_Gesture(object sender, InkCanvasGestureEventArgs e)
{
    ReadOnlyCollection<GestureRecognitionResult> gestureResults = e.GetGestureRecognitionResults();
 
    // Check the first recognition result for a gesture.
    if (gestureResults[0].RecognitionConfidence == RecognitionConfidence.Strong)
    {
        switch (gestureResults[0].ApplicationGesture)
        {
            case ApplicationGesture.Down:
                MessageBox.Show("따운");
                break;
 
            case ApplicationGesture.Circle:
                MessageBox.Show("원");
                break;
 
            case ApplicationGesture.Triangle:
                MessageBox.Show("삼각형");
                break;
        }
    }
}
cs




728x90
반응형