protected override void Run () { var active = IdeApp.Workbench.ActiveDocument; if (active == null) return; var activeNotebook = ((SdiWorkspaceWindow)active.Window).TabControl; var except = GetDocumentException (); var docs = IdeApp.Workbench.Documents .Where (doc => ((SdiWorkspaceWindow)doc.Window).TabControl == activeNotebook && (except == null || doc.Window.ViewContent != except)) .ToArray (); var dirtyDialogShown = docs.Count (doc => doc.IsDirty) > 1; if (dirtyDialogShown) using (var dlg = new DirtyFilesDialog (docs, closeWorkspace: false, groupByProject: false)) { dlg.Modal = true; if (MessageService.ShowCustomDialog (dlg) != (int)Gtk.ResponseType.Ok) return; } foreach (Document doc in docs) if (dirtyDialogShown) doc.Window.CloseWindow (true); else doc.Close (); }
protected override bool OnDeleteEvent (Event evnt) { var documents = IdeApp.Workbench.Documents.Where (IsChildOfMe).ToList (); int howManyDirtyFiles = documents.Count (doc => doc.IsDirty); if (howManyDirtyFiles > 1) { using (var dlg = new DirtyFilesDialog (documents, closeWorkspace: false, groupByProject: false)) { dlg.Modal = true; if (MessageService.ShowCustomDialog (dlg) != (int)Gtk.ResponseType.Ok) return true; } } else if (howManyDirtyFiles == 1) { // Ensure dirty file is closed first. This prevents saved files being closed // if the save is cancelled. documents.Sort (DirtyFilesFirst); } foreach (var d in documents) { if (howManyDirtyFiles > 1) d.Window.CloseWindow (true); else if (!d.Close ()) return true; } return base.OnDeleteEvent (evnt); }
public bool Close() { if (!IdeApp.OnExit ()) return false; IdeApp.Workspace.SavePreferences (); bool showDirtyDialog = false; foreach (IViewContent content in viewContentCollection) { if (content.IsDirty) { showDirtyDialog = true; break; } } if (showDirtyDialog) { DirtyFilesDialog dlg = new DirtyFilesDialog (); dlg.Modal = true; if (MessageService.ShowCustomDialog (dlg, this) != (int)Gtk.ResponseType.Ok) return false; } if (!IdeApp.Workspace.Close (false, false)) return false; CloseAllViews (); PropertyService.Set ("SharpDevelop.Workbench.WorkbenchMemento", this.Memento); IdeApp.OnExited (); OnClosed (null); IdeApp.CommandService.Dispose (); return true; }
protected override void Run () { if (IdeApp.Workbench.Documents.Any (doc => doc.IsDirty)) { DirtyFilesDialog dlg = new DirtyFilesDialog (); dlg.Modal = true; if (MessageService.ShowCustomDialog (dlg, IdeApp.Workbench.RootWindow) != (int)Gtk.ResponseType.Ok) return; } foreach (Document doc in IdeApp.Workbench.Documents) { doc.IsDirty = false; } IdeApp.Workbench.CloseAllDocuments (false); }