Skip to content

Commit

Permalink
Hide header when locked
Browse files Browse the repository at this point in the history
This closes #143
  • Loading branch information
mscrivo committed Jun 14, 2020
1 parent 86b2e21 commit ea47caf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 25 deletions.
28 changes: 12 additions & 16 deletions OotD.Core/Forms/InstanceManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ public void LoadInstances()

var lockPositionMenu = (ToolStripMenuItem)trayIcon.ContextMenuStrip.Items["LockPositionMenu"];
lockPositionMenu.Checked = GlobalPreferences.LockPosition;
LockOrUnlock(GlobalPreferences.LockPosition);
}

private void ChangeTrayIconDate()
Expand Down Expand Up @@ -453,28 +454,23 @@ private void LockPositionMenu_Click(object? sender, EventArgs e)
var lockPositionMenu = (ToolStripMenuItem)trayIcon.ContextMenuStrip.Items["LockPositionMenu"];
if (lockPositionMenu.Checked)
{
GlobalPreferences.LockPosition = false;
lockPositionMenu.Checked = false;

foreach (var (_, formInstance) in _mainFormInstances)
{
formInstance.TransparencySlider.Enabled = true;
formInstance.ToolTip.SetToolTip(formInstance.TransparencySlider, Resources.Transparency_Slider_Help_Message);
formInstance.ToolTip.SetToolTip(formInstance.LabelCurrentDate, Resources.Form_Move_Help_Message);
}
LockOrUnlock(false);
}
else
{
GlobalPreferences.LockPosition = true;
lockPositionMenu.Checked = true;
LockOrUnlock(true);
}
}

foreach (var formInstance in _mainFormInstances)
{
formInstance.Value.TransparencySlider.Enabled = false;
formInstance.Value.ToolTip.SetToolTip(formInstance.Value.TransparencySlider, Resources.Transparency_Slider_Locked_Message);
formInstance.Value.ToolTip.SetToolTip(formInstance.Value.HeaderPanel, Resources.Form_Move_Locked_Message);
formInstance.Value.ToolTip.SetToolTip(formInstance.Value.LabelCurrentDate, Resources.Form_Move_Locked_Message);
}
private void LockOrUnlock(bool @lock)
{
GlobalPreferences.LockPosition = @lock;

foreach (var (_, formInstance) in _mainFormInstances)
{
formInstance.HeaderPanel.Visible = !@lock;
}
}

Expand Down
18 changes: 9 additions & 9 deletions OotD.Core/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace OotD.Forms
/// </summary>
public partial class MainForm : Form
{
private const int _resizeBorderWidth = 4;
private const int ResizeBorderWidth = 4;
private string? _customFolder;
private ToolStripMenuItem? _customMenu;
private MAPIFolder? _outlookFolder;
Expand Down Expand Up @@ -917,42 +917,42 @@ private void MainForm_MouseMove(object sender, MouseEventArgs e)
return;
}

if (e.Location.X < _resizeBorderWidth && e.Location.Y < _resizeBorderWidth)
if (e.Location.X < ResizeBorderWidth && e.Location.Y < ResizeBorderWidth)
{
ResizeDir = ResizeDirection.TopLeft;
}

else if (e.Location.X < _resizeBorderWidth && e.Location.Y > Height - _resizeBorderWidth)
else if (e.Location.X < ResizeBorderWidth && e.Location.Y > Height - ResizeBorderWidth)
{
ResizeDir = ResizeDirection.BottomLeft;
}

else if (e.Location.X > Width - _resizeBorderWidth && e.Location.Y > Height - _resizeBorderWidth)
else if (e.Location.X > Width - ResizeBorderWidth && e.Location.Y > Height - ResizeBorderWidth)
{
ResizeDir = ResizeDirection.BottomRight;
}

else if (e.Location.X > Width - _resizeBorderWidth && e.Location.Y < _resizeBorderWidth)
else if (e.Location.X > Width - ResizeBorderWidth && e.Location.Y < ResizeBorderWidth)
{
ResizeDir = ResizeDirection.TopRight;
}

else if (e.Location.X < _resizeBorderWidth)
else if (e.Location.X < ResizeBorderWidth)
{
ResizeDir = ResizeDirection.Left;
}

else if (e.Location.X > Width - _resizeBorderWidth)
else if (e.Location.X > Width - ResizeBorderWidth)
{
ResizeDir = ResizeDirection.Right;
}

else if (e.Location.Y < _resizeBorderWidth)
else if (e.Location.Y < ResizeBorderWidth)
{
ResizeDir = ResizeDirection.Top;
}

else if (e.Location.Y > Height - _resizeBorderWidth)
else if (e.Location.Y > Height - ResizeBorderWidth)
{
ResizeDir = ResizeDirection.Bottom;
}
Expand Down

0 comments on commit ea47caf

Please sign in to comment.