-4
  • In uwp, need to pan smoothly the polyline from one place to another which has more than 3000 points without applying transform. Because, I will update the points dynamically in mouse move.

  • Attached sample for your reference, which gets panned but not smoothly.

Sample Link: https://github.com/ragulsv/PolyLine/tree/master/PolyLineUwp

Ragul S V
  • 139
  • 6

1 Answers1

1

When you have created a path group as the content of the ContentControl, you can move it as a whole, instead of repositioning it point by point.

private void Page_PointerMoved(object sender, PointerRoutedEventArgs e)
{
    if (pointerPressed)
    {
        
        var point = e.GetCurrentPoint(this);
        var diff = new Point(pressPointer.X - point.Position.X, pressPointer.Y - point.Position.Y);
        
        contentControl.Margin = new Thickness(-diff.X, -diff.Y, 0, 0);
    }
}

In the process of mouse movement, re-rendering point by point will consume a lot of resources. But if it is to move ContentControl it will be much simpler.

Richard Zhang
  • 7,523
  • 1
  • 7
  • 13
  • Thanks, It is similair to applying transform. But, I need to add points dynamically in mouse move. Is there any possible approach? – Ragul S V Oct 28 '20 at 14:27
  • Hello, what are the conditions for you to add points? Add points randomly when the `PointerMoved` event is triggered? You can add points to `pointsCollection` (repeat the process of adding points before), but try to avoid a large number of and high-frequency rendering, which will cause application lag – Richard Zhang Oct 29 '20 at 01:04