/// <summary> /// Hides the window /// </summary> private void HideWindow() { // note if mouse is over the notify icon when hiding the window // if it is, we will assume that the user clicked the icon to hide the window this.MouseClickToHideNotifyIcon = WindowPositioning.IsCursorOverNotifyIcon(this.NotifyIcon) && WindowPositioning.IsNotificationAreaActive; if (this.MouseClickToHideNotifyIcon) { this.MouseClickToHideNotifyIconPoint = WindowPositioning.GetCursorPosition(); } this.ReleaseHandlers(); this.Visibility = Visibility.Hidden; }
/// <summary> /// Notify icon clicked or double-clicked method. /// </summary> /// <param name="sender">The sender of the message.</param> /// <param name="args">System.Windows.Forms.MouseEventArgs (which mouse button was pressed, etc.).</param> private void NotifyIconClick(object sender, System.Windows.Forms.MouseEventArgs args) { // sorry if you swapped the primary mouse button if (args.Button == System.Windows.Forms.MouseButtons.Left && (!this.MouseClickToHideNotifyIcon || (WindowPositioning.GetCursorPosition().X != this.MouseClickToHideNotifyIconPoint.X || WindowPositioning.GetCursorPosition().Y != this.MouseClickToHideNotifyIconPoint.Y))) { if (!this.IsLoaded) { this.Show(); } this.UpdateWindowDisplay(true); } else { this.MouseClickToHideNotifyIcon = false; } }