Merge pull request #341 from irihitech/dialog_drag
Make mask draggable when it's modal and cannot light dismiss.
This commit is contained in:
@@ -119,6 +119,7 @@ public partial class OverlayDialogHost
|
|||||||
|
|
||||||
control.RemoveHandler(OverlayFeedbackElement.ClosedEvent, OnDialogControlClosing);
|
control.RemoveHandler(OverlayFeedbackElement.ClosedEvent, OnDialogControlClosing);
|
||||||
control.RemoveHandler(DialogControlBase.LayerChangedEvent, OnDialogLayerChanged);
|
control.RemoveHandler(DialogControlBase.LayerChangedEvent, OnDialogLayerChanged);
|
||||||
|
control.RemoveHandler(PointerPressedEvent, DragMaskToMoveWindow);
|
||||||
|
|
||||||
Children.Remove(control);
|
Children.Remove(control);
|
||||||
|
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ public partial class OverlayDialogHost
|
|||||||
_modalCount--;
|
_modalCount--;
|
||||||
IsInModalStatus = _modalCount > 0;
|
IsInModalStatus = _modalCount > 0;
|
||||||
layer.Mask.RemoveHandler(PointerPressedEvent, ClickMaskToCloseDialog);
|
layer.Mask.RemoveHandler(PointerPressedEvent, ClickMaskToCloseDialog);
|
||||||
|
layer.Mask.RemoveHandler(PointerReleasedEvent, DragMaskToMoveWindow);
|
||||||
if (!IsAnimationDisabled)
|
if (!IsAnimationDisabled)
|
||||||
{
|
{
|
||||||
var disappearAnimation = CreateAnimation(control.Bounds.Size, control.Position, false);
|
var disappearAnimation = CreateAnimation(control.Bounds.Size, control.Position, false);
|
||||||
|
|||||||
@@ -114,9 +114,29 @@ public partial class OverlayDialogHost: Canvas
|
|||||||
{
|
{
|
||||||
rec.AddHandler(PointerReleasedEvent, ClickMaskToCloseDialog);
|
rec.AddHandler(PointerReleasedEvent, ClickMaskToCloseDialog);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rec.AddHandler(PointerPressedEvent, DragMaskToMoveWindow);
|
||||||
|
}
|
||||||
return rec;
|
return rec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DragMaskToMoveWindow(object? sender, PointerPressedEventArgs e)
|
||||||
|
{
|
||||||
|
if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (sender is PureRectangle mask)
|
||||||
|
{
|
||||||
|
var window = this.GetVisualAncestors().OfType<Window>().FirstOrDefault();
|
||||||
|
if(window is not null)
|
||||||
|
{
|
||||||
|
window.BeginMoveDrag(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ClickMaskToCloseDialog(object? sender, PointerReleasedEventArgs e)
|
private void ClickMaskToCloseDialog(object? sender, PointerReleasedEventArgs e)
|
||||||
{
|
{
|
||||||
if (sender is PureRectangle border)
|
if (sender is PureRectangle border)
|
||||||
@@ -126,6 +146,7 @@ public partial class OverlayDialogHost: Canvas
|
|||||||
{
|
{
|
||||||
layer.Element.Close();
|
layer.Element.Close();
|
||||||
border.RemoveHandler(PointerReleasedEvent, ClickMaskToCloseDialog);
|
border.RemoveHandler(PointerReleasedEvent, ClickMaskToCloseDialog);
|
||||||
|
border.RemoveHandler(PointerPressedEvent, DragMaskToMoveWindow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user