예제 #1
0
 private void graph_DijkstraStepPerformed(object o, StepEventArgs e)
 {
     if (e.Comment == "end")
     {
         this.BeginInvoke(new MethodInvoker(delegate() // ðis ir lai varçtu no viena threada varetu mainiit otru threadu (no servera threada izmaniniit formas threadu)
         {
             kryptonButton1.Enabled = true;
             kryptonButton2.Enabled = false;
             kryptonButton3.Enabled = false;
         }));
     }
     if (e.Argument is int[, ])
     {
         if (e.Comment == "dinit")
         {
             this.BeginInvoke(new MethodInvoker(delegate() // ðis ir lai varçtu no viena threada varetu mainiit otru threadu (no servera threada izmaniniit formas threadu)
             {
                 kryptonRichTextBox1.AppendText("d matrix initialized\n");
                 int[,] d = (int[, ])e.Argument;
                 for (int i = 0; i < graph.VertexCollection.Count; i++)
                 {
                     for (int j = 0; j < graph.VertexCollection.Count; j++)
                     {
                         if (d[i, j] == 9999)
                         {
                             kryptonRichTextBox1.AppendText("\u221E ;");
                         }
                         else
                         {
                             kryptonRichTextBox1.AppendText(d[i, j].ToString() + " ;");
                         }
                     }
                     kryptonRichTextBox1.AppendText("\n");
                 }
                 kryptonRichTextBox1.AppendText("-----\n");
             }));
         }
         else if (e.Comment == "predinit")
         {
             this.BeginInvoke(new MethodInvoker(delegate() // ðis ir lai varçtu no viena threada varetu mainiit otru threadu (no servera threada izmaniniit formas threadu)
             {
                 kryptonRichTextBox2.AppendText("pred matrix initialized\n");
                 int[,] pred = (int[, ])e.Argument;
                 for (int i = 0; i < graph.VertexCollection.Count; i++)
                 {
                     for (int j = 0; j < graph.VertexCollection.Count; j++)
                     {
                         if (pred[i, j] == -1)
                         {
                             kryptonRichTextBox2.AppendText("\u2205 ;");
                         }
                         else
                         {
                             kryptonRichTextBox2.AppendText(pred[i, j].ToString() + " ;");
                         }
                     }
                     kryptonRichTextBox2.AppendText("\n");
                 }
                 kryptonRichTextBox2.AppendText("-----\n");
             }));
             t.Suspend();
         }
         else if (e.Comment == "d")
         {
             this.BeginInvoke(new MethodInvoker(delegate() // ðis ir lai varçtu no viena threada varetu mainiit otru threadu (no servera threada izmaniniit formas threadu)
             {
                 int[,] d = (int[, ])e.Argument;
                 for (int i = 0; i < graph.VertexCollection.Count; i++)
                 {
                     for (int j = 0; j < graph.VertexCollection.Count; j++)
                     {
                         if (d[i, j] == 9999)
                         {
                             kryptonRichTextBox1.AppendText("\u221E ;");
                         }
                         else
                         {
                             kryptonRichTextBox1.AppendText(d[i, j].ToString() + " ;");
                         }
                     }
                     kryptonRichTextBox1.AppendText("\n");
                 }
                 kryptonRichTextBox1.AppendText("-----\n");
             }));
         }
         else if (e.Comment == "pred")
         {
             this.BeginInvoke(new MethodInvoker(delegate() // ðis ir lai varçtu no viena threada varetu mainiit otru threadu (no servera threada izmaniniit formas threadu)
             {
                 int[,] pred = (int[, ])e.Argument;
                 for (int i = 0; i < graph.VertexCollection.Count; i++)
                 {
                     for (int j = 0; j < graph.VertexCollection.Count; j++)
                     {
                         if (pred[i, j] == -1)
                         {
                             kryptonRichTextBox2.AppendText("\u2205 ;");
                         }
                         else
                         {
                             kryptonRichTextBox2.AppendText(pred[i, j].ToString() + " ;");
                         }
                     }
                     kryptonRichTextBox2.AppendText("\n");
                 }
                 kryptonRichTextBox2.AppendText("-----\n");
             }));
             t.Suspend();
         }
     }
 }
예제 #2
0
 private void graph_DijkstraStepPerformed(object o, StepEventArgs e)
 {
     if (e.Argument is String)
     {
         if (e.Comment == "begin")
         {
             this.BeginInvoke(new MethodInvoker(delegate() // ðis ir lai varçtu no viena threada varetu mainiit otru threadu (no servera threada izmaniniit formas threadu)
             {
                 kryptonRichTextBox1.AppendText("Algorithm begin\nSource vertex is " + graph.Source.Key + "\n");
             }));
             t.Suspend();
         }
         else if (e.Comment == "init")
         {
             this.BeginInvoke(new MethodInvoker(delegate() // ðis ir lai varçtu no viena threada varetu mainiit otru threadu (no servera threada izmaniniit formas threadu)
             {
                 kryptonRichTextBox1.AppendText("Graph initialized\n");
                 panel.Invalidate();
             }));
             t.Suspend();
         }
         else if (e.Comment == "end")
         {
             this.BeginInvoke(new MethodInvoker(delegate() // ðis ir lai varçtu no viena threada varetu mainiit otru threadu (no servera threada izmaniniit formas threadu)
             {
                 kryptonRichTextBox1.AppendText("Algorithm end\n");
                 u  = null;
                 uv = null;
                 panel.Invalidate();
             }));
         }
     }
     else if (e.Argument is List <Vertex> )
     {
         if (e.Comment == "S")
         {
             this.BeginInvoke(new MethodInvoker(delegate() // ðis ir lai varçtu no viena threada varetu mainiit otru threadu (no servera threada izmaniniit formas threadu)
             {
                 S = (List <Vertex>)e.Argument;
                 panel.Invalidate();
             }));
         }
     }
     else if (e.Argument is Vertex)
     {
         this.BeginInvoke(new MethodInvoker(delegate() // ðis ir lai varçtu no viena threada varetu mainiit otru threadu (no servera threada izmaniniit formas threadu)
         {
             uv = null;
             u  = (Vertex)e.Argument;
             panel.Invalidate();
             kryptonRichTextBox1.AppendText("u = " + u.Key + "\n");
         }));
         t.Suspend();
     }
     else if (e.Argument is Edge)
     {
         this.BeginInvoke(new MethodInvoker(delegate() // ðis ir lai varçtu no viena threada varetu mainiit otru threadu (no servera threada izmaniniit formas threadu)
         {
             uv = (Edge)e.Argument;
             panel.Invalidate();
             kryptonRichTextBox1.AppendText("Relax " + uv.ToString() + "\n");
         }));
         t.Suspend();
     }
     //Debug.WriteLine(e.Comment);
 }