Ejemplo n.º 1
0
        //Button to write the array in the text file
        private void button3_Click(object sender, EventArgs e)
        {
            SaveFileDialog file_input_array = new SaveFileDialog();

            file_input_array.Filter           = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            file_input_array.FilterIndex      = 1;
            file_input_array.RestoreDirectory = true;
            file_input_array.Title            = "File to save input array";
            if (file_input_array.ShowDialog() == DialogResult.OK)
            {
                Tmas.Write_Input_Array(file_input_array.FileName);
            }
        }
Ejemplo n.º 2
0
 //Button to generate the array with random numbers
 private void button1_Click(object sender, EventArgs e)
 {
     if (numericUpDown4.Value != 0 && numericUpDown6.Value != numericUpDown5.Value)
     {
         Tmas.GenerarElementos((int)numericUpDown4.Value, (int)numericUpDown5.Value, (int)numericUpDown6.Value);
         results.Show();
         results.Focus();
         button5.Enabled = true;
         button3.Enabled = true;
     }
     else
     {
         MessageBox.Show("Incorrect parameters!");
     }
 }
Ejemplo n.º 3
0
 //Button to open a text file with an array
 private void button2_Click(object sender, EventArgs e)
 {
     try
     {
         OpenFileDialog file_with_array = new OpenFileDialog();
         file_with_array.Filter      = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
         file_with_array.FilterIndex = 1;
         file_with_array.Title       = "File with the array";
         if (file_with_array.ShowDialog() == DialogResult.OK)
         {
             Tmas.Read_File_Array(file_with_array.FileName);
             //MessageBox.Show("-"+file_with_array.FileName+"-");
             results.Refresh();
             results.Show();
             results.Focus();
         }
     }
     catch
     {
         MessageBox.Show("Incorrect format of the file!");
     }
 }
Ejemplo n.º 4
0
        //In this method the program is going to put the array entered into the datagridview and the second part is going to execute the selected operation and show into the datagridview and/or textbox
        private void Results_Activated(object sender, EventArgs e)
        {
            textBox1.Text = "";
            dataGridView1.Rows.Clear();
            dataGridView2.Rows.Clear();
            dataGridView1.ColumnCount         = Tmas.FA.GetLength(0);
            dataGridView2.ColumnCount         = Tmas.FA.GetLength(0);
            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            dataGridView2.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            for (int c = 0; c < Tmas.FA.GetLength(0); c++)
            {
                string[] row = new string[Tmas.FA.GetLength(1)];
                for (int i = 0; i < Tmas.FA.GetLength(1); i++)
                {
                    row[i] = Tmas.FA[c, i].ToString();
                }
                dataGridView1.Rows.Add(row);
                dataGridView2.Rows.Add(row);
            }
            label1.Text = "N = " + Tmas.FA.GetLength(0) + "x" + Tmas.FA.GetLength(1) + "; Min = " + Tmas._min + "; Max = " + Tmas._max;
            switch (Tmas.op)
            {
            case 1:
                Tmas.op1 = true;
                Tmas.OP1();
                dataGridView2.Rows.Clear();
                for (int c = 0; c < Tmas.FA.GetLength(0); c++)
                {
                    string[] row = new string[Tmas.FA.GetLength(1)];
                    for (int i = 0; i < Tmas.FA.GetLength(1); i++)
                    {
                        row[i] = Tmas.FA_sort[c, i].ToString();
                    }
                    dataGridView2.Rows.Add(row);
                    textBox1.Text = "Array is sorted ==>";
                }
                break;

            case 2:
                Tmas.op2 = true;
                Tmas.OP2();
                textBox1.Text = "Дисперсию элементов массива:" + Tmas.var.ToString();
                break;

            case 3:
                Tmas.op3 = true;
                Tmas.OP3();
                dataGridView2.Rows.Clear();
                for (int c = 0; c < Tmas.FA.GetLength(0); c++)
                {
                    string[] row = new string[Tmas.FA.GetLength(1)];
                    for (int i = 0; i < Tmas.FA.GetLength(1); i++)
                    {
                        row[i] = Tmas.new_elements[c, i].ToString();
                    }
                    dataGridView2.Rows.Add(row);
                    textBox1.Text = "Элементы массива с суммой индексов кратной 3 умножить на (-g) ==>";
                }
                break;
            }
        }