Exemplo n.º 1
0
        /// <summary>
        /// Change window state on MouseDoubleClick
        /// </summary>
        /// <param name="window"></param>
        /// <param name="e"></param>
        internal static void DoThumbMouseDoubleClick(Window window, MouseButtonEventArgs e)
        {
            // restore/maximize only with left button
            if (e.ChangedButton == MouseButton.Left)
            {
                // we can maximize or restore the window if the title bar height is set (also if title bar is hidden)
                var canResize         = window.ResizeMode == ResizeMode.CanResizeWithGrip || window.ResizeMode == ResizeMode.CanResize;
                var mousePos          = Mouse.GetPosition(window);
                var isMouseOnTitlebar = mousePos.Y <= window.TitleBarHeight && window.TitleBarHeight > 0;
                if (canResize && isMouseOnTitlebar)
                {
#pragma warning disable 618
                    if (window.WindowState == WindowState.Normal)
                    {
                        SystemCommands.MaximizeWindow(window);
                    }
                    else
                    {
                        SystemCommands.RestoreWindow(window);
                    }
#pragma warning restore 618
                    e.Handled = true;
                }
            }
        }
Exemplo n.º 2
0
        private void OnRestoreWindow(object target, ExecutedRoutedEventArgs e)
        {
#if NET4
            Microsoft.Windows.Shell.SystemCommands.RestoreWindow(this);
#else
            SystemCommands.RestoreWindow(this);
#endif
        }
Exemplo n.º 3
0
        /// <summary>
        /// Show system menu on MouseRightButtonUp
        /// </summary>
        /// <param name="window"></param>
        /// <param name="e"></param>
        internal static void DoThumbMouseRightButtonUp(Window window, MouseButtonEventArgs e)
        {
            if (window.ShowSystemMenu)
            {
                // show menu only if mouse pos is on title bar or if we have a window with none style and no title bar
                var mousePos = e.GetPosition(window);
                if ((mousePos.Y <= window.TitleBarHeight && window.TitleBarHeight > 0) || (window.UseNoneWindowStyle && window.TitleBarHeight <= 0))
                {
#pragma warning disable 618
                    SystemCommands.ShowSystemMenu(window, window.PointToScreen(mousePos));
#pragma warning restore 618
                }
            }
        }
Exemplo n.º 4
0
        private void OnIconMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (!ShowSystemMenu)
            {
                return;
            }

            if (e.ClickCount == 2)
            {
                Close();
            }
            else
            {
#pragma warning disable 618
                SystemCommands.ShowSystemMenu(this, PointToScreen(new Point(0, TitleBarHeight)));
#pragma warning restore 618
            }
        }
 private void _OnSystemCommandCloseWindow(object sender, ExecutedRoutedEventArgs e)
 {
     SystemCommands.CloseWindow(this);
 }