Ejemplo n.º 1
0
        private void btnDrawRandomGraphFromLines_Click(object sender, RoutedEventArgs e)
        {
            draw.ClearAll();

            if (Graph.MaxConnections((int)intUpDownRandomPoints1.Value) < (int)intUpDownConnections.Value)
            {
                MessageBox.Show(String.Format("Przekroczono maksymalną liczbę połaczeń!\nMaksymalna liczba polaczen dla {0} wierzcholkow wynosi {1}.",
                                              (int)intUpDownRandomPoints1.Value, Graph.MaxConnections((int)intUpDownRandomPoints1.Value)), "Błąd!");
                return;
            }

            if (intUpDownRandomPoints1.Value != null && intUpDownConnections.Value != null)
            {
                draw.CurrentGraph = GraphCreator.CreateRandomGraph((int)intUpDownRandomPoints1.Value, (int)intUpDownConnections.Value);
            }
            else
            {
                MessageBox.Show("Niepoprawna ilość wierchołków bądź połaczeń!", "Błąd!");
                return;
            }

            draw.NodeRadius = (int)sliderNodeRadius.Value;
            draw.Radius     = (int)sliderRadius.Value;

            draw.DrawMainCircle();
            draw.Draw();
        }
Ejemplo n.º 2
0
        private void btnOpenFromFile_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog();
            openFileDialog.Multiselect = false;
            openFileDialog.Filter      = "Pliki tekstowe | *.txt|Wszystkie pliki |*.*";

            if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                int[,] graphMatrix;
                if (SaveOpenGraph.ReadFromFile(openFileDialog.FileName, out graphMatrix))
                {
                    draw.ClearAll();

                    draw.CurrentGraph = GraphCreator.CreateFromMatrix(graphMatrix);

                    draw.NodeRadius = (int)sliderNodeRadius.Value;
                    draw.Radius     = (int)sliderRadius.Value;

                    draw.DrawMainCircle();
                    draw.Draw();
                }
                else
                {
                    MessageBox.Show("Błędna zawartość pliku!", "Błąd");
                }
            }
        }
Ejemplo n.º 3
0
 private void Output_MouseMove(object sender, MouseEventArgs e)
 {
     if (SelectedNode != null)
     {
         DrawGraph <int> draw = sender == OutputA ? DrawA : DrawB;
         if (ChangeBtn.Checked)
         {
             if (draw.PlaceChangeFree(e.Location, SelectedNode))
             {
                 SelectedNode.Value.P = e.Location;
             }
             UpdatePicter(sender);
         }
         if (AddEdge.Checked)
         {
             ((PictureBox)sender).Image = draw.Draw(SelectedNode, e.Location);
         }
     }
 }
Ejemplo n.º 4
0
 private void UpdatePicter(Object sender)
 {
     ((PictureBox)sender).Image = sender == OutputA?DrawA.Draw() : DrawB.Draw();
 }