forked from arkane-systems/mousejiggler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainForm.cs
132 lines (109 loc) · 3.61 KB
/
MainForm.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#region header
// MouseJiggle - MainForm.cs
//
// Alistair J. R. Young
// Arkane Systems
//
// Copyright Arkane Systems 2012-2013.
//
// Created: 2013-08-24 12:41 PM
#endregion
using System;
using System.Windows.Forms;
using Microsoft.Win32;
namespace ArkaneSystems.MouseJiggle
{
public partial class MainForm : Form
{
private const int MOUSEMOVE = 8;
protected bool zig = true;
public MainForm ()
{
this.InitializeComponent ();
}
private void jiggleTimer_Tick (object sender, EventArgs e)
{
// jiggle
if (this.cbZenJiggle.Checked)
Jiggler.Jiggle (0, 0);
else
{
if (this.zig)
Jiggler.Jiggle (4, 4);
else // zag
{
// I really don't know why this needs to be less to stay in the same
// place; if I was likely to use it again, then I'd worry.
Jiggler.Jiggle (-4, -4);
}
}
this.zig = !this.zig;
}
private void cbEnabled_CheckedChanged (object sender, EventArgs e)
{
this.jiggleTimer.Enabled = this.cbEnabled.Checked;
}
private void cmdAbout_Click (object sender, EventArgs e)
{
using (var a = new AboutBox ())
a.ShowDialog ();
}
private void MainForm_Load (object sender, EventArgs e)
{
try
{
RegistryKey key = Registry.CurrentUser.CreateSubKey (@"Software\Arkane Systems\MouseJiggle",
RegistryKeyPermissionCheck.ReadWriteSubTree);
var zen = (int) key.GetValue ("ZenJiggleEnabled", 0);
if (zen == 0)
this.cbZenJiggle.Checked = false;
else
this.cbZenJiggle.Checked = true;
}
catch (Exception)
{
// Ignore any problems - non-critical operation.
}
if (Program.ZenJiggling)
this.cbZenJiggle.Checked = true;
if (Program.StartJiggling)
this.cbEnabled.Checked = true;
if (Program.StartMinimized)
this.cmdToTray_Click(this, null);
}
private void cbZenJiggle_CheckedChanged (object sender, EventArgs e)
{
try
{
RegistryKey key = Registry.CurrentUser.CreateSubKey (@"Software\Arkane Systems\MouseJiggle",
RegistryKeyPermissionCheck.ReadWriteSubTree);
if (this.cbZenJiggle.Checked)
key.SetValue ("ZenJiggleEnabled", 1);
else
key.SetValue ("ZenJiggleEnabled", 0);
}
catch (Exception)
{
// Ignore any problems - non-critical operation.
}
}
private void cmdToTray_Click (object sender, EventArgs e)
{
// minimize to tray
this.Visible = false;
// remove from taskbar
this.ShowInTaskbar = false;
// show tray icon
this.nifMin.Visible = true;
}
private void nifMin_DoubleClick (object sender, EventArgs e)
{
// restore the window
this.Visible = true;
// replace in taskbar
this.ShowInTaskbar = true;
// hide tray icon
this.nifMin.Visible = false;
}
}
}