/// <summary> /// Analyze a new stroke. /// </summary> /// <param name="stroke"></param> /// <returns>true if the stroke was recognized as belonging to a graph (and so should be excluded from InkAnalyzer)</returns> public bool newStroke(Stroke stroke) { if (strokes.ContainsKey(stroke)) { // already have it! return true; } foreach (Graph g in graphs) { if (g.containsStroke(stroke) && g.takeStroke(stroke)) { strokes.Add(stroke, g); return true; } } Stroke copy = stroke.Clone(); analyzer.AddStroke(copy); analyzer.Analyze(); StrokeCollection sc = new StrokeCollection(new Stroke[] { copy }); ContextNodeCollection ctxNodes = analyzer.FindInkLeafNodes(sc); foreach (ContextNode ctxNode in ctxNodes) { if (ctxNode is InkDrawingNode && (ctxNode as InkDrawingNode).GetShapeName() == "Rectangle") { Graph g = new XYGraph(this, stroke); graphs.Add(g); strokes.Add(stroke, g); analyzer.RemoveStroke(copy); return true; } } analyzer.RemoveStroke(copy); return false; }
public void doMyStrokeAdded(Stroke stroke, string intendedPrivacy) { doMyStrokeAddedExceptHistory(stroke, intendedPrivacy); var thisStroke = stroke.Clone(); UndoHistory.Queue( () => { ClearAdorners(); var existingStroke = Strokes.Where(s => s.sum().checksum == thisStroke.sum().checksum).FirstOrDefault(); if (existingStroke != null) { Strokes.Remove(existingStroke); doMyStrokeRemovedExceptHistory(existingStroke); } }, () => { ClearAdorners(); if (Strokes.Where(s => s.sum().checksum == thisStroke.sum().checksum).Count() == 0) { Strokes.Add(thisStroke); doMyStrokeAddedExceptHistory(thisStroke, thisStroke.tag().privacy); } if(EditingMode == InkCanvasEditingMode.Select) Select(new StrokeCollection(new [] {thisStroke})); addAdorners(); }); }
protected void DrawLeapTouch(Leap.Frame frame) { InteractionBox interactionBox = frame.InteractionBox; if (frame.Pointables.Extended().Count != 1) { return; } Pointable pointable = frame.Pointables.Extended()[0]; // InteractionBox を利用した座標変換 Leap.Vector normalizedPosition = interactionBox.NormalizePoint(pointable.StabilizedTipPosition); double tx = normalizedPosition.x * windowWidth; double ty = windowHeight - normalizedPosition.y * windowHeight; StylusPoint touchPoint = new StylusPoint(tx, ty); StylusPointCollection tips = new StylusPointCollection(new StylusPoint[] { touchPoint }); // タッチ状態 if (normalizedPosition.z <= TouchBorder) { Stroke touchStroke = new Stroke(tips, touchIndicator); this.InkCanvas_LeapPaintLine.Strokes.Add(touchStroke.Clone()); } }