private void openTranslationFile() { // Select file name. // TODO: Refactor to not use OpenFileDialog inside view model. var dialog = new OpenFileDialog { Filter = "XML File|*.xml", CheckFileExists = true }; if (dialog.ShowDialog() != true) { return; } // Read. var service = new TranslationFileService(dialog.FileName); try { var translations = service.Read(); Translations = new ObservableCollection <Translation>(translations); TranslationFileName = dialog.FileName; } catch (InvalidOperationException) { // TODO: Refactor to not use MessageBox inside view model. MessageBox.Show( "The translation file has incorrect data.", "Open error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void saveTranslationFile() { if (string.IsNullOrEmpty(TranslationFileName)) { // Select file name. // TODO: Refactor to not use SaveFileDialog inside view model. var dialog = new SaveFileDialog { Filter = "XML File|*.xml", OverwritePrompt = true, CheckPathExists = true, AddExtension = true }; if (dialog.ShowDialog() != true) { return; } TranslationFileName = dialog.FileName; } // Save. var service = new TranslationFileService(TranslationFileName); service.Save(Translations); // TODO: Refactor to not use MessageBox inside view model. MessageBox.Show("File was saved successfully.", "Save", MessageBoxButton.OK, MessageBoxImage.Information); }