in UWP-Advanced-Inking/XAMLShapesLineCurving/XAMLShapesLineCurving/MainPage.xaml.cs [84:123]
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;
// Display an anchor for curving
int size_centerLine = 45;
Ellipse curvingEllipse = new Ellipse
{
Fill = new SolidColorBrush(Windows.UI.Colors.OrangeRed),
Height = size_centerLine,
Width = size_centerLine
};
ShapesCanvas.Children.Add(curvingEllipse);
// Calculate the points for the center of the ellipse
double centerX = line.X1 + (line.X2 - line.X1) / 2;
double centerY = line.Y1 + (line.Y2 - line.Y1) / 2;
Canvas.SetLeft(curvingEllipse, centerX - size_centerLine / 2);
Canvas.SetTop(curvingEllipse, centerY - size_centerLine / 2);
// Enable manipulation on the anchor
curvingEllipse.ManipulationMode = ManipulationModes.TranslateX | ManipulationModes.TranslateY;
curvingEllipse.ManipulationStarted += CurvingEllipse_ManipulationStarted;
curvingEllipse.ManipulationDelta += CurvingEllipse_ManipulationDelta;
curvingEllipse.ManipulationCompleted += CurvingEllipse_ManipulationCompleted;
InitializeActiveLine(line, curvingEllipse);
}