private void HandleIconMouseDown(object sender, MouseButtonEventArgs e) { switch (e.ChangedButton) { case MouseButton.Left: if (e.ClickCount == 1) { e.Handled = true; WindowSteeringHelper.ShowSystemMenuPhysicalCoordinates(this, e, this.PointToScreen(new Point(0, this.TitleBarHeight))); } else if (e.ClickCount == 2) { e.Handled = true; this.Close(); } break; case MouseButton.Right: e.Handled = true; this.RunInDispatcherAsync(() => WindowSteeringHelper.ShowSystemMenuPhysicalCoordinates(this, e)); break; } }
/// <summary> /// Invoked when an unhandled <see cref="E:System.Windows.UIElement.MouseRightButtonUp"/> routed event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event. /// </summary> /// <param name="e">The <see cref="T:System.Windows.Input.MouseButtonEventArgs"/> that contains the event data. The event data reports that the right mouse button was released.</param> protected override void OnMouseRightButtonUp(MouseButtonEventArgs e) { base.OnMouseRightButtonUp(e); if (this.IsEnabled) { WindowSteeringHelper.ShowSystemMenuPhysicalCoordinates(this, e); } }