private async void SaveAsMenuClick(object sender, ExecutedRoutedEventArgs e) { SaveFileDialog sfd = new SaveFileDialog { Filter = "(Текстовые файлы)|*.txt" }; if (sfd.ShowDialog() == true) { pathToFile = sfd.FileName; labelPathToFile.Content = pathToFile; } else { return; } try { matrix.ArrE.GiveMeMatrixFromTextBox(richTextBoxE); matrix.ArrK.GiveMeMatrixFromTextBox(richTextBoxK); await Task.Factory.StartNew(() => WorkWithFiles.SaveMatrixAs(pathToFile, matrix)); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } }
private async void OpenMenuClick(object sender, ExecutedRoutedEventArgs e) { OpenFileDialog ofd = new OpenFileDialog { Filter = "(Текстовые файлы)|*.txt" }; if (ofd.ShowDialog() == true) { pathToFile = ofd.FileName; labelPathToFile.Content = pathToFile; } else { return; } richTextBoxE.Document.Blocks.Clear(); richTextBoxK.Document.Blocks.Clear(); try { matrix = await Task <Matrix> .Factory.StartNew(() => WorkWithFiles.OpenMatrix(pathToFile)); richTextBoxE.PrintMassiveE(matrix.ArrE, true); richTextBoxK.PrintMassiveK(matrix.ArrK); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private async void SaveMenuClick(object sender, ExecutedRoutedEventArgs e) { if (pathToFile != null) { try { matrix.ArrE.GiveMeMatrixFromTextBox(richTextBoxE); matrix.ArrK.GiveMeMatrixFromTextBox(richTextBoxK); await Task.Factory.StartNew(() => WorkWithFiles.SaveMatrixAs(pathToFile, matrix)); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error); } } else { SaveAsMenuClick(sender, e); } }