예제 #1
0
 /// <summary>
 /// Change to the point erase mode
 /// </summary>
 /// <param name="ss"></param>
 private void ChangeToPointErase(StylusShape ss)
 {
     // Update InkCanvas EditingMode and the point eraser shape.
     EnsureEditingMode(InkCanvasEditingMode.EraseByPoint);
     MyInkCanvas.EraserShape     = ss;
     MyInkCanvas.RenderTransform = new MatrixTransform();
 }
예제 #2
0
        /// <summary>
        /// Change to the ink mode with an eraser setting.
        /// </summary>
        /// <param name="editingModeId"></param>
        private void ChangeToEraseMode(EditingModeId editingModeId)
        {
            switch (editingModeId)
            {
            case EditingModeId.PointEraser1:
            case EditingModeId.PointEraser2:
            case EditingModeId.PointEraser3:
            {
                // Change to the point erase mode
                StylusShape newSS = PointEraserShapeCollection[editingModeId - EditingModeId.PointEraser1];
                ChangeToPointErase(newSS);
                break;
            }

            case EditingModeId.StrokeEraser:
            {
                // Change to the stroke erase mode
                EnsureEditingMode(InkCanvasEditingMode.EraseByStroke);
                break;
            }
            }

            // Update the readonly dependency property.
            SetValue(SampleWindow.CurrentEraserModePropertyKey, editingModeId);
        }
        // Token: 0x06006DC8 RID: 28104 RVA: 0x001F8E30 File Offset: 0x001F7030
        internal static Cursor GetPointEraserCursor(StylusShape stylusShape, Matrix tranform, double dpiScaleX, double dpiScaleY)
        {
            DrawingAttributes drawingAttributes = new DrawingAttributes();

            if (stylusShape.GetType() == typeof(RectangleStylusShape))
            {
                drawingAttributes.StylusTip = StylusTip.Rectangle;
            }
            else
            {
                drawingAttributes.StylusTip = StylusTip.Ellipse;
            }
            drawingAttributes.Height = stylusShape.Height;
            drawingAttributes.Width  = stylusShape.Width;
            drawingAttributes.Color  = Colors.Black;
            if (!tranform.IsIdentity)
            {
                drawingAttributes.StylusTipTransform *= tranform;
            }
            if (!DoubleUtil.IsZero(stylusShape.Rotation))
            {
                Matrix identity = Matrix.Identity;
                identity.Rotate(stylusShape.Rotation);
                drawingAttributes.StylusTipTransform *= identity;
            }
            return(PenCursorManager.GetPenCursor(drawingAttributes, true, false, dpiScaleX, dpiScaleY));
        }
예제 #4
0
 public void BeginEraserPath(Point beginning, StylusShape eraserShape)
 {
     this.eraserShape = eraserShape;
     Erasing          = true;
     eraserPathPoints.Clear();
     eraserPathPoints.Add(beginning);
     removeStrokeIfIntersects();
 }
예제 #5
0
        public StroqCollection HitTest(IEnumerable <Pt> path, StylusShape ss)
        {
            // we trade memory for time--only do the casting for each point once here, rather than embedding this in the Where which would duplicate
            // it for each stroq.
            List <Point> path2 = new List <Point>(path.Select((Pt p) => (Point)p));

            return(new StroqCollection(_stroqs.Where((Stroq s) => s.BackingStroke.HitTest(path2, ss))));
        }
예제 #6
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="nodeShape"></param>
        internal EllipticalNodeOperations(StylusShape nodeShape)
            : base(nodeShape)
        {
            System.Diagnostics.Debug.Assert((nodeShape != null) && nodeShape.IsEllipse);

            _radii = new Size(nodeShape.Width * 0.5, nodeShape.Height * 0.5);

            // All operations with ellipses become simple(r) if transfrom ellipses into circles.
            // Use the max of the radii for the radius of the circle
            _radius = Math.Max(_radii.Width, _radii.Height);

            // Compute ellipse-to-circle and circle-to-elliipse transforms. The former is used
            // in hit-testing operations while the latter is used when computing vertices of
            // a quadrangle connecting two ellipses
            _transform         = nodeShape.Transform;
            _nodeShapeToCircle = _transform;

            Debug.Assert(_nodeShapeToCircle.HasInverse, "About to invert a non-invertible transform");
            _nodeShapeToCircle.Invert();
            if (DoubleUtil.AreClose(_radii.Width, _radii.Height))
            {
                _circleToNodeShape = _transform;
            }
            else
            {
                // Reverse the rotation
                if (false == DoubleUtil.IsZero(nodeShape.Rotation))
                {
                    _nodeShapeToCircle.Rotate(-nodeShape.Rotation);
                    Debug.Assert(_nodeShapeToCircle.HasInverse, "Just rotated an invertible transform and produced a non-invertible one");
                }

                // Scale to enlarge
                double sx, sy;
                if (_radii.Width > _radii.Height)
                {
                    sx = 1;
                    sy = _radii.Width / _radii.Height;
                }
                else
                {
                    sx = _radii.Height / _radii.Width;
                    sy = 1;
                }
                _nodeShapeToCircle.Scale(sx, sy);
                Debug.Assert(_nodeShapeToCircle.HasInverse, "Just scaled an invertible transform and produced a non-invertible one");

                _circleToNodeShape = _nodeShapeToCircle;
                _circleToNodeShape.Invert();
            }
        }
예제 #7
0
        /// <summary>
        /// Create a point eraser cursor from StylusShape
        /// </summary>
        /// <param name="stylusShape">Eraser Shape</param>
        /// <param name="tranform">Transform</param>
        /// <returns></returns>
        internal static Cursor GetPointEraserCursor(StylusShape stylusShape, Matrix tranform, double dpiScaleX, double dpiScaleY)
        {
            Debug.Assert(DoubleUtil.IsZero(tranform.OffsetX) && DoubleUtil.IsZero(tranform.OffsetY), "The EraserShape cannot be translated.");
            Debug.Assert(tranform.HasInverse, "The transform has to be invertable.");

            // Create a DA with IsHollow being set. A point eraser will be rendered to a hollow stroke.
            DrawingAttributes da = new DrawingAttributes();

            if (stylusShape.GetType() == typeof(RectangleStylusShape))
            {
                da.StylusTip = StylusTip.Rectangle;
            }
            else
            {
                da.StylusTip = StylusTip.Ellipse;
            }

            da.Height = stylusShape.Height;
            da.Width  = stylusShape.Width;
            da.Color  = Colors.Black;

            if (!tranform.IsIdentity)
            {
                // Apply the LayoutTransform and/or RenderTransform
                da.StylusTipTransform *= tranform;
            }

            if (!DoubleUtil.IsZero(stylusShape.Rotation))
            {
                // Apply the tip rotation
                Matrix rotationMatrix = Matrix.Identity;
                rotationMatrix.Rotate(stylusShape.Rotation);
                da.StylusTipTransform *= rotationMatrix;
            }

            // Forward to GetPenCursor.
            return(GetPenCursor(da, true, false /*isRightToLeft*/, dpiScaleX, dpiScaleY));
        }
예제 #8
0
        public LanCanvas(InkCanvas canvas, IdGenerator generator, string owner, PermissionsData permissions)
        {
            eraserShape = new EllipseStylusShape(2, 2);

            PointerData                  = new SharedWindows.PointerData();
            PointerData.Attributes       = new DrawingAttributes();
            PointerData.Attributes.Color = Colors.Red;
            PointerData.StayTime         = 1500;
            PointerData.FadeTime         = 500;

            OwnerName        = owner;
            this.generator   = generator;
            this.canvas      = canvas;
            this.Permissions = permissions;

            DefaultDrawingAttributes = new DrawingAttributes();

            cursorLibrary = new CursorLibrary();

            modeChanger = new ModeChanger();
            UpdatePermissions();

            canvas.Dispatcher.Invoke(new Action(canvasInit));

            drawer = new SignedStrokeDrawer(canvas.Strokes, generator, OwnerName);

            eraser = new SignedStrokeEraser(canvas.Strokes, permissions, OwnerName);

            cutter = new SignedStrokeCutter(canvas.Strokes);

            pointerDrawer = new SignedPointerStrokeDrawer(canvas.Strokes, OwnerName, generator, canvas.Dispatcher);

            ManualHandler = new ManualHandle(canvas);

            CanvasHandle = new CanvasEventsHandle(this, drawer, eraser, pointerDrawer);
        }
예제 #9
0
 /// <summary>
 /// Constructor for an incremental node enumerator that builds nodes
 /// from array(s) of points and a given stylus shape.
 /// </summary>
 /// <param name="nodeShape">a shape that defines the stroke contour</param>
 internal StrokeNodeIterator(StylusShape nodeShape)
     : this(null,    //stylusPoints
            StrokeNodeOperations.CreateInstance(nodeShape),
            false)   //usePressure)
 {
 }
예제 #10
0
 /// <summary>
 /// Constructor for static (atomic) erasing
 /// </summary>
 /// <param name="erasingShape">The shape of the eraser's tip</param>
 /// <param name="path">the spine of the erasing stroke</param>
 internal ErasingStroke(StylusShape erasingShape, IEnumerable <Point> path)
     : this(erasingShape)
 {
     MoveTo(path);
 }
예제 #11
0
 /// <summary>
 /// Constructor for incremental erasing
 /// </summary>
 /// <param name="erasingShape">The shape of the eraser's tip</param>
 internal ErasingStroke(StylusShape erasingShape)
 {
     System.Diagnostics.Debug.Assert(erasingShape != null);
     _nodeIterator = new StrokeNodeIterator(erasingShape);
 }