예제 #1
0
 void Obr()
 {
     if (AddNodeBtn.Checked)
     {
         PictureBox     pictureBox     = graph1PB;
         Graphs         gr             = graph1;
         MouseEventArgs mouseEventArgs = FirstClick1;
         gr.AddNode(mouseEventArgs.X, mouseEventArgs.Y);
         gr.Draw(pictureBox.CreateGraphics(), selectionNode);
     }
     else if (DeleteNodeBtn.Checked)
     {
         Graphs         gr             = graph1;
         PictureBox     pictureBox     = graph1PB;
         MouseEventArgs mouseEventArgs = FirstClick1;
         Node           nodeGrathic    = gr.FindNode(mouseEventArgs.Location);
         if (nodeGrathic != null)
         {
             gr.Delete(nodeGrathic);
         }
         gr.Draw(pictureBox.CreateGraphics(), selectionNode);
     }
     else if (GetEdgeBtn.Checked)
     {
         Graphs         gr              = graph1;
         PictureBox     pictureBox      = graph1PB;
         MouseEventArgs mouseEventArgs1 = FirstClick1;
         MouseEventArgs mouseEventArgs2 = SecondClick1;
         Node           nodeGrathic1    = gr.FindNode(mouseEventArgs1.Location);
         Node           nodeGrathic2    = gr.FindNode(mouseEventArgs2.Location);
         if (nodeGrathic1 != null && nodeGrathic2 != null && nodeGrathic1 != nodeGrathic2)
         {
             gr.AddEdge(nodeGrathic1, nodeGrathic2);
         }
         gr.Draw(pictureBox.CreateGraphics(), selectionNode);
     }
     else if (SelectionNodeBtn.Checked)
     {
         Node node = graph1.FindNode(FirstClick1.Location);
         if (node != null)
         {
             if (selectionNode.IndexOf(node) != -1)
             {
                 selectionNode.Remove(node);
             }
             else
             {
                 selectionNode.Add(node);
             }
         }
         graph1.Draw(graph1PB.CreateGraphics(), selectionNode);
     }
 }
예제 #2
0
 private void openGraph1Btn_Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         graph1 = ClassLibrary1.FileGraph.OpenGraph(openFileDialog1.FileName);
         graph1.Draw(graph1PB.CreateGraphics(), selectionNode);
     }
 }
예제 #3
0
 private void ClearBtn_Click(object sender, EventArgs e)
 {
     graph1 = new Graphs();
     graph1.Draw(graph1PB.CreateGraphics(), selectionNode);
     textBox1.Lines = null;
 }