Beispiel #1
0
        //</Snippet13>

        //<Snippet14>
        // Erase the ink that intersects the lasso.
        public void ErasePath(Stroke lasso)
        {
            EllipseStylusShape eraserTip = new EllipseStylusShape(5, 5);

            Point[] strokePoints = (Point[])lasso.StylusPoints;

            presenter.Strokes.Erase(strokePoints, eraserTip);
        }
Beispiel #2
0
    // Prepare to collect stylus packets. Get the
    // IncrementalHitTester from the InkPresenter's
    // StrokeCollection and subscribe to its StrokeHitChanged event.
    private void InitializeEraserHitTester(StylusPointCollection points)
    {
        EllipseStylusShape eraserTip = new EllipseStylusShape(3, 3, 0);

        eraseTester =
            presenter.Strokes.GetIncrementalStrokeHitTester(eraserTip);
        eraseTester.StrokeHit += new StrokeHitEventHandler(eraseTester_StrokeHit);
        eraseTester.AddPoints(points);
    }
Beispiel #3
0
        //</Snippet5>

        //<Snippet6>

        //<Snippet4>
        // Prepare to collect stylus packets. Get the
        // IncrementalHitTester from the InkPresenter's
        // StrokeCollection and subscribe to its StrokeHitChanged event.
        protected override void OnStylusDown(StylusDownEventArgs e)
        {
            base.OnStylusDown(e);

            EllipseStylusShape eraserTip = new EllipseStylusShape(3, 3, 0);

            eraseTester =
                presenter.Strokes.GetIncrementalStrokeHitTester(eraserTip);
            eraseTester.StrokeHit += new StrokeHitEventHandler(eraseTester_StrokeHit);
            eraseTester.AddPoints(e.GetStylusPoints(this));
        }
Beispiel #4
0
 /// <summary>
 /// 调整橡皮擦粗细
 /// </summary>
 public void ChangeEraserSize(string mode, EllipseStylusShape shape)
 {
     if (mode == "finger")
     {
         FingerEraserSize = shape;
     }
     else if (mode == "palm")
     {
         PalmEraserSize = shape;
     }
 }
        private StylusShape generateStylusShape()
        {
            double      size = drawingAttributes.Width;
            StylusShape stylusShape;

            if (drawingAttributes.StylusTip == StylusTip.Ellipse)
            {
                stylusShape = new EllipseStylusShape(size, size);
            }
            else
            {
                stylusShape = new RectangleStylusShape(size, size);
            }

            return(stylusShape);
        }
Beispiel #6
0
        //</Snippet2>

        //</Snippet6>

        //</snippet1>

        //<Snippet11>
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            base.OnMouseLeftButtonDown(e);

            if (e.StylusDevice != null)
            {
                return;
            }

            EllipseStylusShape eraserTip = new EllipseStylusShape(3, 3, 0);

            eraseTester =
                presenter.Strokes.GetIncrementalStrokeHitTester(eraserTip);
            eraseTester.StrokeHit += new StrokeHitEventHandler(eraseTester_StrokeHit);
            eraseTester.AddPoint(e.GetPosition(this));
        }
Beispiel #7
0
        public WhiteBoard()
        {
            InitializeComponent();

            _cmdStack = new CommandStack(canvas.Strokes);
            _editingOperationCount = 0;
            NormalBrush            = new CustomBrush(DEFAULT_NORMAL_COLOR, DEFAULT_NORMAL_WIDTH, DEFAULT_NORMAL_HEIGHT);
            HighlightBrush         = new CustomBrush(DEFAULT_HIGHTLIGHT_COLOR, DEFAULT_HIGHLIGHT_WIDTH, DEFAULT_HIGHLIGHT_HEIGHT);
            FingerEraserSize       = new EllipseStylusShape(50, 50);
            PalmEraserSize         = new EllipseStylusShape(500, 500);
            _bAllowingSizeChanging = true;
            EnterNormalBrushMode();


            canvas.Strokes.StrokesChanged += Strokes_StrokesChanged;
            TaskManager.getInstance().whiteBoard = this;
        }
Beispiel #8
0
        void ChangeColorWithStylusShape(Stroke aStroke)
        {
            //<Snippet9>
            Point[] myPoints = new Point[] {
                new Point(100, 100),
                new     Point(200, 100),
                new     Point(200, 200),
                new     Point(100, 200)
            };

            EllipseStylusShape myStylus = new EllipseStylusShape(5.0, 5.0, 0.0);

            if (aStroke.HitTest(myPoints, myStylus))
            {
                aStroke.DrawingAttributes.Color = Colors.Purple;
            }
            //</Snippet9>
        }
Beispiel #9
0
        void EraseWithStylusShape(Stroke aStroke)
        {
            // <Snippet2>
            Point[] myPoints = new Point[] {
                new Point(100, 100),
                new     Point(200, 100),
                new     Point(200, 200),
                new     Point(100, 200)
            };

            EllipseStylusShape myStylus = new EllipseStylusShape(5.0, 5.0, 0.0);

            StrokeCollection eraseResults = aStroke.GetEraseResult(myPoints, myStylus);

            // inkCanvas1 is the InkCanvas on which we update the strokes
            inkCanvas1.Strokes.Remove(aStroke);
            inkCanvas1.Strokes.Add(eraseResults);
            // </Snippet2>
        }
Beispiel #10
0
        // Prepare to collect stylus packets. Get the
        // IncrementalHitTester from the InkPresenter's
        // StrokeCollection and subscribe to its StrokeHitChanged event.
        protected override void OnStylusDown(StylusDownEventArgs e)
        {
            base.OnStylusDown(e);

            switch (state)
            {
            case sMode.add:
                StylusPointCollection eventPoints = e.GetStylusPoints(this);
                stylusPoints = new StylusPointCollection(eventPoints.Description);
                break;

            case sMode.surround:
                // Use StrokeChanged event handler to detect stroke encirclement when using percentage
                myIncrementalHitTester = myInkPresenter.Strokes.GetIncrementalLassoHitTester(50);

                ((IncrementalLassoHitTester)myIncrementalHitTester).SelectionChanged +=
                    new LassoSelectionChangedEventHandler(myIHT_StrokeHitChanged);

                myIncrementalHitTester.AddPoints(e.GetStylusPoints(this));
                break;

            default:
                // Otherwise we detect when the IHT hits the existing strokes
                // Use StrokeIntersectionChanged event handler to detect stroke hit when using stylus
                EllipseStylusShape eraserTip = new EllipseStylusShape(3, 3, 0);

                myIncrementalHitTester = myInkPresenter.Strokes.GetIncrementalStrokeHitTester(eraserTip);

                ((IncrementalStrokeHitTester)myIncrementalHitTester).StrokeHit +=
                    new StrokeHitEventHandler(myIHT_StrokeIntersectionChanged);

                myIncrementalHitTester.AddPoints(e.GetStylusPoints(this));
                break;
            }

            e.Handled = true;
        }