private bool UnsavedChanges() { var msg = MessageBox.Show("Save Changes?", "Save", MessageBoxButton.YesNoCancel); switch (msg) { case MessageBoxResult.Cancel: return(true); case MessageBoxResult.No: return(false); case MessageBoxResult.Yes: { var dialog = new Microsoft.Win32.SaveFileDialog(); if (dialog.ShowDialog() ?? false) { _main.Save(dialog.FileName); } break; } } return(false); }
private void Save_Click(object sender, RoutedEventArgs e) { try { Microsoft.Win32.SaveFileDialog dialog = new Microsoft.Win32.SaveFileDialog(); if ((bool)dialog.ShowDialog()) { MainCollection.Save(dialog.FileName); } } catch (Exception ex) { MessageBox.Show("Saving Error: " + ex.Message); } finally { ErrorMsg(); } }
private void SaveData() { SaveFileDialog dialog = new SaveFileDialog(); dialog.Filter = "Serialized Data|*.sd|All|*.*"; dialog.FilterIndex = 2; if ((bool)dialog.ShowDialog()) { Data.Save(dialog.FileName); } }
private void SaveCommandHandler(object sender, ExecutedRoutedEventArgs e) { try { SaveFileDialog dlg = new SaveFileDialog(); if (dlg.ShowDialog() == true) { mainCollection.Save(dlg.FileName); } } catch (Exception ex) { MessageBox.Show(this, ex.Message); } }