From ea47cafd7019e7adbc4d8f839aa4aaad8d6061d5 Mon Sep 17 00:00:00 2001 From: Michael Scrivo Date: Sun, 14 Jun 2020 10:24:00 -0400 Subject: [PATCH] Hide header when locked This closes #143 --- OotD.Core/Forms/InstanceManager.cs | 28 ++++++++++++---------------- OotD.Core/Forms/MainForm.cs | 18 +++++++++--------- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/OotD.Core/Forms/InstanceManager.cs b/OotD.Core/Forms/InstanceManager.cs index a9ac289..e700ef0 100644 --- a/OotD.Core/Forms/InstanceManager.cs +++ b/OotD.Core/Forms/InstanceManager.cs @@ -319,6 +319,7 @@ public void LoadInstances() var lockPositionMenu = (ToolStripMenuItem)trayIcon.ContextMenuStrip.Items["LockPositionMenu"]; lockPositionMenu.Checked = GlobalPreferences.LockPosition; + LockOrUnlock(GlobalPreferences.LockPosition); } private void ChangeTrayIconDate() @@ -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; } } diff --git a/OotD.Core/Forms/MainForm.cs b/OotD.Core/Forms/MainForm.cs index 0103912..cc87058 100644 --- a/OotD.Core/Forms/MainForm.cs +++ b/OotD.Core/Forms/MainForm.cs @@ -26,7 +26,7 @@ namespace OotD.Forms /// public partial class MainForm : Form { - private const int _resizeBorderWidth = 4; + private const int ResizeBorderWidth = 4; private string? _customFolder; private ToolStripMenuItem? _customMenu; private MAPIFolder? _outlookFolder; @@ -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; }