Created
September 26, 2015 16:19
-
-
Save dmitry-osin/b5a107495e6596331fef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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