Example #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;
                }
            }
        }
Example #2
0
        private void OnRestoreWindow(object target, ExecutedRoutedEventArgs e)
        {
#if NET4
            Microsoft.Windows.Shell.SystemCommands.RestoreWindow(this);
#else
            SystemCommands.RestoreWindow(this);
#endif
        }