Beispiel #1
0
        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;
            }
        }