public override void MouseClick(PointF location, Keys controlKeys) { GraphicBaseElement element = m_Editor.GetElementAt(location); if (element == null) { if (m_FromElement != null) { //floating connection - create a new connection line FloatingConnection(location); m_LastMouseLocation = location; } return; } if (element is GraphicInputOutputElement == false && element is GraphicConnection == false) { return; } //user clicked a terminal of an element GraphicInputOutputElement ioelem = element as GraphicInputOutputElement; GraphicTerminal graphicTerminal = null; if (ioelem != null) { graphicTerminal = ioelem.GetTerminalAt(location); if (graphicTerminal == null || graphicTerminal.Equals(m_FromElement)) { return; } if (m_FromElement == null) { m_FromElement = graphicTerminal; m_LastMouseLocation = location; return; } TryConnectToTerminal(graphicTerminal, location); m_LastMouseLocation = location; } //user clicked a connection GraphicConnection connection = element as GraphicConnection; if (connection != null) { if (connection.Equals(m_FromElement)) { return; } if (m_FromElement == null) { m_FromElement = connection; m_LastMouseLocation = location; return; } TryConnectToConnection(connection, location); m_LastMouseLocation = location; } }
public override void MouseClick(PointF location, Keys controlKeys) { GraphicBaseElement element = m_Editor.GetElementAt(location); if (element == null) { return; } if (element is GraphicInputOutputElement == false && element is GraphicConnection == false) { return; } GraphicConnection graphicConnection = null; //user clicked a terminal of an element GraphicInputOutputElement ioelem = element as GraphicInputOutputElement; if (ioelem != null) { GraphicTerminal graphicTerminal = ioelem.GetTerminalAt(location); if (graphicTerminal != null) { Terminal terminal = (graphicTerminal.LinkedObject as Terminal); if (terminal.IsConnected) { Connection connection = terminal.Connection; graphicConnection = terminal.Connection.LinkedObject as GraphicConnection; graphicConnection.RemoveChild(graphicTerminal.ConnectionNode.Lines[0]); //terminal.Disconnect(); connection.DisconnectTerminal(terminal); if (connection.Terminals.Count == 0) { m_Editor.RemoveElement(connection.LinkedObject as GraphicConnection); } m_Editor.UpdateDrawing(); m_Editor.RaiseChangedEvent(); m_Editor.Invalidate(); } } } //user clicked a connection graphicConnection = element as GraphicConnection; if (graphicConnection != null) { foreach (GraphicBaseElement child in graphicConnection.Children) { graphicConnection.RemoveChild(child); } Connection connection = graphicConnection.LinkedObject as Connection; foreach (Terminal terminal in connection.Terminals) { //terminal.Disconnect(); connection.DisconnectTerminal(terminal); } m_Editor.RemoveElement(graphicConnection); } }
public override void MouseMove(MouseButtons button, PointF location, Keys controlKeys) { if (m_Editor == null) { return; } GraphicBaseElement element = m_Editor.GetElementAt(location); if (m_HighLightElement != null) { if (element == null || (element.Equals(m_ParentElement) == false && m_HighLightElement is GraphicTerminal) || (element.Equals(m_HighLightElement) == false && m_HighLightElement is GraphicConnection)) { //Un-Hover the element UnHighlightElement(m_HighLightElement); return; } } if (element is GraphicInputOutputElement) { GraphicInputOutputElement ioelem = element as GraphicInputOutputElement; GraphicTerminal graphicTerminal = ioelem.GetTerminalAt(location); if (graphicTerminal != null) { if ((graphicTerminal.LinkedObject as Terminal).IsConnected == false) { //Hover an element m_ParentElement = element; HighlightElement(graphicTerminal); } } else if (m_HighLightElement != null) { //Un-Hover the element UnHighlightElement(m_HighLightElement); } } if (element is GraphicConnection) { if (m_HighLightElement == null) { //Hover an element HighlightElement(element); } } }