From 21c37161c67bb46965752226287dbc858d4cf124 Mon Sep 17 00:00:00 2001 From: Jacob Colyer Date: Tue, 9 Oct 2018 13:28:08 -0400 Subject: [PATCH 1/3] Fixes issue #1379 in xceedsoftware/wpftoolkit Conform to the data contract for GridLength constructor and provide a valid double value when using the grid splitter to resize layout panes. In certain situations, a user can resize panes into negative space which is not valid. --- .../Controls/LayoutGridControl.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutGridControl.cs b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutGridControl.cs index 0f8960d69..cb1c18536 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutGridControl.cs +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutGridControl.cs @@ -416,7 +416,8 @@ private void OnSplitterDragCompleted( object sender, System.Windows.Controls.Pri else { var width = ( prevChildModel.DockWidth.IsAuto ) ? prevChildActualSize.Width : prevChildModel.DockWidth.Value; - prevChildModel.DockWidth = new GridLength( width + delta, GridUnitType.Pixel ); + var resizedWidth = width + delta; + prevChildModel.DockWidth = new GridLength( double.IsNaN(resizedWidth) ? width : resizedWidth, GridUnitType.Pixel ); } if( nextChildModel.DockWidth.IsStar ) @@ -426,7 +427,8 @@ private void OnSplitterDragCompleted( object sender, System.Windows.Controls.Pri else { var width = ( nextChildModel.DockWidth.IsAuto ) ? nextChildActualSize.Width : nextChildModel.DockWidth.Value; - nextChildModel.DockWidth = new GridLength( width - delta, GridUnitType.Pixel ); + var resizedWidth = width - delta; + nextChildModel.DockWidth = new GridLength( double.IsNaN(resizedWidth) ? width : resizedWidth, GridUnitType.Pixel ); } } else @@ -438,7 +440,8 @@ private void OnSplitterDragCompleted( object sender, System.Windows.Controls.Pri else { var height = ( prevChildModel.DockHeight.IsAuto ) ? prevChildActualSize.Height : prevChildModel.DockHeight.Value; - prevChildModel.DockHeight = new GridLength( height + delta, GridUnitType.Pixel ); + var resizedHeight = height + delta; + prevChildModel.DockHeight = new GridLength( double.IsNaN(resizedHeight) ? height : resizedHeight, GridUnitType.Pixel ); } if( nextChildModel.DockHeight.IsStar ) @@ -448,7 +451,8 @@ private void OnSplitterDragCompleted( object sender, System.Windows.Controls.Pri else { var height = ( nextChildModel.DockHeight.IsAuto ) ? nextChildActualSize.Height : nextChildModel.DockHeight.Value; - nextChildModel.DockHeight = new GridLength( height - delta, GridUnitType.Pixel ); + var resizedHeight = height - delta; + nextChildModel.DockHeight = new GridLength( double.IsNaN(resizedHeight) ? height : resizedHeight, GridUnitType.Pixel ); } } From 1b0114dcb3d24ba70b46ee3d75ffb4b84d6c10ab Mon Sep 17 00:00:00 2001 From: Jacob Colyer Date: Mon, 15 Oct 2018 15:17:03 -0400 Subject: [PATCH 2/3] Fixes NullReferenceException in #1354 This issues a fix for the NullReferenceException that occurs in v3.4 of AvalonDock when the _draggingItem is null on MouseEnter (reference issue #1354). --- .../Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableTabItem.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableTabItem.cs b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableTabItem.cs index 743e02656..0d38e6581 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableTabItem.cs +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Controls/LayoutAnchorableTabItem.cs @@ -181,7 +181,8 @@ protected override void OnMouseEnter( MouseEventArgs e ) { base.OnMouseEnter( e ); - if( _draggingItem != this && + if( _draggingItem != null && + _draggingItem != this && e.LeftButton == MouseButtonState.Pressed ) { var model = Model; From 38d36f236727cf48ab0e82e9794e1f927d059695 Mon Sep 17 00:00:00 2001 From: Jacob Colyer Date: Wed, 17 Oct 2018 09:48:43 -0400 Subject: [PATCH 3/3] Prevent crash from setting negative size This change temporarily fixes several issues, as described in #1381 and #1379. The fix is such that the AvalonDock will no longer crash when the control goes out of bounds. However, this does not prevent the actual control from going out of bounds. Therefore, this fix should only be used as a stop-gap until an actual fix can be implemented. --- .../Xceed.Wpf.AvalonDock/Layout/LayoutPositionableGroup.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Layout/LayoutPositionableGroup.cs b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Layout/LayoutPositionableGroup.cs index 9818face0..91d3e5ec2 100644 --- a/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Layout/LayoutPositionableGroup.cs +++ b/ExtendedWPFToolkitSolution/Src/Xceed.Wpf.AvalonDock/Layout/LayoutPositionableGroup.cs @@ -50,7 +50,7 @@ public GridLength DockWidth } set { - if( DockWidth != value ) + if( DockWidth != value && value.Value > 0 ) { RaisePropertyChanging( "DockWidth" ); _dockWidth = value; @@ -74,7 +74,7 @@ public GridLength DockHeight } set { - if( DockHeight != value ) + if( DockHeight != value && value.Value > 0 ) { RaisePropertyChanging( "DockHeight" ); _dockHeight = value;