Ejemplo n.º 1
0
        private void buttonStrStolb_Click(object sender, EventArgs e)
        {
            try
            {
                int str   = 0;
                int stolb = 0;
                switch (n)
                {
                case 2:
                    str   = 2;
                    stolb = 2;
                    break;

                case 3:
                    str   = 2;
                    stolb = 2;
                    break;

                case 4:
                    str   = 2;
                    stolb = 2;
                    break;

                case 5:
                    if (comboBox1.Items.IndexOf(comboBox1.SelectedItem) == 0)
                    {
                        str   = 2;
                        stolb = 3;
                    }
                    else
                    {
                        str   = 3;
                        stolb = 2;
                    }
                    break;

                case 6:
                    if (comboBox1.Items.IndexOf(comboBox1.SelectedItem) == 0)
                    {
                        str   = 2;
                        stolb = 3;
                    }
                    else
                    {
                        str   = 3;
                        stolb = 2;
                    }
                    break;

                case 7:
                    if (comboBox1.Items.IndexOf(comboBox1.SelectedItem) == 0)
                    {
                        str   = 2;
                        stolb = 4;
                    }
                    else
                    {
                        str   = 4;
                        stolb = 2;
                    }
                    break;

                case 8:
                    if (comboBox1.Items.IndexOf(comboBox1.SelectedItem) == 0)
                    {
                        str   = 2;
                        stolb = 4;
                    }
                    else
                    {
                        str   = 4;
                        stolb = 2;
                    }
                    break;

                case 9:
                    str   = 3;
                    stolb = 3;
                    break;

                case 10:
                    if (comboBox1.Items.IndexOf(comboBox1.SelectedItem) == 0)
                    {
                        str   = 2;
                        stolb = 5;
                    }
                    else
                    {
                        str   = 5;
                        stolb = 2;
                    }
                    break;

                case 11:
                    if (comboBox1.Items.IndexOf(comboBox1.SelectedItem) == 0)
                    {
                        str   = 3;
                        stolb = 4;
                    }
                    else
                    {
                        str   = 4;
                        stolb = 3;
                    }
                    break;

                case 12:
                    if (comboBox1.Items.IndexOf(comboBox1.SelectedItem) == 0)
                    {
                        str   = 3;
                        stolb = 4;
                    }
                    else if (comboBox1.Items.IndexOf(comboBox1.SelectedItem) == 1)
                    {
                        str   = 4;
                        stolb = 3;
                    }
                    else if (comboBox1.Items.IndexOf(comboBox1.SelectedItem) == 2)
                    {
                        str   = 2;
                        stolb = 6;
                    }
                    else if (comboBox1.Items.IndexOf(comboBox1.SelectedItem) == 3)
                    {
                        str   = 6;
                        stolb = 2;
                    }
                    break;

                case 13:
                    if (comboBox1.Items.IndexOf(comboBox1.SelectedItem) == 0)
                    {
                        str   = 2;
                        stolb = 7;
                    }
                    else
                    {
                        str   = 7;
                        stolb = 2;
                    }
                    break;

                case 14:
                    if (comboBox1.Items.IndexOf(comboBox1.SelectedItem) == 0)
                    {
                        str   = 2;
                        stolb = 7;
                    }
                    else
                    {
                        str   = 7;
                        stolb = 2;
                    }
                    break;

                case 15:
                    if (comboBox1.Items.IndexOf(comboBox1.SelectedItem) == 0)
                    {
                        str   = 5;
                        stolb = 3;
                    }
                    else
                    {
                        str   = 3;
                        stolb = 5;
                    }
                    break;

                case 16:
                    str   = 4;
                    stolb = 4;
                    break;

                case 17:
                    if (comboBox1.Items.IndexOf(comboBox1.SelectedItem) == 0)
                    {
                        str   = 6;
                        stolb = 3;
                    }
                    else if (comboBox1.Items.IndexOf(comboBox1.SelectedItem) == 1)
                    {
                        str   = 3;
                        stolb = 6;
                    }
                    else if (comboBox1.Items.IndexOf(comboBox1.SelectedItem) == 2)
                    {
                        str   = 2;
                        stolb = 9;
                    }
                    else if (comboBox1.Items.IndexOf(comboBox1.SelectedItem) == 3)
                    {
                        str   = 9;
                        stolb = 2;
                    }
                    break;

                case 18:
                    if (comboBox1.Items.IndexOf(comboBox1.SelectedItem) == 0)
                    {
                        str   = 6;
                        stolb = 3;
                    }
                    else if (comboBox1.Items.IndexOf(comboBox1.SelectedItem) == 1)
                    {
                        str   = 3;
                        stolb = 6;
                    }
                    else if (comboBox1.Items.IndexOf(comboBox1.SelectedItem) == 2)
                    {
                        str   = 2;
                        stolb = 9;
                    }
                    else if (comboBox1.Items.IndexOf(comboBox1.SelectedItem) == 3)
                    {
                        str   = 9;
                        stolb = 2;
                    }
                    break;

                case 19:
                    if (comboBox1.Items.IndexOf(comboBox1.SelectedItem) == 0)
                    {
                        str   = 5;
                        stolb = 4;
                    }
                    else if (comboBox1.Items.IndexOf(comboBox1.SelectedItem) == 1)
                    {
                        str   = 4;
                        stolb = 5;
                    }
                    break;

                case 20:
                    if (comboBox1.Items.IndexOf(comboBox1.SelectedItem) == 0)
                    {
                        str   = 5;
                        stolb = 4;
                    }
                    else if (comboBox1.Items.IndexOf(comboBox1.SelectedItem) == 1)
                    {
                        str   = 4;
                        stolb = 5;
                    }
                    break;
                }
                str_orig                    = str;
                stolb_orig                  = stolb;
                buttonPutSmezh.Enabled      = true;
                buttonGetRasst.Enabled      = true;
                buttonShowPositions.Enabled = true;
                buttonStrStolb.Enabled      = false;
                comboBox1.Enabled           = false;
                rasst       = new Rasst();
                matrixRasst = rasst.determineAndGetRasst(n, str, stolb);
            }
            catch (FormatException ex)
            {
                MessageBox.Show("Ошибка ввода", "Ошибка ввода");
            }
        }
Ejemplo n.º 2
0
 private void buttonGetRasst_Click(object sender, EventArgs e)
 {
     rasst       = new Rasst();
     matrixRasst = rasst.determineAndGetRasst(n, str_orig, stolb_orig);
     rasst.Show();
 }