コード例 #1
0
        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;
        }
コード例 #2
0
 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));
 }
コード例 #3
0
 protected override void AddStroke(PrivateAwareStroke stroke)
 {
     ContentBuffer.AddStroke(stroke, (col) => Canvas.Strokes.Add(col));
 }
コード例 #4
0
 protected abstract void RemoveStroke(PrivateAwareStroke stroke);
コード例 #5
0
 protected override void RemoveStroke(PrivateAwareStroke stroke)
 {
     Canvas.Strokes.Remove(stroke);
 }
コード例 #6
0
 protected abstract void AddStroke(PrivateAwareStroke stroke);
コード例 #7
0
 public PrivateAwareStroke Clone()
 {
     var pas = new PrivateAwareStroke(base.Clone(), target);
     pas.offsetX = offsetX;
     pas.offsetY = offsetY;
     return pas;
 }
コード例 #8
0
 protected override void AddStroke(PrivateAwareStroke stroke)
 {
     Canvas.Strokes.Add(stroke);
 }
コード例 #9
0
 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;
 }
コード例 #10
0
 private PrivateAwareStroke doAdjustStroke(PrivateAwareStroke stroke, Func<PrivateAwareStroke, PrivateAwareStroke> adjustment)
 {
     return adjustment(stroke);
 }
コード例 #11
0
        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);
        }
コード例 #12
0
 public void RemoveStroke(PrivateAwareStroke stroke, Action<PrivateAwareStroke> modifyVisibleContainer)
 {
     strokeFilter.Remove(stroke, modifyVisibleContainer);
 }
コード例 #13
0
 public void AddStroke(PrivateAwareStroke stroke, Action<PrivateAwareStroke> modifyVisibleContainer)
 {
     adjustStroke(stroke, s => s);
     strokeFilter.Add(stroke, modifyVisibleContainer);
 }