-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindow.xaml.cs
More file actions
86 lines (76 loc) · 2.54 KB
/
MainWindow.xaml.cs
File metadata and controls
86 lines (76 loc) · 2.54 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Skyle;
namespace Skyle_Sample
{
public partial class MainWindow : Window
{
private Client skyleClient = new();
public MainWindow()
{
InitializeComponent();
this.Closing += MainWindow_Closing;
skyleClient.IsConnected += SkyleClient_IsConnected;
}
private void SkyleClient_IsConnected(bool obj)
{
Dispatcher.Invoke(() =>
{
Conn.Fill = new SolidColorBrush(obj ? Colors.Green : Colors.Red);
});
}
private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
skyleClient.Positioning -= Show_EyePosition;
skyleClient.Gaze -= Show_Gaze;
}
private void Show_EyePosition(Positioning posData)
{
Dispatcher.Invoke(() =>
{
Canvas.SetLeft(leftEye, posData.LeftEye.X);
Canvas.SetTop(leftEye, posData.LeftEye.Y);
Canvas.SetLeft(rightEye, posData.RightEye.X);
Canvas.SetTop(rightEye, posData.RightEye.Y);
});
}
private void Connect_Click(object sender, RoutedEventArgs e)
{
skyleClient.ConnectAsync();
skyleClient.Positioning += Show_EyePosition;
skyleClient.Gaze += Show_Gaze;
}
private void Exit_Click(object sender, RoutedEventArgs e)
{
Close();
}
private void Calib_Click(object sender, RoutedEventArgs e)
{
Dispatcher.Invoke(() =>
{
CalibBubble.Visibility = Visibility.Visible;
GazeBubble.Visibility = Visibility.Hidden;
});
skyleClient.NextCalibPoint += a => Dispatcher.Invoke(() =>
{
Canvas.SetLeft(CalibBubble, a.X);
Canvas.SetTop(CalibBubble, a.Y);
});
skyleClient.CalibrationFinished += () => Dispatcher.Invoke(() =>
{
CalibBubble.Visibility = Visibility.Hidden;
GazeBubble.Visibility = Visibility.Visible;
});
skyleClient.Calibrate((int)ActualWidth, (int)ActualHeight);
}
private void Show_Gaze(Skyle.Point obj)
{
Dispatcher.Invoke(() =>
{
Canvas.SetLeft(GazeBubble, obj.X);
Canvas.SetTop(GazeBubble, obj.Y);
});
}
}
}