Exemple #1
0
        public override void OnMouseMove(System.Windows.Controls.InkCanvas inkCanvas, System.Windows.Input.MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                bottomRight = e.GetPosition(inkCanvas);
                if (topLeft != bottomRight)
                {
                    StylusPointCollection pts = new StylusPointCollection();
                    GetTriangle(pts, (s) =>
                    {
                        if (StrokeResult != null)
                        {
                            inkCanvas.Strokes.Remove(StrokeResult);
                        }

                        DrawingAttributes drawingAttributes = new DrawingAttributes
                        {
                            Color          = inkCanvas.DefaultDrawingAttributes.Color,
                            Width          = inkCanvas.DefaultDrawingAttributes.Width,
                            StylusTip      = StylusTip.Ellipse,
                            IgnorePressure = true,
                            FitToCurve     = true
                        };
                        var BackgroundColor = inkCanvas.DefaultDrawingAttributes.GetPropertyData(DrawAttributesGuid.BackgroundColor);
                        drawingAttributes.AddPropertyData(DrawAttributesGuid.BackgroundColor, BackgroundColor);

                        StrokeResult = new TriangleStroke(s, drawingAttributes);
                        inkCanvas.Strokes.Add(StrokeResult);
                    }
                                );
                }
            }
        }
Exemple #2
0
        public override void OnMouseMove(System.Windows.Controls.InkCanvas inkCanvas, System.Windows.Input.MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                bottomRight = e.GetPosition(inkCanvas);
                if (topLeft != bottomRight)
                {
                    StylusPointCollection pts = new StylusPointCollection();
                    GetTriangle(pts, (s) =>
                    {
                        if (StrokeResult != null)
                            inkCanvas.Strokes.Remove(StrokeResult);

                        DrawingAttributes drawingAttributes = new DrawingAttributes
                        {
                            Color = inkCanvas.DefaultDrawingAttributes.Color,
                            Width = inkCanvas.DefaultDrawingAttributes.Width,
                            StylusTip = StylusTip.Ellipse,
                            IgnorePressure = true,
                            FitToCurve = true
                        };
                        var BackgroundColor = inkCanvas.DefaultDrawingAttributes.GetPropertyData(DrawAttributesGuid.BackgroundColor);
                        drawingAttributes.AddPropertyData(DrawAttributesGuid.BackgroundColor, BackgroundColor);

                        StrokeResult = new TriangleStroke(s, drawingAttributes);
                        inkCanvas.Strokes.Add(StrokeResult);
                    }
                    );
                }

            }
        }