Пример #1
0
 private void GraphForm_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Right)
     {
         if (m_selection == null)
         {
             return;
         }
         //connect request
         Monitor.Enter(m_graph);
         GraphNodeSelectionVisitor gnsv = new GraphNodeSelectionVisitor(new Point(e.X, e.Y));
         GraphNode target = (GraphNode)m_graph.getVisited(gnsv);
         if (target != null)
         {
             //it was clicked on a node
             m_graph.connect(m_selection, target);
         }
         else
         {
             m_selection = null;
         }
         Monitor.Exit(m_graph);
     }
     else if (e.Button == MouseButtons.Left)
     {
         GraphNodeSelectionVisitor gnsv = new GraphNodeSelectionVisitor(new Point(e.X, e.Y));
         m_selection = (GraphNode)m_graph.getVisited(gnsv);
         if (m_selection != null)
         {
             //it was clicked on a node
             if (e.Clicks > 1)
             {
                 //double click
                 if (m_selection.LowerGraph == null)
                 {
                     m_selection.LowerGraph = m_gen_graph();
                 }
                 m_selection.LowerGraph.Parent = m_graph;
                 m_graph = m_selection.LowerGraph;
                 string tmp   = graph_level.Text.Substring(6);
                 int    level = Convert.ToInt32(tmp);
                 graph_level.Text = "level " + Convert.ToString(level + 1);
                 //m_selection.Name = "dc";
             }
             m_left_down = true;
         }
         else
         {
             m_click = new Point(e.X, e.Y);
             NodeMenu.Show(this, m_click);
         }
     }
     Invalidate();
 }