Esempio n. 1
0
        private void no_file_chosen(string source)
        {
            string error = "Не выбран исходный файл для ";

            if (source == "cycles")
            {
                error += "циклов.";
            }
            else
            {
                error += "графа.";
            }
            PopUp popup = new PopUp(error);

            popup.ShowDialog();
        }
Esempio n. 2
0
 private void ok_button_Click(object sender, EventArgs e)
 {
     if (check_data())
     {
         get_var(variable_1_input.Text);
         if (this.task == 5)
         {
             get_var(variable_2_input.Text);
         }
         this.Close();
     }
     else
     {
         PopUp window = new PopUp("Неверно введены данные.");
         window.Show();
     }
 }
Esempio n. 3
0
        private void run_task(int task)
        {
            if (dir_graph == null)
            {
                no_file_chosen("graph");
            }
            else
            {
                graph = new Graph(dir_graph);
                int              max_node = graph.matrix.Length - 1;
                string           answer   = "";
                List <int[]>     vars;
                Additional_Input window;
                PopUp            err_window;
                string           input_error = "Некорректный граф.";

                switch (task)
                {
                case 1:
                    if (graph_check(false))
                    {
                        answer = graph.euler();
                        res_pop_up(task, answer);
                        to_file(dir_graph, task, answer);
                    }
                    else
                    {
                        err_window = new PopUp(input_error);
                        err_window.ShowDialog();
                    }
                    break;

                case 2:
                    if (graph_check(false))
                    {
                        vars   = new List <int[]>();
                        window = new Additional_Input(task, vars, max_node);
                        window.ShowDialog(); vars = window.vars;
                        answer = graph.clique(vars[0][0]);
                        res_pop_up(task, answer);
                        to_file(dir_graph, task, answer);
                    }
                    else
                    {
                        err_window = new PopUp(input_error);
                        err_window.ShowDialog();
                    }
                    break;

                case 3:
                    if (graph_check(true, false))
                    {
                        answer = graph.topological_sort();
                        res_pop_up(task, answer);
                        to_file(dir_graph, task, answer);
                    }
                    else
                    {
                        err_window = new PopUp(input_error);
                        err_window.ShowDialog();
                    }
                    break;

                case 4:
                    if (dir_fcycles == null)
                    {
                        no_file_chosen("cycles");
                    }
                    else
                    {
                        vars   = new List <int[]>();
                        window = new Additional_Input(task, vars, max_node);
                        window.ShowDialog(); vars = window.vars;
                        answer = graph.cycle_representation(vars[0], dir_fcycles);
                        res_pop_up(task, answer);
                        to_file(dir_graph, task, answer);
                    }
                    break;

                case 5:
                    vars   = new List <int[]>();
                    window = new Additional_Input(task, vars, max_node);
                    window.ShowDialog(); vars = window.vars;
                    answer = graph.a_star(vars[0][0], vars[1][0]);
                    res_pop_up(task, answer);
                    to_file(dir_graph, task, answer);
                    break;
                }
            }
        }