示例#1
0
        private void bt_Calculate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                canvas.Children.Clear();

                double M1    = Convert.ToDouble(tb_M.Text.Replace(Convert.ToChar("."), Convert.ToChar(",")));
                double P1    = Convert.ToDouble(tb_P.Text.Replace(Convert.ToChar("."), Convert.ToChar(",")));
                double rho1  = Convert.ToDouble(tb_rho.Text.Replace(Convert.ToChar("."), Convert.ToChar(",")));
                double T1    = Convert.ToDouble(tb_T.Text.Replace(Convert.ToChar("."), Convert.ToChar(",")));
                double theta = Convert.ToDouble(tb_theta.Text.Replace(Convert.ToChar("."), Convert.ToChar(",")));
                double gamma = Convert.ToDouble(tb_Gamma.Text.Replace(Convert.ToChar("."), Convert.ToChar(",")));
                double R     = Convert.ToDouble(tb_R.Text.Replace(Convert.ToChar("."), Convert.ToChar(",")));

                matrix = new Matriz(rows, columns);
                double U1 = M1 * Math.Sqrt(R * gamma * T1);
                matrix.SetInitialConditions(M1, U1, 0, P1, rho1, T1, theta, gamma, R);
                matrix.CalculateSteps(theta, gamma, R);

                matrix.CalculatePolygons();

                double x = 0;
                for (int j = 0; j < columns && x < L; j++)
                {
                    x = matrix.Matrix[0, j].x;
                    for (int i = 0; i < rows - 1; i++)
                    {
                        canvas.Children.Add(matrix.Matrix[i, j].poligono);

                        // añadimos la cela a una lista.
                        listPolygons.Add(matrix.Matrix[i, j]);
                    }
                }
            }
            catch
            {
                MessageBox.Show("Pleae insert valid / reasonable values.");
            }
        }