3
클래스 Shape
에서 상속 한 모양을 정의하고 'Geometry'속성을 구현합니다. 나는 Shape
을 클릭하고 내 마우스를 이동하면마우스 이동이 다시 그리기 wpf보다 빠릅니다.
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();
}
}
}
, 나는 Shape
가 새 위치에 다시 그려야 할 것으로 예상 - 그것은 작업을 수행합니다
다음은 예입니다. 나는 "너무"마우스를 이동하면
그러나, 빨리, 나는이 OnMouseMove
이벤트를 "떠나"야, 그리고 shape
마우스 포인터와 Shape
의 위치에 있던 마지막 위치에 걸리면 "동기화 ".
그런 문제를 해결할 수 있습니까?
고마워요! 그것은 완벽하게 작동했습니다. – Idanis