in UWP-Advanced-Inking/XAMLShapesAdvancedManipulations/XAMLShapesAdvancedManipulations/MainPage.xaml.cs [72:118]
private void Line_Tapped(object sender, TappedRoutedEventArgs e)
{
// Remove the anchor from the selected line
UnselectActiveLine();
Line line = (Line)sender;
line.Stroke = new SolidColorBrush(Windows.UI.Colors.DarkRed);
line.StrokeThickness = 10;
int size_EndLines = 25;
// Create 2 circles for the ends of the line
Ellipse anchorOrigin = new Ellipse
{
Fill = new SolidColorBrush(Windows.UI.Colors.OrangeRed),
Height = size_EndLines,
Width = size_EndLines
};
ShapesCanvas.Children.Add(anchorOrigin);
Ellipse anchorEnd = new Ellipse
{
Fill = new SolidColorBrush(Windows.UI.Colors.OrangeRed),
Height = size_EndLines,
Width = size_EndLines
};
ShapesCanvas.Children.Add(anchorEnd);
// Put the anchors at the origin and at the end of the line
Canvas.SetLeft(anchorOrigin, line.X1 - size_EndLines / 2);
Canvas.SetLeft(anchorEnd, line.X2 - size_EndLines / 2);
Canvas.SetTop(anchorOrigin, line.Y1 - size_EndLines / 2);
Canvas.SetTop(anchorEnd, line.Y2 - size_EndLines / 2);
// Enable manipulations on the anchors
anchorOrigin.ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.TranslateY;
anchorOrigin.ManipulationStarted += Anchor_ManipulationStarted;
anchorOrigin.ManipulationDelta += Anchor_Origin_ManipulationDelta;
anchorOrigin.ManipulationCompleted += Anchor_Origin_ManipulationCompleted;
anchorEnd.ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.TranslateY;
anchorEnd.ManipulationStarted += Anchor_ManipulationStarted;
anchorEnd.ManipulationDelta += Anchor_End_ManipulationDelta;
anchorEnd.ManipulationCompleted += Anchor_End_ManipulationCompleted;
InitializeActiveLine(line, anchorOrigin, anchorEnd);
}