private PrivateAwareStroke AdjustVisual(PrivateAwareStroke stroke, double xTranslate, double yTranslate, double xScale, double yScale) { var newStroke = stroke.Clone(); if (xTranslate == 0.0 && yTranslate == 0.0 && xScale == 1.0 && yScale == 1.0) return newStroke; //Get bounds of the stroke, translate it to 0, scale it, add the move delta translate to the bounds and tranlate them back Rect myRect = new Rect(); myRect = newStroke.GetBounds(); var transformMatrix = new Matrix(); if (xScale != 1.0 || yScale != 1.0) { transformMatrix.Translate(-myRect.X, -myRect.Y); newStroke.Transform(transformMatrix, false); transformMatrix = new Matrix(); transformMatrix.Scale(xScale,yScale); if(double.IsNaN(xTranslate)) { xTranslate = 0; } if (double.IsNaN(yTranslate)) { yTranslate = 0; } xTranslate = xTranslate + myRect.X; yTranslate = yTranslate + myRect.Y; } transformMatrix.Translate(xTranslate, yTranslate); newStroke.Transform(transformMatrix, false); return newStroke; }
protected override void RemoveStroke(PrivateAwareStroke stroke) { ContentBuffer.RemoveStroke(stroke, (col) => Canvas.Strokes.Remove(col)); // hopefully don't need to keep track of checksums anymore and can just use the stroke's identity //contentBuffer.RemoveStrokeChecksum(stroke, (cs) => strokeChecksums.Remove(cs)); }
protected override void AddStroke(PrivateAwareStroke stroke) { ContentBuffer.AddStroke(stroke, (col) => Canvas.Strokes.Add(col)); }
protected abstract void RemoveStroke(PrivateAwareStroke stroke);
protected override void RemoveStroke(PrivateAwareStroke stroke) { Canvas.Strokes.Remove(stroke); }
protected abstract void AddStroke(PrivateAwareStroke stroke);
public PrivateAwareStroke Clone() { var pas = new PrivateAwareStroke(base.Clone(), target); pas.offsetX = offsetX; pas.offsetY = offsetY; return pas; }
protected override void AddStroke(PrivateAwareStroke stroke) { Canvas.Strokes.Add(stroke); }
private PrivateAwareStroke reassociateStrokeToCanvas(PrivateAwareStroke stroke) { var diffX = logicalX - stroke.offsetX; var diffY = logicalY - stroke.offsetY; if (diffX != 0 || diffY != 0) { var m = new Matrix(); m.Translate(-diffX, -diffY); stroke.Transform(m, false); stroke.offsetX = logicalX; stroke.offsetY = logicalY; } return stroke; }
private PrivateAwareStroke doAdjustStroke(PrivateAwareStroke stroke, Func<PrivateAwareStroke, PrivateAwareStroke> adjustment) { return adjustment(stroke); }
public PrivateAwareStroke adjustStroke(PrivateAwareStroke stroke, Func<PrivateAwareStroke, PrivateAwareStroke> adjustment) { reassociateStrokeToCanvas(stroke); var oldCanvasOffsetX = logicalX; var oldCanvasOffsetY = logicalY; double translateX = 0.0; double translateY = 0.0; var myIncomingRect = stroke.GetBounds(); var localX = myIncomingRect.X; var localY = myIncomingRect.Y; if (checkIfLogicalBoundsUpdates(localX, localY)) { var newBounds = generateLogicalBounds(localX, localY); logicalX = newBounds.X; logicalY = newBounds.Y; translateX = ReturnPositiveValue(ReturnPositiveValue(logicalX) - ReturnPositiveValue(oldCanvasOffsetX)); translateY = ReturnPositiveValue(ReturnPositiveValue(logicalY) - ReturnPositiveValue(oldCanvasOffsetY)); updateCanvasPositioning(strokeFilter.Strokes.Where(s => s.tag().id != stroke.tag().id), textFilter.TextBoxes, imageFilter.Images , translateX, translateY); reassociateStrokeToCanvas(stroke); } return doAdjustStroke(stroke, adjustment); }
public void RemoveStroke(PrivateAwareStroke stroke, Action<PrivateAwareStroke> modifyVisibleContainer) { strokeFilter.Remove(stroke, modifyVisibleContainer); }
public void AddStroke(PrivateAwareStroke stroke, Action<PrivateAwareStroke> modifyVisibleContainer) { adjustStroke(stroke, s => s); strokeFilter.Add(stroke, modifyVisibleContainer); }