Files
DeedyDesigner/DeedyDesigner/Deedy.Activity/Adorner/DragPlacementAdorner.cs
2025-09-26 14:40:02 +08:00

41 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;
using Deedy.Activity.Helpers;
namespace Deedy.Activity
{
public class DragPlacementAdorner : Adorner
{
private static readonly Pen _Pen;
private static readonly Brush _Brush;
public DropPlacement DropPlacement { get; private set; }
public LayoutDirection? LayoutDirection { get; private set; }
static DragPlacementAdorner()
{
// 定义装饰器的画笔与画刷
_Pen = new Pen(Brushes.Transparent, 0);
_Pen.Freeze();
_Brush = new SolidColorBrush(Colors.Red) { Opacity = 0.5 };
_Brush.Freeze();
}
public DragPlacementAdorner(UIElement adornedElement, DropPlacement dropPlacement, LayoutDirection? parentLayoutDirection) : base(adornedElement)
{
this.DropPlacement = dropPlacement;
this.LayoutDirection = parentLayoutDirection;
IsHitTestVisible = false;
}
protected override void OnRender(DrawingContext drawingContext)
=> this.Help_DrawDropAdorner(drawingContext, this.DropPlacement, this.LayoutDirection, _Pen, _Brush);
}
}