public GetRenderingSegments ( ) : IVectorView |
||
Результат | IVectorView |
public Stroke(InkStroke stroke, [CallerMemberName] string methodName = "") { var renderStrokes = stroke.GetRenderingSegments(); StartPoint = renderStrokes.First().Position; foreach (var renderStroke in renderStrokes) { BezierSegments.Add(new BezierSegment { Point1 = renderStroke.BezierControlPoint1, Point2 = renderStroke.BezierControlPoint2, Point3 = renderStroke.Position }); } }
/* #region quadrant ink weight analysis private Rectangle getQuadrantCollision(Line line) { List<Rectangle> quadrants = new List<Rectangle>(); quadrants.Add(box1); quadrants.Add(box2); quadrants.Add(box3); quadrants.Add(box4); foreach (Rectangle quadrant in quadrants) { if (line.X1 > Canvas.GetLeft(quadrant) && line.X1 < Canvas.GetLeft(quadrant) + quadrant.Width && line.Y1 > Canvas.GetTop(quadrant) && line.Y1 < Canvas.GetTop(quadrant) + quadrant.Height) { line.Fill = new SolidColorBrush(Colors.Red); return quadrant; } } return null; } private void analyzeClicked(object sender, RoutedEventArgs e) { //reset the data collection quadWeights[0] = 0; quadWeights[1] = 0; quadWeights[2] = 0; quadWeights[3] = 0; foreach (var stroke in inkManager.GetStrokes()) { foreach (Line line in allLines[stroke]) { Rectangle quad = getQuadrantCollision(line); //increment the counter of the rect with the collision if there was one if (quad != null) { if (quad == box1) { quadWeights[0]++; } else if (quad == box2) { quadWeights[1]++; } else if (quad == box3) { quadWeights[2]++; } else if (quad == box4) { quadWeights[3]++; } dataTextblock.Text = "Top Right: " + quadWeights[0].ToString() + "\n" + "Top Left: " + quadWeights[1].ToString() + "\n" + "Bot Left: " + quadWeights[2].ToString() + "\n" + "Bot Right: " + quadWeights[3].ToString(); } } } } #endregion #region sketch number recognition analysis private int distanceBetweenStrokes(InkStroke stroke1, InkStroke stroke2) { return -1; } private async void recognizedNumberClicked(object sender, RoutedEventArgs e) { //get the available strokes from ink manager and select the strokes var strokes = inkManager.GetStrokes(); foreach (InkStroke stroke in strokes) { //if(stroke.GetRenderingSegments()) //Line startLine = allLines[strokes[0]]; } //set handwriting recognizer var recname = "Microsoft English (US) Handwriting Recognizer"; var recognizers = inkManager.GetRecognizers(); for (int i = 0, len = recognizers.Count; i < len; i++) { if (recname == recognizers[i].Name) { inkManager.SetDefaultRecognizer(recognizers[i]); break; } } //asynchronously recognize the word IReadOnlyList<InkRecognitionResult> recognitionResults = await inkManager.RecognizeAsync(InkRecognitionTarget.All); // Doing a recognition does not update the storage of results (manually update from ink manager) inkManager.UpdateRecognitionResults(recognitionResults); string numbers = ""; foreach (InkRecognitionResult i in recognitionResults) { var candidates = i.GetTextCandidates(); foreach (var possibleWord in candidates) { int num; if (int.TryParse(possibleWord, out num)) { numbers += num + " : "; break; } } } Windows.UI.Popups.MessageDialog mg = new Windows.UI.Popups.MessageDialog(numbers + ""); await mg.ShowAsync(); } #endregion #region sketch correct-time analysis private async void checkTimeClicked(object sender, RoutedEventArgs e) { //for now, assume the last 2 strokes are the 2 hands being drawn var strokes = inkManager.GetStrokes(); foreach(InkStroke stroke in strokes) { //check if this stroke does not have a possible number representation //if it dsnt, check if it starts in/near the center //if it does, check if the slope from the starting line point to the ending line point is correct //if 2 hands have not already been found, then it is one of the hands and do the following: //if 2 hands HAVE been found and another is found, then err //if the hand pointing at 2 is significantly shorter or longer than the circle radius, then err //if the hand pointing at 11 is significantly shorter or longer than half the circle radius, then err } Windows.UI.Popups.MessageDialog mg = new Windows.UI.Popups.MessageDialog(""); await mg.ShowAsync(); } #endregion */ private bool eraserHitTest(InkStroke s, Point testPoint) { foreach (var p in s.GetRenderingSegments()) { if (Math.Abs(testPoint.X - p.Position.X) < 10 && Math.Abs(testPoint.Y - p.Position.Y) < 10) return true; } return false; }
/// <summary> /// Renders a single ink stroke as BezierSegments with the given width and color (also opacity) /// </summary> /// <param name="stroke">Stroke to be rendered</param> /// <param name="color">Color to use while rendering the ink stroke</param> /// <param name="width">Size of the stroke</param> /// <param name="opacity">Opacity of the stroke to be created</param> private void RenderStroke(InkStroke stroke, Color color, double width, double opacity = 1) { var renderingStrokes = stroke.GetRenderingSegments(); var path = new Path(); path.Data = new PathGeometry(); ((PathGeometry)path.Data).Figures = new PathFigureCollection(); var pathFigure = new PathFigure(); pathFigure.StartPoint = renderingStrokes.First().Position; ((PathGeometry)path.Data).Figures.Add(pathFigure); foreach (var renderStroke in renderingStrokes) { pathFigure.Segments.Add(new BezierSegment { Point1 = renderStroke.BezierControlPoint1, Point2 = renderStroke.BezierControlPoint2, Point3 = renderStroke.Position }); } path.StrokeThickness = width; path.Stroke = new SolidColorBrush(color); path.Opacity = opacity; m_Canvas.Children.Add(path); }