Beispiel #1
0
        private void btnOriginal_Click(object sender, EventArgs e)
        {
            try
            {
                groupBoxMatriz1.Controls.Clear();


                Matriz1 = new TextBox[tempMatriz1.GetLength(0), tempMatriz1.GetLength(1)];
                int TamanhoText = (groupBoxMatriz1.Width / Matriz1.GetLength(1)) - 5;

                for (int x = 0; x < Matriz1.GetLength(0); x++)
                {
                    for (int y = 0; y < Matriz1.GetLength(1); y++)
                    {
                        Matriz1[x, y]       = new TextBox();
                        Matriz1[x, y].Text  = tempMatriz1[x, y].ToString();
                        Matriz1[x, y].Top   = (x * Matriz1[x, y].Height) + 20;
                        Matriz1[x, y].Left  = y * TamanhoText + 6;
                        Matriz1[x, y].Width = TamanhoText - 5;
                        groupBoxMatriz1.Controls.Add(Matriz1[x, y]);
                    }
                }

                groupBoxMatriz1.Height = 20 * Matriz1.GetLength(1) + 30;
            }
            catch (Exception)
            {
                MessageBox.Show("Error en el traspaso", "Error");
            }
        }
        private void checkOpo(TextBox[,] Matriz_x)
        {
            float[,] tempMatriz = new float[Matriz_x.GetLength(0), Matriz_x.GetLength(1)];

            for (int i = 0; i < Matriz_x.GetLength(0); i++)
            {
                for (int j = 0; j < Matriz_x.GetLength(1); j++)
                {
                    float k = 0;
                    if (float.TryParse(Matriz_x[i, j].Text, out k))
                    {
                        tempMatriz[i, j] = float.Parse(Matriz_x[i, j].Text);
                    }
                }
            }

            float[,] answer = calculos.Oposta(tempMatriz);

            for (int i = 0; i < answer.GetLength(0); i++)
            {
                for (int j = 0; j < answer.GetLength(1); j++)
                {
                    Matriz_x[i, j].Text = "" + answer[i, j];
                }
            }
        }
Beispiel #3
0
        private void Graficar()
        {
            int incognitas;

            Grilla_Mat.Controls.Clear();

            if (!int.TryParse(txt_NumeroIncognitas.Text, out incognitas))
            {
                MessageBox.Show("El numero de incognitas es nula.", "Error");
                return;
            }

            int Columna = incognitas + 1;
            int Fila    = incognitas;

            Matriz = new TextBox[Fila, Columna];
            int TamañoText = ((Grilla_Mat.Width / Columna));

            for (int x = 0; x < Matriz.GetLength(0); x++)
            {
                for (int y = 0; y < Matriz.GetLength(1); y++)
                {
                    Matriz[x, y]       = new TextBox();
                    Matriz[x, y].Text  = string.Empty;
                    Matriz[x, y].Top   = (x * Matriz[x, y].Height) + 20;
                    Matriz[x, y].Left  = y * TamañoText;
                    Matriz[x, y].Width = TamañoText - 1;
                    Grilla_Mat.Controls.Add(Matriz[x, y]);
                }
            }
        }
        private void btnCriarMatriz2_Click(object sender, EventArgs e)
        {
            groupBoxMatriz2.Controls.Clear();

            if (!int.TryParse(textBox2.Text, out linha2))
            {
                MessageBox.Show("Nula", "Error");
                return;
            }
            if (!int.TryParse(textBox4.Text, out coluna2))
            {
                MessageBox.Show("Nula", "Error");
                return;
            }
            int TamanhoText = groupBoxMatriz2.Width / coluna2;

            Matriz2     = new TextBox[linha2, coluna2];
            TamanhoText = groupBoxMatriz2.Width / coluna2;
            for (int x = 0; x < Matriz2.GetLength(0); x++)
            {
                for (int y = 0; y < Matriz2.GetLength(1); y++)
                {
                    Matriz2[x, y]       = new TextBox();
                    Matriz2[x, y].Text  = "0";
                    Matriz2[x, y].Top   = (x * Matriz2[x, y].Height) + 20;
                    Matriz2[x, y].Left  = y * TamanhoText + 6;
                    Matriz2[x, y].Width = TamanhoText;
                    groupBoxMatriz2.Controls.Add(Matriz2[x, y]);
                }
            }
        }
Beispiel #5
0
        void InitializeMatrixEditor()
        {
            int rowsC = textBoxes.GetLength(0);
            int colsC = textBoxes.GetLength(1);

            this.tableLayoutMElements.ColumnStyles.Clear();
            this.tableLayoutMElements.RowStyles.Clear();

            this.tableLayoutMElements.ColumnCount = colsC;
            this.tableLayoutMElements.RowCount    = rowsC;

            for (int i = 0; i < colsC; i++)
            {
                this.tableLayoutMElements.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100.0f / colsC));
            }

            for (int i = 0; i < rowsC; i++)
            {
                this.tableLayoutMElements.RowStyles.Add(new RowStyle(SizeType.Percent, 100.0f / rowsC));
            }


            for (int i = 0; i < colsC; i++)
            {
                for (int j = 0; j < rowsC; j++)
                {
                    TextBox tb;
                    textBoxes[j, i] = tb = GetTextBox();
                    tableLayoutMElements.Controls.Add(tb, i, j);
                }
            }
        }
Beispiel #6
0
        private void btnAddMatrix1_Click(object sender, EventArgs e)
        {
            groupBoxmatrix1.Controls.Clear();


            if (!int.TryParse(textBox1.Text, out raw1))
            {
                MessageBox.Show("Error");
                return;
            }
            if (!int.TryParse(textBox3.Text, out coulmn1))
            {
                MessageBox.Show("Error");
                return;
            }

            matrix1 = new TextBox[raw1, coulmn1];
            int sizeText = groupBoxmatrix1.Width / coulmn1;

            for (int x = 0; x < matrix1.GetLength(0); x++)
            {
                for (int y = 0; y < matrix1.GetLength(1); y++)
                {
                    matrix1[x, y]       = new TextBox();
                    matrix1[x, y].Text  = "0";
                    matrix1[x, y].Top   = (x * matrix1[x, y].Height) + 20;
                    matrix1[x, y].Left  = y * sizeText + 6;
                    matrix1[x, y].Width = sizeText;
                    groupBoxmatrix1.Controls.Add(matrix1[x, y]);
                }
            }
        }
Beispiel #7
0
        private void ADDmatriz1(object sender, EventArgs e)
        {
            groupBox1.Controls.Clear();


            if (!int.TryParse(textBox1.Text, out linha1))
            {
                MessageBox.Show("Adicione a linha.", "Erro");
                return;
            }

            if (!int.TryParse(textBox2.Text, out coluna1))
            {
                MessageBox.Show("Adicione a coluna.", "Erro");
                return;
            }

            Matriz1 = new TextBox[linha1, coluna1];
            int TamanhoText = groupBox1.Width / coluna1;

            for (int x = 0; x < Matriz1.GetLength(0); x++)
            {
                for (int y = 0; y < Matriz1.GetLength(1); y++)
                {
                    Matriz1[x, y]       = new TextBox();
                    Matriz1[x, y].Text  = "0";
                    Matriz1[x, y].Top   = (x * Matriz1[x, y].Height) + 20;
                    Matriz1[x, y].Left  = y * TamanhoText + 6;
                    Matriz1[x, y].Width = TamanhoText;
                    groupBox1.Controls.Add(Matriz1[x, y]);
                }
            }
        }
Beispiel #8
0
 private int CaminoCorto(TextBox[,] Matriz, int x, int y, int suma, int xAnt, int yAnt, int numAnt)
 {
     suma = Math.Abs(numAnt - Convert.ToInt32(Matriz[x, y].Text)) + suma;
     if (x == Matriz.GetLength(0) && y == Matriz.GetLength(1))
     {
         return(suma);
     }
     else
     {
         if (x != Matriz.GetLength(0))
         {
             CaminoCorto(Matriz, x + 1, y, suma, x, y, Convert.ToInt32(Matriz[x, y].Text));
         }
         if (y != Matriz.GetLength(1))
         {
             CaminoCorto(Matriz, x, y + 1, suma, x, y, Convert.ToInt32(Matriz[x, y].Text));
         }
         if (x != 0)
         {
             CaminoCorto(Matriz, x - 1, y, suma, x, y, Convert.ToInt32(Matriz[x, y].Text));
         }
         if (y != 0)
         {
             CaminoCorto(Matriz, x, y - 1, suma, x, y, Convert.ToInt32(Matriz[x, y].Text));
         }
     }
 }
        private void btnCriaResultante_Click(object sender, EventArgs e)
        {
            groupBoxResultante.Controls.Clear();
            if (!int.TryParse(edtR.Text, out linhaR))
            {
                MessageBox.Show("A linha da matriz é nula.", "Erro");
                return;
            }

            MatrizResultante = new TextBox[linhaR, 1];
            int TamanhoText = groupBoxResultante.Width;

            for (int x = 0; x < MatrizResultante.GetLength(0); x++)
            {
                for (int y = 0; y < MatrizResultante.GetLength(1); y++)
                {
                    MatrizResultante[x, y]       = new TextBox();
                    MatrizResultante[x, y].Text  = "0";
                    MatrizResultante[x, y].Top   = (x * MatrizResultante[x, y].Height) + 20;
                    MatrizResultante[x, y].Left  = y * TamanhoText + 6;
                    MatrizResultante[x, y].Width = TamanhoText;
                    groupBoxResultante.Controls.Add(MatrizResultante[x, y]);
                }
            }
        }
Beispiel #10
0
        private void MostrarResultado(ResultadoEcuacionesGaussJordan resultado)
        {
            Grilla_Res.Controls.Clear();


            int Columna = resultado.Solucion.Count;

            ResultadoMat = new TextBox[2, Columna];

            int TamañoText = Grilla_Res.Width / Columna;


            for (int y = 0; y < ResultadoMat.GetLength(1); y++)
            {
                for (int x = 0; x < ResultadoMat.GetLength(0); x++)
                {
                    ResultadoMat[x, y] = new TextBox();

                    if (x == 0)
                    {
                        ResultadoMat[x, y].Text = resultado.Solucion[y].Nombre;
                    }
                    else
                    {
                        ResultadoMat[x, y].Text = resultado.Solucion[y].Valor.ToString("0.0000");
                    }

                    ResultadoMat[x, y].Top   = (x * Matriz[x, y].Height) + 20;
                    ResultadoMat[x, y].Left  = y * TamañoText;
                    ResultadoMat[x, y].Width = TamañoText - 2;
                    Grilla_Res.Controls.Add(ResultadoMat[x, y]);
                }
            }
        }
Beispiel #11
0
 public static void Clean(TextBox[,] textBoxes, TextBox textBox)
 {
     for (int i = 0; i < textBoxes.GetLength(0); i++)
     {
         for (int j = 0; j < textBoxes.GetLength(1); j++)
         {
             if (textBoxes[i, j].Text != "" && textBox.Text != "")
             {
                 if (textBoxes[i, j].IsReadOnly)
                 {
                     textBoxes[i, j].Background = Brushes.GhostWhite;
                     textBoxes[i, j].Foreground = Brushes.Black;
                     textBoxes[i, j].FontSize   = 25;
                     textBoxes[i, j].FontWeight = FontWeights.Bold;
                 }
                 else
                 {
                     textBoxes[i, j].Background = Brushes.White;
                     textBoxes[i, j].Foreground = Brushes.Black;
                     textBoxes[i, j].FontSize   = 25;
                     textBoxes[i, j].FontWeight = FontWeights.Bold;
                 }
             }
         }
     }
 }
Beispiel #12
0
        public void Animate(int row, int col, int time, TextBox[,] textBoxes, Grid SudokuGrid)
        {
            double counter = 0;

            Task.Run(() =>
            {
                var label = Dispatcher.Invoke(() => DrawLabelWin(SudokuGrid, "Win!", 25, row, col));

                for (int a = 0; a < textBoxes.GetLength(0); a++)
                {
                    for (int b = 0; b < textBoxes.GetLength(1); b++)
                    {
                        Dispatcher.Invoke(() => label.Foreground = Brushes.Red);
                        counter += 0.0009;
                        Dispatcher.Invoke(() => label.Opacity += counter);

                        Thread.Sleep(time);
                        Dispatcher.Invoke(() => label.Foreground = Brushes.Black);
                        Thread.Sleep(time);
                    }
                }

                Dispatcher.Invoke(() => SudokuGrid.Children.Remove(label));
            });
        }
        private void btnCriarMatriz_Click(object sender, EventArgs e)
        {
            groupBoxMatriz.Controls.Clear();
            if (!int.TryParse(edtX.Text, out linha))
            {
                MessageBox.Show("A linha da matriz é nula.", "Erro");
                return;
            }
            if (!int.TryParse(edtY.Text, out coluna))
            {
                MessageBox.Show("A coluna da matriz é nula.", "Erro");
                return;
            }

            Matriz = new TextBox[linha, coluna];
            int TamanhoText = groupBoxMatriz.Width / coluna;

            for (int x = 0; x < Matriz.GetLength(0); x++)
            {
                for (int y = 0; y < Matriz.GetLength(1); y++)
                {
                    Matriz[x, y]       = new TextBox();
                    Matriz[x, y].Text  = "0";
                    Matriz[x, y].Top   = (x * Matriz[x, y].Height) + 20;
                    Matriz[x, y].Left  = y * TamanhoText + 6;
                    Matriz[x, y].Width = TamanhoText;
                    groupBoxMatriz.Controls.Add(Matriz[x, y]);
                }
            }
        }
Beispiel #14
0
        void Nhan()
        {
            txtCotM1.ReadOnly  = false;
            txtCotM2.ReadOnly  = false;
            txtHangM2.ReadOnly = false;
            txtHangM1.ReadOnly = false;
            txtCot.ReadOnly    = true;
            txtHang.ReadOnly   = true;

            arr1 = TaoGroup(grorp1, int.Parse(txtHangM1.Text = "0"), int.Parse(txtCotM1.Text = "0"));
            arr2 = TaoGroup(group2, int.Parse(txtHangM2.Text), int.Parse(txtCotM2.Text));

            var ar1 = MangInt(arr1);
            var ar2 = MangInt(arr2);

            for (int i = 0; i < arr1.GetLength(0); i++)
            {
                for (int j = 0; j < arr1.GetLength(1); j++)
                {
                    for (int k = 0; k < arr1.GetLength(0); k++)
                    {
                        arr[i, j].Text = (int.Parse(ar1[i, k].ToString()) + int.Parse(ar2[k, j].ToString())).ToString();
                    }
                }
            }
        }
Beispiel #15
0
        public void OperacaoMatrizes3x3(TextBox[,] Matriz1, TextBox[,] Matriz2, TextBox[,] Resultado, string Operacao)
        {
            for (int i = 0; i < Matriz1.GetLength(0); i++)
            {
                for (int j = 0; j < Matriz1.GetLength(1); j++)
                {
                    if (Operacao == "soma")
                    {
                        double convertido1 = Convert.ToDouble(Matriz1[i, j].Text);
                        double convertido2 = Convert.ToDouble(Matriz2[i, j].Text);
                        double result      = (convertido1 + convertido2);
                        Resultado[i, j].Text = result.ToString();
                    }

                    if (Operacao == "diferença")
                    {
                        double convertido1 = Convert.ToDouble(Matriz1[i, j].Text);
                        double convertido2 = Convert.ToDouble(Matriz2[i, j].Text);
                        double result      = (convertido1 - convertido2);
                        Resultado[i, j].Text = result.ToString();
                    }

                    if (Operacao == "oposta")
                    {
                        double result = -(Convert.ToDouble(Matriz1[i, j].Text));
                        Resultado[i, j].Text = result.ToString();
                    }

                    if (Operacao == "transposta")
                    {
                        Resultado[j, i].Text = Matriz1[i, j].Text;
                    }
                }
            }
        }
Beispiel #16
0
        public NumberColorsOnEnter(TextBox[,] textBoxes, TextBox textBox, int[,] sudokuMap)
        {
            for (int i = 0; i < textBoxes.GetLength(0); i++)
            {
                for (int j = 0; j < textBoxes.GetLength(1); j++)
                {
                    if (textBoxes[i, j].Text == textBox.Text)
                    {
                        if (textBoxes[i, j].Text != sudokuMap[i, j].ToString() && textBoxes[i, j].Text != "")
                        {
                            Dispatcher.Invoke(() => textBoxes[i, j].Background = Brushes.Crimson);
                            Dispatcher.Invoke(() => textBoxes[i, j].Foreground = Brushes.White);
                            Dispatcher.Invoke(() => textBoxes[i, j].FontWeight = FontWeights.ExtraBlack);
                        }

                        else if (textBoxes[i, j].Text == sudokuMap[i, j].ToString())
                        {
                            Dispatcher.Invoke(() => textBoxes[i, j].Background = Brushes.SeaGreen);
                            Dispatcher.Invoke(() => textBoxes[i, j].Foreground = Brushes.White);
                            Dispatcher.Invoke(() => textBoxes[i, j].FontWeight = FontWeights.ExtraBlack);
                        }
                    }
                }
            }
        }
Beispiel #17
0
 public EditMatrix(char name, string[,] input)
 {
     InitializeComponent();
     if (input.GetLength(0) >= 1 && input.GetLength(0) <= MAXSIZE)
     {
         currentHeight = input.GetLength(0);
     }
     if (input.GetLength(1) >= 1 && input.GetLength(1) <= MAXSIZE)
     {
         currentWidth = input.GetLength(1);
     }
     text_matrixHeight.Text = currentHeight.ToString();
     text_matrixWidth.Text  = currentWidth.ToString();
     matrix = new TextBox[currentHeight, currentWidth];
     for (int i = 0; i < matrix.GetLength(0); i++)
     {
         for (int j = 0; j < matrix.GetLength(1); j++)
         {
             matrix[i, j]          = new TextBox();
             matrix[i, j].Size     = new Size(50, 20);
             matrix[i, j].Location = new Point(3 + j * (50 + 6), 3 + i * (20 + 6));
             matrix[i, j].TabIndex = i * currentHeight + j;
             matrix[i, j].Text     = input[i, j];
             panel_matrixView.Controls.Add(matrix[i, j]);
         }
     }
     currentName           = name;
     label_matrixName.Text = currentName.ToString();
     ResizeMatrix();
 }
        //MATRIZ 2
        private void lineUpDown2_ValueChanged(object sender, EventArgs e)
        {
            this.matrixBox2.Controls.Clear();

            NumericUpDown upDownSelect = sender as NumericUpDown;
            int           linha, coluna;

            linha  = Convert.ToInt32(lineUpDown2.Value);
            coluna = Convert.ToInt32(columnUpDown2.Value);

            Matriz_2 = new TextBox[linha, coluna];

            for (int i = 0; i < Matriz_2.GetLength(0); i++)
            {
                for (int j = 0; j < Matriz_2.GetLength(1); j++)
                {
                    Matriz_2[i, j]       = new TextBox();
                    Matriz_2[i, j].Text  = "0";
                    Matriz_2[i, j].Top   = (i * Matriz_2[i, j].Height) + 100;
                    Matriz_2[i, j].Left  = j * 35 + 15;
                    Matriz_2[i, j].Width = 30;
                    this.matrixBox2.Controls.Add(Matriz_2[i, j]);
                }
            }
        }
Beispiel #19
0
        private void btnAddMatrix2_Click(object sender, EventArgs e)
        {
            if (!int.TryParse(textBox2.Text, out raw2))
            {
                MessageBox.Show("Error");
                return;
            }
            if (!int.TryParse(textBox4.Text, out coulmn2))
            {
                MessageBox.Show("Error");
                return;
            }
            int sizeText = groupBoxmatrix2.Width / coulmn2;

            matrix2  = new TextBox[raw2, coulmn2];
            sizeText = groupBoxmatrix2.Width / coulmn2;
            for (int x = 0; x < matrix2.GetLength(0); x++)
            {
                for (int y = 0; y < matrix2.GetLength(1); y++)
                {
                    matrix2[x, y]       = new TextBox();
                    matrix2[x, y].Text  = "0";
                    matrix2[x, y].Top   = (x * matrix2[x, y].Height) + 20;
                    matrix2[x, y].Left  = y * sizeText + 6;
                    matrix2[x, y].Width = sizeText;
                    groupBoxmatrix2.Controls.Add(matrix2[x, y]);
                }
            }
        }
        private void buttonSum_Click(object sender, EventArgs e)
        {
            float[,] valorMatriz1 = new float[Matriz.GetLength(0), Matriz.GetLength(1)];
            float[,] valorMatriz2 = new float[Matriz_2.GetLength(0), Matriz_2.GetLength(1)];

            for (int i = 0; i < Matriz.GetLength(0); i++)
            {
                for (int j = 0; j < Matriz.GetLength(1); j++)
                {
                    float k = 0;
                    if (float.TryParse(Matriz[i, j].Text, out k))
                    {
                        valorMatriz1[i, j] = float.Parse(Matriz[i, j].Text);
                    }
                }
            }

            Console.WriteLine(valorMatriz1);

            for (int i = 0; i < Matriz_2.GetLength(0); i++)
            {
                for (int j = 0; j < Matriz_2.GetLength(1); j++)
                {
                    float k = 0;
                    if (float.TryParse(Matriz_2[i, j].Text, out k))
                    {
                        valorMatriz2[i, j] = float.Parse(Matriz_2[i, j].Text);
                    }
                }
            }

            Console.WriteLine(valorMatriz2);

            float[,] answer = calculos.Soma(valorMatriz1, valorMatriz2);

            for (int i = 0; i < Matriz.GetLength(0); i++)
            {
                for (int j = 0; j < Matriz.GetLength(1); j++)
                {
                    Console.WriteLine("Text: " + (Matriz[i, j] as TextBox).Text);
                    Console.WriteLine("NAME: " + Matriz[i, j].Name);
                }
            }

            /*for (int i = 0; i < answer.GetLength(0); i++)
             * {
             *  for (int j = 0; j < answer.GetLength(1); j++)
             *  {*/

            /* }
             * }*/

            for (int i = 0; i < Matriz_3.GetLength(0); i++)
            {
                for (int j = 0; j < Matriz_3.GetLength(1); j++)
                {
                    Matriz_3[i, j].Text = "" + answer[i, j];
                }
            }
        }
Beispiel #21
0
        private void button2_Click(object sender, EventArgs e)
        {
            groupBox1.Controls.Clear();
            if (!int.TryParse(textBox1.Text, out satir))
            {
                MessageBox.Show("Satır sayısı boş bırakılamaz.");
                return;
            }
            if (!int.TryParse(textBox2.Text, out sutun))
            {
                MessageBox.Show("Sutun sayısı boş bırakılamaz.");
                return;
            }

            matris2 = new TextBox[satir, sutun];
            int boyut = groupBox1.Width / sutun;

            for (int i = 0; i < matris2.GetLength(0); i++)
            {
                for (int j = 0; j < matris2.GetLength(1); j++)
                {
                    matris2[i, j] = new TextBox();
                    double sayi = rastgele.Next(9);
                    matris2[i, j].Text  = sayi.ToString();
                    matris2[i, j].Top   = (i * matris2[i, j].Height) + 20;
                    matris2[i, j].Left  = j * boyut + 6;
                    matris2[i, j].Width = boyut;
                    groupBox1.Controls.Add(matris2[i, j]);
                }
            }
        }
Beispiel #22
0
        private void button6_Click(object sender, EventArgs e)
        {
            double[,] temp = new double[matris2.GetLength(0), matris2.GetLength(1)];
            for (int x = 0; x < matris2.GetLength(0); x++)
            {
                for (int y = 0; y < matris2.GetLength(1); y++)
                {
                    float n = 0;
                    float.TryParse(matris2[x, y].Text, out n);
                    temp[x, y] = n;
                }
            }
            double[,] sonuc = matematikselİslemler.transpoze(temp);
            double[,] temp2 = matematikselİslemler.carpma(sonuc, temp);


            temp4 = new TextBox[temp2.GetLength(0), temp2.GetLength(1)];
            int boyut = groupBox1.Width / temp4.GetLength(1);

            groupBox1.Controls.Clear();
            for (int i = 0; i < temp4.GetLength(0); i++)
            {
                for (int j = 0; j < temp4.GetLength(1); j++)
                {
                    temp4[i, j] = new TextBox();

                    temp4[i, j].Text  = temp2[i, j].ToString();
                    temp4[i, j].Top   = (i * temp4[i, j].Height) + 20;
                    temp4[i, j].Left  = j * boyut + 6;
                    temp4[i, j].Width = boyut;
                    groupBox1.Controls.Add(temp4[i, j]);
                }
            }
        }
Beispiel #23
0
        private void bttn_NumOfPoints_Click(object sender, EventArgs e)
        {
            if (Convert.ToInt32(txtbx_NumOfPoints.Text) > 15 || Convert.ToInt32(txtbx_NumOfPoints.Text) < 2) // ограничение на кол-во вершин
            {
                MessageBox.Show("Неверный ввод!\nКол-во вершин принимает значение от 2 до 15", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtbx_NumOfPoints.Text = numOfPoints.ToString();
            }
            else
            {
                bttn_NumOfPoints.Enabled = false;

                for (int i = 0; i < linesMatrix.GetLength(0); i++) // удаление предыдущих текстбоксов
                {
                    for (int j = 0; j < linesMatrix.GetLength(1); j++)
                    {
                        Controls.Remove(linesMatrix[i, j]);
                    }
                }

                numOfPoints = Convert.ToInt32(txtbx_NumOfPoints.Text); // кол-во вершин

                linesMatrix = new TextBox[numOfPoints - 1, 2];         // матрица ребер

                int startX = 12;                                       // левая граница по х
                int endX   = 400;                                      // правая граница по х

                int startY = 170;                                      // верхняя граница по у
                int endY   = 700;                                      // нижняя граница по у

                int stepX = (endX - startX) / 2;                       // шаг по х
                int stepY = (endY - startY) / 15;                      // шаг по у

                int currX = startX;
                int currY = startY;

                // вывод текстбоксов
                for (int i = 0; i < linesMatrix.GetLength(0); i++)
                {
                    for (int j = 0; j < linesMatrix.GetLength(1); j++)
                    {
                        linesMatrix[i, j]          = new TextBox();
                        linesMatrix[i, j].Location = new Point(currX, currY);
                        linesMatrix[i, j].Size     = new Size(100, 30);
                        //matrix[i, j].Show();
                        Controls.Add(linesMatrix[i, j]);

                        if (j == 0)
                        {
                            currX += stepX;
                        }
                        else
                        {
                            currY += stepY;
                            currX  = startX;
                        }
                    }
                }
            }
        }
Beispiel #24
0
        private void Initial_Control_Arrays()
        {
            for (int i = 0; i < numUDGainsArray.GetLength(0); i++)
            {
                for (int j = 0; j < numUDGainsArray.GetLength(1); j++)
                {
                    // instance the control
                    numUDGainsArray[i, j] = new NumericUpDown();
                    lbGainsArray[i, j]    = new Label();
                    // set some initial properties
                    numUDGainsArray[i, j].Name      = "numUD" + GainsName.ElementAt(j).Replace(" ", "_") + AxisName.ElementAt(i).Replace(" ", "_");
                    lbGainsArray[i, j].Name         = "lb" + GainsName.ElementAt(j).Replace(" ", "_") + AxisName.ElementAt(i).Replace(" ", "_");
                    numUDGainsArray[i, j].TextAlign = HorizontalAlignment.Right;
                    numUDGainsArray[i, j].TabIndex  = (20 + (i * 13) + j); //"";
                    lbGainsArray[i, j].Text         = GainsName.ElementAt(j) + AxisName.ElementAt(i) + ":";
                    // add to form
                    this.Controls.Add(numUDGainsArray[i, j]);
                    this.Controls.Add(lbGainsArray[i, j]);
                    numUDGainsArray[i, j].Parent = gbGains;
                    lbGainsArray[i, j].Parent    = gbGains;
                    // set position and size
                    numUDGainsArray[i, j].Size      = new Size(50, 25);
                    numUDGainsArray[i, j].Location  = new Point(150 + i * 190, 20 + j * 28);
                    lbGainsArray[i, j].Size         = new Size(130, 25);
                    lbGainsArray[i, j].Location     = new Point(20 + i * 190, 25 + j * 28);
                    numUDGainsArray[i, j].Leave    += new System.EventHandler(this.GainsArrayLeave);
                    numUDGainsArray[i, j].KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.GainsArrayKeyPress);
                }
            }

            for (int i = 0; i < tboxPIDArray.GetLength(0); i++)
            {
                for (int j = 0; j < tboxPIDArray.GetLength(1); j++)
                {
                    tboxPIDArray[i, j]           = new TextBox();
                    lbPIDArray[i, j]             = new Label();
                    tboxPIDArray[i, j].Name      = "tbox" + PIDName.ElementAt(j).Replace(" ", "_") + AxisName.ElementAt(i).Replace(" ", "_");
                    lbPIDArray[i, j].Name        = "lb" + PIDName.ElementAt(j).Replace(" ", "_") + AxisName.ElementAt(i).Replace(" ", "_");
                    lbPIDArray[i, j].Text        = PIDName.ElementAt(j) + AxisName.ElementAt(i) + ":";
                    tboxPIDArray[i, j].TextAlign = HorizontalAlignment.Right;
                    tboxPIDArray[i, j].Text      = "0.00";
                    this.Controls.Add(tboxPIDArray[i, j]);
                    this.Controls.Add(lbPIDArray[i, j]);
                    tboxPIDArray[i, j].Parent   = gbPID;
                    lbPIDArray[i, j].Parent     = gbPID;
                    tboxPIDArray[i, j].TabIndex = (60 + (i * 5) + j);
                    // set position and size
                    tboxPIDArray[i, j].Size      = new Size(40, 25);
                    tboxPIDArray[i, j].Location  = new Point(100 + i * 135, 20 + j * 30);
                    lbPIDArray[i, j].Size        = new Size(80, 25);
                    lbPIDArray[i, j].Location    = new Point(10 + i * 140, 22 + j * 30);
                    tboxPIDArray[i, j].Leave    += new System.EventHandler(this.PIDArrayLeave);
                    tboxPIDArray[i, j].KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.PIDArrayKeyPress);
                }
            }
        }
Beispiel #25
0
 private void show_numbers(TextBox[,] matrix, int[,] numbers)
 {
     for (int i = 0; i < matrix.GetLength(0); i++)
     {
         for (int j = 0; j < matrix.GetLength(1); j++)
         {
             matrix[i, j].Text = numbers[i, j].ToString();
         }
     }
 }
Beispiel #26
0
 private void ClearTextBoxes(TextBox[,] textBoxes)
 {
     for (int i = 0; i < textBoxes.GetLength(0); i++)
     {
         for (int j = 0; j < textBoxes.GetLength(1); j++)
         {
             textBoxes[i, j].Text = "";
         }
     }
 }
Beispiel #27
0
 public void Clear(TextBox[,] Cell) //Clears the entries of the matrix
 {
     for (int i = 0; i < Cell.GetLength(1); i++)
     {
         for (int j = 0; j < Cell.GetLength(0); j++)
         {
             Cell[j, i].Text = "";
         }
     }
 }
Beispiel #28
0
 public void Remove(TextBox[,] Cell)             //Removes the dynamically created textboxes
 {
     for (int i = 0; i < Cell.GetLength(1); i++) //GetLength(1) = Col
     {
         for (int j = 0; j < Cell.GetLength(0); j++)
         {
             this.Controls.Remove(Cell[j, i]);
         }
     }
 }
        public override bool podeCalcular(TextBox[,] matriz1, TextBox[,] matriz2)
        {
            if (matriz1.GetLength(0) != matriz2.GetLength(0) || matriz1.GetLength(1) != matriz2.GetLength(1))
            {
                MessageBox.Show("Tamanho das matrizes tem de ser idêntico.", "Erro na Matriz 3");
                return(false);
            }

            return(true);
        }
        private void btnGeraMultiplica_Click(object sender, EventArgs e)
        {
            if (Matriz == null || MatrizResultante == null)
            {
                MessageBox.Show("Matriz nula !", "Error - Matriz");
                return;
            }
            float[,] tempMatriz           = new float[Matriz.GetLength(0), Matriz.GetLength(1)];
            float[,] tempMatrizResultante = new float[MatrizResultante.GetLength(0), MatrizResultante.GetLength(1)];
            if (tempMatriz.GetLength(1) != tempMatrizResultante.GetLength(0))
            {
                MessageBox.Show("So e possivel a multiplicacao de matrizes onde a coluna da matriz 1 e igual a linha da matriz 2!", "Erro - Multiplicacao Matrizes");
                return;
            }

            for (int x = 0; x < Matriz.GetLength(0); x++)
            {
                for (int y = 0; y < Matriz.GetLength(1); y++)
                {
                    float n = 0;
                    float.TryParse(Matriz[x, y].Text, out n);
                    tempMatriz[x, y] = n;
                }
            }
            matrix = new Matriz(tempMatriz);
            for (int x = 0; x < MatrizResultante.GetLength(0); x++)
            {
                for (int y = 0; y < MatrizResultante.GetLength(1); y++)
                {
                    float n = 0;
                    float.TryParse(MatrizResultante[x, y].Text, out n);
                    tempMatrizResultante[x, y] = n;
                }
            }
            result = new Matriz(tempMatrizResultante);

            float[,] tempMatrizResultado = matrix.Multiplicacao(tempMatrizResultante);
            MatrizResultado = new TextBox[tempMatrizResultante.GetLength(0), tempMatrizResultante.GetLength(1)];
            int TamanhoText = groupBoxResultante.Width;

            groupBoxResultante.Controls.Clear();
            for (int x = 0; x < MatrizResultado.GetLength(0); x++)
            {
                for (int y = 0; y < MatrizResultado.GetLength(1); y++)
                {
                    MatrizResultado[x, y]       = new TextBox();
                    MatrizResultado[x, y].Text  = tempMatrizResultado[x, y].ToString();
                    MatrizResultado[x, y].Top   = (x * MatrizResultado[x, y].Height) + 20;
                    MatrizResultado[x, y].Left  = y * TamanhoText + 6;
                    MatrizResultado[x, y].Width = TamanhoText;
                    groupBoxResultante.Controls.Add(MatrizResultado[x, y]);
                }
            }
            groupBoxMatriz.Controls.Clear();
        }
        private void btnCriarMatriz2_Click(object sender, EventArgs e)
        {
            groupBoxMatriz2.Controls.Clear();
                /*if (textBox2.Text == null)
                {
                    MessageBox.Show("A linha da matriz 2 é nula.", "Erro");
                    return;
                }

                if (textBox4.Text == null)
                {
                    MessageBox.Show("A coluna da matriz 2 é nula.", "Erro");
                    return;
                }
            linha2 = Convert.ToInt32(textBox2.Text);
            coluna2 = Convert.ToInt32(textBox4.Text);*/
            if (!int.TryParse(textBox2.Text, out linha2))
            {
                MessageBox.Show("A linha da matriz 2 é nula.", "Erro");
                return;
            }
            if (!int.TryParse(textBox4.Text, out coluna2))
            {
                MessageBox.Show("A coluna da matriz 2 é nula.", "Erro");
                return;
            }
            int TamanhoText = groupBoxMatriz2.Width / coluna2;
            Matriz2 = new TextBox[linha2, coluna2];
            TamanhoText = groupBoxMatriz2.Width / coluna2;
            for (int x = 0; x < Matriz2.GetLength(0); x++)
            {
                for (int y = 0; y < Matriz2.GetLength(1); y++)
                {
                    Matriz2[x, y] = new TextBox();
                    Matriz2[x, y].Text = "0";
                    Matriz2[x, y].Top = (x * Matriz2[x, y].Height) + 20;
                    Matriz2[x, y].Left = y * TamanhoText + 6;
                    Matriz2[x, y].Width = TamanhoText;
                    groupBoxMatriz2.Controls.Add(Matriz2[x, y]);
                }
            }
        }
        private void Criar_Matriz(object sender, EventArgs e)
        {
            int linha = Int16.Parse(Linhas1.Text);
            int coluna = Int16.Parse(Colunas1.Text);

            Matriz = new TextBox[linha, coluna];

            for (i = 0; i < Matriz.GetLength(0); i++)
            {
                for (j = 0; j < Matriz.GetLength(1); j++)
                {
                    Matriz[i, j] = new TextBox();
                    Matriz[i, j].Text = "0";
                    Matriz[i, j].Top = (i * Matriz[i, j].Height) + 100;
                    Matriz[i, j].Left = j * 35 + 15;
                    Matriz[i, j].Width = 30;
                    this.Controls.Add(Matriz[i, j]);
                }
            }
        }
        private void btnGerarTranspostM2_Click(object sender, EventArgs e)
        {
            if (Matriz2 == null)
            {
                MessageBox.Show("Matriz nula !", "Error - Matriz");
                return;
            }
            float[,] tempResultante = new float[Matriz2.GetLength(0), Matriz2.GetLength(1)];

            for (int x = 0; x < Matriz2.GetLength(0); x++)
            {
                for (int y = 0; y < Matriz2.GetLength(1); y++)
                {
                    float n = 0;
                    float.TryParse(Matriz2[x, y].Text, out n);
                    tempResultante[x, y] = n;
                    //tempResultante[x, y] = Convert.ToInt32(Matriz2[x, y].Text);
                }
            }

            float[,] tempMatrizResultante = CalculosMatrizes.GerarTransposta(tempResultante);
            int TamanhoText = groupBoxMatriz2.Width / Matriz2.GetLength(1);
            Matriz2 = new TextBox[tempMatrizResultante.GetLength(0), tempMatrizResultante.GetLength(1)];
            groupBoxMatriz2.Controls.Clear();
            for (int x = 0; x < Matriz2.GetLength(0); x++)
            {
                for (int y = 0; y < Matriz2.GetLength(1); y++)
                {
                    Matriz2[x, y] = new TextBox();
                    Matriz2[x, y].Text = tempMatrizResultante[x, y].ToString();
                    Matriz2[x, y].Top = (x * Matriz2[x, y].Height) + 20;
                    Matriz2[x, y].Left = y * TamanhoText + 6;
                    Matriz2[x, y].Width = TamanhoText;
                    groupBoxMatriz2.Controls.Add(Matriz2[x, y]);
                }
            }
        }
        private void MinButton_Click(object sender, EventArgs e)
        {
            linhaResposta = linha1;
            colunaResposta = coluna1;

            if (MatrixR != null)
            {
                for (int i = 0; i < MatrixR.GetLength(0); i++)
                {
                    for (int j = 0; j < MatrixR.GetLength(1); j++)
                    {
                        if (MatrixR[i, j] != null)
                            this.Controls.Remove(MatrixR[i, j]);
                    }
                }
            }

            MatrixR = new TextBox[linhaResposta, colunaResposta];

            if (linha1 == linha2 && coluna2 == coluna1)
            {
                for (int i = 0; i < MatrixR.GetLength(0); i++)
                {
                    for (int j = 0; j < MatrixR.GetLength(0); j++)
                    {
                        MatrixR[i, j] = new TextBox();
                        MatrixR[i, j].Text = Convert.ToString(Convert.ToInt32(Matrix1[i, j].Text) - Convert.ToInt32(Matrix2[i, j].Text));
                        MatrixR[i, j].Top = (i * MatrixR[i, j].Height) + 180;
                        MatrixR[i, j].Left = (j * 35) + 245;
                        MatrixR[i, j].Width = 30;
                        this.Controls.Add(MatrixR[i, j]);
                    }

                }

            }
        }
        private void lineUpDown3_ValueChanged(object sender, EventArgs e)
        {
            matrixBox3.Controls.Clear();

            int linha, coluna;
            linha = Convert.ToInt32(lineUpDown3.Value);
            coluna = Convert.ToInt32(columnUpDown3.Value);

            Matriz_3 = new TextBox[linha, coluna];

            for (int i = 0; i < Matriz_3.GetLength(0); i++)
            {
                for (int j = 0; j < Matriz_3.GetLength(1); j++)
                {
                    Matriz_3[i, j] = new TextBox();
                    Matriz_3[i, j].Text = "0";
                    Matriz_3[i, j].Top = (i * Matriz_3[i, j].Height) + 100;
                    Matriz_3[i, j].Left = j * 35 + 15;
                    Matriz_3[i, j].Width = 30;
                    this.matrixBox3.Controls.Add(Matriz_3[i, j]);
                }
            }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            matrixBox1.Controls.Clear();

            int linha, coluna;
            linha = Convert.ToInt32(lineUpDown1.Value);
            coluna = Convert.ToInt32(columnUpDown1.Value);

            Matriz = new TextBox[linha, coluna];

            for (int i = 0; i < Matriz.GetLength(0); i++)
            {
                for (int j = 0; j < Matriz.GetLength(1); j++)
                {
                    Matriz[i, j] = new TextBox();
                    Matriz[i, j].Text = "0";
                    Matriz[i, j].Top = (i * Matriz[i, j].Height) + 100;
                    Matriz[i, j].Left = j * 35 + 15;
                    Matriz[i, j].Width = 30;
                    this.matrixBox1.Controls.Add(Matriz[i, j]);
                }
            }

            matrixBox2.Controls.Clear();

            linha = Convert.ToInt32(lineUpDown2.Value);
            coluna = Convert.ToInt32(columnUpDown2.Value);

            Matriz_2 = new TextBox[linha, coluna];

            for (int i = 0; i < Matriz_2.GetLength(0); i++)
            {
                for (int j = 0; j < Matriz_2.GetLength(1); j++)
                {
                    Matriz_2[i, j] = new TextBox();
                    Matriz_2[i, j].Text = "0";
                    Matriz_2[i, j].Top = (i * Matriz_2[i, j].Height) + 100;
                    Matriz_2[i, j].Left = j * 35 + 15;
                    Matriz_2[i, j].Width = 30;
                    this.matrixBox2.Controls.Add(Matriz_2[i, j]);
                }
            }

            matrixBox3.Controls.Clear();

            linha = Convert.ToInt32(lineUpDown3.Value);
            coluna = Convert.ToInt32(columnUpDown3.Value);

            Matriz_3 = new TextBox[linha, coluna];

            for (int i = 0; i < Matriz_3.GetLength(0); i++)
            {
                for (int j = 0; j < Matriz_3.GetLength(1); j++)
                {
                    Matriz_3[i, j] = new TextBox();
                    Matriz_3[i, j].Text = "0";
                    Matriz_3[i, j].Top = (i * Matriz_3[i, j].Height) + 100;
                    Matriz_3[i, j].Left = j * 35 + 15;
                    Matriz_3[i, j].Width = 30;
                    this.matrixBox3.Controls.Add(Matriz_3[i, j]);
                }
            }

            matrixBox4.Controls.Clear();

            linha = Convert.ToInt32(lineUpDown4.Value);
            coluna = Convert.ToInt32(columnUpDown4.Value);

            Matriz_4 = new TextBox[linha, coluna];

            for (int i = 0; i < Matriz_4.GetLength(0); i++)
            {
                for (int j = 0; j < Matriz_4.GetLength(1); j++)
                {
                    Matriz_4[i, j] = new TextBox();
                    Matriz_4[i, j].Text = "0";
                    Matriz_4[i, j].Top = (i * Matriz[i, j].Height) + 100;
                    Matriz_4[i, j].Left = j * 35 + 15;
                    Matriz_4[i, j].Width = 30;
                    this.matrixBox4.Controls.Add(Matriz_4[i, j]);
                }
            }

            matrixBox5.Controls.Clear();

            linha = Convert.ToInt32(lineUpDown5.Value);
            coluna = Convert.ToInt32(columnUpDown5.Value);

            Matriz_5 = new TextBox[linha, coluna];

            for (int i = 0; i < Matriz_5.GetLength(0); i++)
            {
                for (int j = 0; j < Matriz_5.GetLength(1); j++)
                {
                    Matriz_5[i, j] = new TextBox();
                    Matriz_5[i, j].Text = "0";
                    Matriz_5[i, j].Top = (i * Matriz[i, j].Height) + 100;
                    Matriz_5[i, j].Left = j * 35 + 15;
                    Matriz_5[i, j].Width = 30;
                    this.matrixBox5.Controls.Add(Matriz_5[i, j]);
                }
            }
        }
Beispiel #37
0
        /// <summary>
        /// Generates the textboxes for the form. Needed for Sudoku game (and to display the other basic grids).
        /// </summary>
        private void CreateTextboxes()
        {
            //For a 9 x 9 Sudoku.
            const int AMOUNT = 9;
            textboxes = new TextBox[AMOUNT, AMOUNT];
            Panel[,] panels = new Panel[AMOUNT, AMOUNT]; //For a nicer looking GUI behind the textboxes.

            for (int i = 0; i < textboxes.GetLength(0); i++)
                for (int j = 0; j < textboxes.GetLength(1); j++)
                {
                    panels[i, j] = new Panel();

                    //Sets up the positioning and size of the panels onto the form.
                    //Checks if the beginning of a 3 by 3 grid's row of the sudoku has been reached and if so, makes the panels sides wider apart.
                    if (j >= 6)
                        panels[i, j].Left = 6;
                    else if (j >= 3)
                        panels[i, j].Left = 3;

                    panels[i, j].Left += 5 + 60 * j; //leftStartingPoint + distanceFromPreviousPanel.

                    //Checks if the beginning of a 3 by 3 grid's row of the sudoku has been reached and if so, makes the panels tops wider apart.
                    if (i >= 6)
                        panels[i, j].Top = 6;
                    else if (i >= 3)
                        panels[i, j].Top = 3;

                    panels[i, j].Top += 6 + 62 * i; //topStartingPoint + distanceFromPreviousPanel.
                    panels[i, j].Width = 57;
                    panels[i, j].Height = 59;
                    panels[i, j].Name = "panel " + i + "_" + j;
                    panels[i, j].BackColor = Color.MistyRose;
                    panel1.Controls.Add(panels[i, j]);

                    textboxes[i, j] = new TextBox();

                    //Sets up the positioning and size of the textboxes onto the form.
                    textboxes[i, j].Left = 3;
                    textboxes[i, j].Top = 5;
                    textboxes[i, j].Width = 51;
                    textboxes[i, j].Height = 49;
                    textboxes[i, j].Name = "txt " + i + "_" + j;

                    //Sets up misc. settings for how the textbox is.
                    textboxes[i, j].Multiline = true;
                    textboxes[i, j].MaxLength = 1;
                    textboxes[i, j].TextAlign = HorizontalAlignment.Center;
                    textboxes[i, j].Enabled = false;
                    textboxes[i, j].BackColor = Color.LightPink;

                    Font test = new Font(FontFamily.GenericSansSerif, 29);
                    textboxes[i, j].Font = test;

                    textboxes[i, j].KeyPress += new KeyPressEventHandler(NumbersOnly_KeyPress); //Stops crap from being entered.
                    textboxes[i, j].TextChanged += new EventHandler(Textboxes_TextChanged); //Checks if the user is done playing, if they sucessfully completed the sudoku, and also utilizes the hint system.
                    panels[i, j].Controls.Add(textboxes[i, j]);
                }
        }
        private void btnSomar_Click(object sender, EventArgs e)
        {
            if (Matriz1 == null || Matriz2 == null)
            {
                MessageBox.Show("Matriz nula !", "Error - Matriz");
                return;
            }
            float[,] tempMatriz1 = new float[Matriz1.GetLength(0), Matriz1.GetLength(1)];
            float[,] tempMatriz2 = new float[Matriz2.GetLength(0), Matriz2.GetLength(1)];
            if (tempMatriz1.GetLength(0) != tempMatriz2.GetLength(0) || tempMatriz1.GetLength(1) != tempMatriz2.GetLength(1))
            {
                MessageBox.Show("So e possivel a soma de matrizes de mesma ordem !", "Erro - Soma Matrizes");
                return;
            }

            for (int x = 0; x < Matriz1.GetLength(0); x++)
            {
                for (int y = 0; y < Matriz1.GetLength(1); y++)
                {
                    float n = 0;
                    float.TryParse(Matriz1[x, y].Text, out n);
                    tempMatriz1[x, y] = n;
                    //tempMatriz1[x, y] = Convert.ToInt32(Matriz1[x, y].Text);
                }
            }
            for (int x = 0; x < Matriz2.GetLength(0); x++)
            {
                for (int y = 0; y < Matriz2.GetLength(1); y++)
                {
                    float n = 0;
                    float.TryParse(Matriz2[x, y].Text, out n);
                    tempMatriz2[x, y] = n;
                    //tempMatriz2[x, y] = Convert.ToInt32(Matriz2[x, y].Text);
                }
            }

            float[,] tempMatrizResultante = CalculosMatrizes.SomarMatrizes(tempMatriz1, tempMatriz2);
            MatrizResultante = new TextBox[tempMatrizResultante.GetLength(0), tempMatrizResultante.GetLength(1)];
            int TamanhoText = groupBoxMatrizResultante.Width / MatrizResultante.GetLength(1);
            groupBoxMatrizResultante.Controls.Clear();
            for (int x = 0; x < MatrizResultante.GetLength(0); x++)
            {
                for (int y = 0; y < MatrizResultante.GetLength(1); y++)
                {
                    MatrizResultante[x, y] = new TextBox();
                    MatrizResultante[x, y].Text = tempMatrizResultante[x, y].ToString();
                    MatrizResultante[x, y].Top = (x * MatrizResultante[x, y].Height) + 20;
                    MatrizResultante[x, y].Left = y * TamanhoText + 6;
                    MatrizResultante[x, y].Width = TamanhoText;
                    groupBoxMatrizResultante.Controls.Add(MatrizResultante[x, y]);
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
           
            groupBox1.Controls.Clear();
            /*if (textBox1.Text == "0" || textBox1.Text == "" || textBox2.Text == "0" || textBox2.Text == "")
            {
                return;
            }*/
            if (comboBox1.SelectedItem == null && comboBox2.SelectedItem == null)
            {
                MessageBox.Show("Por favor selecione o número de linhas e de colunas ");
                return;
            }
            if(comboBox1.SelectedItem == null || comboBox2.SelectedItem == null)
            {
                MessageBox.Show("Por favor selecione o número de linhas e de colunas ");
                return;
            }
            linhas = Convert.ToInt32(comboBox1.SelectedItem.ToString());

            colunas = Convert.ToInt32(comboBox2.SelectedItem.ToString());
            int TamanhoText = groupBox1.Width / colunas;
            if (linhas > 10 || colunas > 10)
            {
                return;
            }

            matriz = new TextBox[linhas, colunas];

            for (int x = 0; x < matriz.GetLength(0); x++)
            {
                for (int y = 0; y < matriz.GetLength(1); y++)
                {
                    matriz[x, y] = new TextBox();
                    matriz[x, y].Text = "0";
                    matriz[x, y].KeyPress += new KeyPressEventHandler(keypressed);
                    matriz[x, y].TextAlign = HorizontalAlignment.Center;
                    matriz[x, y].Top = (x * matriz[x, y].Height) + 20;
                    matriz[x, y].Left = y * TamanhoText;
                    matriz[x, y].Width = TamanhoText;
                    groupBox1.Controls.Add(matriz[x, y]);




                }
            }
        }
        private void button3_Click(object sender, EventArgs e)
        {
            if(comboBox5.SelectedItem == null)
            {
                MessageBox.Show("Selecione alguma operação");
                return;
            }
            if (comboBox5.SelectedItem.ToString() == "Adição")
            {
                radioButton3.Visible = true;
                groupBox3.Enabled = true;
                if (groupBox1.Controls.Count == 0 || groupBox2.Controls.Count == 0)
                {
                    return;
                }
                float[,] tempMatriz1 = new float[matriz.GetLength(0), matriz.GetLength(1)];
                float[,] tempMatriz2 = new float[matriz2.GetLength(0), matriz2.GetLength(1)];
                if (tempMatriz1.GetLength(0) != tempMatriz2.GetLength(0) || tempMatriz1.GetLength(1) != tempMatriz2.GetLength(1))
                {
                    MessageBox.Show("So e possivel a soma de matrizes de mesma ordem !", "Erro - Soma Matrizes");
                    return;
                }



                for (int x = 0; x < matriz.GetLength(0); x++)
                {

                    for (int y = 0; y < matriz.GetLength(1); y++)
                    {

                        float n = 0;
                        float.TryParse(matriz[x, y].Text, out n);
                        tempMatriz1[x, y] = n;


                    }
                }
                for (int x = 0; x < matriz2.GetLength(0); x++)
                {
                    for (int y = 0; y < matriz2.GetLength(1); y++)
                    {

                        float n = 0;
                        float.TryParse(matriz2[x, y].Text, out n);
                        tempMatriz2[x, y] = n;


                    }
                }
                
                float[,] tempMatrizResultante = Calculos.SomarMatrizes(tempMatriz1, tempMatriz2);
                resultante = new TextBox[tempMatrizResultante.GetLength(0), tempMatrizResultante.GetLength(1)];
                int TamanhoText = groupBox3.Width / resultante.GetLength(1);
                groupBox3.Controls.Clear();
                for (int x = 0; x < resultante.GetLength(0); x++)
                {
                    for (int y = 0; y < resultante.GetLength(1); y++)
                    {
                        resultante[x, y] = new TextBox();
                        resultante[x, y].KeyPress += new KeyPressEventHandler(keypressed);
                        resultante[x, y].TextAlign = HorizontalAlignment.Center;
                        resultante[x, y].Text = tempMatrizResultante[x, y].ToString();
                        resultante[x, y].Top = (x * resultante[x, y].Height) + 20;
                        resultante[x, y].Left = y * TamanhoText;
                        resultante[x, y].Width = TamanhoText;
                        groupBox3.Controls.Add(resultante[x, y]);
                    }
                }

            }
            ////
            if (comboBox5.SelectedItem.ToString() == "Subtração")
            {
                radioButton3.Visible = true;
                groupBox3.Enabled = true;
                if (groupBox1.Controls.Count == 0 || groupBox2.Controls.Count == 0)
                {
                    return;
                }
                float[,] tempMatriz1 = new float[matriz.GetLength(0), matriz.GetLength(1)];
                float[,] tempMatriz2 = new float[matriz2.GetLength(0), matriz2.GetLength(1)];
                if (tempMatriz1.GetLength(0) != tempMatriz2.GetLength(0) || tempMatriz1.GetLength(1) != tempMatriz2.GetLength(1))
                {
                    MessageBox.Show("So e possivel a soma de matrizes de mesma ordem !", "Erro - Soma Matrizes");
                    return;
                }



                for (int x = 0; x < matriz.GetLength(0); x++)
                {

                    for (int y = 0; y < matriz.GetLength(1); y++)
                    {

                        float n = 0;
                        float.TryParse(matriz[x, y].Text, out n);
                        tempMatriz1[x, y] = n;


                    }
                }
                for (int x = 0; x < matriz2.GetLength(0); x++)
                {
                    for (int y = 0; y < matriz2.GetLength(1); y++)
                    {

                        float n = 0;
                        float.TryParse(matriz2[x, y].Text, out n);
                        tempMatriz2[x, y] = n;


                    }
                }

                float[,] tempMatrizResultante = Calculos.SubtrairMatrizes(tempMatriz1, tempMatriz2);
                 resultante = new TextBox[tempMatrizResultante.GetLength(0), tempMatrizResultante.GetLength(1)];
                int TamanhoText = groupBox3.Width / resultante.GetLength(1);
                groupBox3.Controls.Clear();
                for (int x = 0; x < resultante.GetLength(0); x++)
                {
                    for (int y = 0; y < resultante.GetLength(1); y++)
                    {
                        resultante[x, y] = new TextBox();
                        resultante[x, y].KeyPress += new KeyPressEventHandler(keypressed);
                        resultante[x, y].TextAlign = HorizontalAlignment.Center;
                        resultante[x, y].Text = tempMatrizResultante[x, y].ToString();
                        resultante[x, y].Top = (x * resultante[x, y].Height) + 20;
                        resultante[x, y].Left = y * TamanhoText;
                        resultante[x, y].Width = TamanhoText;
                        groupBox3.Controls.Add(resultante[x, y]);
                    }
                }

            }
            if (comboBox5.SelectedItem.ToString() == "Multiplicação")
            {
                radioButton3.Visible = true;
                groupBox3.Enabled = true;
                if (groupBox1.Controls.Count == 0 || groupBox2.Controls.Count == 0)
                {
                    return;
                }
                float[,] tempMatriz1 = new float[matriz.GetLength(0), matriz.GetLength(1)];
                float[,] tempMatriz2 = new float[matriz2.GetLength(0), matriz2.GetLength(1)];




                for (int x = 0; x < matriz.GetLength(0); x++)
                {

                    for (int y = 0; y < matriz.GetLength(1); y++)
                    {

                        float n = 0;
                        float.TryParse(matriz[x, y].Text, out n);
                        tempMatriz1[x, y] = n;


                    }
                }
                for (int x = 0; x < matriz2.GetLength(0); x++)
                {
                    for (int y = 0; y < matriz2.GetLength(1); y++)
                    {

                        float n = 0;
                        float.TryParse(matriz2[x, y].Text, out n);
                        tempMatriz2[x, y] = n;


                    }
                }

                float[,] tempMatrizResultante = Calculos.MultiplicarMatrizes(tempMatriz1, tempMatriz2);
                resultante = new TextBox[tempMatrizResultante.GetLength(0), tempMatrizResultante.GetLength(1)];
                int TamanhoText = groupBox3.Width / resultante.GetLength(1);
                groupBox3.Controls.Clear();
                for (int x = 0; x < resultante.GetLength(0); x++)
                {
                    for (int y = 0; y < resultante.GetLength(1); y++)
                    {
                        resultante[x, y] = new TextBox();
                        resultante[x, y].KeyPress += new KeyPressEventHandler(keypressed);
                        resultante[x, y].TextAlign = HorizontalAlignment.Center;
                        resultante[x, y].Text = tempMatrizResultante[x, y].ToString();
                        resultante[x, y].Top = (x * resultante[x, y].Height) + 20;
                        resultante[x, y].Left = y * TamanhoText;
                        resultante[x, y].Width = TamanhoText;
                        groupBox3.Controls.Add(resultante[x, y]);
                    }
                }

            }

            //////////////////////////
            if (radioButton1.Checked == true)
            {
                ///MatirzFormula
                if (comboBox5.SelectedItem.ToString() == "GerarMatrizAtravésDeFormula")
                {

                    MessageBox.Show("Digite a formula na caixa que apareceu na parte de baixo da calculadora, com qual você quer que seja gerada   a matriz 1");
                    label14.Visible = true;
                    textBox4.Visible = true;
                    button9.Visible = true;



                }
                else if (comboBox5.SelectedItem.ToString() != "GerarMatrizAtravésDeFormula")
                {
                    label14.Visible = false;
                    textBox4.Visible = false;
                    button9.Visible = false;

                }
                ///Multiplicação por número real
                if (comboBox5.SelectedItem.ToString() == "Multiplicação Por Número Real") 
                {
                    if (matriz == null)
                    {
                        MessageBox.Show("Primeiro você deve gerar a matriz");
                        return;
                    }
                    MessageBox.Show("Digite o valor na caixa que apareceu abaixo da matriz 1, com qual você quer que seja multiplicado a matriz 1");
                    label11.Visible = true;
                    textBox1.Visible = true;
                    button6.Visible = true;
                   
                     

                }
                else if (comboBox5.SelectedItem.ToString() != "Multiplicação Por Número Real")
                {
                    textBox1.Text = "";
                    textBox2.Text = "";
                    textBox3.Text = "";
                    label11.Visible = false;
                    textBox1.Visible = false;
                    button6.Visible = false;
                    label12.Visible= false;
                    textBox2.Visible = false;
                    button7.Visible = false;
                    label13.Visible = false;
                    textBox3.Visible = false;
                    button8.Visible = false;
                
                }
                if (comboBox5.SelectedItem.ToString() == "Transposta")
                {
                    if (matriz == null)
                    {
                        MessageBox.Show("Primeiro você deve gerar a matriz");
                        return;
                    }
                    groupBox1.Controls.Clear();
                    float[,] tempMatriz1 = new float[matriz.GetLength(0), matriz.GetLength(1)];
                    //float[,] tempMatriz2 = new float[matriz2.GetLength(0), matriz2.GetLength(1)];
                    //if (tempMatriz1.GetLength(0) != tempMatriz2.GetLength(0) || tempMatriz1.GetLength(1) != tempMatriz2.GetLength(1))
                    /*{
                        MessageBox.Show("So e possivel a soma de matrizes de mesma ordem !", "Erro - Soma Matrizes");
                        return;
                    }*/



                    for (int x = 0; x < matriz.GetLength(0); x++)
                    {

                        for (int y = 0; y < matriz.GetLength(1); y++)
                        {

                            float n = 0;
                            float.TryParse(matriz[x, y].Text, out n);
                            tempMatriz1[x, y] = n;


                        }
                    }
                    /* for (int x = 0; x < matriz2.GetLength(0); x++)
                     {
                         for (int y = 0; y < matriz2.GetLength(1); y++)
                         {

                             float n = 0;
                             float.TryParse(matriz2[x, y].Text, out n);
                             tempMatriz2[x, y] = n;


                         }
                     }*/

                    float[,] tempMatrizResultante = Calculos.Transposta1(tempMatriz1);
                    matriz = new TextBox[tempMatrizResultante.GetLength(0), tempMatrizResultante.GetLength(1)];
                    int TamanhoText = groupBox1.Width / matriz.GetLength(1);

                    for (int x = 0; x < matriz.GetLength(0); x++)
                    {
                        for (int y = 0; y < matriz.GetLength(1); y++)
                        {
                            matriz[x, y] = new TextBox();
                            matriz[x, y].KeyPress += new KeyPressEventHandler(keypressed);
                            matriz[x, y].TextAlign = HorizontalAlignment.Center;
                            matriz[x, y].Text = tempMatrizResultante[x, y].ToString();
                            matriz[x, y].Top = (x * matriz[x, y].Height) + 20;
                            matriz[x, y].Left = y * TamanhoText;
                            matriz[x, y].Width = TamanhoText;
                            groupBox1.Controls.Add(matriz[x, y]);
                        }
                    }


                }
                if (comboBox5.SelectedItem.ToString() == "Oposta")
                {
                    groupBox1.Controls.Clear();
                    if (matriz == null)
                    {
                        MessageBox.Show("Primeiro você deve gerar a matriz");
                        return;
                    }
                    float[,] tempMatriz1 = new float[matriz.GetLength(0), matriz.GetLength(1)];
                    //float[,] tempMatriz2 = new float[matriz2.GetLength(0), matriz2.GetLength(1)];
                    //if (tempMatriz1.GetLength(0) != tempMatriz2.GetLength(0) || tempMatriz1.GetLength(1) != tempMatriz2.GetLength(1))
                    /*{
                        MessageBox.Show("So e possivel a soma de matrizes de mesma ordem !", "Erro - Soma Matrizes");
                        return;
                    }*/



                    for (int x = 0; x < matriz.GetLength(0); x++)
                    {

                        for (int y = 0; y < matriz.GetLength(1); y++)
                        {

                            float n = 0;
                            float.TryParse(matriz[x, y].Text, out n);
                            tempMatriz1[x, y] = n;


                        }
                    }
                    /* for (int x = 0; x < matriz2.GetLength(0); x++)
                     {
                         for (int y = 0; y < matriz2.GetLength(1); y++)
                         {

                             float n = 0;
                             float.TryParse(matriz2[x, y].Text, out n);
                             tempMatriz2[x, y] = n;


                         }
                     }*/

                    float[,] tempMatrizResultante = Calculos.Oposta(tempMatriz1);
                    matriz = new TextBox[tempMatrizResultante.GetLength(0), tempMatrizResultante.GetLength(1)];
                    int TamanhoText = groupBox1.Width / matriz.GetLength(1);

                    for (int x = 0; x < matriz.GetLength(0); x++)
                    {
                        for (int y = 0; y < matriz.GetLength(1); y++)
                        {
                            matriz[x, y] = new TextBox();
                            matriz[x, y].KeyPress += new KeyPressEventHandler(keypressed);
                            matriz[x, y].TextAlign = HorizontalAlignment.Center;
                            matriz[x, y].Text = tempMatrizResultante[x, y].ToString();
                            matriz[x, y].Top = (x * matriz[x, y].Height) + 20;
                            matriz[x, y].Left = y * TamanhoText;
                            matriz[x, y].Width = TamanhoText;
                            groupBox1.Controls.Add(matriz[x, y]);
                        }
                    }
                }
                string value;
                if (comboBox5.SelectedItem.ToString() == "Determinate")
                {
                    if (matriz == null)
                    {
                        MessageBox.Show("Primeiro você deve gerar a matriz");
                        return;
                    }

                    if (comboBox1.SelectedItem.ToString() != comboBox2.SelectedItem.ToString())
                    {
                        return;
                    }
                    else if (comboBox1.SelectedItem.ToString() == comboBox2.SelectedItem.ToString())
                    {

                        //cria uma matriz e seta os valores para serem a da matriz que usaremos
                        double[,] MT = new double[(matriz.GetLength(0)), (matriz.GetLength(1))];
                        for (int i = 0; i < matriz.GetLength(0); i++)
                        {
                            for (int j = 0; j < matriz.GetLength(1); j++)
                            {
                                double n = 0;
                                double.TryParse(matriz[i, j].Text, out n);
                                MT[i, j] = n;
                                matriz[i, j].KeyPress += new KeyPressEventHandler(keypressed);
                            }
                        }
                        // escreve na caixa de texto o retorno da det
                        value = Calculos.DET(MT, int.Parse(comboBox2.SelectedItem.ToString())).ToString();
                        MessageBox.Show( value);
                    }

                  



                }
                if (comboBox5.SelectedItem.ToString() == "Inversa")
                {
                    if (matriz == null)
                    {
                        MessageBox.Show("Primeiro você deve gerar a matriz");
                        return;
                    }
                    double[,] MT = new double[(matriz.GetLength(0)), (matriz.GetLength(1))];
                    for (int i = 0; i < matriz.GetLength(0); i++)
                    {
                        for (int j = 0; j < matriz.GetLength(1); j++)
                        {
                            double n = 0;
                            double.TryParse(matriz[i, j].Text, out n);
                            matriz[i, j].KeyPress += new KeyPressEventHandler(keypressed);
                            MT[i, j] = n;
                        }
                    }
                    double det = Calculos.DET(MT, int.Parse(comboBox1.SelectedItem.ToString()));
                    if (det != 0)
                    {
                        // seta o tamanho da matriz do resultado
                   
                        
                       
                        // pega a inversa e coloca em cada caixa de texto
                        MT = Calculos.Invert(det, MT, int.Parse(comboBox1.SelectedItem.ToString()));
                        for (int i = 0; i < int.Parse(comboBox1.SelectedItem.ToString()); i++)
                        {
                            for (int j = 0; j < int.Parse(comboBox2.SelectedItem.ToString()); j++)
                            {
                                matriz[i, j].Text = MT[i, j].ToString();
                            }
                        }
                    }


                }
                }
               
                if (radioButton2.Checked == true)
                {

                    if (comboBox5.SelectedItem.ToString() == "Multiplicação Por Número Real")
                    {
                        if (matriz2 == null)
                        {
                            MessageBox.Show("Primeiro você deve gerar a matriz");
                            return;
                        }

                        MessageBox.Show("Digite o valor na caixa que apareceu abaixo da matriz 1, com qual você quer que seja multiplicado a matriz 1");
                        label12.Visible = true;
                        textBox2.Visible= true;
                        button7.Visible = true;



                    }
                    else if (comboBox5.SelectedItem.ToString() != "Multiplicação Por Número Real")
                    {
                        textBox1.Text = "";
                        textBox2.Text = "";
                        textBox3.Text = "";
                        label11.Visible = false;
                        textBox1.Visible = false;
                        button6.Visible = false;
                        label12.Visible = false;
                        textBox2.Visible = false;
                        button7.Visible = false;
                        label13.Visible = false;
                        textBox3.Visible = false;
                        button8.Visible = false;

                    }
                    if (comboBox5.SelectedItem.ToString() == "Transposta")
                    {
                        groupBox2.Controls.Clear();
                        if (matriz2 == null)
                        {
                            MessageBox.Show("Primeiro você deve gerar a matriz");
                            return;
                        }
                        float[,] tempMatriz2 = new float[matriz2.GetLength(0), matriz2.GetLength(1)];
                        //float[,] tempMatriz2 = new float[matriz2.GetLength(0), matriz2.GetLength(1)];
                        //if (tempMatriz1.GetLength(0) != tempMatriz2.GetLength(0) || tempMatriz1.GetLength(1) != tempMatriz2.GetLength(1))
                        /*{
                            MessageBox.Show("So e possivel a soma de matrizes de mesma ordem !", "Erro - Soma Matrizes");
                            return;
                        }*/



                        for (int x = 0; x < matriz2.GetLength(0); x++)
                        {

                            for (int y = 0; y < matriz2.GetLength(1); y++)
                            {

                                float n = 0;
                                float.TryParse(matriz2[x, y].Text, out n);
                                tempMatriz2[x, y] = n;


                            }
                        }
                        /* for (int x = 0; x < matriz2.GetLength(0); x++)
                         {
                             for (int y = 0; y < matriz2.GetLength(1); y++)
                             {

                                 float n = 0;
                                 float.TryParse(matriz2[x, y].Text, out n);
                                 tempMatriz2[x, y] = n;


                             }
                         }*/

                        float[,] tempMatrizResultante = Calculos.Transposta1(tempMatriz2);
                        matriz2 = new TextBox[tempMatrizResultante.GetLength(0), tempMatrizResultante.GetLength(1)];
                        int TamanhoText = groupBox2.Width /matriz2.GetLength(1);

                        for (int x = 0; x < matriz2.GetLength(0); x++)
                        {
                            for (int y = 0; y < matriz2.GetLength(1); y++)
                            {
                                matriz2[x, y] = new TextBox();
                                matriz2[x, y].KeyPress += new KeyPressEventHandler(keypressed);
                                matriz2[x, y].TextAlign = HorizontalAlignment.Center;
                                matriz2[x, y].Text = tempMatrizResultante[x, y].ToString();
                                matriz2[x, y].Top = (x * matriz2[x, y].Height) + 20;
                                matriz2[x, y].Left = y * TamanhoText;
                                matriz2[x, y].Width = TamanhoText;
                                groupBox2.Controls.Add(matriz2[x, y]);
                            }
                        }


                    }
                    if (comboBox5.SelectedItem.ToString() == "Oposta")
                    {
                        groupBox2.Controls.Clear();
               
                        
                        if(matriz2 == null)
                        {
                            MessageBox.Show("Primeiro você deve gerar a matriz");
                            return;
                        }
                        float[,] tempMatriz1 = new float[matriz2.GetLength(0), matriz2.GetLength(1)];
                        //float[,] tempMatriz2 = new float[matriz2.GetLength(0), matriz2.GetLength(1)];
                        //if (tempMatriz1.GetLength(0) != tempMatriz2.GetLength(0) || tempMatriz1.GetLength(1) != tempMatriz2.GetLength(1))
                        /*{
                            MessageBox.Show("So e possivel a soma de matrizes de mesma ordem !", "Erro - Soma Matrizes");
                            return;
                        }*/



                        for (int x = 0; x < matriz2.GetLength(0); x++)
                        {

                            for (int y = 0; y < matriz2.GetLength(1); y++)
                            {

                                float n = 0;
                                float.TryParse(matriz2[x, y].Text, out n);
                                tempMatriz1[x, y] = n;


                            }
                        }
                        /* for (int x = 0; x < matriz2.GetLength(0); x++)
                         {
                             for (int y = 0; y < matriz2.GetLength(1); y++)
                             {

                                 float n = 0;
                                 float.TryParse(matriz2[x, y].Text, out n);
                                 tempMatriz2[x, y] = n;


                             }
                         }*/

                        float[,] tempMatrizResultante = Calculos.Oposta(tempMatriz1);
                        matriz2 = new TextBox[tempMatrizResultante.GetLength(0), tempMatrizResultante.GetLength(1)];
                        int TamanhoText = groupBox1.Width / matriz2.GetLength(1);

                        for (int x = 0; x < matriz2.GetLength(0); x++)
                        {
                            for (int y = 0; y < matriz2.GetLength(1); y++)
                            {
                                matriz2[x, y] = new TextBox();
                                matriz2[x, y].KeyPress += new KeyPressEventHandler(keypressed);
                                matriz2[x, y].TextAlign = HorizontalAlignment.Center;
                                matriz2[x, y].Text = tempMatrizResultante[x, y].ToString();
                                matriz2[x, y].Top = (x * matriz2[x, y].Height) + 20;
                                matriz2[x, y].Left = y * TamanhoText;
                                matriz2[x, y].Width = TamanhoText;
                                groupBox2.Controls.Add(matriz2[x, y]);
                            }
                        }
                    }



                    string value2;
                    if (comboBox5.SelectedItem.ToString() == "Determinate")
                    {
                        if (matriz2 == null)
                        {
                            MessageBox.Show("Primeiro você deve gerar a matriz");
                            return;
                        }

                        if (comboBox3.SelectedItem.ToString() != comboBox4.SelectedItem.ToString())
                        {
                            return;
                        }
                        else if (comboBox3.SelectedItem.ToString() == comboBox4.SelectedItem.ToString())
                        {

                            //cria uma matriz e seta os valores para serem a da matriz que usaremos
                            double[,] MT = new double[(matriz2.GetLength(0)), (matriz2.GetLength(1))];
                            for (int i = 0; i < matriz2.GetLength(0); i++)
                            {
                                for (int j = 0; j < matriz2.GetLength(1); j++)
                                {
                                    double n = 0;
                                    double.TryParse(matriz2[i, j].Text, out n);
                                    matriz2[i, j].KeyPress += new KeyPressEventHandler(keypressed);
                                    MT[i, j] = n;
                                }
                            }
                            // escreve na caixa de texto o retorno da det
                            value2 = Calculos.DET(MT, int.Parse(comboBox4.SelectedItem.ToString())).ToString();
                            MessageBox.Show(value2);
                        }



                    }

                }
            ////Calculos para matrizresultante
            if(radioButton3.Checked == true)
            {

               if (comboBox5.SelectedItem.ToString() == "Multiplicação Por Número Real")
                    {
                        if (resultante == null)
                        {
                            MessageBox.Show("Primeiro a matriz deve ser gerada");
                            return;
                        }

                        MessageBox.Show("Digite o valor na caixa que apareceu abaixo da matriz 1, com qual você quer que seja multiplicado a matriz 1");
                        label13.Visible = true;
                        textBox3.Visible = true;
                        button8.Visible = true;



                    }
                    else if (comboBox5.SelectedItem.ToString() != "Multiplicação Por Número Real")
                    {
                        textBox1.Text = "";
                        textBox2.Text = "";
                        textBox3.Text = "";
                        label11.Visible = false;
                        textBox1.Visible = false;
                        button6.Visible = false;
                        label12.Visible = false;
                        textBox2.Visible = false;
                        button7.Visible = false;
                        label13.Visible = false;
                        textBox3.Visible = false;
                        button8.Visible = false;

                    }
                    if (comboBox5.SelectedItem.ToString() == "Transposta")
                    {
                        groupBox3.Controls.Clear();
                        if (resultante == null)
                        {
                            MessageBox.Show("Primeiro a matriz deve ser gerada");
                            return;
                        }
                        float[,] tempMatriz2 = new float[resultante.GetLength(0), resultante.GetLength(1)];
                        //float[,] tempMatriz2 = new float[matriz2.GetLength(0), matriz2.GetLength(1)];
                        //if (tempMatriz1.GetLength(0) != tempMatriz2.GetLength(0) || tempMatriz1.GetLength(1) != tempMatriz2.GetLength(1))
                        /*{
                            MessageBox.Show("So e possivel a soma de matrizes de mesma ordem !", "Erro - Soma Matrizes");
                            return;
                        }*/



                        for (int x = 0; x < resultante.GetLength(0); x++)
                        {

                            for (int y = 0; y < resultante.GetLength(1); y++)
                            {

                                float n = 0;
                                float.TryParse(resultante[x, y].Text, out n);
                                tempMatriz2[x, y] = n;


                            }
                        }
                        /* for (int x = 0; x < matriz2.GetLength(0); x++)
                         {
                             for (int y = 0; y < matriz2.GetLength(1); y++)
                             {

                                 float n = 0;
                                 float.TryParse(matriz2[x, y].Text, out n);
                                 tempMatriz2[x, y] = n;


                             }
                         }*/

                        float[,] tempMatrizResultante = Calculos.Transposta1(tempMatriz2);
                        resultante = new TextBox[tempMatrizResultante.GetLength(0), tempMatrizResultante.GetLength(1)];
                        int TamanhoText = groupBox3.Width / resultante.GetLength(1);

                        for (int x = 0; x < resultante.GetLength(0); x++)
                        {
                            for (int y = 0; y < resultante.GetLength(1); y++)
                            {
                                resultante[x, y] = new TextBox();
                                resultante[x, y].KeyPress += new KeyPressEventHandler(keypressed);
                                resultante[x, y].TextAlign = HorizontalAlignment.Center;
                                resultante[x, y].Text = tempMatrizResultante[x, y].ToString();
                                resultante[x, y].Top = (x * resultante[x, y].Height) + 20;
                                resultante[x, y].Left = y * TamanhoText;
                                resultante[x, y].Width = TamanhoText;
                                groupBox3.Controls.Add(resultante[x, y]);
                            }
                        }


                    }
                    if (comboBox5.SelectedItem.ToString() == "Oposta")
                    {
                        groupBox3.Controls.Clear();
                        if (resultante == null)
                        {
                            MessageBox.Show("Primeiro a matriz deve ser gerada");
                            return;
                        }
                        float[,] tempMatriz1 = new float[resultante.GetLength(0), resultante.GetLength(1)];
                        //float[,] tempMatriz2 = new float[matriz2.GetLength(0), matriz2.GetLength(1)];
                        //if (tempMatriz1.GetLength(0) != tempMatriz2.GetLength(0) || tempMatriz1.GetLength(1) != tempMatriz2.GetLength(1))
                        /*{
                            MessageBox.Show("So e possivel a soma de matrizes de mesma ordem !", "Erro - Soma Matrizes");
                            return;
                        }*/



                        for (int x = 0; x < resultante.GetLength(0); x++)
                        {

                            for (int y = 0; y < resultante.GetLength(1); y++)
                            {

                                float n = 0;
                                float.TryParse(resultante[x, y].Text, out n);
                                tempMatriz1[x, y] = n;


                            }
                        }
                        /* for (int x = 0; x < matriz2.GetLength(0); x++)
                         {
                             for (int y = 0; y < matriz2.GetLength(1); y++)
                             {

                                 float n = 0;
                                 float.TryParse(matriz2[x, y].Text, out n);
                                 tempMatriz2[x, y] = n;


                             }
                         }*/

                        float[,] tempMatrizResultante = Calculos.Oposta(tempMatriz1);
                        resultante = new TextBox[tempMatrizResultante.GetLength(0), tempMatrizResultante.GetLength(1)];
                        int TamanhoText = groupBox3.Width / resultante.GetLength(1);

                        for (int x = 0; x < resultante.GetLength(0); x++)
                        {
                            for (int y = 0; y < resultante.GetLength(1); y++)
                            {
                                resultante[x, y] = new TextBox();
                                resultante[x, y].KeyPress += new KeyPressEventHandler(keypressed);
                                resultante[x, y].TextAlign = HorizontalAlignment.Center;
                                resultante[x, y].Text = tempMatrizResultante[x, y].ToString();
                                resultante[x, y].Top = (x * resultante[x, y].Height) + 20;
                                resultante[x, y].Left = y * TamanhoText;
                                resultante[x, y].Width = TamanhoText;
                                groupBox3.Controls.Add(resultante[x, y]);
                            }
                        }
                    }



                    string value2;
                    if (comboBox5.SelectedItem.ToString() == "Determinate")
                    {
                        if (resultante == null)
                        {
                            MessageBox.Show("Primeiro a matriz deve ser gerada");
                            return;
                        }

                      

                            //cria uma matriz e seta os valores para serem a da matriz que usaremos
                        double[,] MT = new double[(resultante.GetLength(0)), (resultante.GetLength(1))];
                        for (int i = 0; i < resultante.GetLength(0); i++)
                            {
                                for (int j = 0; j < resultante.GetLength(1); j++)
                                {
                                    double n = 0;
                                    double.TryParse(resultante[i, j].Text, out n);
                                    resultante[i, j].KeyPress += new KeyPressEventHandler(keypressed);
                                    MT[i, j] = n;
                                }
                            }
                            // escreve na caixa de texto o retorno da det
                            value2 = Calculos.DET(MT, int.Parse(comboBox4.SelectedItem.ToString())).ToString();
                            MessageBox.Show(value2);
                        



                    }
            }
            }
        private void button11_Click_1(object sender, EventArgs e)
        {
            
            if(desenho == null)
            {
                MessageBox.Show("Primeiro crie a matriz prinpal e desenhe a figura");
                return;
            }
            button12.Visible = true;
            linhast = Convert.ToInt32(comboBox6.SelectedItem.ToString());
            colunast = Convert.ToInt32(comboBox7.SelectedItem.ToString());
            translacaomatriz =  new TextBox[linhast,colunast];
            int TamanhoText = groupBox4.Width / colunast;

            for (int x = 0; x < translacaomatriz.GetLength(0); x++)
            {
                for (int y = 0; y < translacaomatriz.GetLength(1); y++)
                {
                    translacaomatriz[x, y] = new TextBox();
                    translacaomatriz[x, y].Text = "0";
                    translacaomatriz[x, y].KeyPress += new KeyPressEventHandler(keypressed);
                    translacaomatriz[x, y].TextAlign = HorizontalAlignment.Center;
                    translacaomatriz[x, y].Top = (x * translacaomatriz[x, y].Height) + 20;
                    translacaomatriz[x, y].Left = y * TamanhoText;
                    translacaomatriz[x, y].Width = TamanhoText;
                    groupBox6.Controls.Add(translacaomatriz[x, y]);




                }
            }

        }
        private void button13_Click(object sender, EventArgs e)
        {
            Calculos.numberDesenho = Convert.ToDouble(textBox8.Text);


            groupBox4.Controls.Clear();
            double[,] tempMatriz1 = new double[desenho.GetLength(0), desenho.GetLength(1)];

            for (int x = 0; x < desenho.GetLength(0); x++)
            {

                for (int y = 0; y < desenho.GetLength(1); y++)
                {

                    double n = 0;
                    double.TryParse(desenho[x, y].Text, out n);
                    tempMatriz1[x, y] = n;


                }
            }


            double[,] tempMatrizResultante = Calculos.NumeroRealDesenho(tempMatriz1);
            desenho = new TextBox[tempMatrizResultante.GetLength(0), tempMatrizResultante.GetLength(1)];
            int TamanhoText = groupBox4.Width / desenho.GetLength(1);

            for (int x = 0; x < desenho.GetLength(0); x++)
            {
                for (int y = 0; y < desenho.GetLength(1); y++)
                {
                    desenho[x, y] = new TextBox();
                    desenho[x, y].KeyPress += new KeyPressEventHandler(keypressed);
                    desenho[x, y].TextAlign = HorizontalAlignment.Center;
                    desenho[x, y].Text = tempMatrizResultante[x, y].ToString();
                    desenho[x, y].Top = (x * desenho[x, y].Height) + 20;
                    desenho[x, y].Left = y * TamanhoText;
                    desenho[x, y].Width = TamanhoText;
                    groupBox4.Controls.Add(desenho[x, y]);
                }
            }
            Pen blackPen = new Pen(Color.Blue);


            PointF[] pontos;
            pontos = new PointF[desenho.GetLength(1)];
            List<Point> point2 = new List<Point>();
            //pontos = new Point(x, y);
            for (int i = 0; i < desenho.GetLength(1); i++)
            {


                pontos[i] = new PointF(Convert.ToSingle(desenho[0, i].Text), -Convert.ToSingle(desenho[1, i].Text));
                pontos[i].X += pictureBox1.Width / 2;
                pontos[i].Y += pictureBox1.Height / 2;

                //g.DrawPolygon(blackPen, pontos);

                //MessageBox.Show("allahu akbar :" + desenho[0, i].Text + ", " + desenho[1, i].Text);
            }

            Graphics g = pictureBox1.CreateGraphics();
            g.Clear(Color.White);
            g.DrawPolygon(blackPen, pontos);
            cartesiano = pictureBox1.CreateGraphics();
            Pen pen2 = new Pen(Color.Black);

            Point point1 = new Point(0, 20);
            Point pointhue = new Point(340, 20);
            Point point3 = new Point(0, 40);
            Point point4 = new Point(340, 40);
            Point point5 = new Point(0, 60);
            Point point6 = new Point(340, 60);
            Point point7 = new Point(0, 80);
            Point point8 = new Point(340, 80);
            Point point9 = new Point(0, 100);
            Point point10 = new Point(340, 100);
            Point point11 = new Point(0, 120);
            Point point12 = new Point(340, 120);
            Point point13 = new Point(0, 140);
            Point point14 = new Point(340, 140);
            Point point15 = new Point(0, 160);
            Point point16 = new Point(340, 160);
            Point point17 = new Point(0, 180);
            Point point18 = new Point(340, 180);
            Point point19 = new Point(0, 200);
            Point point20 = new Point(340, 200);
            Point point21 = new Point(0, 220);
            Point point22 = new Point(340, 220);
            Point point23 = new Point(0, 240);
            Point point24 = new Point(340, 240);
            Point point25 = new Point(0, 260);
            Point point26 = new Point(340, 260);
            Point point27 = new Point(0, 280);
            Point point28 = new Point(340, 280);
            Point point29 = new Point(0, 300);
            Point point30 = new Point(340, 300);
            Point point31 = new Point(0, 320);
            Point point32 = new Point(340, 320);
            Point point33 = new Point(0, 340);
            Point point34 = new Point(340, 340);


            cartesiano.DrawLine(pen2, point1, pointhue);
            cartesiano.DrawLine(pen2, point3, point4);
            cartesiano.DrawLine(pen2, point5, point6);
            cartesiano.DrawLine(pen2, point7, point8);
            cartesiano.DrawLine(pen2, point9, point10);
            cartesiano.DrawLine(pen2, point11, point12);
            cartesiano.DrawLine(pen2, point13, point14);
            cartesiano.DrawLine(pen2, point15, point16);
            cartesiano.DrawLine(pen2, point17, point18);
            cartesiano.DrawLine(pen2, point19, point20);
            cartesiano.DrawLine(pen2, point21, point22);
            cartesiano.DrawLine(pen2, point23, point24);
            cartesiano.DrawLine(pen2, point25, point26);
            cartesiano.DrawLine(pen2, point27, point28);
            cartesiano.DrawLine(pen2, point29, point30);
            cartesiano.DrawLine(pen2, point31, point32);
            cartesiano.DrawLine(pen2, point33, point34);

            Point point35 = new Point(20, 0);
            Point point36 = new Point(20, 340);
            Point point37 = new Point(40, 0);
            Point point38 = new Point(40, 340);
            Point point39 = new Point(60, 0);
            Point point40 = new Point(60, 340);
            Point point41 = new Point(80, 0);
            Point point42 = new Point(80, 340);
            Point point43 = new Point(100, 0);
            Point point44 = new Point(100, 340);
            Point point45 = new Point(120, 0);
            Point point46 = new Point(120, 340);
            Point point47 = new Point(140, 0);
            Point point48 = new Point(140, 340);
            Point point49 = new Point(160, 0);
            Point point50 = new Point(160, 340);
            Point point51 = new Point(180, 0);
            Point point52 = new Point(180, 340);
            Point point53 = new Point(200, 0);
            Point point54 = new Point(200, 340);
            Point point55 = new Point(220, 0);
            Point point56 = new Point(220, 340);
            Point point57 = new Point(240, 0);
            Point point58 = new Point(240, 340);
            Point point59 = new Point(260, 0);
            Point point60 = new Point(260, 340);
            Point point61 = new Point(280, 0);
            Point point62 = new Point(280, 340);
            Point point63 = new Point(300, 0);
            Point point64 = new Point(300, 340);
            Point point65 = new Point(320, 0);
            Point point66 = new Point(320, 340);
            Point point67 = new Point(340, 0);
            Point point68 = new Point(340, 340);
            cartesiano.DrawLine(pen2, point35, point36);
            cartesiano.DrawLine(pen2, point37, point38);
            cartesiano.DrawLine(pen2, point39, point40);
            cartesiano.DrawLine(pen2, point41, point42);
            cartesiano.DrawLine(pen2, point43, point44);
            cartesiano.DrawLine(pen2, point45, point46);
            cartesiano.DrawLine(pen2, point47, point48);
            cartesiano.DrawLine(pen2, point49, point50);
            cartesiano.DrawLine(pen2, point51, point52);
            cartesiano.DrawLine(pen2, point53, point54);
            cartesiano.DrawLine(pen2, point55, point56);
            cartesiano.DrawLine(pen2, point57, point58);
            cartesiano.DrawLine(pen2, point59, point60);
            cartesiano.DrawLine(pen2, point61, point62);
            cartesiano.DrawLine(pen2, point63, point64);
            cartesiano.DrawLine(pen2, point65, point66);
            cartesiano.DrawLine(pen2, point67, point68);
        
                           
        }
        //soma -- ok
        private void SumButton_Click(object sender, EventArgs e)
        {
            linhaResposta = linha1;
            colunaResposta = coluna1;

            if (MatrixR != null)
            {
                for (int i = 0; i < MatrixR.GetLength(0); i++)
                {
                    for (int j = 0; j < MatrixR.GetLength(1); j++)
                    {
                        if (MatrixR[i, j] != null)
                            groupBox3.Controls.Remove(MatrixR[i, j]);
                    }
                }
            }

            MatrixR = new TextBox[linhaResposta, colunaResposta];

            if(linha1 == linha2 && coluna2 == coluna1){
                for (int i = 0; i < MatrixR.GetLength(0); i++)
                {
                    for (int j = 0; j < MatrixR.GetLength(1); j++)
                    {
                        MatrixR[i, j] = new TextBox();
                        MatrixR[i, j].Text = Convert.ToString(Convert.ToInt32(Matrix1[i, j].Text) + Convert.ToInt32(Matrix2[i,j].Text));
                        MatrixR[i, j].Top = 10 + (i * 30); ;
                        MatrixR[i, j].Left = (j * 35) + 10;
                        MatrixR[i, j].Width = 30;
                        groupBox3.Controls.Add(MatrixR[i,j]);
                    }

                }

            }
            else { MessageBox.Show("É necessario que as matrizes tenham o mesmo tamanho"); }
        }
        private void button10_Click_1(object sender, EventArgs e)
        {
         
            if(desenho == null)
            {
                MessageBox.Show("Primeiro crie e desenhe a figura");

                return;
            }
            if(textBox7.Text == "")
            {
                MessageBox.Show("Escreva o angulo na qual o desenho será rotacionado");
                return;

            }
            matrizrotacao[0, 0].Text = Math.Cos(Convert.ToDouble(textBox7.Text) * (Math.PI / 180)).ToString();
            matrizrotacao[0, 1].Text = Math.Sin(-Convert.ToDouble(textBox7.Text) * (Math.PI / 180)).ToString();
            matrizrotacao[1, 0].Text = Math.Sin(Convert.ToDouble(textBox7.Text) * (Math.PI / 180)).ToString();
            matrizrotacao[1, 1].Text = Math.Cos(Convert.ToDouble(textBox7.Text) * (Math.PI / 180)).ToString();
            double[,] tempMatriz1 =  new double[desenho.GetLength(0), desenho.GetLength(1)];
            double[,] tempMatriz2 = new double[matrizrotacao.GetLength(0), matrizrotacao.GetLength(1)];
            if (tempMatriz1.GetLength(0) != tempMatriz2.GetLength(1))
            {
                MessageBox.Show("So e possivel a multiplicacao de matrizes onde a coluna da matriz 1 e igual a linha da matriz 2  !", "Erro - Multiplicacao Matrizes");

                return;
            }



            for (int x = 0; x < desenho.GetLength(0); x++)
            {
                for (int y = 0; y < desenho.GetLength(1); y++)
                {

                    float n = 0;
                    float.TryParse(desenho[x, y].Text, out n);
                    tempMatriz1[x, y] = n;


                }
            }
            for (int x = 0; x < matrizrotacao.GetLength(0); x++)
            {

                for (int y = 0; y < matrizrotacao.GetLength(1); y++)
                {

                    float n = 0;
                    float.TryParse(matrizrotacao[x, y].Text, out n);
                    tempMatriz2[x, y] = n;


                }
            }

            double[,] tempMatrizResultante = Calculos.MultiplicarMatrizesDesenho(tempMatriz1, tempMatriz2);
            desenho = new TextBox[tempMatrizResultante.GetLength(0), tempMatrizResultante.GetLength(1)];
            int TamanhoText = groupBox4.Width / desenho.GetLength(1);
            groupBox4.Controls.Clear();
            for (int x = 0; x < desenho.GetLength(0); x++)
            {
                for (int y = 0; y < desenho.GetLength(1); y++)
                {
                    desenho[x, y] = new TextBox();
                    desenho[x, y].TextAlign = HorizontalAlignment.Center;

                    desenho[x, y].Text = tempMatrizResultante[x, y].ToString();
                    desenho[x, y].Top = (x * desenho[x, y].Height) + 20;
                    desenho[x, y].Left = y * TamanhoText;
                    desenho[x, y].Width = TamanhoText;
                    groupBox4.Controls.Add(desenho[x, y]);
                    //MessageBox.Show("" + resultante[x,y]);
                }
            }

            Graphics j = pictureBox1.CreateGraphics();

            j.Clear(Color.White);
            Pen blackPen = new Pen(Color.Red, 1);

            PointF[] pontos;

            pontos = new PointF[desenho.GetLength(1)];
            List<Point> point2 = new List<Point>();
            //pontos = new Point(x, y);
            for (int i = 0; i < desenho.GetLength(1); i++)
            {


                pontos[i] = new PointF(Convert.ToSingle(desenho[0, i].Text), -Convert.ToSingle(desenho[1, i].Text));
                pontos[i].X += pictureBox1.Width / 2;
                pontos[i].Y += pictureBox1.Height / 2;

                //j.DrawPolygon(blackPen, pontos);

                //MessageBox.Show("allahu akbar :" + desenho[0, i].Text + ", " + desenho[1, i].Text);
            }
            j.DrawPolygon(blackPen, pontos);
            cartesiano = pictureBox1.CreateGraphics();
            Pen pen2 = new Pen(Color.Black);

            Point point1 = new Point(0, 20);
            Point pointhue = new Point(340, 20);
            Point point3 = new Point(0, 40);
            Point point4 = new Point(340, 40);
            Point point5 = new Point(0, 60);
            Point point6 = new Point(340, 60);
            Point point7 = new Point(0, 80);
            Point point8 = new Point(340, 80);
            Point point9 = new Point(0, 100);
            Point point10 = new Point(340, 100);
            Point point11 = new Point(0, 120);
            Point point12 = new Point(340, 120);
            Point point13 = new Point(0, 140);
            Point point14 = new Point(340, 140);
            Point point15 = new Point(0, 160);
            Point point16 = new Point(340, 160);
            Point point17 = new Point(0, 180);
            Point point18 = new Point(340, 180);
            Point point19 = new Point(0, 200);
            Point point20 = new Point(340, 200);
            Point point21 = new Point(0, 220);
            Point point22 = new Point(340, 220);
            Point point23 = new Point(0, 240);
            Point point24 = new Point(340, 240);
            Point point25 = new Point(0, 260);
            Point point26 = new Point(340, 260);
            Point point27 = new Point(0, 280);
            Point point28 = new Point(340, 280);
            Point point29 = new Point(0, 300);
            Point point30 = new Point(340, 300);
            Point point31 = new Point(0, 320);
            Point point32 = new Point(340, 320);
            Point point33 = new Point(0, 340);
            Point point34 = new Point(340, 340);


            cartesiano.DrawLine(pen2, point1, pointhue);
            cartesiano.DrawLine(pen2, point3, point4);
            cartesiano.DrawLine(pen2, point5, point6);
            cartesiano.DrawLine(pen2, point7, point8);
            cartesiano.DrawLine(pen2, point9, point10);
            cartesiano.DrawLine(pen2, point11, point12);
            cartesiano.DrawLine(pen2, point13, point14);
            cartesiano.DrawLine(pen2, point15, point16);
            cartesiano.DrawLine(pen2, point17, point18);
            cartesiano.DrawLine(pen2, point19, point20);
            cartesiano.DrawLine(pen2, point21, point22);
            cartesiano.DrawLine(pen2, point23, point24);
            cartesiano.DrawLine(pen2, point25, point26);
            cartesiano.DrawLine(pen2, point27, point28);
            cartesiano.DrawLine(pen2, point29, point30);
            cartesiano.DrawLine(pen2, point31, point32);
            cartesiano.DrawLine(pen2, point33, point34);

            Point point35 = new Point(20, 0);
            Point point36 = new Point(20, 340);
            Point point37 = new Point(40, 0);
            Point point38 = new Point(40, 340);
            Point point39 = new Point(60, 0);
            Point point40 = new Point(60, 340);
            Point point41 = new Point(80, 0);
            Point point42 = new Point(80, 340);
            Point point43 = new Point(100, 0);
            Point point44 = new Point(100, 340);
            Point point45 = new Point(120, 0);
            Point point46 = new Point(120, 340);
            Point point47 = new Point(140, 0);
            Point point48 = new Point(140, 340);
            Point point49 = new Point(160, 0);
            Point point50 = new Point(160, 340);
            Point point51 = new Point(180, 0);
            Point point52 = new Point(180, 340);
            Point point53 = new Point(200, 0);
            Point point54 = new Point(200, 340);
            Point point55 = new Point(220, 0);
            Point point56 = new Point(220, 340);
            Point point57 = new Point(240, 0);
            Point point58 = new Point(240, 340);
            Point point59 = new Point(260, 0);
            Point point60 = new Point(260, 340);
            Point point61 = new Point(280, 0);
            Point point62 = new Point(280, 340);
            Point point63 = new Point(300, 0);
            Point point64 = new Point(300, 340);
            Point point65 = new Point(320, 0);
            Point point66 = new Point(320, 340);
            Point point67 = new Point(340, 0);
            Point point68 = new Point(340, 340);
            cartesiano.DrawLine(pen2, point35, point36);
            cartesiano.DrawLine(pen2, point37, point38);
            cartesiano.DrawLine(pen2, point39, point40);
            cartesiano.DrawLine(pen2, point41, point42);
            cartesiano.DrawLine(pen2, point43, point44);
            cartesiano.DrawLine(pen2, point45, point46);
            cartesiano.DrawLine(pen2, point47, point48);
            cartesiano.DrawLine(pen2, point49, point50);
            cartesiano.DrawLine(pen2, point51, point52);
            cartesiano.DrawLine(pen2, point53, point54);
            cartesiano.DrawLine(pen2, point55, point56);
            cartesiano.DrawLine(pen2, point57, point58);
            cartesiano.DrawLine(pen2, point59, point60);
            cartesiano.DrawLine(pen2, point61, point62);
            cartesiano.DrawLine(pen2, point63, point64);
            cartesiano.DrawLine(pen2, point65, point66);
            cartesiano.DrawLine(pen2, point67, point68);
        
                           
           
          
        }
        //multiplicação -- ok
        private void Mult(object sender, EventArgs e)
        {
            if (MatrixR != null)
            {
                for (int i = 0; i < MatrixR.GetLength(0); i++)
                {
                    for (int j = 0; j < MatrixR.GetLength(1); j++)
                    {
                        if (MatrixR[i, j] != null)
                            groupBox3.Controls.Remove(MatrixR[i, j]);

                    }
                }
            }
            linhaResposta = linha1;
            colunaResposta = coluna2;
            MatrixR = new TextBox[linha1, coluna2];
            double CasasR = 0;
            bool ok = false;
            //enche essa bregueça de ifs
            if (coluna1 == linha2) ok = true;
            if (coluna1 != linha1)
            {
                int m1L = linha2;
                int m1c = coluna2;
                int m2L = linha1;
                int m2c = coluna1;
                if (m1L != m2c) { MessageBox.Show("Impossivel Multiplicar Essas Matrizes"); ; ok = false; }
                else
                {
                    linha1 = m1L;
                    coluna1 = m1c;
                    linha2 = m2L;
                    coluna2 = m2c;
                    MessageBox.Show("A ordem das matrizes foi alterada para tornar possivel a multiplicação");
                    ok = true;
                }
            }

            if (ok)
            {
                if (MatrixR != null)
                {
                    for (int i = 0; i < MatrixR.GetLength(0); i++)
                    {
                        for (int j = 0; j < MatrixR.GetLength(1); j++)
                        {
                            if (MatrixR[i, j] != null)
                                groupBox3.Controls.Remove(MatrixR[i, j]);

                        }
                    }
                }

                for (int i = 0; i < MatrixR.GetLength(0); i++)
                {
                    for (int j = 0; j < MatrixR.GetLength(1); j++)
                    {

                        for (int n = 0; n < coluna1; n++)
                        {
                            CasasR += Convert.ToDouble(Matrix1[i, n].Text) * Convert.ToDouble(Matrix2[n, j].Text);
                        }
                        MatrixR[i, j] = new TextBox();
                        MatrixR[i, j].Text = Convert.ToString(CasasR);
                        MatrixR[i, j].Top = (i * MatrixR[i, j].Height) + 10;
                        MatrixR[i, j].Left = (j * 35) + 10;
                        MatrixR[i, j].Width = 30;
                        groupBox3.Controls.Add(MatrixR[i, j]);
                        CasasR = 0;

                    }
                }
            }
        }
        private void button4_Click(object sender, EventArgs e)
        {
            Graphics g = pictureBox1.CreateGraphics();
            groupBox4.Controls.Clear();
            groupBox6.Controls.Clear();
            button12.Visible = false;
           // pictureBox1.Image = Properties.Resources.vem_bicho;
            g.Clear(Color.White);

            cartesiano = pictureBox1.CreateGraphics();
            Pen pen = new Pen(Color.Black);

            Point point1 = new Point(0, 20);
            Point point2 = new Point(340, 20);
            Point point3 = new Point(0, 40);
            Point point4 = new Point(340, 40);
            Point point5 = new Point(0, 60);
            Point point6 = new Point(340, 60);
            Point point7 = new Point(0, 80);
            Point point8 = new Point(340, 80);
            Point point9 = new Point(0, 100);
            Point point10 = new Point(340, 100);
            Point point11 = new Point(0, 120);
            Point point12 = new Point(340, 120);
            Point point13 = new Point(0, 140);
            Point point14 = new Point(340, 140);
            Point point15 = new Point(0, 160);
            Point point16 = new Point(340, 160);
            Point point17 = new Point(0, 180);
            Point point18 = new Point(340, 180);
            Point point19 = new Point(0, 200);
            Point point20 = new Point(340, 200);
            Point point21 = new Point(0, 220);
            Point point22 = new Point(340, 220);
            Point point23 = new Point(0, 240);
            Point point24 = new Point(340, 240);
            Point point25 = new Point(0, 260);
            Point point26 = new Point(340, 260);
            Point point27 = new Point(0, 280);
            Point point28 = new Point(340, 280);
            Point point29 = new Point(0, 300);
            Point point30 = new Point(340, 300);
            Point point31 = new Point(0, 320);
            Point point32 = new Point(340, 320);
            Point point33 = new Point(0, 340);
            Point point34 = new Point(340, 340);


            cartesiano.DrawLine(pen, point1, point2);
            cartesiano.DrawLine(pen, point3, point4);
            cartesiano.DrawLine(pen, point5, point6);
            cartesiano.DrawLine(pen, point7, point8);
            cartesiano.DrawLine(pen, point9, point10);
            cartesiano.DrawLine(pen, point11, point12);
            cartesiano.DrawLine(pen, point13, point14);
            cartesiano.DrawLine(pen, point15, point16);
            cartesiano.DrawLine(pen, point17, point18);
            cartesiano.DrawLine(pen, point19, point20);
            cartesiano.DrawLine(pen, point21, point22);
            cartesiano.DrawLine(pen, point23, point24);
            cartesiano.DrawLine(pen, point25, point26);
            cartesiano.DrawLine(pen, point27, point28);
            cartesiano.DrawLine(pen, point29, point30);
            cartesiano.DrawLine(pen, point31, point32);
            cartesiano.DrawLine(pen, point33, point34);

            Point point35 = new Point(20, 0);
            Point point36 = new Point(20, 340);
            Point point37 = new Point(40, 0);
            Point point38 = new Point(40, 340);
            Point point39 = new Point(60, 0);
            Point point40 = new Point(60, 340);
            Point point41 = new Point(80, 0);
            Point point42 = new Point(80, 340);
            Point point43 = new Point(100, 0);
            Point point44 = new Point(100, 340);
            Point point45 = new Point(120, 0);
            Point point46 = new Point(120, 340);
            Point point47 = new Point(140, 0);
            Point point48 = new Point(140, 340);
            Point point49 = new Point(160, 0);
            Point point50 = new Point(160, 340);
            Point point51 = new Point(180, 0);
            Point point52 = new Point(180, 340);
            Point point53 = new Point(200, 0);
            Point point54 = new Point(200, 340);
            Point point55 = new Point(220, 0);
            Point point56 = new Point(220, 340);
            Point point57 = new Point(240, 0);
            Point point58 = new Point(240, 340);
            Point point59 = new Point(260, 0);
            Point point60 = new Point(260, 340);
            Point point61 = new Point(280, 0);
            Point point62 = new Point(280, 340);
            Point point63 = new Point(300, 0);
            Point point64 = new Point(300, 340);
            Point point65 = new Point(320, 0);
            Point point66 = new Point(320, 340);
            Point point67 = new Point(340, 0);
            Point point68 = new Point(340, 340);
            cartesiano.DrawLine(pen, point35, point36);
            cartesiano.DrawLine(pen, point37, point38);
            cartesiano.DrawLine(pen, point39, point40);
            cartesiano.DrawLine(pen, point41, point42);
            cartesiano.DrawLine(pen, point43, point44);
            cartesiano.DrawLine(pen, point45, point46);
            cartesiano.DrawLine(pen, point47, point48);
            cartesiano.DrawLine(pen, point49, point50);
            cartesiano.DrawLine(pen, point51, point52);
            cartesiano.DrawLine(pen, point53, point54);
            cartesiano.DrawLine(pen, point55, point56);
            cartesiano.DrawLine(pen, point57, point58);
            cartesiano.DrawLine(pen, point59, point60);
            cartesiano.DrawLine(pen, point61, point62);
            cartesiano.DrawLine(pen, point63, point64);
            cartesiano.DrawLine(pen, point65, point66);
            cartesiano.DrawLine(pen, point67, point68);
        
            if(comboBox6.SelectedItem == null && comboBox7.SelectedItem == null)
            {
                MessageBox.Show("Selecione o número de linhas e colunas");
                return;
            }
            if (comboBox6.SelectedItem == null || comboBox7.SelectedItem == null)
            {
                MessageBox.Show("Selecione o número de linhas e colunas");
                return;
            }
            linhasDesenho = Convert.ToInt32(comboBox6.SelectedItem.ToString());

            colunasDesenho = Convert.ToInt32(comboBox7.SelectedItem.ToString());

            int TamanhoText = groupBox4.Width / colunasDesenho;
           

            desenho = new TextBox[linhasDesenho, colunasDesenho];

            for (int x = 0; x < desenho.GetLength(0); x++)
            {
                for (int y = 0; y < desenho.GetLength(1); y++)
                {
                    desenho[x, y] = new TextBox();
                    desenho[x, y].Text = "0";
                   desenho[x, y].KeyPress += new KeyPressEventHandler(keypressed);
                    desenho[x, y].TextAlign = HorizontalAlignment.Center;
                    desenho[x, y].Top = (x * desenho[x, y].Height) + 20;
                    desenho[x, y].Left = y * TamanhoText;
                    desenho[x, y].Width = TamanhoText;
                    groupBox4.Controls.Add(desenho[x, y]);




                }
            }
            
            groupBox2.Controls.Clear();
            linhas2 = 2;
            colunas2 = 2;
            int TamanhoText2 = groupBox5.Width / colunas2;


            matrizrotacao = new TextBox[linhas2, colunas2];
            for (int x = 0; x < matrizrotacao.GetLength(0); x++)
            {

                for (int y = 0; y < matrizrotacao.GetLength(1); y++)
                {
                    matrizrotacao[x, y] = new TextBox();
                    matrizrotacao[x, y].Text = "0";
                    matrizrotacao[x, y].TextAlign = HorizontalAlignment.Center;
                    matrizrotacao[x, y].Top = (x * matrizrotacao[x, y].Height) + 20;
                    matrizrotacao[x, y].Left = y * TamanhoText2;
                    matrizrotacao[x, y].Width = TamanhoText2;
                    groupBox5.Controls.Add(matrizrotacao[x, y]);
                }
            }

        }
        //troca linha por coluna -- ok
        private void Transposta()
        {
            if (MatrixR != null)
            {
                for (int i = 0; i < MatrixR.GetLength(0); i++)
                {
                    for (int j = 0; j < MatrixR.GetLength(1); j++)
                    {
                        if (MatrixR[i, j] != null)
                            groupBox3.Controls.Remove(MatrixR[i, j]);
                    }
                }
            }

            MatrixR = new TextBox[coluna1,linha1];

            for (int i = 0; i < MatrixR.GetLength(0); i++)
            {
                for (int j = 0; j < MatrixR.GetLength(1); j++)
                {
                    MatrixR[i, j] = new TextBox();
                    if(matrizReferente == "Matriz1")MatrixR[i, j].Text = Convert.ToString(Matrix1[j,i].Text);
                    else if (matrizReferente == "Matriz2") MatrixR[i, j].Text = Convert.ToString(Matrix2[j, i].Text);
                    MatrixR[i, j].Top = (i * MatrixR[i, j].Height) + 10;
                    MatrixR[i, j].Left = (j * 35) + 10;
                    MatrixR[i, j].Width = 30;
                    groupBox3.Controls.Add(MatrixR[i, j]);
                }
            }
        }
        private void button8_Click(object sender, EventArgs e)
        {
            Calculos.number = Convert.ToInt32(textBox3.Text);


            groupBox3.Controls.Clear();
            float[,] tempMatriz1 = new float[resultante.GetLength(0), resultante.GetLength(1)];

            for (int x = 0; x < resultante.GetLength(0); x++)
            {

                for (int y = 0; y < resultante.GetLength(1); y++)
                {

                    float n = 0;
                    float.TryParse(resultante[x, y].Text, out n);
                    tempMatriz1[x, y] = n;


                }
            }


            float[,] tempMatrizResultante = Calculos.NumeroReal(tempMatriz1);
            resultante = new TextBox[tempMatrizResultante.GetLength(0), tempMatrizResultante.GetLength(1)];
            int TamanhoText = groupBox3.Width / resultante.GetLength(1);

            for (int x = 0; x < resultante.GetLength(0); x++)
            {
                for (int y = 0; y < resultante.GetLength(1); y++)
                {
                    resultante[x, y] = new TextBox();
                    resultante[x, y].KeyPress += new KeyPressEventHandler(keypressed);
                    resultante[x, y].TextAlign = HorizontalAlignment.Center;
                    resultante[x, y].Text = tempMatrizResultante[x, y].ToString();
                    resultante[x, y].Top = (x * resultante[x, y].Height) + 20;
                    resultante[x, y].Left = y * TamanhoText;
                    resultante[x, y].Width = TamanhoText;
                    groupBox3.Controls.Add(resultante[x, y]);
                }
            }
        }