tags:

views:

72

answers:

0

I wrote a custom adorner for the WPF InkCanvas. It takes over the built-in adorner that InkCanvas provides, and I designed it to do the same things (Select, Resize, Move) the adorned elements.

My Thumbs (one on each corner of a Path that has a RectangelGeomoetry locate perfectly. However, the DragDelta code is not operating correctly. I'll use the TopLeft THumb as the example. As I click on the Thumb and drag it, the Thumb lags about 50-100 pixels behind the mouse point. After I let go, it places correctly, But when I select it again, it bounces back to the TopLeft corner briefly before it starts tracking.

Here is the code.

  // Handler for thumb dragging
void LrsThumbPointAdorner_OnDragDelta(object sender, DragDeltaEventArgs args)
{
  FrameworkElement adornedElement = this.AdornedElement as FrameworkElement;
  Thumb movingThumb = sender as Thumb;

  if (adornedElement == null || movingThumb == null) return;
    {      

        if ((Math.Abs(args.HorizontalChange) > 0) || (Math.Abs(args.VerticalChange) > 0))
        {
            Rect rect = new Rect( (movingThumb as FrameworkElement).DesiredSize);

            rect.Offset(args.HorizontalChange, args.VerticalChange);

            movingThumb.Arrange(rect);
            this.UpdateLayout();

        }

      }
}