1
1
using System ;
2
- using System . Windows . Controls ;
2
+ using System . Diagnostics ;
3
+ using System . IO ;
3
4
using System . Windows ;
5
+ using System . Windows . Controls ;
4
6
using System . Windows . Forms ;
5
7
using System . Windows . Forms . Integration ;
6
- using System . Diagnostics ;
7
- using System . IO ;
8
+ using System . Windows . Media ;
8
9
using SindenCompanionShared ;
10
+ using Application = System . Windows . Forms . Application ;
11
+ using RichTextBox = System . Windows . Controls . RichTextBox ;
9
12
10
13
namespace SindenCompanion
11
14
{
12
15
public partial class AppForm : Form
13
16
{
14
- public readonly System . Windows . Controls . RichTextBox WpfRichTextBox ;
15
-
16
- private bool _userRequestedClose = false ;
17
-
18
17
private readonly Config _conf ;
18
+ public readonly RichTextBox WpfRichTextBox ;
19
19
20
20
private Action < RecoilProfile > _callback ;
21
+
22
+ private bool _userRequestedClose ;
23
+
21
24
public AppForm ( Config conf )
22
25
{
23
26
_conf = conf ;
24
27
InitializeComponent ( ) ;
25
28
var richTextBoxHost = new ElementHost
26
29
{
27
- Dock = DockStyle . Fill ,
30
+ Dock = DockStyle . Fill
28
31
} ;
29
32
30
33
_richTextBoxPanel . Controls . Add ( richTextBoxHost ) ;
31
34
32
- var wpfRichTextBox = new System . Windows . Controls . RichTextBox
35
+ var wpfRichTextBox = new RichTextBox
33
36
{
34
- Background = System . Windows . Media . Brushes . Black ,
35
- Foreground = System . Windows . Media . Brushes . LightGray ,
36
- FontFamily = new System . Windows . Media . FontFamily ( "Cascadia Mono, Consolas, Courier New, monospace" ) ,
37
+ Background = Brushes . Black ,
38
+ Foreground = Brushes . LightGray ,
39
+ FontFamily = new FontFamily ( "Cascadia Mono, Consolas, Courier New, monospace" ) ,
37
40
FontSize = 14 ,
38
41
IsReadOnly = true ,
39
42
VerticalScrollBarVisibility = ScrollBarVisibility . Auto ,
40
43
HorizontalScrollBarVisibility = ScrollBarVisibility . Auto ,
41
- Margin = new Thickness ( 0 ) ,
44
+ Margin = new Thickness ( 0 )
42
45
} ;
43
46
44
47
wpfRichTextBox . TextChanged += wpfRichTextBox_TextChanged ;
@@ -54,7 +57,6 @@ public void SetCallback(Action<RecoilProfile> callback)
54
57
55
58
private void AppForm_Load ( object sender , EventArgs e )
56
59
{
57
-
58
60
}
59
61
60
62
private void wpfRichTextBox_TextChanged ( object sender , EventArgs e )
@@ -73,22 +75,22 @@ private void AppForm_FormClosing(object sender, FormClosingEventArgs e)
73
75
74
76
private void notificationIcon_MouseDoubleClick ( object sender , MouseEventArgs e )
75
77
{
76
- this . WindowState = FormWindowState . Minimized ;
78
+ WindowState = FormWindowState . Minimized ;
77
79
Show ( ) ;
78
- this . WindowState = FormWindowState . Normal ;
80
+ WindowState = FormWindowState . Normal ;
79
81
}
80
82
81
83
private void showMenuItem_Click ( object sender , EventArgs e )
82
84
{
83
- this . WindowState = FormWindowState . Minimized ;
85
+ WindowState = FormWindowState . Minimized ;
84
86
Show ( ) ;
85
- this . WindowState = FormWindowState . Normal ;
87
+ WindowState = FormWindowState . Normal ;
86
88
}
87
89
88
90
private void exitMenuItem_Click ( object sender , EventArgs e )
89
91
{
90
92
_userRequestedClose = true ;
91
- System . Windows . Forms . Application . Exit ( ) ;
93
+ Application . Exit ( ) ;
92
94
}
93
95
94
96
private void configFileMenuItem_Click ( object sender , EventArgs e )
@@ -99,13 +101,9 @@ private void configFileMenuItem_Click(object sender, EventArgs e)
99
101
private void bootMenuItem_Click ( object sender , EventArgs e )
100
102
{
101
103
if ( Startup . IsInStartup ( ) )
102
- {
103
104
Startup . RemoveFromStartup ( ) ;
104
- }
105
105
else
106
- {
107
106
Startup . RunOnStartup ( ) ;
108
- }
109
107
110
108
bootMenuItem . Checked = Startup . IsInStartup ( ) ;
111
109
}
@@ -117,22 +115,18 @@ private void NotificationIconMenu_Opened(object sender, EventArgs e)
117
115
foreach ( var profile in _conf . RecoilProfiles )
118
116
{
119
117
var item = new ToolStripMenuItem ( profile . Name ) ;
120
- item . Click += ( s , a ) =>
121
- {
122
- _callback ( profile ) ;
123
- } ;
118
+ item . Click += ( s , a ) => { _callback ( profile ) ; } ;
124
119
changeProfileMenuItem . DropDownItems . Add ( item ) ;
125
- }
120
+ }
126
121
}
127
122
128
123
private void AppForm_Resize ( object sender , EventArgs e )
129
124
{
130
- if ( this . WindowState == FormWindowState . Minimized )
125
+ if ( WindowState == FormWindowState . Minimized )
131
126
{
132
127
Hide ( ) ;
133
128
NotificationIcon . Visible = true ;
134
129
}
135
130
}
136
-
137
131
}
138
- }
132
+ }
0 commit comments