From 7b4f7bf6b84d61f918981e0712b4741bbe386921 Mon Sep 17 00:00:00 2001 From: Jan Karger Date: Mon, 23 Nov 2015 23:13:31 +0100 Subject: [PATCH 01/12] use thumb for dragmove (not yet finished) thx goes to @ButchersBoy --- MahApps.Metro/Controls/MetroWindow.cs | 83 +++++++++++++++---- .../Standard/NativeMethods.cs | 1 + MahApps.Metro/Themes/MetroWindow.xaml | 31 +++++++ 3 files changed, 98 insertions(+), 17 deletions(-) diff --git a/MahApps.Metro/Controls/MetroWindow.cs b/MahApps.Metro/Controls/MetroWindow.cs index 82905574b9..c1375ac8a5 100644 --- a/MahApps.Metro/Controls/MetroWindow.cs +++ b/MahApps.Metro/Controls/MetroWindow.cs @@ -10,6 +10,7 @@ using MahApps.Metro.Native; using System.Windows.Shapes; using System.Collections.Generic; +using System.Windows.Controls.Primitives; namespace MahApps.Metro.Controls { @@ -19,6 +20,7 @@ namespace MahApps.Metro.Controls [TemplatePart(Name = PART_Icon, Type = typeof(UIElement))] [TemplatePart(Name = PART_TitleBar, Type = typeof(UIElement))] [TemplatePart(Name = PART_WindowTitleBackground, Type = typeof(UIElement))] + [TemplatePart(Name = PART_WindowRestoreThumb, Type = typeof(Thumb))] [TemplatePart(Name = PART_LeftWindowCommands, Type = typeof(WindowCommands))] [TemplatePart(Name = PART_RightWindowCommands, Type = typeof(WindowCommands))] [TemplatePart(Name = PART_WindowButtonCommands, Type = typeof(WindowButtonCommands))] @@ -31,6 +33,7 @@ public class MetroWindow : Window private const string PART_Icon = "PART_Icon"; private const string PART_TitleBar = "PART_TitleBar"; private const string PART_WindowTitleBackground = "PART_WindowTitleBackground"; + private const string PART_WindowRestoreThumb = "PART_WindowRestoreThumb"; private const string PART_LeftWindowCommands = "PART_LeftWindowCommands"; private const string PART_RightWindowCommands = "PART_RightWindowCommands"; private const string PART_WindowButtonCommands = "PART_WindowButtonCommands"; @@ -99,6 +102,7 @@ public class MetroWindow : Window UIElement icon; UIElement titleBar; UIElement titleBarBackground; + Thumb windowRestoreThumb; internal ContentPresenter LeftWindowCommandsPresenter; internal ContentPresenter RightWindowCommandsPresenter; internal WindowButtonCommands WindowButtonCommands; @@ -890,6 +894,7 @@ public override void OnApplyTemplate() icon = GetTemplateChild(PART_Icon) as UIElement; titleBar = GetTemplateChild(PART_TitleBar) as UIElement; titleBarBackground = GetTemplateChild(PART_WindowTitleBackground) as UIElement; + windowRestoreThumb = GetTemplateChild(PART_WindowRestoreThumb) as Thumb; this.SetVisibiltyForAllTitleElements(this.TitlebarHeight > 0); } @@ -897,6 +902,11 @@ public override void OnApplyTemplate() private void ClearWindowEvents() { // clear all event handlers first: + if (windowRestoreThumb != null) + { + windowRestoreThumb.DragDelta -= WindowMoveThumbOnDragDelta; + windowRestoreThumb.MouseDoubleClick -= WindowRestoreThumbOnMouseDoubleClick; + } if (titleBarBackground != null) { titleBarBackground.MouseDown -= TitleBarMouseDown; @@ -927,18 +937,24 @@ private void SetWindowEvents() icon.MouseDown += IconMouseDown; } + if (windowRestoreThumb != null) + { + windowRestoreThumb.DragDelta += WindowMoveThumbOnDragDelta; + windowRestoreThumb.MouseDoubleClick += WindowRestoreThumbOnMouseDoubleClick; + } + // handle mouse events for PART_WindowTitleBackground -> MetroWindow if (titleBarBackground != null && titleBarBackground.Visibility == Visibility.Visible) { - titleBarBackground.MouseDown += TitleBarMouseDown; - titleBarBackground.MouseUp += TitleBarMouseUp; + //titleBarBackground.MouseDown += TitleBarMouseDown; + //titleBarBackground.MouseUp += TitleBarMouseUp; } // handle mouse events for PART_TitleBar -> MetroWindow if (titleBar != null && titleBar.Visibility == Visibility.Visible) { - titleBar.MouseDown += TitleBarMouseDown; - titleBar.MouseUp += TitleBarMouseUp; + //titleBar.MouseDown += TitleBarMouseDown; + //titleBar.MouseUp += TitleBarMouseUp; // special title resizing for centered title if (titleBar.GetType() == typeof(Grid)) @@ -949,8 +965,8 @@ private void SetWindowEvents() else { // handle mouse events for windows without PART_WindowTitleBackground or PART_TitleBar - MouseDown += TitleBarMouseDown; - MouseUp += TitleBarMouseUp; + //MouseDown += TitleBarMouseDown; + //MouseUp += TitleBarMouseUp; } } @@ -969,23 +985,56 @@ private void IconMouseDown(object sender, MouseButtonEventArgs e) } } - protected void TitleBarMouseDown(object sender, MouseButtonEventArgs e) + private void WindowMoveThumbOnDragDelta(object sender, DragDeltaEventArgs dragDeltaEventArgs) + { + if (!IsWindowDraggable && + (!(Math.Abs(dragDeltaEventArgs.HorizontalChange) > 2) && + !(Math.Abs(dragDeltaEventArgs.VerticalChange) > 2))) return; + + var windowHandle = new WindowInteropHelper(this).Handle; + var cursorPos = Standard.NativeMethods.GetCursorPos(); + //UnsafeNativeMethods.ReleaseCapture(); + if (WindowState == WindowState.Maximized) + { + Top = 2; + Left = Math.Max(cursorPos.x - RestoreBounds.Width / 2, 0); + } + var lParam = (int)(uint)cursorPos.x | (cursorPos.y << 16); + Standard.NativeMethods.SendMessage(windowHandle, Standard.WM.LBUTTONUP, (IntPtr)Standard.HT.CAPTION, (IntPtr)lParam); + Standard.NativeMethods.SendMessage(windowHandle, Standard.WM.SYSCOMMAND, (IntPtr)Standard.SC.MOUSEMOVE, IntPtr.Zero); + } + + private void WindowRestoreThumbOnMouseDoubleClick(object sender, MouseButtonEventArgs mouseButtonEventArgs) { // if UseNoneWindowStyle = true no movement, no maximize please - if (e.ChangedButton == MouseButton.Left && !this.UseNoneWindowStyle) + if (mouseButtonEventArgs.ChangedButton == MouseButton.Left && !this.UseNoneWindowStyle) { var mPoint = Mouse.GetPosition(this); - - if (IsWindowDraggable) + var canResize = this.ResizeMode == ResizeMode.CanResizeWithGrip || this.ResizeMode == ResizeMode.CanResize; + // we can maximize or restore the window if the title bar height is set (also if title bar is hidden) + var isMouseOnTitlebar = mPoint.Y <= this.TitlebarHeight && this.TitlebarHeight > 0; + if (canResize && isMouseOnTitlebar) { - IntPtr windowHandle = new WindowInteropHelper(this).Handle; - UnsafeNativeMethods.ReleaseCapture(); - var wpfPoint = this.PointToScreen(mPoint); - var x = Convert.ToInt16(wpfPoint.X); - var y = Convert.ToInt16(wpfPoint.Y); - var lParam = (int) (uint) x | (y << 16); - UnsafeNativeMethods.SendMessage(windowHandle, Constants.WM_NCLBUTTONDOWN, Constants.HT_CAPTION, lParam); + //UnsafeNativeMethods.ReleaseCapture(); + if (this.WindowState == WindowState.Maximized) + { + Microsoft.Windows.Shell.SystemCommands.RestoreWindow(this); + } + else + { + Microsoft.Windows.Shell.SystemCommands.MaximizeWindow(this); + } + mouseButtonEventArgs.Handled = true; } + } + } + + protected void TitleBarMouseDown(object sender, MouseButtonEventArgs e) + { + // if UseNoneWindowStyle = true no movement, no maximize please + if (e.ChangedButton == MouseButton.Left && !this.UseNoneWindowStyle) + { + var mPoint = Mouse.GetPosition(this); var canResize = this.ResizeMode == ResizeMode.CanResizeWithGrip || this.ResizeMode == ResizeMode.CanResize; // we can maximize or restore the window if the title bar height is set (also if title bar is hidden) diff --git a/MahApps.Metro/Microsoft.Windows.Shell/Standard/NativeMethods.cs b/MahApps.Metro/Microsoft.Windows.Shell/Standard/NativeMethods.cs index c2a0a29c51..27f920948b 100644 --- a/MahApps.Metro/Microsoft.Windows.Shell/Standard/NativeMethods.cs +++ b/MahApps.Metro/Microsoft.Windows.Shell/Standard/NativeMethods.cs @@ -1160,6 +1160,7 @@ internal enum SC { SIZE = 0xF000, MOVE = 0xF010, + MOUSEMOVE = 0xF012, MINIMIZE = 0xF020, MAXIMIZE = 0xF030, NEXTWINDOW = 0xF040, diff --git a/MahApps.Metro/Themes/MetroWindow.xaml b/MahApps.Metro/Themes/MetroWindow.xaml index e27a04017e..3b3404e6cb 100644 --- a/MahApps.Metro/Themes/MetroWindow.xaml +++ b/MahApps.Metro/Themes/MetroWindow.xaml @@ -10,6 +10,19 @@ + + @@ -92,6 +105,12 @@ + + + + + @@ -364,6 +386,12 @@ + + + + + From d30c87d6947e898c4dba93d6450578d6f6f277bb Mon Sep 17 00:00:00 2001 From: Jan Karger Date: Mon, 7 Dec 2015 23:10:09 +0100 Subject: [PATCH 02/12] RowSpan is better --- MahApps.Metro/Themes/MetroWindow.xaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MahApps.Metro/Themes/MetroWindow.xaml b/MahApps.Metro/Themes/MetroWindow.xaml index 3b3404e6cb..d732831d1b 100644 --- a/MahApps.Metro/Themes/MetroWindow.xaml +++ b/MahApps.Metro/Themes/MetroWindow.xaml @@ -234,7 +234,7 @@ - + - + Date: Mon, 7 Dec 2015 23:10:58 +0100 Subject: [PATCH 03/12] dragging/restoring with WindowStyle none --- MahApps.Metro/Controls/MetroWindow.cs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/MahApps.Metro/Controls/MetroWindow.cs b/MahApps.Metro/Controls/MetroWindow.cs index c1375ac8a5..63e372479d 100644 --- a/MahApps.Metro/Controls/MetroWindow.cs +++ b/MahApps.Metro/Controls/MetroWindow.cs @@ -987,14 +987,23 @@ private void IconMouseDown(object sender, MouseButtonEventArgs e) private void WindowMoveThumbOnDragDelta(object sender, DragDeltaEventArgs dragDeltaEventArgs) { + // drag only if IsWindowDraggable is set to true if (!IsWindowDraggable && (!(Math.Abs(dragDeltaEventArgs.HorizontalChange) > 2) && !(Math.Abs(dragDeltaEventArgs.VerticalChange) > 2))) return; var windowHandle = new WindowInteropHelper(this).Handle; var cursorPos = Standard.NativeMethods.GetCursorPos(); - //UnsafeNativeMethods.ReleaseCapture(); - if (WindowState == WindowState.Maximized) + + // if the window is maximized dragging is only allowed on title bar (also if not visible) + var windowIsMaximized = WindowState == WindowState.Maximized; + var isMouseOnTitlebar = cursorPos.y <= this.TitlebarHeight && this.TitlebarHeight > 0; + if (!isMouseOnTitlebar && windowIsMaximized) + { + return; + } + + if (windowIsMaximized) { Top = 2; Left = Math.Max(cursorPos.x - RestoreBounds.Width / 2, 0); @@ -1006,16 +1015,15 @@ private void WindowMoveThumbOnDragDelta(object sender, DragDeltaEventArgs dragDe private void WindowRestoreThumbOnMouseDoubleClick(object sender, MouseButtonEventArgs mouseButtonEventArgs) { - // if UseNoneWindowStyle = true no movement, no maximize please - if (mouseButtonEventArgs.ChangedButton == MouseButton.Left && !this.UseNoneWindowStyle) + // restore/maximize only with left button + if (mouseButtonEventArgs.ChangedButton == MouseButton.Left) { - var mPoint = Mouse.GetPosition(this); - var canResize = this.ResizeMode == ResizeMode.CanResizeWithGrip || this.ResizeMode == ResizeMode.CanResize; // we can maximize or restore the window if the title bar height is set (also if title bar is hidden) + var canResize = this.ResizeMode == ResizeMode.CanResizeWithGrip || this.ResizeMode == ResizeMode.CanResize; + var mPoint = Mouse.GetPosition(this); var isMouseOnTitlebar = mPoint.Y <= this.TitlebarHeight && this.TitlebarHeight > 0; if (canResize && isMouseOnTitlebar) { - //UnsafeNativeMethods.ReleaseCapture(); if (this.WindowState == WindowState.Maximized) { Microsoft.Windows.Shell.SystemCommands.RestoreWindow(this); From da4e8621546579e7089bd6ee260cd15c87727547 Mon Sep 17 00:00:00 2001 From: Jan Karger Date: Mon, 7 Dec 2015 23:27:47 +0100 Subject: [PATCH 04/12] right click on thumb --- MahApps.Metro/Controls/MetroWindow.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/MahApps.Metro/Controls/MetroWindow.cs b/MahApps.Metro/Controls/MetroWindow.cs index 63e372479d..5b0c920afe 100644 --- a/MahApps.Metro/Controls/MetroWindow.cs +++ b/MahApps.Metro/Controls/MetroWindow.cs @@ -906,6 +906,7 @@ private void ClearWindowEvents() { windowRestoreThumb.DragDelta -= WindowMoveThumbOnDragDelta; windowRestoreThumb.MouseDoubleClick -= WindowRestoreThumbOnMouseDoubleClick; + windowRestoreThumb.MouseRightButtonUp -= WindowMenuThumbOnMouseRightButtonUp; } if (titleBarBackground != null) { @@ -941,6 +942,7 @@ private void SetWindowEvents() { windowRestoreThumb.DragDelta += WindowMoveThumbOnDragDelta; windowRestoreThumb.MouseDoubleClick += WindowRestoreThumbOnMouseDoubleClick; + windowRestoreThumb.MouseRightButtonUp += WindowMenuThumbOnMouseRightButtonUp; } // handle mouse events for PART_WindowTitleBackground -> MetroWindow @@ -1020,8 +1022,8 @@ private void WindowRestoreThumbOnMouseDoubleClick(object sender, MouseButtonEven { // we can maximize or restore the window if the title bar height is set (also if title bar is hidden) var canResize = this.ResizeMode == ResizeMode.CanResizeWithGrip || this.ResizeMode == ResizeMode.CanResize; - var mPoint = Mouse.GetPosition(this); - var isMouseOnTitlebar = mPoint.Y <= this.TitlebarHeight && this.TitlebarHeight > 0; + var mousePos = Mouse.GetPosition(this); + var isMouseOnTitlebar = mousePos.Y <= this.TitlebarHeight && this.TitlebarHeight > 0; if (canResize && isMouseOnTitlebar) { if (this.WindowState == WindowState.Maximized) @@ -1037,6 +1039,19 @@ private void WindowRestoreThumbOnMouseDoubleClick(object sender, MouseButtonEven } } + private void WindowMenuThumbOnMouseRightButtonUp(object sender, MouseButtonEventArgs e) + { + if (this.ShowSystemMenuOnRightClick) + { + // 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(this); + if ((mousePos.Y <= this.TitlebarHeight && this.TitlebarHeight > 0) || (this.UseNoneWindowStyle && this.TitlebarHeight <= 0)) + { + ShowSystemMenuPhysicalCoordinates(this, PointToScreen(mousePos)); + } + } + } + protected void TitleBarMouseDown(object sender, MouseButtonEventArgs e) { // if UseNoneWindowStyle = true no movement, no maximize please From 27ecaed6c051420e5c5c97bfef532f77321eabc7 Mon Sep 17 00:00:00 2001 From: Jan Karger Date: Mon, 7 Dec 2015 23:40:22 +0100 Subject: [PATCH 05/12] remove old stuff --- MahApps.Metro/Controls/MetroWindow.cs | 74 ++------------------------- 1 file changed, 3 insertions(+), 71 deletions(-) diff --git a/MahApps.Metro/Controls/MetroWindow.cs b/MahApps.Metro/Controls/MetroWindow.cs index 5b0c920afe..1dda2a6270 100644 --- a/MahApps.Metro/Controls/MetroWindow.cs +++ b/MahApps.Metro/Controls/MetroWindow.cs @@ -908,22 +908,10 @@ private void ClearWindowEvents() windowRestoreThumb.MouseDoubleClick -= WindowRestoreThumbOnMouseDoubleClick; windowRestoreThumb.MouseRightButtonUp -= WindowMenuThumbOnMouseRightButtonUp; } - if (titleBarBackground != null) - { - titleBarBackground.MouseDown -= TitleBarMouseDown; - titleBarBackground.MouseUp -= TitleBarMouseUp; - } - if (titleBar != null) - { - titleBar.MouseDown -= TitleBarMouseDown; - titleBar.MouseUp -= TitleBarMouseUp; - } if (icon != null) { icon.MouseDown -= IconMouseDown; } - MouseDown -= TitleBarMouseDown; - MouseUp -= TitleBarMouseUp; SizeChanged -= MetroWindow_SizeChanged; } @@ -945,30 +933,10 @@ private void SetWindowEvents() windowRestoreThumb.MouseRightButtonUp += WindowMenuThumbOnMouseRightButtonUp; } - // handle mouse events for PART_WindowTitleBackground -> MetroWindow - if (titleBarBackground != null && titleBarBackground.Visibility == Visibility.Visible) - { - //titleBarBackground.MouseDown += TitleBarMouseDown; - //titleBarBackground.MouseUp += TitleBarMouseUp; - } - - // handle mouse events for PART_TitleBar -> MetroWindow - if (titleBar != null && titleBar.Visibility == Visibility.Visible) + // handle size if we have a Grid for the title (e.g. clean window have a centered title) + if (titleBar != null && titleBar.GetType() == typeof(Grid)) { - //titleBar.MouseDown += TitleBarMouseDown; - //titleBar.MouseUp += TitleBarMouseUp; - - // special title resizing for centered title - if (titleBar.GetType() == typeof(Grid)) - { - SizeChanged += MetroWindow_SizeChanged; - } - } - else - { - // handle mouse events for windows without PART_WindowTitleBackground or PART_TitleBar - //MouseDown += TitleBarMouseDown; - //MouseUp += TitleBarMouseUp; + SizeChanged += MetroWindow_SizeChanged; } } @@ -1052,42 +1020,6 @@ private void WindowMenuThumbOnMouseRightButtonUp(object sender, MouseButtonEvent } } - protected void TitleBarMouseDown(object sender, MouseButtonEventArgs e) - { - // if UseNoneWindowStyle = true no movement, no maximize please - if (e.ChangedButton == MouseButton.Left && !this.UseNoneWindowStyle) - { - var mPoint = Mouse.GetPosition(this); - - var canResize = this.ResizeMode == ResizeMode.CanResizeWithGrip || this.ResizeMode == ResizeMode.CanResize; - // we can maximize or restore the window if the title bar height is set (also if title bar is hidden) - var isMouseOnTitlebar = mPoint.Y <= this.TitlebarHeight && this.TitlebarHeight > 0; - if (e.ClickCount == 2 && canResize && isMouseOnTitlebar) - { - if (this.WindowState == WindowState.Maximized) - { - Microsoft.Windows.Shell.SystemCommands.RestoreWindow(this); - } - else - { - Microsoft.Windows.Shell.SystemCommands.MaximizeWindow(this); - } - } - } - } - - protected void TitleBarMouseUp(object sender, MouseButtonEventArgs e) - { - if (ShowSystemMenuOnRightClick) - { - var mousePosition = e.GetPosition(this); - if (e.ChangedButton == MouseButton.Right && (UseNoneWindowStyle || mousePosition.Y <= TitlebarHeight)) - { - ShowSystemMenuPhysicalCoordinates(this, PointToScreen(mousePosition)); - } - } - } - /// /// Gets the template child with the given name. /// From 3afc66ad915eec7369f27382109e20f0906954c2 Mon Sep 17 00:00:00 2001 From: Jan Karger Date: Tue, 8 Dec 2015 00:30:46 +0100 Subject: [PATCH 06/12] Flyout thumb --- MahApps.Metro/Controls/Flyout.cs | 67 ++++++++++++++++++++++-- MahApps.Metro/Controls/FlyoutsControl.cs | 6 +++ MahApps.Metro/Controls/MetroWindow.cs | 51 +++++++++++------- MahApps.Metro/Themes/Flyout.xaml | 17 ++++++ 4 files changed, 119 insertions(+), 22 deletions(-) diff --git a/MahApps.Metro/Controls/Flyout.cs b/MahApps.Metro/Controls/Flyout.cs index e29893e892..8488fca13b 100644 --- a/MahApps.Metro/Controls/Flyout.cs +++ b/MahApps.Metro/Controls/Flyout.cs @@ -1,7 +1,7 @@ using System; -using System.Linq; using System.Windows; using System.Windows.Controls; +using System.Windows.Controls.Primitives; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; @@ -15,6 +15,7 @@ namespace MahApps.Metro.Controls /// /// [TemplatePart(Name = "PART_BackButton", Type = typeof(Button))] + [TemplatePart(Name = "PART_WindowRestoreThumb", Type = typeof(Thumb))] [TemplatePart(Name = "PART_Header", Type = typeof(ContentPresenter))] [TemplatePart(Name = "PART_Content", Type = typeof(ContentPresenter))] public class Flyout : ContentControl @@ -212,6 +213,13 @@ public Flyout() this.Loaded += (sender, args) => UpdateFlyoutTheme(); } + private MetroWindow parentWindow; + + private MetroWindow ParentWindow + { + get { return this.parentWindow ?? (this.parentWindow = this.TryFindParent()); } + } + private void UpdateFlyoutTheme() { var flyoutsControl = this.TryFindParent(); @@ -221,7 +229,7 @@ private void UpdateFlyoutTheme() this.Visibility = flyoutsControl != null ? Visibility.Collapsed : Visibility.Visible; } - var window = this.TryFindParent(); + var window = this.ParentWindow; if (window != null) { var windowTheme = DetectTheme(this); @@ -282,7 +290,7 @@ private static Tuple DetectTheme(Flyout flyout) return null; // first look for owner - var window = flyout.TryFindParent(); + var window = flyout.ParentWindow; var theme = window != null ? ThemeManager.DetectAppStyle(window) : null; if (theme != null && theme.Item2 != null) return theme; @@ -460,6 +468,7 @@ static Flyout() SplineDoubleKeyFrame fadeOutFrame; ContentPresenter PART_Header; ContentPresenter PART_Content; + Thumb windowRestoreThumb; public override void OnApplyTemplate() { @@ -471,7 +480,19 @@ public override void OnApplyTemplate() PART_Header = (ContentPresenter)GetTemplateChild("PART_Header"); PART_Content = (ContentPresenter)GetTemplateChild("PART_Content"); - + windowRestoreThumb = GetTemplateChild("PART_WindowRestoreThumb") as Thumb; + + if (windowRestoreThumb != null) + { + windowRestoreThumb.DragDelta -= WindowMoveThumbOnDragDelta; + windowRestoreThumb.MouseDoubleClick -= WindowRestoreThumbOnMouseDoubleClick; + windowRestoreThumb.MouseRightButtonUp -= WindowMenuThumbOnMouseRightButtonUp; + + windowRestoreThumb.DragDelta += WindowMoveThumbOnDragDelta; + windowRestoreThumb.MouseDoubleClick += WindowRestoreThumbOnMouseDoubleClick; + windowRestoreThumb.MouseRightButtonUp += WindowMenuThumbOnMouseRightButtonUp; + } + hideStoryboard = (Storyboard)GetTemplateChild("HideStoryboard"); hideFrame = (SplineDoubleKeyFrame)GetTemplateChild("hideFrame"); hideFrameY = (SplineDoubleKeyFrame)GetTemplateChild("hideFrameY"); @@ -485,6 +506,44 @@ public override void OnApplyTemplate() ApplyAnimation(Position, AnimateOpacity); } + protected internal void CleanUp(FlyoutsControl flyoutsControl) + { + if (windowRestoreThumb != null) + { + windowRestoreThumb.DragDelta -= WindowMoveThumbOnDragDelta; + windowRestoreThumb.MouseDoubleClick -= WindowRestoreThumbOnMouseDoubleClick; + windowRestoreThumb.MouseRightButtonUp -= WindowMenuThumbOnMouseRightButtonUp; + } + this.parentWindow = null; + } + + private void WindowMoveThumbOnDragDelta(object sender, DragDeltaEventArgs dragDeltaEventArgs) + { + var window = this.ParentWindow; + if (window != null) + { + MetroWindow.DoWindowMoveThumbOnDragDelta(window, dragDeltaEventArgs); + } + } + + private void WindowRestoreThumbOnMouseDoubleClick(object sender, MouseButtonEventArgs mouseButtonEventArgs) + { + var window = this.ParentWindow; + if (window != null) + { + MetroWindow.DoWindowRestoreThumbOnMouseDoubleClick(window, mouseButtonEventArgs); + } + } + + private void WindowMenuThumbOnMouseRightButtonUp(object sender, MouseButtonEventArgs e) + { + var window = this.ParentWindow; + if (window != null) + { + MetroWindow.DoWindowMenuThumbOnMouseRightButtonUp(window, e); + } + } + internal void ApplyAnimation(Position position, bool animateOpacity, bool resetShowFrame = true) { if (root == null || hideFrame == null || showFrame == null || hideFrameY == null || showFrameY == null || fadeOutFrame == null) diff --git a/MahApps.Metro/Controls/FlyoutsControl.cs b/MahApps.Metro/Controls/FlyoutsControl.cs index ad6c7486ec..66a2ae226c 100644 --- a/MahApps.Metro/Controls/FlyoutsControl.cs +++ b/MahApps.Metro/Controls/FlyoutsControl.cs @@ -58,6 +58,12 @@ protected override void PrepareContainerForItemOverride(DependencyObject element this.AttachHandlers((Flyout)element); } + protected override void ClearContainerForItemOverride(DependencyObject element, object item) + { + ((Flyout) element).CleanUp(this); + base.ClearContainerForItemOverride(element, item); + } + private void AttachHandlers(Flyout flyout) { var isOpenNotifier = new PropertyChangeNotifier(flyout, Flyout.IsOpenProperty); diff --git a/MahApps.Metro/Controls/MetroWindow.cs b/MahApps.Metro/Controls/MetroWindow.cs index 1dda2a6270..b582f88586 100644 --- a/MahApps.Metro/Controls/MetroWindow.cs +++ b/MahApps.Metro/Controls/MetroWindow.cs @@ -956,18 +956,33 @@ private void IconMouseDown(object sender, MouseButtonEventArgs e) } private void WindowMoveThumbOnDragDelta(object sender, DragDeltaEventArgs dragDeltaEventArgs) + { + DoWindowMoveThumbOnDragDelta(this, dragDeltaEventArgs); + } + + private void WindowRestoreThumbOnMouseDoubleClick(object sender, MouseButtonEventArgs mouseButtonEventArgs) + { + DoWindowRestoreThumbOnMouseDoubleClick(this, mouseButtonEventArgs); + } + + private void WindowMenuThumbOnMouseRightButtonUp(object sender, MouseButtonEventArgs e) + { + DoWindowMenuThumbOnMouseRightButtonUp(this, e); + } + + internal static void DoWindowMoveThumbOnDragDelta(MetroWindow window, DragDeltaEventArgs dragDeltaEventArgs) { // drag only if IsWindowDraggable is set to true - if (!IsWindowDraggable && + if (!window.IsWindowDraggable && (!(Math.Abs(dragDeltaEventArgs.HorizontalChange) > 2) && !(Math.Abs(dragDeltaEventArgs.VerticalChange) > 2))) return; - var windowHandle = new WindowInteropHelper(this).Handle; + var windowHandle = new WindowInteropHelper(window).Handle; var cursorPos = Standard.NativeMethods.GetCursorPos(); // if the window is maximized dragging is only allowed on title bar (also if not visible) - var windowIsMaximized = WindowState == WindowState.Maximized; - var isMouseOnTitlebar = cursorPos.y <= this.TitlebarHeight && this.TitlebarHeight > 0; + var windowIsMaximized = window.WindowState == WindowState.Maximized; + var isMouseOnTitlebar = cursorPos.y <= window.TitlebarHeight && window.TitlebarHeight > 0; if (!isMouseOnTitlebar && windowIsMaximized) { return; @@ -975,47 +990,47 @@ private void WindowMoveThumbOnDragDelta(object sender, DragDeltaEventArgs dragDe if (windowIsMaximized) { - Top = 2; - Left = Math.Max(cursorPos.x - RestoreBounds.Width / 2, 0); + window.Top = 2; + window.Left = Math.Max(cursorPos.x - window.RestoreBounds.Width / 2, 0); } var lParam = (int)(uint)cursorPos.x | (cursorPos.y << 16); Standard.NativeMethods.SendMessage(windowHandle, Standard.WM.LBUTTONUP, (IntPtr)Standard.HT.CAPTION, (IntPtr)lParam); Standard.NativeMethods.SendMessage(windowHandle, Standard.WM.SYSCOMMAND, (IntPtr)Standard.SC.MOUSEMOVE, IntPtr.Zero); } - private void WindowRestoreThumbOnMouseDoubleClick(object sender, MouseButtonEventArgs mouseButtonEventArgs) + internal static void DoWindowRestoreThumbOnMouseDoubleClick(MetroWindow window, MouseButtonEventArgs mouseButtonEventArgs) { // restore/maximize only with left button if (mouseButtonEventArgs.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 = this.ResizeMode == ResizeMode.CanResizeWithGrip || this.ResizeMode == ResizeMode.CanResize; - var mousePos = Mouse.GetPosition(this); - var isMouseOnTitlebar = mousePos.Y <= this.TitlebarHeight && this.TitlebarHeight > 0; + 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) { - if (this.WindowState == WindowState.Maximized) + if (window.WindowState == WindowState.Maximized) { - Microsoft.Windows.Shell.SystemCommands.RestoreWindow(this); + Microsoft.Windows.Shell.SystemCommands.RestoreWindow(window); } else { - Microsoft.Windows.Shell.SystemCommands.MaximizeWindow(this); + Microsoft.Windows.Shell.SystemCommands.MaximizeWindow(window); } mouseButtonEventArgs.Handled = true; } } } - private void WindowMenuThumbOnMouseRightButtonUp(object sender, MouseButtonEventArgs e) + internal static void DoWindowMenuThumbOnMouseRightButtonUp(MetroWindow window, MouseButtonEventArgs e) { - if (this.ShowSystemMenuOnRightClick) + if (window.ShowSystemMenuOnRightClick) { // 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(this); - if ((mousePos.Y <= this.TitlebarHeight && this.TitlebarHeight > 0) || (this.UseNoneWindowStyle && this.TitlebarHeight <= 0)) + var mousePos = e.GetPosition(window); + if ((mousePos.Y <= window.TitlebarHeight && window.TitlebarHeight > 0) || (window.UseNoneWindowStyle && window.TitlebarHeight <= 0)) { - ShowSystemMenuPhysicalCoordinates(this, PointToScreen(mousePos)); + ShowSystemMenuPhysicalCoordinates(window, window.PointToScreen(mousePos)); } } } diff --git a/MahApps.Metro/Themes/Flyout.xaml b/MahApps.Metro/Themes/Flyout.xaml index 78208adc23..f2b3f23a6a 100644 --- a/MahApps.Metro/Themes/Flyout.xaml +++ b/MahApps.Metro/Themes/Flyout.xaml @@ -9,6 +9,19 @@ + + + Date: Tue, 8 Dec 2015 08:45:31 +0100 Subject: [PATCH 07/12] better || instead && --- MahApps.Metro/Controls/MetroWindow.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MahApps.Metro/Controls/MetroWindow.cs b/MahApps.Metro/Controls/MetroWindow.cs index b582f88586..74cbc190d9 100644 --- a/MahApps.Metro/Controls/MetroWindow.cs +++ b/MahApps.Metro/Controls/MetroWindow.cs @@ -973,7 +973,7 @@ private void WindowMenuThumbOnMouseRightButtonUp(object sender, MouseButtonEvent internal static void DoWindowMoveThumbOnDragDelta(MetroWindow window, DragDeltaEventArgs dragDeltaEventArgs) { // drag only if IsWindowDraggable is set to true - if (!window.IsWindowDraggable && + if (!window.IsWindowDraggable || (!(Math.Abs(dragDeltaEventArgs.HorizontalChange) > 2) && !(Math.Abs(dragDeltaEventArgs.VerticalChange) > 2))) return; From ca380140a04676959106e184fe3921090db395a1 Mon Sep 17 00:00:00 2001 From: Jan Karger Date: Tue, 8 Dec 2015 08:53:33 +0100 Subject: [PATCH 08/12] better naming --- MahApps.Metro/Controls/Flyout.cs | 40 ++++++++++++------------- MahApps.Metro/Controls/MetroWindow.cs | 42 +++++++++++++-------------- MahApps.Metro/Themes/Flyout.xaml | 2 +- MahApps.Metro/Themes/MetroWindow.xaml | 8 ++--- 4 files changed, 46 insertions(+), 46 deletions(-) diff --git a/MahApps.Metro/Controls/Flyout.cs b/MahApps.Metro/Controls/Flyout.cs index 8488fca13b..904d7d810f 100644 --- a/MahApps.Metro/Controls/Flyout.cs +++ b/MahApps.Metro/Controls/Flyout.cs @@ -15,7 +15,7 @@ namespace MahApps.Metro.Controls /// /// [TemplatePart(Name = "PART_BackButton", Type = typeof(Button))] - [TemplatePart(Name = "PART_WindowRestoreThumb", Type = typeof(Thumb))] + [TemplatePart(Name = "PART_WindowTitleThumb", Type = typeof(Thumb))] [TemplatePart(Name = "PART_Header", Type = typeof(ContentPresenter))] [TemplatePart(Name = "PART_Content", Type = typeof(ContentPresenter))] public class Flyout : ContentControl @@ -468,7 +468,7 @@ static Flyout() SplineDoubleKeyFrame fadeOutFrame; ContentPresenter PART_Header; ContentPresenter PART_Content; - Thumb windowRestoreThumb; + Thumb windowTitleThumb; public override void OnApplyTemplate() { @@ -480,17 +480,17 @@ public override void OnApplyTemplate() PART_Header = (ContentPresenter)GetTemplateChild("PART_Header"); PART_Content = (ContentPresenter)GetTemplateChild("PART_Content"); - windowRestoreThumb = GetTemplateChild("PART_WindowRestoreThumb") as Thumb; + this.windowTitleThumb = GetTemplateChild("PART_WindowTitleThumb") as Thumb; - if (windowRestoreThumb != null) + if (this.windowTitleThumb != null) { - windowRestoreThumb.DragDelta -= WindowMoveThumbOnDragDelta; - windowRestoreThumb.MouseDoubleClick -= WindowRestoreThumbOnMouseDoubleClick; - windowRestoreThumb.MouseRightButtonUp -= WindowMenuThumbOnMouseRightButtonUp; + this.windowTitleThumb.DragDelta -= this.WindowTitleThumbMoveOnDragDelta; + this.windowTitleThumb.MouseDoubleClick -= this.WindowTitleThumbChangeWindowStateOnMouseDoubleClick; + this.windowTitleThumb.MouseRightButtonUp -= this.WindowTitleThumbSystemMenuOnMouseRightButtonUp; - windowRestoreThumb.DragDelta += WindowMoveThumbOnDragDelta; - windowRestoreThumb.MouseDoubleClick += WindowRestoreThumbOnMouseDoubleClick; - windowRestoreThumb.MouseRightButtonUp += WindowMenuThumbOnMouseRightButtonUp; + this.windowTitleThumb.DragDelta += this.WindowTitleThumbMoveOnDragDelta; + this.windowTitleThumb.MouseDoubleClick += this.WindowTitleThumbChangeWindowStateOnMouseDoubleClick; + this.windowTitleThumb.MouseRightButtonUp += this.WindowTitleThumbSystemMenuOnMouseRightButtonUp; } hideStoryboard = (Storyboard)GetTemplateChild("HideStoryboard"); @@ -508,39 +508,39 @@ public override void OnApplyTemplate() protected internal void CleanUp(FlyoutsControl flyoutsControl) { - if (windowRestoreThumb != null) + if (this.windowTitleThumb != null) { - windowRestoreThumb.DragDelta -= WindowMoveThumbOnDragDelta; - windowRestoreThumb.MouseDoubleClick -= WindowRestoreThumbOnMouseDoubleClick; - windowRestoreThumb.MouseRightButtonUp -= WindowMenuThumbOnMouseRightButtonUp; + this.windowTitleThumb.DragDelta -= this.WindowTitleThumbMoveOnDragDelta; + this.windowTitleThumb.MouseDoubleClick -= this.WindowTitleThumbChangeWindowStateOnMouseDoubleClick; + this.windowTitleThumb.MouseRightButtonUp -= this.WindowTitleThumbSystemMenuOnMouseRightButtonUp; } this.parentWindow = null; } - private void WindowMoveThumbOnDragDelta(object sender, DragDeltaEventArgs dragDeltaEventArgs) + private void WindowTitleThumbMoveOnDragDelta(object sender, DragDeltaEventArgs dragDeltaEventArgs) { var window = this.ParentWindow; if (window != null) { - MetroWindow.DoWindowMoveThumbOnDragDelta(window, dragDeltaEventArgs); + MetroWindow.DoWindowTitleThumbMoveOnDragDelta(window, dragDeltaEventArgs); } } - private void WindowRestoreThumbOnMouseDoubleClick(object sender, MouseButtonEventArgs mouseButtonEventArgs) + private void WindowTitleThumbChangeWindowStateOnMouseDoubleClick(object sender, MouseButtonEventArgs mouseButtonEventArgs) { var window = this.ParentWindow; if (window != null) { - MetroWindow.DoWindowRestoreThumbOnMouseDoubleClick(window, mouseButtonEventArgs); + MetroWindow.DoWindowTitleThumbChangeWindowStateOnMouseDoubleClick(window, mouseButtonEventArgs); } } - private void WindowMenuThumbOnMouseRightButtonUp(object sender, MouseButtonEventArgs e) + private void WindowTitleThumbSystemMenuOnMouseRightButtonUp(object sender, MouseButtonEventArgs e) { var window = this.ParentWindow; if (window != null) { - MetroWindow.DoWindowMenuThumbOnMouseRightButtonUp(window, e); + MetroWindow.DoWindowTitleThumbSystemMenuOnMouseRightButtonUp(window, e); } } diff --git a/MahApps.Metro/Controls/MetroWindow.cs b/MahApps.Metro/Controls/MetroWindow.cs index 74cbc190d9..bcd9a0436c 100644 --- a/MahApps.Metro/Controls/MetroWindow.cs +++ b/MahApps.Metro/Controls/MetroWindow.cs @@ -20,7 +20,7 @@ namespace MahApps.Metro.Controls [TemplatePart(Name = PART_Icon, Type = typeof(UIElement))] [TemplatePart(Name = PART_TitleBar, Type = typeof(UIElement))] [TemplatePart(Name = PART_WindowTitleBackground, Type = typeof(UIElement))] - [TemplatePart(Name = PART_WindowRestoreThumb, Type = typeof(Thumb))] + [TemplatePart(Name = PART_WindowTitleThumb, Type = typeof(Thumb))] [TemplatePart(Name = PART_LeftWindowCommands, Type = typeof(WindowCommands))] [TemplatePart(Name = PART_RightWindowCommands, Type = typeof(WindowCommands))] [TemplatePart(Name = PART_WindowButtonCommands, Type = typeof(WindowButtonCommands))] @@ -33,7 +33,7 @@ public class MetroWindow : Window private const string PART_Icon = "PART_Icon"; private const string PART_TitleBar = "PART_TitleBar"; private const string PART_WindowTitleBackground = "PART_WindowTitleBackground"; - private const string PART_WindowRestoreThumb = "PART_WindowRestoreThumb"; + private const string PART_WindowTitleThumb = "PART_WindowTitleThumb"; private const string PART_LeftWindowCommands = "PART_LeftWindowCommands"; private const string PART_RightWindowCommands = "PART_RightWindowCommands"; private const string PART_WindowButtonCommands = "PART_WindowButtonCommands"; @@ -102,7 +102,7 @@ public class MetroWindow : Window UIElement icon; UIElement titleBar; UIElement titleBarBackground; - Thumb windowRestoreThumb; + Thumb windowTitleThumb; internal ContentPresenter LeftWindowCommandsPresenter; internal ContentPresenter RightWindowCommandsPresenter; internal WindowButtonCommands WindowButtonCommands; @@ -894,7 +894,7 @@ public override void OnApplyTemplate() icon = GetTemplateChild(PART_Icon) as UIElement; titleBar = GetTemplateChild(PART_TitleBar) as UIElement; titleBarBackground = GetTemplateChild(PART_WindowTitleBackground) as UIElement; - windowRestoreThumb = GetTemplateChild(PART_WindowRestoreThumb) as Thumb; + this.windowTitleThumb = GetTemplateChild(PART_WindowTitleThumb) as Thumb; this.SetVisibiltyForAllTitleElements(this.TitlebarHeight > 0); } @@ -902,11 +902,11 @@ public override void OnApplyTemplate() private void ClearWindowEvents() { // clear all event handlers first: - if (windowRestoreThumb != null) + if (this.windowTitleThumb != null) { - windowRestoreThumb.DragDelta -= WindowMoveThumbOnDragDelta; - windowRestoreThumb.MouseDoubleClick -= WindowRestoreThumbOnMouseDoubleClick; - windowRestoreThumb.MouseRightButtonUp -= WindowMenuThumbOnMouseRightButtonUp; + this.windowTitleThumb.DragDelta -= this.WindowTitleThumbMoveOnDragDelta; + this.windowTitleThumb.MouseDoubleClick -= this.WindowTitleThumbChangeWindowStateOnMouseDoubleClick; + this.windowTitleThumb.MouseRightButtonUp -= this.WindowTitleThumbSystemMenuOnMouseRightButtonUp; } if (icon != null) { @@ -926,11 +926,11 @@ private void SetWindowEvents() icon.MouseDown += IconMouseDown; } - if (windowRestoreThumb != null) + if (this.windowTitleThumb != null) { - windowRestoreThumb.DragDelta += WindowMoveThumbOnDragDelta; - windowRestoreThumb.MouseDoubleClick += WindowRestoreThumbOnMouseDoubleClick; - windowRestoreThumb.MouseRightButtonUp += WindowMenuThumbOnMouseRightButtonUp; + this.windowTitleThumb.DragDelta += this.WindowTitleThumbMoveOnDragDelta; + this.windowTitleThumb.MouseDoubleClick += this.WindowTitleThumbChangeWindowStateOnMouseDoubleClick; + this.windowTitleThumb.MouseRightButtonUp += this.WindowTitleThumbSystemMenuOnMouseRightButtonUp; } // handle size if we have a Grid for the title (e.g. clean window have a centered title) @@ -955,22 +955,22 @@ private void IconMouseDown(object sender, MouseButtonEventArgs e) } } - private void WindowMoveThumbOnDragDelta(object sender, DragDeltaEventArgs dragDeltaEventArgs) + private void WindowTitleThumbMoveOnDragDelta(object sender, DragDeltaEventArgs dragDeltaEventArgs) { - DoWindowMoveThumbOnDragDelta(this, dragDeltaEventArgs); + DoWindowTitleThumbMoveOnDragDelta(this, dragDeltaEventArgs); } - private void WindowRestoreThumbOnMouseDoubleClick(object sender, MouseButtonEventArgs mouseButtonEventArgs) + private void WindowTitleThumbChangeWindowStateOnMouseDoubleClick(object sender, MouseButtonEventArgs mouseButtonEventArgs) { - DoWindowRestoreThumbOnMouseDoubleClick(this, mouseButtonEventArgs); + DoWindowTitleThumbChangeWindowStateOnMouseDoubleClick(this, mouseButtonEventArgs); } - private void WindowMenuThumbOnMouseRightButtonUp(object sender, MouseButtonEventArgs e) + private void WindowTitleThumbSystemMenuOnMouseRightButtonUp(object sender, MouseButtonEventArgs e) { - DoWindowMenuThumbOnMouseRightButtonUp(this, e); + DoWindowTitleThumbSystemMenuOnMouseRightButtonUp(this, e); } - internal static void DoWindowMoveThumbOnDragDelta(MetroWindow window, DragDeltaEventArgs dragDeltaEventArgs) + internal static void DoWindowTitleThumbMoveOnDragDelta(MetroWindow window, DragDeltaEventArgs dragDeltaEventArgs) { // drag only if IsWindowDraggable is set to true if (!window.IsWindowDraggable || @@ -998,7 +998,7 @@ internal static void DoWindowMoveThumbOnDragDelta(MetroWindow window, DragDeltaE Standard.NativeMethods.SendMessage(windowHandle, Standard.WM.SYSCOMMAND, (IntPtr)Standard.SC.MOUSEMOVE, IntPtr.Zero); } - internal static void DoWindowRestoreThumbOnMouseDoubleClick(MetroWindow window, MouseButtonEventArgs mouseButtonEventArgs) + internal static void DoWindowTitleThumbChangeWindowStateOnMouseDoubleClick(MetroWindow window, MouseButtonEventArgs mouseButtonEventArgs) { // restore/maximize only with left button if (mouseButtonEventArgs.ChangedButton == MouseButton.Left) @@ -1022,7 +1022,7 @@ internal static void DoWindowRestoreThumbOnMouseDoubleClick(MetroWindow window, } } - internal static void DoWindowMenuThumbOnMouseRightButtonUp(MetroWindow window, MouseButtonEventArgs e) + internal static void DoWindowTitleThumbSystemMenuOnMouseRightButtonUp(MetroWindow window, MouseButtonEventArgs e) { if (window.ShowSystemMenuOnRightClick) { diff --git a/MahApps.Metro/Themes/Flyout.xaml b/MahApps.Metro/Themes/Flyout.xaml index f2b3f23a6a..f0cf4a20ca 100644 --- a/MahApps.Metro/Themes/Flyout.xaml +++ b/MahApps.Metro/Themes/Flyout.xaml @@ -247,7 +247,7 @@ + x:Name="PART_WindowTitleThumb" /> + x:Name="PART_WindowTitleThumb" /> - + + x:Name="PART_WindowTitleThumb" /> - + Date: Tue, 8 Dec 2015 08:56:16 +0100 Subject: [PATCH 09/12] disable bottom Flyout for the first --- MahApps.Metro/Controls/Flyout.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MahApps.Metro/Controls/Flyout.cs b/MahApps.Metro/Controls/Flyout.cs index 904d7d810f..05912f9c9f 100644 --- a/MahApps.Metro/Controls/Flyout.cs +++ b/MahApps.Metro/Controls/Flyout.cs @@ -520,7 +520,7 @@ protected internal void CleanUp(FlyoutsControl flyoutsControl) private void WindowTitleThumbMoveOnDragDelta(object sender, DragDeltaEventArgs dragDeltaEventArgs) { var window = this.ParentWindow; - if (window != null) + if (window != null && this.Position != Position.Bottom) { MetroWindow.DoWindowTitleThumbMoveOnDragDelta(window, dragDeltaEventArgs); } @@ -529,7 +529,7 @@ private void WindowTitleThumbMoveOnDragDelta(object sender, DragDeltaEventArgs d private void WindowTitleThumbChangeWindowStateOnMouseDoubleClick(object sender, MouseButtonEventArgs mouseButtonEventArgs) { var window = this.ParentWindow; - if (window != null) + if (window != null && this.Position != Position.Bottom) { MetroWindow.DoWindowTitleThumbChangeWindowStateOnMouseDoubleClick(window, mouseButtonEventArgs); } @@ -538,7 +538,7 @@ private void WindowTitleThumbChangeWindowStateOnMouseDoubleClick(object sender, private void WindowTitleThumbSystemMenuOnMouseRightButtonUp(object sender, MouseButtonEventArgs e) { var window = this.ParentWindow; - if (window != null) + if (window != null && this.Position != Position.Bottom) { MetroWindow.DoWindowTitleThumbSystemMenuOnMouseRightButtonUp(window, e); } From 7f4ed20d30561334fafc6470a250d34af9322ad1 Mon Sep 17 00:00:00 2001 From: Jan Karger Date: Tue, 8 Dec 2015 09:04:51 +0100 Subject: [PATCH 10/12] only one style, rename to WindowTitleThumbStyle --- MahApps.Metro/MahApps.Metro.NET45.csproj | 4 ++++ MahApps.Metro/MahApps.Metro.csproj | 4 ++++ MahApps.Metro/Themes/Flyout.xaml | 16 ++-------------- MahApps.Metro/Themes/MetroWindow.xaml | 18 +++--------------- MahApps.Metro/Themes/Thumb.xaml | 15 +++++++++++++++ 5 files changed, 28 insertions(+), 29 deletions(-) create mode 100644 MahApps.Metro/Themes/Thumb.xaml diff --git a/MahApps.Metro/MahApps.Metro.NET45.csproj b/MahApps.Metro/MahApps.Metro.NET45.csproj index cd3a328e33..184de5b9b1 100644 --- a/MahApps.Metro/MahApps.Metro.NET45.csproj +++ b/MahApps.Metro/MahApps.Metro.NET45.csproj @@ -642,6 +642,10 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/MahApps.Metro/MahApps.Metro.csproj b/MahApps.Metro/MahApps.Metro.csproj index 9ee1adad54..7b281af575 100644 --- a/MahApps.Metro/MahApps.Metro.csproj +++ b/MahApps.Metro/MahApps.Metro.csproj @@ -593,6 +593,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + Designer MSBuild:Compile diff --git a/MahApps.Metro/Themes/Flyout.xaml b/MahApps.Metro/Themes/Flyout.xaml index f0cf4a20ca..c8d2879f3e 100644 --- a/MahApps.Metro/Themes/Flyout.xaml +++ b/MahApps.Metro/Themes/Flyout.xaml @@ -7,21 +7,9 @@ + - - - diff --git a/MahApps.Metro/Themes/MetroWindow.xaml b/MahApps.Metro/Themes/MetroWindow.xaml index 4bd217364d..556eec4de4 100644 --- a/MahApps.Metro/Themes/MetroWindow.xaml +++ b/MahApps.Metro/Themes/MetroWindow.xaml @@ -6,23 +6,11 @@ + - - @@ -108,7 +96,7 @@ @@ -389,7 +377,7 @@ diff --git a/MahApps.Metro/Themes/Thumb.xaml b/MahApps.Metro/Themes/Thumb.xaml new file mode 100644 index 0000000000..ec2c600abe --- /dev/null +++ b/MahApps.Metro/Themes/Thumb.xaml @@ -0,0 +1,15 @@ + + + + + \ No newline at end of file From 43237d744cdc0dca1388bafec370b0ff21e1e57c Mon Sep 17 00:00:00 2001 From: Jan Karger Date: Tue, 8 Dec 2015 14:32:39 +0100 Subject: [PATCH 11/12] update 1.2.0.md --- docs/release-notes/1.2.0.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/release-notes/1.2.0.md b/docs/release-notes/1.2.0.md index 92fc0abb48..05d8887543 100644 --- a/docs/release-notes/1.2.0.md +++ b/docs/release-notes/1.2.0.md @@ -98,6 +98,7 @@ This is a bug fix and feature release of MahApps.Metro v1.2.0. - New `ContentControlEx` to reduce some boilerplate XAML code + Used for all possible `ContentCharacterCasing` usage (`Button`, `GroupBox`, `Expander`, `ListView` columns, `DataGrid` columns, `DropDownButton`, `SplitButton`, `WindowCommands`, `TabItem`) - Copy command for the message text in `MessageDialog` #2223 (@akinyooa) +- Use a `Thumb` for Window DragMove #2226 # Bugfixes @@ -159,3 +160,6 @@ This is a bug fix and feature release of MahApps.Metro v1.2.0. - Fixed `ComboBox` watermark padding issue with `IsEditable` states #2210 - Fixed missing `ContentCharacterCasing` for `TabItem` #2209 - Fixed style inheritence of `MetroAnimatedTabControl` style #2219 +- Fixed not draggable Window when Flyout is open #1821 #1635 #2226 +- Fixed `AvalonDock` anchorables could not be dragged inside `MetroWindow` #2036 #2226 +- Fixed System menu present everywhere when fullscreen is toggled on #1849 From d4ed4ce9e10b2c5bdc664133c0c07b5dedae31be Mon Sep 17 00:00:00 2001 From: Jan Karger Date: Tue, 8 Dec 2015 14:35:49 +0100 Subject: [PATCH 12/12] update 1.2.0.md (reverted from commit 43237d744cdc0dca1388bafec370b0ff21e1e57c) --- docs/release-notes/1.2.0.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docs/release-notes/1.2.0.md b/docs/release-notes/1.2.0.md index 05d8887543..92fc0abb48 100644 --- a/docs/release-notes/1.2.0.md +++ b/docs/release-notes/1.2.0.md @@ -98,7 +98,6 @@ This is a bug fix and feature release of MahApps.Metro v1.2.0. - New `ContentControlEx` to reduce some boilerplate XAML code + Used for all possible `ContentCharacterCasing` usage (`Button`, `GroupBox`, `Expander`, `ListView` columns, `DataGrid` columns, `DropDownButton`, `SplitButton`, `WindowCommands`, `TabItem`) - Copy command for the message text in `MessageDialog` #2223 (@akinyooa) -- Use a `Thumb` for Window DragMove #2226 # Bugfixes @@ -160,6 +159,3 @@ This is a bug fix and feature release of MahApps.Metro v1.2.0. - Fixed `ComboBox` watermark padding issue with `IsEditable` states #2210 - Fixed missing `ContentCharacterCasing` for `TabItem` #2209 - Fixed style inheritence of `MetroAnimatedTabControl` style #2219 -- Fixed not draggable Window when Flyout is open #1821 #1635 #2226 -- Fixed `AvalonDock` anchorables could not be dragged inside `MetroWindow` #2036 #2226 -- Fixed System menu present everywhere when fullscreen is toggled on #1849