This is a migrated thread and some comments may be shown as answers.

LineTool

1 Answer 27 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Anders Lind
Top achievements
Rank 1
Anders Lind asked on 07 Jan 2015, 10:00 AM
How does i go about making custom drawing tool, had no luck finding any resources on this area.

I am trying to make a LineTool.

Currently i am Initializing the tool like this. Which i am aware might be incorrect but using "LineTool" results in no geometry being shown.

DrawingService.InitializeDraw(shape, "PencilTool"); //LineTool does not show anything


Also i need the ManipulationAdorner changed but only when a single LineShape is selected. I would like two resize handles at the end of the line. The diagram will contain other shapes that still will show four resize handles. Is it possible to make different styles for the ManipulationAdorner dependent on what the current selection is.


public override bool MouseDown(PointerArgs e)
        {
            if (!IsActive)
                return false;

            DrawingService.StartDraw();
            DrawingService.DrawPoints(e.TransformedPoint, e.TransformedPoint);

            return base.MouseDown(e);
        }

        public override bool MouseMove(PointerArgs e)
        {
            if (!IsActive || !ToolService.IsMouseDown || (ToolService.IsControlDown || !DrawingService.IsDrawing))
                return false;
            
            if (DrawingService.ActiveShape == null)
            {
                var shape = CreateShape();
                shape.IsSelected = true;
                shape.Geometry = new LineGeometry(e.TransformedPoint, e.TransformedPoint);

                DrawingService.InitializeDraw(shape, "PencilTool"); //LineTool does not show anything
                //SelectionService.ClearSelection();
                
                return base.MouseMove(e);
            }


            if (DrawingService.AnchorPoints.Count() > 1)
                DrawingService.RemoveLastAnchorPoint();
                
            DrawingService.DrawPoints(e.TransformedPoint, e.TransformedPoint);
            return true;
        }

        public override bool MouseUp(PointerArgs e)
        {
            if (!IsActive || !DrawingService.IsDrawing)
                return base.MouseUp(e);
            CompleteTool();
            _diagram.ActiveTool = MouseTool.PointerTool;
            return true;
        }

1 Answer, 1 is accepted

Sort by
0
Anders Lind
Top achievements
Rank 1
answered on 07 Jan 2015, 10:01 AM
Woops duplicate post, got an error message on the first. Feel free to remove this
Tags
Diagram
Asked by
Anders Lind
Top achievements
Rank 1
Answers by
Anders Lind
Top achievements
Rank 1
Share this question
or