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

Commit

Permalink
Fixed #8
Browse files Browse the repository at this point in the history
  • Loading branch information
avarayr committed Mar 5, 2016
1 parent 20c9970 commit da1252f
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 3 deletions.
6 changes: 6 additions & 0 deletions SublimeOverlay/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
<setting name="windowControlsOnTheRight" serializeAs="String">
<value>False</value>
</setting>
<setting name="lastWindowSize" serializeAs="String">
<value>400, 300</value>
</setting>
<setting name="lastWindowPosition" serializeAs="String">
<value>20, 20</value>
</setting>
</SublimeOverlay.Properties.Settings>
</userSettings>
</configuration>
22 changes: 19 additions & 3 deletions SublimeOverlay/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public MainForm()
Region = RoundRegion(Width, Height, radius);
settingsWindow = new Settings(this);
this.GotFocus += MainForm_GotFocus;
this.MaximumSize = Screen.PrimaryScreen.WorkingArea.Size;
this.MaximumSize = Screen.FromControl(this).WorkingArea.Size;
}

private bool isWindowActive(IntPtr hWnd)
Expand Down Expand Up @@ -115,6 +115,7 @@ private void DockWindow()
ChildTracker.RestoreWindow(pDocked.MainWindowHandle);
HideTitleBar(pDocked.MainWindowHandle);
NativeMethods.SetWindowLong(pDocked.MainWindowHandle, -8 /* OWNER */, (int)container.Handle);
RestorePreviousSize();
FitToWindow();
InvalidateWindow(pDocked.MainWindowHandle);
NativeMethods.SendMessage(pDocked.MainWindowHandle, (uint)0x000F /* WMPAINT */, UIntPtr.Zero, IntPtr.Zero);
Expand Down Expand Up @@ -172,6 +173,7 @@ private void MainForm_Load(object sender, EventArgs e)
}
private void editor_Exited(object sender, EventArgs e)
{
MainForm_FormClosed(null, null); // fire the formclosed event
Environment.Exit(0);
}
private void ParseArgs()
Expand Down Expand Up @@ -327,14 +329,21 @@ private void Maximize()
}
else
{
Region = RoundRegion(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, 0);
Region = RoundRegion(Screen.FromControl(this).Bounds.Width, Screen.FromControl(this).Bounds.Height, 0);
WindowState = FormWindowState.Maximized;
}
}
private Region RoundRegion(int width, int height, int radius)
{
return System.Drawing.Region.FromHrgn(NativeMethods.CreateRoundRectRgn(0, 0, width, height, radius, radius));
}
private void RestorePreviousSize()
{
Size previousSize = Properties.Settings.Default.lastWindowSize;
Point previousPosition = Properties.Settings.Default.lastWindowPosition;
this.Size = previousSize;
this.Location = previousPosition;
}
private void minimizeButton_Click(object sender, EventArgs e)
{
if (ReverseWindowControls)
Expand Down Expand Up @@ -501,11 +510,18 @@ private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
{
try
{
SetRestoreSize();
ChildTracker.Unhook();
pDocked.CloseMainWindow();
}
catch { }
}

private void SetRestoreSize()
{
Properties.Settings.Default.lastWindowSize = Size;
Properties.Settings.Default.lastWindowPosition = Location;
Properties.Settings.Default.Save();
}
private void MainForm_Move(object sender, EventArgs e)
{
if (pDocked != null)
Expand Down
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 @@ -23,5 +23,11 @@
<Setting Name="windowControlsOnTheRight" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="lastWindowSize" Type="System.Drawing.Size" Scope="User">
<Value Profile="(Default)">400, 300</Value>
</Setting>
<Setting Name="lastWindowPosition" Type="System.Drawing.Point" Scope="User">
<Value Profile="(Default)">20, 20</Value>
</Setting>
</Settings>
</SettingsFile>
6 changes: 6 additions & 0 deletions SublimeOverlay/bin/Release/SublimeOverlay.exe.config
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
<setting name="windowControlsOnTheRight" serializeAs="String">
<value>False</value>
</setting>
<setting name="lastWindowSize" serializeAs="String">
<value>400, 300</value>
</setting>
<setting name="lastWindowPosition" serializeAs="String">
<value>20, 20</value>
</setting>
</SublimeOverlay.Properties.Settings>
</userSettings>
</configuration>
6 changes: 6 additions & 0 deletions SublimeOverlay/bin/Release/SublimeOverlay.vshost.exe.config
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
<setting name="windowControlsOnTheRight" serializeAs="String">
<value>False</value>
</setting>
<setting name="lastWindowSize" serializeAs="String">
<value>400, 300</value>
</setting>
<setting name="lastWindowPosition" serializeAs="String">
<value>20, 20</value>
</setting>
</SublimeOverlay.Properties.Settings>
</userSettings>
</configuration>

0 comments on commit da1252f

Please sign in to comment.