private void GetAnswer(object sender, EventArgs e) { int c = 0; string answer = ""; foreach (var i in TextLine.Text) { foreach (var h in new char[] { 'M', 'D', 'C', 'L', 'X', 'V', 'I' }) { if (i == h) { c += 1; } } } if (c == TextLine.Text.Length) { answer = GetFromRomeToArab(TextLine.Text); } else if (c == 0) { answer = GetFromArabToRome(TextLine.Text); } else { answer = "Неправильный запрос"; } TextArea.Text = answer; if (SettingsPage.CheckEventLogger) { PanelLogBook.InsertVariable("Конвертер чисел", TextLine.Text, TextArea.Text); } }
private void EnterAnswer(object sender, EventArgs e) { AnswerTextBox.Clear(); string answer = ""; if (FirstTextBox.Text != "" && SecondTextBox.Text != "") { bool boolean1 = NumberSystem.initilize_string(FirstTextBox.Text, Convert.ToInt32(FirstNumeric.Value)); bool boolean2 = NumberSystem.initilize_string(SecondTextBox.Text, Convert.ToInt32(SecondNumeric.Value)); if (boolean1 == true && boolean2 == true) { if (symbol != 'n') { try { string var1 = NumberSystem.numsysPoing2(FirstTextBox.Text, Convert.ToInt32(FirstNumeric.Value)); string var2 = NumberSystem.numsysPoing2(SecondTextBox.Text, Convert.ToInt32(SecondNumeric.Value)); switch (symbol) { case '+': answer = (Convert.ToInt32(var1) + Convert.ToInt32(var2)).ToString(); break; case '-': answer = (Convert.ToInt32(var1) - Convert.ToInt32(var2)).ToString(); break; case '/': answer = (Convert.ToInt32(var1) / Convert.ToInt32(var2)).ToString(); break; case '*': answer = (Convert.ToInt32(var1) * Convert.ToInt32(var2)).ToString(); break; } answer = NumberSystem.numsysPoint1(answer, Convert.ToInt32(AnswerNumeric.Value)); AnswerTextBox.Text += $"{FirstTextBox.Text}({FirstNumeric.Text}) {symbol} {SecondTextBox.Text}({SecondNumeric.Value}) = {answer}({AnswerNumeric.Value})"; if (SettingsPage.CheckEventLogger) { PanelLogBook.InsertVariable("Вычисление СС", $"{FirstTextBox.Text}({FirstNumeric.Text}) {symbol} {SecondTextBox.Text}({SecondNumeric.Value})", $"{answer} ({AnswerNumeric.Value})"); } } catch (OverflowException ex) { MessageBox.Show("Ошибка", ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { AnswerTextBox.Text += "Какую операцию должна выполнить программа!"; } } else if (boolean1 == false || boolean2 == false) { AnswerTextBox.Text += "Неправильный запрос!"; } } else { AnswerTextBox.Text += "Заполните все поля!"; } }
private new void Enter(object sender, EventArgs e) { TextArea.Clear(); string answer = ""; if (TextLine.Text != "") { if (initilize_string(TextLine.Text, Convert.ToInt32(Numeric1.Value)) == true) { try{ if (Numeric1.Value == 10 && Numeric2.Value != 10) { answer = numsysPoint1(TextLine.Text, Convert.ToInt32(Numeric2.Value)); } else if (Numeric2.Value == 10 && Numeric1.Value != 10) { answer = numsysPoing2(TextLine.Text, Convert.ToInt32(Numeric1.Value)); } else if (Numeric1.Value != Numeric2.Value) { answer = numsysPoing2(TextLine.Text, Convert.ToInt32(Numeric1.Value)); answer = numsysPoint1(answer, Convert.ToInt32(Numeric2.Value)); } else { TextArea.Text = "Один и тот же тип счисления"; return; } TextArea.Text = $"Ответ: {TextLine.Text}({Numeric1.Value}) = {answer}({Numeric2.Value})"; if (SettingsPage.CheckEventLogger) { PanelLogBook.InsertVariable("Система счислений", $"{TextLine.Text}({Numeric1.Value})", $"{answer}({Numeric2.Value})"); } } catch (OverflowException) { TextArea.Text = "Слишком большое число!"; } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), ex.Source.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { TextArea.Text = "Неправильный запрос!"; } } else { TextArea.Text = "Заполните строку!"; } }
private void GetAnswer(object sender, EventArgs e) { TextLine.Clear(); ScriptEngine ScriptEngine = Python.CreateEngine(); ScriptScope ScriptScope = ScriptEngine.CreateScope(); string request = SetFloatNumbers(TextArea.Text); ScriptEngine.Execute("function = " + request + Environment.NewLine + "print function", ScriptScope); dynamic answer = ScriptScope.GetVariable("function"); if (SettingsPage.CheckEventLogger) { PanelLogBook.InsertVariable("Обычный калькулятор", TextArea.Text, Convert.ToString(answer)); } TextArea.Text = Convert.ToString(answer); }
private void StartScript(object sender, EventArgs e) { try { ConsoleTextBox.Text = ""; Console.Height = Console.MaximumSize.Height; string answer = "", error = ""; Evaluate.Eval(TextArea.Lines, out answer, out error); if (error != "") { ConsoleTextBox.Text += error; } else if (error == "" && answer != "") { ConsoleTextBox.Text += answer; } if (SettingsPage.CheckEventLogger) { PanelLogBook.InsertVariable("MathScript", TextArea.Text, ConsoleTextBox.Text); } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public new void Enter(object sender, EventArgs e) { TextArea.Clear(); if (TextLine.Text.IndexOf('a') >= 0 && TextLine.Text.IndexOf('b') >= 0) { if (numC == null || numC == "") { numC = "0"; } double argA = Convert.ToDouble(numA), argB = Convert.ToDouble(numB), argC = Convert.ToDouble(numC), D = Math.Sqrt((argB * argB) - 4 * argA * argC), x1 = 0, x2 = 0; TextArea.Text += $"{TextLine.Text} = 0;" + Environment.NewLine; TextArea.Text += $"D = {argB}^2 - 4 * {argA} * {argC} = √{D * D} = {D};" + Environment.NewLine; if (D >= 0) { x1 = (-argB + D) / (2 * argA); x2 = (-argB - D) / (2 * argA); TextArea.Text += $"x1 = {x1};" + Environment.NewLine; TextArea.Text += $"x2 = {x2};" + Environment.NewLine; TextArea.Text += $"Выражение в скобках: " + Environment.NewLine; if (argA != 1) { TextArea.Text += $"{argA}"; } TextArea.Text += "(x"; if (x1 < 0) { TextArea.Text += $" + {-x1}"; } else { TextArea.Text += $" - {x1}"; } TextArea.Text += ")(x"; if (x2 < 0) { TextArea.Text += $" + {-x2})"; } else { TextArea.Text += $" - {x2})"; } } else { TextArea.Text = "Нет корней"; } } else { TextArea.Text = "Неправильный запрос"; } if (SettingsPage.CheckEventLogger) { PanelLogBook.InsertVariable("Уравнение ax^2+bx+c", TextLine.Text, TextArea.Text); } reader = ""; TextLine.Clear(); }