Hey,
I am trying to make a custom LineTool but i am having some trouble changing the geometry for the inserted shape. Do you guys have some examples of making custom tools, feels like i am missing something, but haven't been able to find any resources on this area.
On MouseMove is create a new GeometryShape and set the geometry data to a line. But it still show a arc geomtry even thoug active shape holds a LineGeometry. Seem like DrawingService.InitializeDraw(shape, "PencilTool"); is wrong but use "LineTool" as paramter will result in no geometry at all.
Also a other issue is that i need the manipulation adorner to only show resize handles in the end of the line. I can override the style for the ManipulationAdorner, but the issues is i will also have other shapes that need all four resize handles?
This is my custom tool:
public class LineTool : DrawingToolBase
{
private readonly RadDiagram _diagram;
public const string ToolName = "LineTool";
public LineTool(RadDiagram diagram)
: base("LineTool")
{
_diagram = diagram;
Cursor = Cursors.Cross;
}
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 custom LineTool but i am having some trouble changing the geometry for the inserted shape. Do you guys have some examples of making custom tools, feels like i am missing something, but haven't been able to find any resources on this area.
On MouseMove is create a new GeometryShape and set the geometry data to a line. But it still show a arc geomtry even thoug active shape holds a LineGeometry. Seem like DrawingService.InitializeDraw(shape, "PencilTool"); is wrong but use "LineTool" as paramter will result in no geometry at all.
Also a other issue is that i need the manipulation adorner to only show resize handles in the end of the line. I can override the style for the ManipulationAdorner, but the issues is i will also have other shapes that need all four resize handles?
This is my custom tool:
public class LineTool : DrawingToolBase
{
private readonly RadDiagram _diagram;
public const string ToolName = "LineTool";
public LineTool(RadDiagram diagram)
: base("LineTool")
{
_diagram = diagram;
Cursor = Cursors.Cross;
}
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;
}
}