diff --git a/Dragablz.Test/Dragablz.Test.csproj b/Dragablz.Test/Dragablz.Test.csproj
index ce2dd8c..fc5e45d 100644
--- a/Dragablz.Test/Dragablz.Test.csproj
+++ b/Dragablz.Test/Dragablz.Test.csproj
@@ -1,24 +1,24 @@
-
- net5.0-windows;netcoreapp3.0;net45;net40
+
+ net6.0-windows;netcoreapp3.1;net48
- false
-
+ false
+
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
-
-
-
+
+
+
diff --git a/Dragablz/Dragablz.csproj b/Dragablz/Dragablz.csproj
index 240a266..93798d1 100644
--- a/Dragablz/Dragablz.csproj
+++ b/Dragablz/Dragablz.csproj
@@ -1,7 +1,7 @@
- net5.0-windows;netcoreapp3.0;net45;net40
+ net6.0-windows;netcoreapp3.1;net48
true
false
https://raw.githubusercontent.com/ButchersBoy/Dragablz/master/Resources/D32.png
@@ -10,7 +10,7 @@
http://dragablz.net
https://github.com/ButchersBoy/Dragablz
WPF TabControl Tab Tearable
- Support for .Net Core 3.0
+ Support for .NET 6
git
..\bin\Release\Dragablz.xml
diff --git a/Dragablz/DragablzItem.cs b/Dragablz/DragablzItem.cs
index d767e8e..ca89405 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/DragablzDemo/DragablzDemo.csproj b/DragablzDemo/DragablzDemo.csproj
index f09a8ef..f3689d5 100644
--- a/DragablzDemo/DragablzDemo.csproj
+++ b/DragablzDemo/DragablzDemo.csproj
@@ -1,15 +1,15 @@
-
- WinExe
- net5.0-windows;netcoreapp3.0;net45;net40
- true
- false
- DragablzDemo.Boot
-
+
+ WinExe
+ net6.0-windows;netcoreapp3.1;net48
+ true
+ false
+ DragablzDemo.Boot
+
-
-
-
+
+
+
\ No newline at end of file