-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.xaml.cs
107 lines (97 loc) · 3.1 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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System.Windows;
using System.Text.RegularExpressions;
using System.Windows.Input;
using System.Threading;
using System.Windows.Media;
namespace MouseMover
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
#region Initalset General
public static bool running = false;
public static bool smooth = false;
public static bool abort = false;
public static int seconds = 0;
public static int MoveSteps = 100;
Thread t1;
#endregion
public MainWindow()
{
InitializeComponent();
#region Initalset WPF
input_str.IsEnabled = true;
start_btn.IsEnabled = true;
seconds_label.Opacity = 0;
Operation.Opacity = 0;
Status.Fill = new SolidColorBrush(Colors.Red);
#endregion
this.KeyDown += new KeyEventHandler(MainWindow_KeyDown);
}
void MainWindow_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.F5)
{
Status.Fill = new SolidColorBrush(Colors.Orange);
running = false;
input_str.IsEnabled = true;
abort = true;
Operation.Opacity = 100;
start_btn.Content = "Start Idle";
}
}
private void start_btn_Click(object sender, RoutedEventArgs e)
{
if (running == false)
{
if(seconds >= 5)
{
abort = false;
Operation.Opacity = 0;
input_str.IsEnabled = false;
seconds_label.Opacity = 0;
running = true;
start_btn.Content = "Stopp Idle";
Status.Fill = new SolidColorBrush(Colors.Green);
t1 = new Thread(new ThreadStart(Moving.Move));
t1.Start();
}
else
{
seconds_label.Opacity = 100;
}
}
else
{
abort = true;
input_str.IsEnabled = true;
running = false;
start_btn.Content = "Start Idle";
Status.Fill = new SolidColorBrush(Colors.Red);
}
}
private void PreviewTextInput(object sender, TextCompositionEventArgs e)
{
Regex regex = new Regex("[^0-9]+");
e.Handled = regex.IsMatch(e.Text);
}
private void input_str_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
{
if (input_str.Text != null)
{
start_btn.IsEnabled = true;
seconds = int.Parse(input_str.Text);
}
else
{
start_btn.IsEnabled = false;
}
}
private void CheckBox_Click(object sender, RoutedEventArgs e)
{
smooth = (bool)Smooth_Mouse.IsChecked;
}
}
}