LineTool

2 posts, 0 answers
  1. Anders Lind
    Anders Lind avatar
    5 posts
    Member since:
    Aug 2014

    Posted 07 Jan 2015 Link to this post

    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;
            }
  2. Anders Lind
    Anders Lind avatar
    5 posts
    Member since:
    Aug 2014

    Posted 07 Jan 2015 Link to this post

    Woops duplicate post, got an error message on the first. Feel free to remove this
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top