public handles: UserHandleModel[] = [
{
name: 'CustomConnectorDrawingTool',
pathData:
'M60.3,18H27.5c-3,0-5.5,2.4-5.5,5.5v38.2h5.5V23.5h32.7V18z M68.5,28.9h-30c-3,' +
'0-5.5,2.4-5.5,5.5v38.2c0,3,2.4,5.5,5.5,5.5h30c3,0,5.5-2.4,5.5-5.5V34.4C73.9,31.4,71.5,28.9,68.5,28.9z ' +
'M68.5,72.5h-30V34.4h30V72.5z',
visible: true,
offset: 0,
side: 'Bottom',
margin: {top: 0, bottom: 0, left: 0, right: 0}
}
];
public getTool(action: string): ToolBase {
let tool: ToolBase;
if (action === 'CustomConnectorDrawingTool') {
let currNode = this.diagram.selectedItems.nodes[0];
console.log(currNode)
let cloneTool: CustomConnectorDrawingTool = new CustomConnectorDrawingTool(this.diagram.commandHandler, '', currNode as any);
cloneTool.diagram = this.diagram;
cloneTool.node = currNode;
return cloneTool;
}
return tool;
}
class CustomConnectorDrawingTool extends ConnectorDrawingTool {
public diagram: Diagram = null;
public node:NodeModel = null
public mouseMove(args: MouseEventArgs): boolean {
console.log(this)
//if (!this.diagram.drawingObject) return false;
return super.mouseMove(args);
}
public mouseUp(args: MouseEventArgs): Promise<void> {
args.source = this.node as any as IElement;
if(args.source) args.sourceWrapper = args.source.wrapper;
let superReturn = super.mouseUp(args);
return superReturn;
}
mouseLeave(args: MouseEventArgs): void {
args.source = this.node as any as IElement;
if(args.source) args.sourceWrapper = args.source.wrapper;
}
public mouseDown(args: MouseEventArgs): Promise<void> {
console.log(args);
args.startTouches;
args.position = {
x: this.node.offsetX,
y: this.node.offsetY
};
args.source = this.node as IElement;
args.actualObject = this.node as IElement;
if(args.source) args.sourceWrapper = args.source.wrapper;
return super.mouseDown(args);
;
}
}
public mouseMove(args: MouseEventArgs): boolean {
console.log(this);
if (this.diagram.drawingObject === undefined) {
this.diagram.drawingObject = {
type: "Straight",
sourceID: args.actualObject.id // Code added
};
}
//if (!this.diagram.drawingObject) return false;
return super.mouseMove(args);
} |