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

Commit

Permalink
Added #5 and #7
Browse files Browse the repository at this point in the history
  • Loading branch information
Mika Melikyan authored and Mika Melikyan committed Feb 10, 2016
1 parent cfd9d91 commit 7fc8099
Show file tree
Hide file tree
Showing 13 changed files with 232 additions and 30 deletions.
6 changes: 6 additions & 0 deletions SublimeOverlay/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
<setting name="radius" serializeAs="String">
<value>10</value>
</setting>
<setting name="reverseWindowControls" serializeAs="String">
<value>False</value>
</setting>
<setting name="windowControlsOnTheRight" serializeAs="String">
<value>False</value>
</setting>
</SublimeOverlay.Properties.Settings>
</userSettings>
</configuration>
25 changes: 19 additions & 6 deletions SublimeOverlay/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

85 changes: 80 additions & 5 deletions SublimeOverlay/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public partial class MainForm : Form
private static int oY = Properties.Settings.Default.offsetY;
private static bool showTitle = Properties.Settings.Default.showTitle;
private static Color currentColor = Properties.Settings.Default.color;
private static bool reverseWindowControls = Properties.Settings.Default.reverseWindowControls;
private static bool windowControlsOnTheRight = Properties.Settings.Default.windowControlsOnTheRight;
private Settings settingsWindow;
private bool preventForceFocus = false;
public MainForm()
Expand Down Expand Up @@ -90,6 +92,7 @@ public void RefreshVisuals()
this.panelContainer.Padding = new Padding(OffsetX, OffsetY, OffsetX, OffsetY);
radius = Properties.Settings.Default.radius;
Region = RoundRegion(Width, Height, radius);
MoveWindowControls(WindowControlsOnTheRight ? WindowControlPosition.Right : WindowControlPosition.Left, WindowControlsOnTheRight);
}

private void DockWindow()
Expand Down Expand Up @@ -121,6 +124,40 @@ public void HideTitle()
titleWatcher.Stop();
titleText.Hide();
}
// Needs optimization
private void MoveWindowControls(WindowControlPosition position, bool switchButtonPositions)
{
switch (position)
{
case WindowControlPosition.Right:
windowControlsContainer.Location = new Point(titleBar.Width - 77, windowControlsContainer.Location.Y);
windowControlsContainer.Anchor = AnchorStyles.Right | AnchorStyles.Top;
settingsButton.Location = new Point(20, 0);
settingsButton.Anchor = AnchorStyles.Left | AnchorStyles.Top;
// detect if currently close and minimize buttons are switched
if (closeButton.Location.X < minimizeButton.Location.X)
{
int closeButtonLocationX = closeButton.Location.X;
int minimizeButtonLocationX = minimizeButton.Location.X;
closeButton.Location = new Point(minimizeButtonLocationX, closeButton.Location.Y);
minimizeButton.Location = new Point(closeButtonLocationX, closeButton.Location.Y);
}
break;
case WindowControlPosition.Left:
windowControlsContainer.Location = new Point(12, windowControlsContainer.Location.Y);
windowControlsContainer.Anchor = AnchorStyles.Left | AnchorStyles.Top;
settingsButton.Location = new Point(titleBar.Width - 49, 0);
settingsButton.Anchor = AnchorStyles.Right | AnchorStyles.Top;
if (closeButton.Location.X > minimizeButton.Location.X)
{
int closeButtonLocationX = closeButton.Location.X;
int minimizeButtonLocationX = minimizeButton.Location.X;
closeButton.Location = new Point(minimizeButtonLocationX, closeButton.Location.Y);
minimizeButton.Location = new Point(closeButtonLocationX, closeButton.Location.Y);
}
break;
}
}
private void MainForm_Load(object sender, EventArgs e)
{

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

private void maximizeButton_Click(object sender, EventArgs e)
{
Maximize();
if (ReverseWindowControls)
Minimize();
else
Maximize();
}
private void Minimize()
{
WindowState = FormWindowState.Minimized;
}

private void Maximize()
{
if (WindowState == FormWindowState.Maximized)
Expand All @@ -258,7 +301,10 @@ private Region RoundRegion(int width, int height, int radius)
}
private void minimizeButton_Click(object sender, EventArgs e)
{
WindowState = FormWindowState.Minimized;
if (ReverseWindowControls)
Maximize();
else
Minimize();
}

private void titleBar_DoubleClick(object sender, EventArgs e)
Expand Down Expand Up @@ -440,7 +486,10 @@ public int OffsetY
{
return oY;
}
set { oY = value; }
set
{
oY = value;
}
}
public bool ShowTitle
{
Expand All @@ -464,8 +513,34 @@ public Color CurrentColor
currentColor = value;
}
}
public bool ReverseWindowControls
{
get
{
return reverseWindowControls;
}
set
{
reverseWindowControls = value;
}
}
public bool WindowControlsOnTheRight
{
get
{
return windowControlsOnTheRight;
}
set
{
windowControlsOnTheRight = value;
}
}


enum WindowControlPosition
{
Left,
Right
}



Expand Down
4 changes: 2 additions & 2 deletions SublimeOverlay/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]
24 changes: 24 additions & 0 deletions SublimeOverlay/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions SublimeOverlay/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,11 @@
<Setting Name="radius" Type="System.Int32" Scope="User">
<Value Profile="(Default)">10</Value>
</Setting>
<Setting Name="reverseWindowControls" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="windowControlsOnTheRight" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
Loading

0 comments on commit 7fc8099

Please sign in to comment.