Skip to content
This repository was archived by the owner on Oct 18, 2021. It is now read-only.

Commit 7fc8099

Browse files
Mika MelikyanMika Melikyan
authored andcommitted
Added #5 and #7
1 parent cfd9d91 commit 7fc8099

13 files changed

+232
-30
lines changed

SublimeOverlay/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
<setting name="radius" serializeAs="String">
2626
<value>10</value>
2727
</setting>
28+
<setting name="reverseWindowControls" serializeAs="String">
29+
<value>False</value>
30+
</setting>
31+
<setting name="windowControlsOnTheRight" serializeAs="String">
32+
<value>False</value>
33+
</setting>
2834
</SublimeOverlay.Properties.Settings>
2935
</userSettings>
3036
</configuration>

SublimeOverlay/MainForm.Designer.cs

Lines changed: 19 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SublimeOverlay/MainForm.cs

Lines changed: 80 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public partial class MainForm : Form
2020
private static int oY = Properties.Settings.Default.offsetY;
2121
private static bool showTitle = Properties.Settings.Default.showTitle;
2222
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;
2325
private Settings settingsWindow;
2426
private bool preventForceFocus = false;
2527
public MainForm()
@@ -90,6 +92,7 @@ public void RefreshVisuals()
9092
this.panelContainer.Padding = new Padding(OffsetX, OffsetY, OffsetX, OffsetY);
9193
radius = Properties.Settings.Default.radius;
9294
Region = RoundRegion(Width, Height, radius);
95+
MoveWindowControls(WindowControlsOnTheRight ? WindowControlPosition.Right : WindowControlPosition.Left, WindowControlsOnTheRight);
9396
}
9497

9598
private void DockWindow()
@@ -121,6 +124,40 @@ public void HideTitle()
121124
titleWatcher.Stop();
122125
titleText.Hide();
123126
}
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+
}
124161
private void MainForm_Load(object sender, EventArgs e)
125162
{
126163

@@ -236,9 +273,15 @@ private void closeButton_Click(object sender, EventArgs e)
236273

237274
private void maximizeButton_Click(object sender, EventArgs e)
238275
{
239-
Maximize();
276+
if (ReverseWindowControls)
277+
Minimize();
278+
else
279+
Maximize();
280+
}
281+
private void Minimize()
282+
{
283+
WindowState = FormWindowState.Minimized;
240284
}
241-
242285
private void Maximize()
243286
{
244287
if (WindowState == FormWindowState.Maximized)
@@ -258,7 +301,10 @@ private Region RoundRegion(int width, int height, int radius)
258301
}
259302
private void minimizeButton_Click(object sender, EventArgs e)
260303
{
261-
WindowState = FormWindowState.Minimized;
304+
if (ReverseWindowControls)
305+
Maximize();
306+
else
307+
Minimize();
262308
}
263309

264310
private void titleBar_DoubleClick(object sender, EventArgs e)
@@ -440,7 +486,10 @@ public int OffsetY
440486
{
441487
return oY;
442488
}
443-
set { oY = value; }
489+
set
490+
{
491+
oY = value;
492+
}
444493
}
445494
public bool ShowTitle
446495
{
@@ -464,8 +513,34 @@ public Color CurrentColor
464513
currentColor = value;
465514
}
466515
}
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+
}
467538

468-
539+
enum WindowControlPosition
540+
{
541+
Left,
542+
Right
543+
}
469544

470545

471546

SublimeOverlay/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.1.0.0")]
36-
[assembly: AssemblyFileVersion("1.1.0.0")]
35+
[assembly: AssemblyVersion("1.2.0.0")]
36+
[assembly: AssemblyFileVersion("1.2.0.0")]

SublimeOverlay/Properties/Settings.Designer.cs

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SublimeOverlay/Properties/Settings.settings

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,11 @@
1717
<Setting Name="radius" Type="System.Int32" Scope="User">
1818
<Value Profile="(Default)">10</Value>
1919
</Setting>
20+
<Setting Name="reverseWindowControls" Type="System.Boolean" Scope="User">
21+
<Value Profile="(Default)">False</Value>
22+
</Setting>
23+
<Setting Name="windowControlsOnTheRight" Type="System.Boolean" Scope="User">
24+
<Value Profile="(Default)">False</Value>
25+
</Setting>
2026
</Settings>
2127
</SettingsFile>

0 commit comments

Comments
 (0)