public void Save(string file) { this.Mainframe.ResetAutoSaveTimer(); string oldFile = this.File; if (System.IO.File.Exists(file)) { string temp = Mainframe.TempFile(file); string backup = null; if (Settings.User.CreateBackupFileOnSave) { backup = Mainframe.BackupFile(file); } this.CircuitProject.Save(temp); System.IO.File.Replace(temp, file, backup); } else { this.CircuitProject.Save(file); } this.File = file; this.savedVersion = this.CircuitProject.Version; Mainframe.DeleteAutoSaveFile(oldFile); this.NotifyPropertyChanged("Caption"); }
private bool EnsureSaved() { if (this.Editor != null && this.Editor.HasChanges) { MessageBoxResult result = DialogMessage.Show(this, this.Title, Properties.Resources.MessageSaveFile(this.Editor.Project.Name), null, MessageBoxImage.Question, MessageBoxButton.YesNoCancel ); switch (result) { case MessageBoxResult.Yes: this.Save(); break; case MessageBoxResult.No: this.ResetAutoSaveTimer(); Mainframe.DeleteAutoSaveFile(this.Editor?.File); break; case MessageBoxResult.Cancel: this.Status = Properties.Resources.OperationCanceled; return(false); } } return(true); }