示例#1
0
    //<Snippet9>
    private void InitializeHitTester(StylusPointCollection collectedPoints)
    {
        // Deselect any selected strokes.
        foreach (Stroke selectedStroke in selectedStrokes)
        {
            selectedStroke.DrawingAttributes.Color = inkDA.Color;
        }
        selectedStrokes.Clear();

        if (mode == InkMode.Select)
        {
            // Remove the previously drawn lasso, if it exists.
            if (lassoPath != null)
            {
                presenter.Strokes.Remove(lassoPath);
                lassoPath = null;
            }

            selectionTester =
                presenter.Strokes.GetIncrementalLassoHitTester(80);
            selectionTester.SelectionChanged +=
                new LassoSelectionChangedEventHandler(selectionTester_SelectionChanged);
            selectionTester.AddPoints(collectedPoints);
        }
    }
示例#2
0
 private void AddPointsToHitTester(StylusPointCollection collectedPoints)
 {
     if (mode == InkMode.Select && selectionTester.IsValid)
     {
         // When the control is selecting strokes, add the
         // stylus packetList to selectionTester.
         selectionTester.AddPoints(collectedPoints);
     }
 }
示例#3
0
        public override void Perform()
        {
            IncrementalStrokeHitTester IncrementalStroke = InkCanvas.Strokes.GetIncrementalStrokeHitTester(EraserShape);
            IncrementalLassoHitTester  IncrementalLasso  = InkCanvas.Strokes.GetIncrementalLassoHitTester(OptionIndex % 100);

            switch (OptionIndex % 2)
            {
            case 0:      //AddPoint
            {
                StrokeCollection strokeCollection = InkCanvas.Strokes;

                if (IsRandomPoint == true || strokeCollection == null || strokeCollection.Count == 0)
                {
                    IncrementalStroke.AddPoint(Point);
                    IncrementalLasso.AddPoint(Point);
                }
                else
                {
                    //get list of all points on the stroke
                    foreach (Stroke stoke in strokeCollection)
                    {
                        StylusPointCollection.Add(stoke.StylusPoints.Reformat(StylusPointCollection.Description));
                    }

                    IncrementalStroke.AddPoint(StylusPointCollection[RandomIndex % StylusPointCollection.Count].ToPoint());
                    IncrementalLasso.AddPoint(StylusPointCollection[RandomIndex % StylusPointCollection.Count].ToPoint());
                }
            }
            break;

            case 1:       //AddPoints
            {
                IncrementalLasso.AddPoints(PointCollection);
                IncrementalStroke.AddPoints(PointCollection);
            }
            break;
            }
        }