diff --git a/OutlookDesktop/Forms/MainForm.Designer.cs b/OutlookDesktop/Forms/MainForm.Designer.cs index 27b6642..6f71dc6 100644 --- a/OutlookDesktop/Forms/MainForm.Designer.cs +++ b/OutlookDesktop/Forms/MainForm.Designer.cs @@ -77,6 +77,7 @@ private void InitializeComponent() this.NotifyIcon = new System.Windows.Forms.NotifyIcon(this.components); this.ToolTip = new System.Windows.Forms.ToolTip(this.components); this.WindowMessageTimer = new System.Windows.Forms.Timer(this.components); + this.label1 = new System.Windows.Forms.Label(); this.TrayMenu.SuspendLayout(); this.HeaderPanel.SuspendLayout(); this.ViewControlHostPanel.SuspendLayout(); @@ -237,6 +238,7 @@ private void InitializeComponent() // HeaderPanel // this.HeaderPanel.BackColor = System.Drawing.SystemColors.ActiveCaption; + this.HeaderPanel.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.HeaderPanel.Controls.Add(this.TransparencySlider); this.HeaderPanel.Controls.Add(this.LabelCurrentDate); this.HeaderPanel.Controls.Add(this.ButtonPrevious); @@ -246,6 +248,7 @@ private void InitializeComponent() this.HeaderPanel.Controls.Add(this.MonthButton); this.HeaderPanel.Controls.Add(this.WeekButton); this.HeaderPanel.Controls.Add(this.DayButton); + this.HeaderPanel.Controls.Add(this.label1); this.HeaderPanel.Dock = System.Windows.Forms.DockStyle.Top; this.HeaderPanel.Location = new System.Drawing.Point(4, 4); this.HeaderPanel.Margin = new System.Windows.Forms.Padding(4); @@ -290,10 +293,12 @@ private void InitializeComponent() // // LabelCurrentDate // - this.LabelCurrentDate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.LabelCurrentDate.Location = new System.Drawing.Point(167, -1); + this.LabelCurrentDate.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.LabelCurrentDate.Location = new System.Drawing.Point(97, -1); this.LabelCurrentDate.Name = "LabelCurrentDate"; - this.LabelCurrentDate.Size = new System.Drawing.Size(178, 20); + this.LabelCurrentDate.Size = new System.Drawing.Size(246, 20); this.LabelCurrentDate.TabIndex = 9; this.LabelCurrentDate.TextAlign = System.Drawing.ContentAlignment.MiddleRight; this.ToolTip.SetToolTip(this.LabelCurrentDate, global::OutlookDesktop.Properties.Resources.Form_Move_Help_Message); @@ -339,9 +344,9 @@ private void InitializeComponent() this.TodayButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.TodayButton.ForeColor = System.Drawing.SystemColors.ActiveCaption; this.TodayButton.Image = global::OutlookDesktop.Properties.Resources.Today; - this.TodayButton.Location = new System.Drawing.Point(349, -1); + this.TodayButton.Location = new System.Drawing.Point(349, -2); this.TodayButton.Name = "TodayButton"; - this.TodayButton.Size = new System.Drawing.Size(20, 19); + this.TodayButton.Size = new System.Drawing.Size(20, 20); this.TodayButton.TabIndex = 1; this.ToolTip.SetToolTip(this.TodayButton, global::OutlookDesktop.Properties.Resources.Go_to_Today); this.TodayButton.UseVisualStyleBackColor = true; @@ -452,6 +457,16 @@ private void InitializeComponent() // this.WindowMessageTimer.Tick += new System.EventHandler(this.WindowMessageTimer_Tick); // + // label1 + // + this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.label1.Location = new System.Drawing.Point(340, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(167, 19); + this.label1.TabIndex = 11; + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -520,6 +535,7 @@ private void InitializeComponent() public System.Windows.Forms.Label LabelCurrentDate; #pragma warning disable CS3003 // Type is not CLS-compliant public MACTrackBar TransparencySlider; + private System.Windows.Forms.Label label1; #pragma warning restore CS3003 // Type is not CLS-compliant } } \ No newline at end of file diff --git a/OutlookDesktop/Forms/MainForm.cs b/OutlookDesktop/Forms/MainForm.cs index 30e92c9..0f49393 100644 --- a/OutlookDesktop/Forms/MainForm.cs +++ b/OutlookDesktop/Forms/MainForm.cs @@ -2,7 +2,6 @@ using System.Collections; using System.Collections.Generic; using System.Diagnostics; -using System.Drawing; using System.Globalization; using System.Linq; using System.Runtime.InteropServices; @@ -38,7 +37,6 @@ public partial class MainForm : Form private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); // ReSharper disable once NotAccessedField.Local private StickyWindow _stickyWindow; - private bool _formMovedOrResized; /// /// Sets up the form for the current instance. @@ -73,8 +71,18 @@ public MainForm(string instanceName) ResumeLayout(); SendWindowToBack(); + // hook up sticky window instance and events to let us know when resizing/moving + // has ended so we can update the form dimensions in the preferences. _stickyWindow = new StickyWindow(this); - + _stickyWindow.MoveEnded += (sender, args) => + { + SaveFormDimensions(); + }; + _stickyWindow.ResizeEnded += (sender, args) => + { + SaveFormDimensions(); + }; + // hook up event to keep the date in the header bar up to date OutlookViewControl.SelectionChange += OnAxOutlookViewControlOnSelectionChange; } @@ -120,7 +128,6 @@ protected override CreateParams CreateParams { CreateParams cp = base.CreateParams; cp.ExStyle |= 0x80; // Turn on WS_EX_TOOLWINDOW style bit to hide window from alt-tab - //cp.ExStyle |= 0x02000000; // Turn on WS_EX_COMPOSITED to turn on double-buffering for the entire form and controls. return cp; } } @@ -622,7 +629,6 @@ private void ResizeForm(ResizeDirection direction) { UnsafeNativeMethods.ReleaseCapture(); UnsafeNativeMethods.SendMessage(Handle, UnsafeNativeMethods.WM_NCLBUTTONDOWN, (IntPtr)dir, IntPtr.Zero); - _formMovedOrResized = true; } } @@ -633,8 +639,6 @@ private void MoveForm() UnsafeNativeMethods.ReleaseCapture(); UnsafeNativeMethods.SendMessage(Handle, UnsafeNativeMethods.WM_NCLBUTTONDOWN, (IntPtr)UnsafeNativeMethods.HTCAPTION, IntPtr.Zero); - - _formMovedOrResized = true; } #region Event Handlers @@ -765,16 +769,19 @@ private void UpdateTimer_Tick(object sender, EventArgs e) } } _previousDate = DateTime.Now; + } - // Update our position in the settings - if (_formMovedOrResized) - { - Preferences.Left = Left; - Preferences.Top = Top; - Preferences.Width = Width; - Preferences.Height = Height; - _formMovedOrResized = false; - } + private void SaveFormDimensions() + { + Debug.WriteLine("Saving window position"); + Debug.WriteLine("Left: {0}", Left); + Debug.WriteLine("Top: {0}", Top); + Debug.WriteLine("Width: {0}", Width); + Debug.WriteLine("Height: {0}", Height); + Preferences.Left = Left; + Preferences.Top = Top; + Preferences.Width = Width; + Preferences.Height = Height; } private void ExitMenu_Click(object sender, EventArgs e) diff --git a/OutlookDesktop/Forms/MainForm.resx b/OutlookDesktop/Forms/MainForm.resx index 24ae31e..439099e 100644 --- a/OutlookDesktop/Forms/MainForm.resx +++ b/OutlookDesktop/Forms/MainForm.resx @@ -126,6 +126,12 @@ 355, 17 + + 355, 17 + + + 355, 17 + @@ -142,6 +148,9 @@ Rb/fGQZAu092OCV66NLZAAAAAElFTkSuQmCC + + 355, 17 + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w diff --git a/OutlookDesktop/Properties/AssemblyInfo.cs b/OutlookDesktop/Properties/AssemblyInfo.cs index 4821903..10474cf 100644 --- a/OutlookDesktop/Properties/AssemblyInfo.cs +++ b/OutlookDesktop/Properties/AssemblyInfo.cs @@ -29,8 +29,8 @@ // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("3.2.3.1")] -[assembly: AssemblyFileVersion("3.2.3.1")] +[assembly: AssemblyVersion("3.2.4.0")] +[assembly: AssemblyFileVersion("3.2.4.0")] // // In order to sign your assembly you must specify a key to use. Refer to the diff --git a/OutlookDesktop/Utility/StickyWindow.cs b/OutlookDesktop/Utility/StickyWindow.cs index 0d9acbf..5e5d3f2 100644 --- a/OutlookDesktop/Utility/StickyWindow.cs +++ b/OutlookDesktop/Utility/StickyWindow.cs @@ -17,6 +17,7 @@ using System; using System.Collections; +using System.ComponentModel; using System.Drawing; using System.Runtime.InteropServices; using System.Security.Permissions; @@ -139,6 +140,9 @@ public class StickyWindow : NativeWindow // public properties private static int _stickGap = 10; // distance to stick + public event EventHandler ResizeEnded; + public event EventHandler MoveEnded; + #region StickyWindow Constructor /// @@ -477,6 +481,7 @@ private bool ResizeMsgProcessor(ref Message m) private void EndResize() { Cancel(); + OnResizeEnded(); } #endregion @@ -686,6 +691,7 @@ private bool MoveMsgProcessor(ref Message m) private void EndMove() { Cancel(); + OnMoveEnded(); } #endregion @@ -774,12 +780,12 @@ private void Move_Stick(Rectangle toRect, bool bInsideStick) { if (bInsideStick) { - if (Math.Abs(_formRect.Top - toRect.Bottom) <= Math.Abs(_formOffsetPoint.Y) && bInsideStick) + if (Math.Abs(_formRect.Top - toRect.Bottom) <= Math.Abs(_formOffsetPoint.Y)) { // Stick Top to Bottom _formOffsetPoint.Y = toRect.Bottom - _formRect.Top; } - if (Math.Abs(_formRect.Top + _formRect.Height - toRect.Top) <= Math.Abs(_formOffsetPoint.Y) && bInsideStick) + if (Math.Abs(_formRect.Top + _formRect.Height - toRect.Top) <= Math.Abs(_formOffsetPoint.Y)) { // snap Bottom to Top _formOffsetPoint.Y = toRect.Top - _formRect.Height - _formRect.Top; @@ -801,5 +807,15 @@ private void Move_Stick(Rectangle toRect, bool bInsideStick) } #endregion + + protected virtual void OnResizeEnded() + { + ResizeEnded?.Invoke(this, EventArgs.Empty); + } + + protected virtual void OnMoveEnded() + { + MoveEnded?.Invoke(this, EventArgs.Empty); + } } } \ No newline at end of file