C# 鼠标移动比重画wpf更快

C# 鼠标移动比重画wpf更快,c#,wpf,shape,mousemove,onmousemove,C#,Wpf,Shape,Mousemove,Onmousemove,我正在定义从类Shape继承并实现“Geometry”属性的形状 下面是一个例子: public class Landmark : Shape { public override bool IsInBounds(Point currentLocation) { return (((currentLocation.X >= Location.X - 3) && (currentLocation.X <= Location.X + 3))

我正在定义从类
Shape
继承并实现“Geometry”属性的形状

下面是一个例子:

public class Landmark : Shape
{
    public override bool IsInBounds(Point currentLocation)
    {

        return (((currentLocation.X >= Location.X - 3) && (currentLocation.X <= Location.X + 3)) && ((currentLocation.Y >= Location.Y - 3) && (currentLocation.Y <= Location.Y + 3)));
    }

    protected override Geometry DefiningGeometry
    {
        get
        {
            var landMark = new EllipseGeometry {Center = Location};

            Stroke = Brushes.Red;
            return landMark;
        }
    }

    protected override void OnIsMouseDirectlyOverChanged(DependencyPropertyChangedEventArgs e)
    {
        StrokeThickness = IsMouseDirectlyOver ? 12 : 6;
        Mouse.OverrideCursor = IsMouseDirectlyOver ? Mouse.OverrideCursor = Cursors.ScrollAll : Mouse.OverrideCursor = Cursors.Arrow;
    }
    protected override void OnMouseMove(MouseEventArgs e)
    {
        if (e.LeftButton == MouseButtonState.Pressed)
        {
            Location = e.GetPosition(this);
            InvalidateVisual();
        }
    }
}
公共类地标:形状
{
公共覆盖边界(点当前位置)
{
返回((currentLocation.X>=Location.X-3)和&(currentLocation.X=Location.Y-3)和&(currentLocation.YYes)

为此,您必须确定何时捕获和何时释放。由于您希望使用鼠标左键执行此操作,因此可以在
OnMouseDown
中捕获并在
onmousedup
中释放鼠标