-
Notifications
You must be signed in to change notification settings - Fork 19
/
MainWindow.xaml.cs
55 lines (50 loc) · 1.64 KB
/
MainWindow.xaml.cs
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
using System;
using System.Windows;
namespace MouseToJoystick2
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private MouseToJoystickHandler handler = null;
public MainWindow()
{
InitializeComponent();
}
private void ToggleButton_Click(object sender, RoutedEventArgs e)
{
var model = (MainWindowModel)this.DataContext;
if (model.ShouldRun == true)
{
uint deviceId = Convert.ToUInt32(model.DeviceId);
int manualWidth = Convert.ToInt32(model.ScreenWidth);
int manualHeight = Convert.ToInt32(model.ScreenHeight);
try
{
handler = new MouseToJoystickHandler(deviceId, model.InvertX, model.InvertY, model.AutoCenter, model.AutoScreenSize, manualWidth, manualHeight);
model.SettingsEnabled = false;
}
catch (Exception err)
{
Console.WriteLine("Whoops!");
System.Windows.Forms.MessageBox.Show(err.Message);
model.ShouldRun = false;
}
}
else
{
if (this.handler != null)
{
this.handler.Dispose();
this.handler = null;
}
model.SettingsEnabled = true;
}
}
private void Hyperlink_Click(object sender, RoutedEventArgs e)
{
new OSSInfoWindow().Show();
}
}
}