private void MouseCreateCanvasConnection(ICanvas canvas, IPoint point) { var root = Insert.Pin(canvas, point, Context.DiagramCreator, Context.EnableSnap); Context.CurrentRoot = root; double x = Context.CurrentRoot.GetX(); double y = Context.CurrentRoot.GetY(); Context.CurrentLine = WireEditor.Connect(canvas, Context.CurrentRoot, Context.CurrentLine, x, y, Context.DiagramCreator); if (Context.CurrentLine == null) { Context.CurrentRoot = null; } Context.CurrentRoot = root; Context.CurrentLine = WireEditor.Connect(canvas, Context.CurrentRoot, Context.CurrentLine, x, y, Context.DiagramCreator); }
public IElement Add(ICanvas canvas, string type, IPoint point) { var context = Context.DiagramCreator; var snap = Context.EnableSnap; switch (type) { case Constants.TagElementInput: return(Insert.Input(canvas, point, context, snap)); case Constants.TagElementOutput: return(Insert.Output(canvas, point, context, snap)); case Constants.TagElementAndGate: return(Insert.AndGate(canvas, point, context, snap)); case Constants.TagElementOrGate: return(Insert.OrGate(canvas, point, context, snap)); case Constants.TagElementPin: return(Insert.Pin(canvas, point, context, snap)); default: return(null); } }
public static bool Split(ICanvas canvas, ILine line, ILine currentLine, IPoint point, IDiagramCreator creator, bool snap) { var pin = Insert.Pin(canvas, point, creator, snap); double x = pin.GetX(); double y = pin.GetY(); var temp = Connect(canvas, pin, currentLine, x, y, creator); canvas.Remove(line); var connections = ModelEditor.RemoveWireConnections(canvas, line); if (connections != null && connections.Count == 2) { Reconnect(canvas, line, pin, x, y, connections, temp, creator); } else { throw new InvalidOperationException("LineEx should have only two connections: Start and End."); } return(true); }