/// <summary> /// Возвращает к предыдущем окну. /// </summary> /// <param name="sender">CodeWindow</param> /// <param name="e">RoutedEventArgs</param> private void PreviousWindowButton_Click(object sender, RoutedEventArgs e) { CodeDescriptionWindow win = new CodeDescriptionWindow(AGCode); win.Top = this.Top; win.Left = this.Left; win.Show(); this.Close(); }
/// <summary> /// Переходит к окну с характеристиками выбранного кода или к окну для создания нового кода. /// </summary> /// <param name="sender">SelectCodeWindow</param> /// <param name="e">RoutedEventArgs</param> private void nextWindowButton_Click(object sender, RoutedEventArgs e) { if ((codeSelector.SelectedIndex >= 0) && (codeSelector.SelectedIndex < codes.Count)) { CodeDescriptionWindow win2 = new CodeDescriptionWindow(codes[codeSelector.SelectedIndex]); win2.Top = this.Top; win2.Left = this.Left; win2.Show(); this.Close(); } else if (itemName == "Cоздать новый код...") { CodeGeneratingWindow win2 = new CodeGeneratingWindow(); win2.Top = this.Top; win2.Left = this.Left; win2.Show(); this.Close(); } else { codeSelector.IsDropDownOpen = true; } }
/// <summary> /// Генерирует алгеброгеометрический код. /// </summary> /// <param name="sender">CodeGeneratingWindow</param> /// <param name="e">RoutedEventArgs</param> private void NextWindowButton_Click(object sender, RoutedEventArgs e) { try { t.Content = ""; if (groupSize == 0) { throw new ArgumentNullException("количество переменных", "Невведено количество переменных!"); } /* * for (int i = 0; i < equations.Document.Blocks.Count; i++) * { * equations.Document.Blocks.ElementAt<Block>(i).Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); * } */ foreach (Block block in equations.Document.Blocks) { block.Foreground = new SolidColorBrush(Color.FromArgb(255, 0, 0, 0)); } #region Формирование системы уравнений в памяти line = new TextRange(equations.Document.ContentStart, equations.Document.ContentEnd).Text; lines = line.Split('\n'); for (int i = 0; i < lines.Length; i++) { try { if (i != lines.Length - 1) { lines[i] = lines[i].Remove(lines[i].Length - 1, 1); } MyStatics.Reading(lines[i], groupSize, systemOfEquations, i); } catch (TokenizerException ex) { t.Content += (i + 1) + " уравнение: " + ex.Message + "\n"; equations.Document.Blocks.ElementAt <Block>(ex.Index).Foreground = new SolidColorBrush(Color.FromArgb(255, 200, 21, 21)); flag = false; } catch (ParserException ex) { t.Content += (i + 1) + " уравнение: " + ex.Message + "\n"; equations.Document.Blocks.ElementAt <Block>(ex.Index).Foreground = new SolidColorBrush(Color.FromArgb(255, 200, 21, 21)); flag = false; } catch (UnknownCodeMessageException ex) { t.Content += (i + 1) + " уравнение: " + ex.Message + "\n"; equations.Document.Blocks.ElementAt <Block>(ex.Index).Foreground = new SolidColorBrush(Color.FromArgb(255, 200, 21, 21)); flag = false; } } #endregion if (flag) { #region ешение системы уравнений theAnswer = solver.Solve(systemOfEquations); if (theAnswer.Matrix.Count == 0) { throw new NullReferenceException("Система уравнений не имеет решений!"); } #endregion #region Формирование кода и вывод на экран его основных параметров AGCode = new Code(theAnswer, lines); CodeDescriptionWindow win = new CodeDescriptionWindow(AGCode); win.Top = this.Top; win.Left = this.Left; win.Show(); this.Close(); #endregion } flag = true; } catch (CodeGeneratingException ex) { t.Content = ex.Message; foreach (Block block in equations.Document.Blocks) { block.Foreground = new SolidColorBrush(Color.FromArgb(255, 200, 21, 21)); } } catch (ArgumentNullException) { size.IsDropDownOpen = true; } catch (NullReferenceException ex) { t.Content += ex.Message; foreach (Block block in equations.Document.Blocks) { block.Foreground = new SolidColorBrush(Color.FromArgb(255, 200, 21, 21)); } } catch (TokenizerException ex) { t.Content += ex.Message + "\n"; equations.Document.Blocks.ElementAt(ex.Index).Foreground = new SolidColorBrush(Color.FromArgb(255, 200, 21, 21)); } catch (ParserException ex) { t.Content += ex.Message + "\n"; equations.Document.Blocks.ElementAt(ex.Index).Foreground = new SolidColorBrush(Color.FromArgb(255, 200, 21, 21)); } catch (UnknownCodeMessageException ex) { t.Content += ex.Message + "\n"; equations.Document.Blocks.ElementAt(ex.Index).Foreground = new SolidColorBrush(Color.FromArgb(255, 200, 21, 21)); } finally { systemOfEquations = new List <Equation>(); } }