コード例 #1
0
        protected override void OnStrokeCollected(InkCanvasStrokeCollectedEventArgs e)
        {
            switch (_inkMode)
            {
            case InkMode.None:
            case InkMode.Ink:
            case InkMode.GestureOnly:
            case InkMode.InkAndGesture:
            case InkMode.Select:
            case InkMode.EraseByPoint:
            case InkMode.EraseByStroke:
                base.OnStrokeCollected(e);
                break;

            case InkMode.Rectangle:
                // Remove the original stroke and add a custom stroke.
                this.Strokes.Remove(e.Stroke);
                Stroke stroke = RectangleStroke.GetRectangleStroke(e.Stroke.StylusPoints);
                this.Strokes.Add(stroke);

                // Pass the custom stroke to base class' OnStrokeCollected method.
                InkCanvasStrokeCollectedEventArgs args =
                    new InkCanvasStrokeCollectedEventArgs(stroke);
                base.OnStrokeCollected(args);
                break;

            default:
                break;
            }
        }
コード例 #2
0
ファイル: RectDraw.cs プロジェクト: Optofizik/Graphic-Editor
        //Метод, отвечающий за рисование прямоугольника с помощью штрихов
        public override void EndDrawing(object sender, MouseButtonEventArgs e)
        {
            if (isDrawing == true)
            {
                RectangleStroke lineStroke = new RectangleStroke(new StylusPointCollection { new StylusPoint(startPoint.X, startPoint.Y), new StylusPoint(endPoint.X, endPoint.Y) }, this.strokeColor, this.strokeThickness, this.fillColor);

                Surface.Strokes.Add(lineStroke);
                Surface.Children.Remove(rect);
                rect = null;
                isDrawing = false;
            }
        }
コード例 #3
0
ファイル: StrokeBuilder.cs プロジェクト: tingxin/Kiosk
        private static Stroke DataToStroke(StrokeData data, System.Windows.Size size)
        {
            Stroke stroke = null;

            switch (data.Type)
            {
            case StrokeTypes.Arrow:
                stroke = new ArrowStroke(StrokeDataEx.ToStylusPoints(data.Points, size));
                break;

            case StrokeTypes.Circle:
                CircleStroke cs = new CircleStroke(StrokeDataEx.ToStylusPoints(data.Points, size));
                stroke = cs;
                break;

            case StrokeTypes.Line:
                stroke = new StraightStroke(StrokeDataEx.ToStylusPoints(data.Points, size));
                break;

            case StrokeTypes.Rectangle:
                stroke = new RectangleStroke(StrokeDataEx.ToStylusPoints(data.Points, size));
                break;

            case StrokeTypes.Triangle:
                stroke = new TriangleStroke(StrokeDataEx.ToStylusPoints(data.Points, size));
                break;

            default:
                stroke = new Stroke(StrokeDataEx.ToStylusPoints(data.Points, size));
                break;
            }


            StrokeEx.SetID(stroke, data.ID);
            stroke.DrawingAttributes = DrawingAttributesDataEx.ToDrawingAttributes(data.Atts);
            if (stroke is ShapeStroke)
            {
                stroke.DrawingAttributes.FitToCurve = false;
            }
            return(stroke);
        }