private void btn_result_Click(object sender, EventArgs e) { Complex c1; var c2 = new Complex(); var d = 1.0; if (!TryGetComplex(textBoxReal1, textBoxImaginary1, out c1) || (CurrentOperation < Operation.Pow && !TryGetComplex(textBoxReal2, textBoxImaginary2, out c2)) || (CurrentOperation == Operation.Pow && !double.TryParse(textBoxPow.Text, out d))) { MessageBox.Show("Заполните поля корректными значениями!"); return; } string result; switch (CurrentOperation) { case Operation.Add: result = ComplexUtils.Add(c1, c2, checkBoxDetails.Checked); break; case Operation.Mul: result = ComplexUtils.Multiply(c1, c2, checkBoxDetails.Checked); break; case Operation.Div: result = ComplexUtils.Divide(c1, c2, checkBoxDetails.Checked); break; case Operation.Pow: result = ComplexUtils.Power(c1, d, checkBoxDetails.Checked); break; case Operation.Convert: result = ComplexUtils.Convert(c1, checkBoxDetails.Checked); break; default: throw new ArgumentOutOfRangeException(); } //очистка временной директории try { Directory.Delete(DirectoriesSettings.ComplexCalculatorPath, true); } catch (Exception ex) { Logs.WriteLine("При удалении старых файлов калькулятора комплексных чисел. Подробности:" + ex.Message); } var render = new TexUtils.Render(DirectoriesSettings.ComplexCalculatorPath); var lines = result.Split(new[] { Environment.NewLine }, StringSplitOptions.None); render.StringsToHtml(lines, "калькулятора матриц"); browserResults.Navigate("file:///" + render.HtmlPath); _settings.ApplyWebBrowserStyle(browserResults); }
private void btn_calculate_Click(object sender, EventArgs e) { Expression[,] A = new Expression[dgv_mtr1.Rows.Count, dgv_mtr1.Columns.Count]; Expression[,] B = new Expression[dgv_mtr2.Rows.Count, dgv_mtr2.Columns.Count]; try { ReadMatr(dgv_mtr1, A); } catch { MessageBox.Show("Ошибка при считывании первой матрицы", "Ошибка матрицы", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (dgv_mtr2.Visible) { try { ReadMatr(dgv_mtr2, B); } catch { MessageBox.Show("Ошибка при считывании второй матрицы", "Ошибка матрицы", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } foreach (object obj in groupBoxOperations.Controls) { if (obj is RadioButton) { RadioButton radioButton = (RadioButton)obj; string result = ""; if (radioButton.Checked) { Type matr_utils = typeof(MatrixUtils); switch (radioButton.Name) { case "radioButtonSumMatrix": result += MatrixUtils.две_матр_действия_сложение(A, B, this.chbx_details.Checked); break; case "radioButtonSubMatrix": result += MatrixUtils.две_матр_действия_вычитание(A, B, this.chbx_details.Checked); break; case "radioButtonMultMatrix": result += MatrixUtils.две_матр_действия_умножение(A, B, this.chbx_details.Checked); break; case "radioButtonDeterminantSarrus": result += MatrixUtils.определитель_саррюс(A, this.chbx_details.Checked); break; case "radioButtonDeterminantRow": result += MatrixUtils.определитель_разложение_строка(A, (int)numericUpDownDeterminantRow.Value - 1, this.chbx_details.Checked); break; case "radioButtonDeterminantColumn": result += MatrixUtils.определитель_разложение_столбец(A, (int)numericUpDownDeterminantColumn.Value - 1, this.chbx_details.Checked); break; case "radioButtonDeterminantLaplas": result += MatrixUtils.определитель_лаплас(A, (int)numericUpDownDeterminantLaplasString1.Value - 1, (int)numericUpDownDeterminantLaplasString2.Value - 1, this.chbx_details.Checked); break; case "radioButtonRankIdentityMatrix": result += MatrixUtils.ранг_метод_окаймляющих_миноров(A, this.chbx_details.Checked); break; case "radioButtonRankGauss": result += MatrixUtils.ранг(A, this.chbx_details.Checked); // неправильно работает для нулевой матрицы break; case "radioButtonEquationCheck": result += MatrixUtils.проверка_критерия_совместности(A, this.chbx_details.Checked); break; case "radioButtonEquationSolveGauss": result += MatrixUtils.слу_гаусс(A, this.chbx_details.Checked); // не всегда работает break; case "radioButtonReverseIdentity": result += MatrixUtils.обратная_матрица_приписывание(A, this.chbx_details.Checked); break; case "radioButtonReverseTransformation": result += MatrixUtils.обратная_матрица_алгебраические_дополнения(A, this.chbx_details.Checked); break; } TexUtils.Render r1 = new TexUtils.Render(DirectoriesSettings.MatrixCalculatorPath); string[] temp = result.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); r1.StringsToHtml(temp, "калькулятора матриц"); browser_results.Navigate(String.Format("file:///{0}", r1.HtmlPath)); settings.ApplyWebBrowserStyle(browser_results); } } } }