重写「ActionViewer」类的「OnDragOver」方法

This commit is contained in:
zengwenjie
2025-09-26 15:33:21 +08:00
parent 64dc58fd08
commit 6a938f680d
2 changed files with 18 additions and 18 deletions

View File

@@ -17,6 +17,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Navigation; using System.Windows.Navigation;
using System.Windows.Shapes; using System.Windows.Shapes;
using Deedy.Activity.Helpers;
namespace Deedy.Activity namespace Deedy.Activity
{ {
@@ -745,7 +746,7 @@ namespace Deedy.Activity
} }
protected internal bool _CanDropInParent = false; // 通过组装校验逻辑设置此字段 protected internal bool _CanDropInParent = false; // 通过组装校验逻辑设置此字段
protected internal bool _CanDropChild = false; // 通过组装校验逻辑设置此字段 protected internal bool _CanDropChild = false; // 通过组装校验逻辑设置此字段
protected internal DropPlacement _DropPlacement = DropPlacement.Uncertain; // 用于最终放置逻辑 protected internal DropPlacement _DropPlacement = DropPlacement.UnDragged; // 用于最终放置逻辑
protected override void OnDragOver(DragEventArgs e) protected override void OnDragOver(DragEventArgs e)
{ {
//HACK这里要考虑父容器的布局方向 //HACK这里要考虑父容器的布局方向
@@ -756,22 +757,21 @@ namespace Deedy.Activity
if (this.TitleContainer != null && this.TitleContainer.Visibility == Visibility.Visible) if (this.TitleContainer != null && this.TitleContainer.Visibility == Visibility.Visible)
hitElement = this.TitleContainer; hitElement = this.TitleContainer;
Point currentPoint = e.GetPosition(hitElement); this._DropPlacement = this.ActionElement.Help_CheckDropPlacement(hitElement.RenderSize, e.GetPosition(hitElement));
if (this._CanDropInParent && (currentPoint.Y < 10 || currentPoint.Y < 10)) if (false
{ || (this._CanDropInParent
this._DropPlacement = DropPlacement.BeforeMe; && (this._DropPlacement == DropPlacement.BeforeMe
|| this._DropPlacement == DropPlacement.BehindMe
|| this._DropPlacement == DropPlacement.ReplaceMe
)
)
|| (this._CanDropChild
&& (this._DropPlacement == DropPlacement.Uncertain
|| this._DropPlacement == DropPlacement.WithinMe
)
)
)
this.UpdateDragAdorner(this._DropPlacement, (this.ActionElement?.ParentElement as ICombinedElement)?.Direction); this.UpdateDragAdorner(this._DropPlacement, (this.ActionElement?.ParentElement as ICombinedElement)?.Direction);
}
else if (this._CanDropInParent && (hitElement.ActualHeight - currentPoint.Y < 10 || hitElement.ActualWidth - currentPoint.X < 10))
{
this._DropPlacement = DropPlacement.BehindMe;
this.UpdateDragAdorner(this._DropPlacement, (this.ActionElement?.ParentElement as ICombinedElement)?.Direction);
}
else if (this._CanDropChild)
{
this._DropPlacement = DropPlacement.WithinMe;
this.UpdateDragAdorner(this._DropPlacement);
}
else else
{ {
this._DropPlacement = DropPlacement.Rejected; this._DropPlacement = DropPlacement.Rejected;

View File

@@ -87,9 +87,9 @@ namespace Deedy.Activity.Helpers
DropPlacement result = DropPlacement.UnDragged; DropPlacement result = DropPlacement.UnDragged;
if (element != null) if (element != null)
{ {
double horRuler = size.Width / 3; double horRuler = size.Width / 4;
if (horRuler > 20) horRuler = 20; if (horRuler > 20) horRuler = 20;
double verRuler = size.Height / 3; double verRuler = size.Height / 4;
if (verRuler > 20) verRuler = 20; if (verRuler > 20) verRuler = 20;
LayoutDirection direction = LayoutDirection.Cannot; LayoutDirection direction = LayoutDirection.Cannot;
if (element is ICombinedElement) if (element is ICombinedElement)