Skip to content

Instantly share code, notes, and snippets.

@dmitry-osin
Created September 26, 2015 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmitry-osin/b5a107495e6596331fef to your computer and use it in GitHub Desktop.
Save dmitry-osin/b5a107495e6596331fef to your computer and use it in GitHub Desktop.
// Canvas
private Windows.UI.Xaml.Shapes.Path _Current;
private void inkCanvas_PointerReleased(object sender, PointerRoutedEventArgs e)
{
_Current = null;
}
private void inkCanvas_PointerMoved(object sender, PointerRoutedEventArgs e)
{
var pointer = e.GetCurrentPoint(inkCanvas);
if (!pointer.Properties.IsLeftButtonPressed || _Current == null)
return;
var segments = (_Current.Data as PathGeometry).Figures.First().Segments.First() as PolyLineSegment;
segments.Points.Add(pointer.Position);
}
private void inkCanvas_PointerPressed(object sender, PointerRoutedEventArgs e)
{
var pointer = e.GetCurrentPoint(inkCanvas);
if (!pointer.Properties.IsLeftButtonPressed)
return;
_Current = new Windows.UI.Xaml.Shapes.Path
{
Data = new PathGeometry
{
Figures =
{
new PathFigure
{
StartPoint = pointer.Position,
Segments = {new PolyLineSegment()}
}
}
},
Stroke = new SolidColorBrush(_colors),
StrokeThickness = _strokeThickness,
};
inkCanvas.Children.Add(_Current);
}
// Canvas end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment