diff --git a/Dragablz.Test/Dragablz.Test.csproj b/Dragablz.Test/Dragablz.Test.csproj index ce2dd8c2..1f9a17e6 100644 --- a/Dragablz.Test/Dragablz.Test.csproj +++ b/Dragablz.Test/Dragablz.Test.csproj @@ -1,24 +1,25 @@  - - net5.0-windows;netcoreapp3.0;net45;net40 + + net8.0-windows10.0.17763.0 + win-x64 + x64 + false + - false - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - - + + + diff --git a/Dragablz/Dockablz/Layout.cs b/Dragablz/Dockablz/Layout.cs index e86e89a8..43836028 100644 --- a/Dragablz/Dockablz/Layout.cs +++ b/Dragablz/Dockablz/Layout.cs @@ -1,5 +1,4 @@ using System; -using System.CodeDom; using System.Collections; using System.Collections.Generic; using System.Linq; @@ -193,12 +192,26 @@ public static BranchResult Branch(TabablzControl tabablzControl, TabablzControl return branchResult; } + // Add parition as dependency property + public static readonly DependencyProperty PartitionProperty = DependencyProperty.Register( + "Partition", typeof (object), typeof (Layout), new PropertyMetadata(default(object))); + /// /// Use in conjuction with the on a /// to isolate drag and drop spaces/control instances. /// - public string Partition { get; set; } + public object Partition + { + get { return (object) GetValue(PartitionProperty); } + set { SetValue(PartitionProperty, value); } + } + /// + /// Use in conjuction with the on a + /// to isolate drag and drop spaces/control instances. + /// + //public string Partition { get; set; } + public static readonly DependencyProperty InterLayoutClientProperty = DependencyProperty.Register( "InterLayoutClient", typeof (IInterLayoutClient), typeof (Layout), new PropertyMetadata(new DefaultInterLayoutClient())); @@ -450,7 +463,7 @@ private static void SetupParticipatingLayouts(DragablzItem dragablzItem) if (draggingWindow == null) return; foreach (var loadedLayout in LoadedLayouts.Where(l => - l.Partition == dragablzItem.PartitionAtDragStart && + l.Partition?.ToString() == dragablzItem.PartitionAtDragStart && !Equals(Window.GetWindow(l), draggingWindow))) { diff --git a/Dragablz/Dragablz.csproj b/Dragablz/Dragablz.csproj index 240a2663..fca2863f 100644 --- a/Dragablz/Dragablz.csproj +++ b/Dragablz/Dragablz.csproj @@ -1,33 +1,34 @@ - + - - net5.0-windows;netcoreapp3.0;net45;net40 - true - false - https://raw.githubusercontent.com/ButchersBoy/Dragablz/master/Resources/D32.png - - LICENSE - http://dragablz.net - https://github.com/ButchersBoy/Dragablz - WPF TabControl Tab Tearable - Support for .Net Core 3.0 - git - ..\bin\Release\Dragablz.xml - + + net8.0-windows10.0.17763.0 + win-x64 + x64 + true + false + https://raw.githubusercontent.com/ButchersBoy/Dragablz/master/Resources/D32.png + + LICENSE + http://dragablz.net + https://github.com/ButchersBoy/Dragablz + WPF TabControl Tab Tearable + Support for .NET 8 + git + - - ..\bin\Debug - + + ..\bin\Debug + - - ..\bin\Release - + + ..\bin\Release + - - - True - - - + + + True + + + diff --git a/Dragablz/DragablzItem.cs b/Dragablz/DragablzItem.cs index d767e8e6..ca894058 100644 --- a/Dragablz/DragablzItem.cs +++ b/Dragablz/DragablzItem.cs @@ -1,6 +1,6 @@ using System; -using System.Dynamic; using System.Linq; +using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; @@ -39,20 +39,20 @@ public class DragablzItem : ContentControl static DragablzItem() { - DefaultStyleKeyProperty.OverrideMetadata(typeof(DragablzItem), new FrameworkPropertyMetadata(typeof(DragablzItem))); + DefaultStyleKeyProperty.OverrideMetadata(typeof(DragablzItem), new FrameworkPropertyMetadata(typeof(DragablzItem))); } public DragablzItem() { - AddHandler(MouseDownEvent, new RoutedEventHandler(MouseDownHandler), true); + AddHandler(MouseDownEvent, new RoutedEventHandler(MouseDownHandler), true); } public static readonly DependencyProperty XProperty = DependencyProperty.Register( - "X", typeof (double), typeof (DragablzItem), new PropertyMetadata(default(double), OnXChanged)); + "X", typeof(double), typeof(DragablzItem), new PropertyMetadata(default(double), OnXChanged)); public double X { - get { return (double) GetValue(XProperty); } + get { return (double)GetValue(XProperty); } set { SetValue(XProperty, value); } } @@ -71,7 +71,7 @@ public event RoutedPropertyChangedEventHandler XChanged private static void OnXChanged( DependencyObject d, DependencyPropertyChangedEventArgs e) - { + { var instance = (DragablzItem)d; var args = new RoutedPropertyChangedEventArgs( (double)e.OldValue, @@ -79,15 +79,15 @@ private static void OnXChanged( { RoutedEvent = XChangedEvent }; - instance.RaiseEvent(args); - } + instance.RaiseEvent(args); + } public static readonly DependencyProperty YProperty = DependencyProperty.Register( - "Y", typeof (double), typeof (DragablzItem), new PropertyMetadata(default(double), OnYChanged)); + "Y", typeof(double), typeof(DragablzItem), new PropertyMetadata(default(double), OnYChanged)); public double Y { - get { return (double) GetValue(YProperty); } + get { return (double)GetValue(YProperty); } set { SetValue(YProperty, value); } } @@ -119,7 +119,7 @@ private static void OnYChanged( private static readonly DependencyPropertyKey LogicalIndexPropertyKey = DependencyProperty.RegisterReadOnly( - "LogicalIndex", typeof (int), typeof (DragablzItem), + "LogicalIndex", typeof(int), typeof(DragablzItem), new PropertyMetadata(default(int), OnLogicalIndexChanged)); public static readonly DependencyProperty LogicalIndexProperty = @@ -127,7 +127,7 @@ private static void OnYChanged( public int LogicalIndex { - get { return (int) GetValue(LogicalIndexProperty); } + get { return (int)GetValue(LogicalIndexProperty); } internal set { SetValue(LogicalIndexPropertyKey, value); } } @@ -135,8 +135,8 @@ public int LogicalIndex EventManager.RegisterRoutedEvent( "LogicalIndexChanged", RoutingStrategy.Bubble, - typeof (RoutedPropertyChangedEventHandler), - typeof (DragablzItem)); + typeof(RoutedPropertyChangedEventHandler), + typeof(DragablzItem)); public event RoutedPropertyChangedEventHandler LogicalIndexChanged { @@ -147,18 +147,18 @@ public event RoutedPropertyChangedEventHandler LogicalIndexChanged private static void OnLogicalIndexChanged( DependencyObject d, DependencyPropertyChangedEventArgs e) { - var instance = (DragablzItem) d; + var instance = (DragablzItem)d; var args = new RoutedPropertyChangedEventArgs( - (int) e.OldValue, - (int) e.NewValue) + (int)e.OldValue, + (int)e.NewValue) { RoutedEvent = DragablzItem.LogicalIndexChangedEvent }; instance.RaiseEvent(args); - } + } public static readonly DependencyProperty SizeGripProperty = DependencyProperty.RegisterAttached( - "SizeGrip", typeof (SizeGrip), typeof (DragablzItem), new PropertyMetadata(default(SizeGrip), SizeGripPropertyChangedCallback)); + "SizeGrip", typeof(SizeGrip), typeof(DragablzItem), new PropertyMetadata(default(SizeGrip), SizeGripPropertyChangedCallback)); private static void SizeGripPropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) { @@ -169,17 +169,17 @@ private static void SizeGripPropertyChangedCallback(DependencyObject dependencyO private static void SizeThumbOnDragDelta(object sender, DragDeltaEventArgs dragDeltaEventArgs) { - var thumb = ((Thumb) sender); + var thumb = ((Thumb)sender); var dragablzItem = thumb.VisualTreeAncestory().OfType().FirstOrDefault(); if (dragablzItem == null) return; - var sizeGrip = (SizeGrip) thumb.GetValue(SizeGripProperty); + var sizeGrip = (SizeGrip)thumb.GetValue(SizeGripProperty); var width = dragablzItem.ActualWidth; var height = dragablzItem.ActualHeight; var x = dragablzItem.X; var y = dragablzItem.Y; switch (sizeGrip) - { + { case SizeGrip.NotApplicable: break; case SizeGrip.Left: @@ -193,7 +193,7 @@ private static void SizeThumbOnDragDelta(object sender, DragDeltaEventArgs dragD y += dragDeltaEventArgs.VerticalChange; break; case SizeGrip.Top: - height += -dragDeltaEventArgs.VerticalChange; + height += -dragDeltaEventArgs.VerticalChange; y += dragDeltaEventArgs.VerticalChange; break; case SizeGrip.TopRight: @@ -232,14 +232,14 @@ public static void SetSizeGrip(DependencyObject element, SizeGrip value) public static SizeGrip GetSizeGrip(DependencyObject element) { - return (SizeGrip) element.GetValue(SizeGripProperty); + return (SizeGrip)element.GetValue(SizeGripProperty); } /// /// Allows item content to be rotated (in suppported templates), typically for use in a vertical/side tab. /// public static readonly DependencyProperty ContentRotateTransformAngleProperty = DependencyProperty.RegisterAttached( - "ContentRotateTransformAngle", typeof (double), typeof (DragablzItem), new FrameworkPropertyMetadata(default(double), FrameworkPropertyMetadataOptions.Inherits)); + "ContentRotateTransformAngle", typeof(double), typeof(DragablzItem), new FrameworkPropertyMetadata(default(double), FrameworkPropertyMetadataOptions.Inherits)); /// /// Allows item content to be rotated (in suppported templates), typically for use in a vertical/side tab. @@ -258,7 +258,7 @@ public static void SetContentRotateTransformAngle(DependencyObject element, doub /// public static double GetContentRotateTransformAngle(DependencyObject element) { - return (double) element.GetValue(ContentRotateTransformAngleProperty); + return (double)element.GetValue(ContentRotateTransformAngleProperty); } public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register( @@ -266,13 +266,13 @@ public static double GetContentRotateTransformAngle(DependencyObject element) public bool IsSelected { - get { return (bool) GetValue(IsSelectedProperty); } + get { return (bool)GetValue(IsSelectedProperty); } set { SetValue(IsSelectedProperty, value); } } private static readonly DependencyPropertyKey IsDraggingPropertyKey = DependencyProperty.RegisterReadOnly( - "IsDragging", typeof (bool), typeof (DragablzItem), + "IsDragging", typeof(bool), typeof(DragablzItem), new PropertyMetadata(default(bool), OnIsDraggingChanged)); public static readonly DependencyProperty IsDraggingProperty = @@ -280,7 +280,7 @@ public bool IsSelected public bool IsDragging { - get { return (bool) GetValue(IsDraggingProperty); } + get { return (bool)GetValue(IsDraggingProperty); } internal set { SetValue(IsDraggingPropertyKey, value); } } @@ -288,8 +288,8 @@ public bool IsDragging EventManager.RegisterRoutedEvent( "IsDraggingChanged", RoutingStrategy.Bubble, - typeof (RoutedPropertyChangedEventHandler), - typeof (DragablzItem)); + typeof(RoutedPropertyChangedEventHandler), + typeof(DragablzItem)); public event RoutedPropertyChangedEventHandler IsDraggingChanged { @@ -305,7 +305,8 @@ private static void OnIsDraggingChanged( var instance = (DragablzItem)d; var args = new RoutedPropertyChangedEventArgs( (bool)e.OldValue, - (bool)e.NewValue) { RoutedEvent = IsDraggingChangedEvent }; + (bool)e.NewValue) + { RoutedEvent = IsDraggingChangedEvent }; instance.RaiseEvent(args); } @@ -314,7 +315,7 @@ private static void OnIsDraggingChanged( "MouseDownWithin", RoutingStrategy.Bubble, typeof(DragablzItemEventHandler), - typeof (DragablzItem)); + typeof(DragablzItem)); private static void OnMouseDownWithin(DependencyObject d) { @@ -324,7 +325,7 @@ private static void OnMouseDownWithin(DependencyObject d) private static readonly DependencyPropertyKey IsSiblingDraggingPropertyKey = DependencyProperty.RegisterReadOnly( - "IsSiblingDragging", typeof (bool), typeof (DragablzItem), + "IsSiblingDragging", typeof(bool), typeof(DragablzItem), new PropertyMetadata(default(bool), OnIsSiblingDraggingChanged)); public static readonly DependencyProperty IsSiblingDraggingProperty = @@ -332,7 +333,7 @@ private static void OnMouseDownWithin(DependencyObject d) public bool IsSiblingDragging { - get { return (bool) GetValue(IsSiblingDraggingProperty); } + get { return (bool)GetValue(IsSiblingDraggingProperty); } internal set { SetValue(IsSiblingDraggingPropertyKey, value); } } @@ -340,8 +341,8 @@ public bool IsSiblingDragging EventManager.RegisterRoutedEvent( "IsSiblingDraggingChanged", RoutingStrategy.Bubble, - typeof (RoutedPropertyChangedEventHandler), - typeof (DragablzItem)); + typeof(RoutedPropertyChangedEventHandler), + typeof(DragablzItem)); public event RoutedPropertyChangedEventHandler IsSiblingDraggingChanged { @@ -352,15 +353,15 @@ public event RoutedPropertyChangedEventHandler IsSiblingDraggingChanged private static void OnIsSiblingDraggingChanged( DependencyObject d, DependencyPropertyChangedEventArgs e) { - var instance = (DragablzItem) d; + var instance = (DragablzItem)d; var args = new RoutedPropertyChangedEventArgs( - (bool) e.OldValue, - (bool) e.NewValue) + (bool)e.OldValue, + (bool)e.NewValue) { RoutedEvent = IsSiblingDraggingChangedEvent }; instance.RaiseEvent(args); - } + } public static readonly RoutedEvent DragStarted = EventManager.RegisterRoutedEvent( @@ -370,7 +371,7 @@ private static void OnIsSiblingDraggingChanged( typeof(DragablzItem)); protected void OnDragStarted(DragablzDragStartedEventArgs e) - { + { RaiseEvent(e); } @@ -378,12 +379,12 @@ protected void OnDragStarted(DragablzDragStartedEventArgs e) EventManager.RegisterRoutedEvent( "DragDelta", RoutingStrategy.Bubble, - typeof (DragablzDragDeltaEventHandler), - typeof (DragablzItem)); + typeof(DragablzDragDeltaEventHandler), + typeof(DragablzItem)); protected void OnDragDelta(DragablzDragDeltaEventArgs e) - { - RaiseEvent(e); + { + RaiseEvent(e); } public static readonly RoutedEvent PreviewDragDelta = @@ -394,7 +395,7 @@ protected void OnDragDelta(DragablzDragDeltaEventArgs e) typeof(DragablzItem)); protected void OnPreviewDragDelta(DragablzDragDeltaEventArgs e) - { + { RaiseEvent(e); } @@ -425,7 +426,7 @@ protected void OnDragCompleted(DragCompletedEventArgs e) /// the default thumb will handle mouse interaction). /// public static readonly DependencyProperty IsCustomThumbProperty = DependencyProperty.RegisterAttached( - "IsCustomThumb", typeof (bool), typeof (DragablzItem), new PropertyMetadata(default(bool), IsCustomThumbPropertyChangedCallback)); + "IsCustomThumb", typeof(bool), typeof(DragablzItem), new PropertyMetadata(default(bool), IsCustomThumbPropertyChangedCallback)); private static void IsCustomThumbPropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs) { @@ -436,7 +437,7 @@ private static void IsCustomThumbPropertyChangedCallback(DependencyObject depend ApplyCustomThumbSetting(thumb); else thumb.Loaded += CustomThumbOnLoaded; - } + } /// /// templates contain a thumb, which is used to drag the item around. @@ -452,17 +453,17 @@ public static void SetIsCustomThumb(Thumb element, bool value) public static bool GetIsCustomThumb(Thumb element) { - return (bool) element.GetValue(IsCustomThumbProperty); + return (bool)element.GetValue(IsCustomThumbProperty); } private bool _isTemplateThumbWithMouseAfterSeize = false; public override void OnApplyTemplate() { - base.OnApplyTemplate(); - + base.OnApplyTemplate(); + var thumbAndSubscription = SelectAndSubscribeToThumb(); _templateSubscriptions.Disposable = thumbAndSubscription.Item2; - + if (_seizeDragWithTemplate && thumbAndSubscription.Item1 != null) { _isTemplateThumbWithMouseAfterSeize = true; @@ -473,27 +474,27 @@ public override void OnApplyTemplate() Dispatcher.BeginInvoke(new Action(() => thumbAndSubscription.Item1.RaiseEvent(new MouseButtonEventArgs(InputManager.Current.PrimaryMouseDevice, 0, - MouseButton.Left) {RoutedEvent = MouseLeftButtonDownEvent}))); + MouseButton.Left) + { RoutedEvent = MouseLeftButtonDownEvent }))); } _seizeDragWithTemplate = false; } - protected override void OnPreviewMouseRightButtonDown(MouseButtonEventArgs e) - { + protected override async void OnPreviewMouseRightButtonDown(MouseButtonEventArgs e) + { if (_thumb != null) { var currentThumbIsHitTestVisible = _thumb.IsHitTestVisible; _thumb.SetCurrentValue(IsHitTestVisibleProperty, false); - _rightMouseUpCleanUpDisposable.Disposable = Disposable.Create(() => + + while (Mouse.RightButton == MouseButtonState.Pressed) { - _thumb.SetCurrentValue(IsHitTestVisibleProperty, currentThumbIsHitTestVisible); - }); + await Task.Delay(25); + }; + + _thumb.SetCurrentValue(IsHitTestVisibleProperty, currentThumbIsHitTestVisible); } - else - { - _rightMouseUpCleanUpDisposable.Disposable = Disposable.Empty; - } - + base.OnPreviewMouseRightButtonDown(e); } @@ -515,7 +516,7 @@ internal void InstigateDrag(Action continuation) var thumb = GetTemplateChild(ThumbPartName) as Thumb; if (thumb != null) { - thumb.CaptureMouse(); + thumb.CaptureMouse(); } else _seizeDragWithTemplate = true; @@ -573,7 +574,7 @@ private void ThumbOnDragDelta(object sender, DragDeltaEventArgs dragDeltaEventAr private void ThumbOnDragStarted(object sender, DragStartedEventArgs dragStartedEventArgs) { MouseAtDragStart = Mouse.GetPosition(this); - OnDragStarted(new DragablzDragStartedEventArgs(DragStarted, this, dragStartedEventArgs)); + OnDragStarted(new DragablzDragStartedEventArgs(DragStarted, this, dragStartedEventArgs)); } private void MouseDownHandler(object sender, RoutedEventArgs routedEventArgs) @@ -591,10 +592,10 @@ private static void CustomThumbOnLoaded(object sender, RoutedEventArgs routedEve private Thumb FindCustomThumb() { return this.VisualTreeDepthFirstTraversal().OfType().FirstOrDefault(GetIsCustomThumb); - } + } private static void ApplyCustomThumbSetting(Thumb thumb) - { + { var dragablzItem = thumb.VisualTreeAncestory().OfType().FirstOrDefault(); if (dragablzItem == null) throw new ApplicationException("Cannot find parent DragablzItem for custom thumb"); @@ -605,14 +606,15 @@ private static void ApplyCustomThumbSetting(Thumb thumb) if (dragablzItem._customThumb != null && dragablzItem._isTemplateThumbWithMouseAfterSeize) dragablzItem.Dispatcher.BeginInvoke(new Action(() => dragablzItem._customThumb.RaiseEvent(new MouseButtonEventArgs(InputManager.Current.PrimaryMouseDevice, 0, - MouseButton.Left) { RoutedEvent = MouseLeftButtonDownEvent }))); + MouseButton.Left) + { RoutedEvent = MouseLeftButtonDownEvent }))); } private Tuple SelectAndSubscribeToThumb() { var templateThumb = GetTemplateChild(ThumbPartName) as Thumb; templateThumb?.SetCurrentValue(IsHitTestVisibleProperty, _customThumb == null); - + _thumb = _customThumb ?? templateThumb; if (_thumb != null) { diff --git a/Dragablz/InterTabController.cs b/Dragablz/InterTabController.cs index 6853e452..0353aa16 100644 --- a/Dragablz/InterTabController.cs +++ b/Dragablz/InterTabController.cs @@ -1,5 +1,4 @@ -using System.Dynamic; -using System.Windows; +using System.Windows; namespace Dragablz { @@ -48,8 +47,7 @@ public IInterTabClient InterTabClient get { return (IInterTabClient) GetValue(InterTabClientProperty); } set { SetValue(InterTabClientProperty, value); } } - - /* + public static readonly DependencyProperty PartitionProperty = DependencyProperty.Register( "Partition", typeof (object), typeof (InterTabController), new PropertyMetadata(default(object))); @@ -62,12 +60,13 @@ public object Partition get { return (object) GetValue(PartitionProperty); } set { SetValue(PartitionProperty, value); } } - */ + /* /// /// The partition allows on or more tab environments in a single application. Only tabs which have a tab controller /// with a common partition will be allowed to have tabs dragged between them. null is a valid partition (i.e global). /// public string Partition { get; set; } + */ } } \ No newline at end of file diff --git a/Dragablz/TabEmptiedResponse.cs b/Dragablz/TabEmptiedResponse.cs index 9ac913db..8c756734 100644 --- a/Dragablz/TabEmptiedResponse.cs +++ b/Dragablz/TabEmptiedResponse.cs @@ -3,9 +3,15 @@ namespace Dragablz public enum TabEmptiedResponse { /// - /// Allow the Window to be closed automatically. + /// Allow the Window and Layout branch to be closed automatically. /// CloseWindowOrLayoutBranch, + + /// + /// Allow the Layout branch to be closed automatically, but not the window. + /// + CloseLayoutBranch, + /// /// The window will not be closed by the , probably meaning the implementor will close the window manually /// diff --git a/Dragablz/TabablzControl.cs b/Dragablz/TabablzControl.cs index c1617708..66351940 100644 --- a/Dragablz/TabablzControl.cs +++ b/Dragablz/TabablzControl.cs @@ -369,6 +369,24 @@ public int FixedHeaderCount set { SetValue(FixedHeaderCountProperty, value); } } + + public static readonly DependencyProperty DisableBranchConsolidationProperty = DependencyProperty.Register( + "DisableBranchConsolidation", typeof (bool), typeof (TabablzControl), new PropertyMetadata(default(bool))); + + /// + /// Disable the consolidation of branches when a tab is dragged out of a branch. Set it to true if you have + /// a main TabablzControl that is used to create new tab items and you don't want to remove this TabaBlzControl + /// when the last tab is dragged out. In dynamically created TabablzControls this property should then be set to + /// false (default). + /// If this is set to true the and + /// is ignored. + /// + public bool DisableBranchConsolidation + { + get { return (bool) GetValue(DisableBranchConsolidationProperty); } + set { SetValue(DisableBranchConsolidationProperty, value); } + } + public static readonly DependencyProperty InterTabControllerProperty = DependencyProperty.Register( "InterTabController", typeof (InterTabController), typeof (TabablzControl), new PropertyMetadata(null, InterTabControllerPropertyChangedCallback)); @@ -508,8 +526,6 @@ public ItemActionCallback ConsolidatingOrphanedItemCallback set { SetValue(ConsolidatingOrphanedItemCallbackProperty, value); } } - - private static readonly DependencyPropertyKey IsDraggingWindowPropertyKey = DependencyProperty.RegisterReadOnly( "IsDraggingWindow", typeof (bool), typeof (TabablzControl), @@ -973,7 +989,7 @@ private void ItemDragStarted(object sender, DragablzDragStartedEventArgs e) foreach (var otherItem in _dragablzItemsControl.Containers().Except(e.DragablzItem)) otherItem.IsSelected = false; e.DragablzItem.IsSelected = true; - e.DragablzItem.PartitionAtDragStart = InterTabController?.Partition; + e.DragablzItem.PartitionAtDragStart = InterTabController?.Partition.ToString(); var item = _dragablzItemsControl.ItemContainerGenerator.ItemFromContainer(e.DragablzItem); var tabItem = item as TabItem; if (tabItem != null) @@ -1099,7 +1115,7 @@ internal object RemoveItem(DragablzItem dragablzItem) var minSize = EmptyHeaderSizingHint == EmptyHeaderSizingHint.PreviousTab ? new Size(_dragablzItemsControl.ActualWidth, _dragablzItemsControl.ActualHeight) : new Size(); - + _dragablzItemsControl.MinHeight = 0; _dragablzItemsControl.MinWidth = 0; @@ -1107,15 +1123,38 @@ internal object RemoveItem(DragablzItem dragablzItem) RemoveFromSource(item); _itemsHolder.Children.Remove(contentPresenter); - if (Items.Count != 0) return item; + // Return if it is not the last item + if (Items.Count != 0) + return item; + // Set min size + _dragablzItemsControl.MinHeight = minSize.Height; + _dragablzItemsControl.MinWidth = minSize.Width; + + // Disable branch consolidation (close branch or window is ignored) + if (DisableBranchConsolidation) + return item; + + // Find window var window = Window.GetWindow(this); - if (window != null - && InterTabController != null - && InterTabController.InterTabClient.TabEmptiedHandler(this, window) == TabEmptiedResponse.CloseWindowOrLayoutBranch) - { - if (Layout.ConsolidateBranch(this)) return item; + if (window == null || InterTabController == null) + return item; + + // Get tab emptied response + var tabEmptiedResponse = InterTabController.InterTabClient.TabEmptiedHandler(this, window); + + // This is e.g. to DoNothing + if (tabEmptiedResponse is not (TabEmptiedResponse.CloseLayoutBranch or TabEmptiedResponse.CloseWindowOrLayoutBranch)) + return item; + + // Consolidate branch + if (Layout.ConsolidateBranch(this)) + return item; + + // Close window + if (tabEmptiedResponse is TabEmptiedResponse.CloseWindowOrLayoutBranch) + { try { SetIsClosingAsPartOfDragOperation(window, true); @@ -1124,13 +1163,9 @@ internal object RemoveItem(DragablzItem dragablzItem) finally { SetIsClosingAsPartOfDragOperation(window, false); - } - } - else - { - _dragablzItemsControl.MinHeight = minSize.Height; - _dragablzItemsControl.MinWidth = minSize.Width; + } } + return item; } @@ -1227,7 +1262,9 @@ private void MonitorBreach(DragablzDragDeltaEventArgs e) { _dragablzItemsControl.MinHeight = minSize.Height; _dragablzItemsControl.MinWidth = minSize.Width; - Layout.ConsolidateBranch(this); + + if(!DisableBranchConsolidation) + Layout.ConsolidateBranch(this); } RestorePreviousSelection(); diff --git a/Dragablz/Themes/MahApps.xaml b/Dragablz/Themes/MahApps.xaml index c26d9a33..79e1333b 100644 --- a/Dragablz/Themes/MahApps.xaml +++ b/Dragablz/Themes/MahApps.xaml @@ -152,7 +152,7 @@ diff --git a/DragablzDemo/DragablzDemo.csproj b/DragablzDemo/DragablzDemo.csproj index f09a8efe..2917411c 100644 --- a/DragablzDemo/DragablzDemo.csproj +++ b/DragablzDemo/DragablzDemo.csproj @@ -1,15 +1,17 @@  - - WinExe - net5.0-windows;netcoreapp3.0;net45;net40 - true - false - DragablzDemo.Boot - + + WinExe + net8.0-windows10.0.17763.0 + win-x64 + x64 + true + false + DragablzDemo.Boot + - - - + + + \ No newline at end of file diff --git a/README.md b/README.md index b7d73c80..021f3b2e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ ![Dragablz](https://dragablz.files.wordpress.com/2015/01/dragablztext22.png "Dragablz") -======== +======= [![Gitter](https://img.shields.io/badge/Gitter-Join%20Chat-green.svg?style=flat-square)](https://gitter.im/ButchersBoy/Dragablz?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![NuGet](https://img.shields.io/nuget/v/Dragablz.svg?style=flat-square)](http://www.nuget.org/packages/Dragablz/) [![Build](https://img.shields.io/appveyor/ci/ButchersBoy/dragablz.svg?style=flat-square)](https://ci.appveyor.com/project/ButchersBoy/dragablz)