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;
}
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;
}