@@ -20,6 +20,8 @@ public partial class MainForm : Form
20
20
private static int oY = Properties . Settings . Default . offsetY ;
21
21
private static bool showTitle = Properties . Settings . Default . showTitle ;
22
22
private static Color currentColor = Properties . Settings . Default . color ;
23
+ private static bool reverseWindowControls = Properties . Settings . Default . reverseWindowControls ;
24
+ private static bool windowControlsOnTheRight = Properties . Settings . Default . windowControlsOnTheRight ;
23
25
private Settings settingsWindow ;
24
26
private bool preventForceFocus = false ;
25
27
public MainForm ( )
@@ -90,6 +92,7 @@ public void RefreshVisuals()
90
92
this . panelContainer . Padding = new Padding ( OffsetX , OffsetY , OffsetX , OffsetY ) ;
91
93
radius = Properties . Settings . Default . radius ;
92
94
Region = RoundRegion ( Width , Height , radius ) ;
95
+ MoveWindowControls ( WindowControlsOnTheRight ? WindowControlPosition . Right : WindowControlPosition . Left , WindowControlsOnTheRight ) ;
93
96
}
94
97
95
98
private void DockWindow ( )
@@ -121,6 +124,40 @@ public void HideTitle()
121
124
titleWatcher . Stop ( ) ;
122
125
titleText . Hide ( ) ;
123
126
}
127
+ // Needs optimization
128
+ private void MoveWindowControls ( WindowControlPosition position , bool switchButtonPositions )
129
+ {
130
+ switch ( position )
131
+ {
132
+ case WindowControlPosition . Right :
133
+ windowControlsContainer . Location = new Point ( titleBar . Width - 77 , windowControlsContainer . Location . Y ) ;
134
+ windowControlsContainer . Anchor = AnchorStyles . Right | AnchorStyles . Top ;
135
+ settingsButton . Location = new Point ( 20 , 0 ) ;
136
+ settingsButton . Anchor = AnchorStyles . Left | AnchorStyles . Top ;
137
+ // detect if currently close and minimize buttons are switched
138
+ if ( closeButton . Location . X < minimizeButton . Location . X )
139
+ {
140
+ int closeButtonLocationX = closeButton . Location . X ;
141
+ int minimizeButtonLocationX = minimizeButton . Location . X ;
142
+ closeButton . Location = new Point ( minimizeButtonLocationX , closeButton . Location . Y ) ;
143
+ minimizeButton . Location = new Point ( closeButtonLocationX , closeButton . Location . Y ) ;
144
+ }
145
+ break ;
146
+ case WindowControlPosition . Left :
147
+ windowControlsContainer . Location = new Point ( 12 , windowControlsContainer . Location . Y ) ;
148
+ windowControlsContainer . Anchor = AnchorStyles . Left | AnchorStyles . Top ;
149
+ settingsButton . Location = new Point ( titleBar . Width - 49 , 0 ) ;
150
+ settingsButton . Anchor = AnchorStyles . Right | AnchorStyles . Top ;
151
+ if ( closeButton . Location . X > minimizeButton . Location . X )
152
+ {
153
+ int closeButtonLocationX = closeButton . Location . X ;
154
+ int minimizeButtonLocationX = minimizeButton . Location . X ;
155
+ closeButton . Location = new Point ( minimizeButtonLocationX , closeButton . Location . Y ) ;
156
+ minimizeButton . Location = new Point ( closeButtonLocationX , closeButton . Location . Y ) ;
157
+ }
158
+ break ;
159
+ }
160
+ }
124
161
private void MainForm_Load ( object sender , EventArgs e )
125
162
{
126
163
@@ -236,9 +273,15 @@ private void closeButton_Click(object sender, EventArgs e)
236
273
237
274
private void maximizeButton_Click ( object sender , EventArgs e )
238
275
{
239
- Maximize ( ) ;
276
+ if ( ReverseWindowControls )
277
+ Minimize ( ) ;
278
+ else
279
+ Maximize ( ) ;
280
+ }
281
+ private void Minimize ( )
282
+ {
283
+ WindowState = FormWindowState . Minimized ;
240
284
}
241
-
242
285
private void Maximize ( )
243
286
{
244
287
if ( WindowState == FormWindowState . Maximized )
@@ -258,7 +301,10 @@ private Region RoundRegion(int width, int height, int radius)
258
301
}
259
302
private void minimizeButton_Click ( object sender , EventArgs e )
260
303
{
261
- WindowState = FormWindowState . Minimized ;
304
+ if ( ReverseWindowControls )
305
+ Maximize ( ) ;
306
+ else
307
+ Minimize ( ) ;
262
308
}
263
309
264
310
private void titleBar_DoubleClick ( object sender , EventArgs e )
@@ -440,7 +486,10 @@ public int OffsetY
440
486
{
441
487
return oY ;
442
488
}
443
- set { oY = value ; }
489
+ set
490
+ {
491
+ oY = value ;
492
+ }
444
493
}
445
494
public bool ShowTitle
446
495
{
@@ -464,8 +513,34 @@ public Color CurrentColor
464
513
currentColor = value ;
465
514
}
466
515
}
516
+ public bool ReverseWindowControls
517
+ {
518
+ get
519
+ {
520
+ return reverseWindowControls ;
521
+ }
522
+ set
523
+ {
524
+ reverseWindowControls = value ;
525
+ }
526
+ }
527
+ public bool WindowControlsOnTheRight
528
+ {
529
+ get
530
+ {
531
+ return windowControlsOnTheRight ;
532
+ }
533
+ set
534
+ {
535
+ windowControlsOnTheRight = value ;
536
+ }
537
+ }
467
538
468
-
539
+ enum WindowControlPosition
540
+ {
541
+ Left ,
542
+ Right
543
+ }
469
544
470
545
471
546
0 commit comments