internal void RecoderDocuments(int oldPlacement, int newPlacement) { if (this.documents == null) { return; } CocoStudio.Core.Document document = this.documents[oldPlacement]; this.documents.RemoveAt(oldPlacement); this.documents.Insert(newPlacement, document); }
private void OnWindowClosed(object sender, DocumentWindowEventArgs e) { IDocumentWindow window = (IDocumentWindow)sender; CocoStudio.Core.Document document = this.FindDocument(window); window.Closing -= new EventHandler <DocumentWindowEventArgs>(this.OnWindowClosing); window.Closed -= new EventHandler <DocumentWindowEventArgs>(this.OnWindowClosed); this.documents.Remove(document); this.OnDocumentClosed(document); document.DisposeDocument(); }
public CocoStudio.Core.Document OpenDocument(FilePath file, Project project, bool bringToFront = true) { if (string.IsNullOrEmpty(file.FileName)) { return((CocoStudio.Core.Document)null); } foreach (CocoStudio.Core.Document document in this.Documents) { IBaseViewContent baseViewContent = (IBaseViewContent)null; if (document.Window.ViewContent.CanReuseView((string)file)) { baseViewContent = (IBaseViewContent)document.Window.ViewContent; } if (baseViewContent != null) { if (project != null && document.Project != project) { document.SetProject(project); } if (bringToFront) { document.Select(); document.Window.SelectWindow(); } return(document); } } IProgressMonitor statusProgressMonitor = this.ProgressMonitors.GetStatusProgressMonitor(); FileOpenInfo openFileInfo = new FileOpenInfo(file, project, bringToFront); this.RealOpenFile(statusProgressMonitor, openFileInfo); statusProgressMonitor.Dispose(); if (openFileInfo.NewContent == null) { return((CocoStudio.Core.Document)null); } CocoStudio.Core.Document doc = this.WrapDocument(openFileInfo.NewContent.WorkbenchWindow); if (doc != null && openFileInfo.BringToFront) { doc.RunWhenLoaded((System.Action)(() => { if (doc.Window == null) { return; } doc.Window.SelectWindow(); })); } doc.SetProject(project); return(doc); }
private void OnDocumentClosing(CocoStudio.Core.Document doc) { try { DocumentEventArgs e = new DocumentEventArgs(doc); EventHandler <DocumentEventArgs> documentClosing = this.DocumentClosing; if (documentClosing == null) { return; } documentClosing((object)this, e); } catch (Exception ex) { LoggingService.LogError("Exception before closing documents", ex); } }
private void OnDocumentClosed(CocoStudio.Core.Document doc) { try { DocumentEventArgs e = new DocumentEventArgs(doc); EventHandler <DocumentEventArgs> documentClosed = this.DocumentClosed; if (documentClosed != null) { documentClosed((object)this, e); } Services.TaskService.Clear((object)doc); } catch (Exception ex) { LoggingService.LogError("Exception while closing documents", ex); } }
internal CocoStudio.Core.Document WrapDocument(IDocumentWindow window) { if (window == null) { return((CocoStudio.Core.Document)null); } CocoStudio.Core.Document document = this.FindDocument(window); if (document != null) { return(document); } CocoStudio.Core.Document doc = new CocoStudio.Core.Document(window); window.Closing += new EventHandler <DocumentWindowEventArgs>(this.OnWindowClosing); window.Closed += new EventHandler <DocumentWindowEventArgs>(this.OnWindowClosed); this.documents.Add(doc); doc.OnDocumentAttached(); this.OnDocumentOpened(new DocumentEventArgs(doc)); return(doc); }
public bool CloseAll(bool dontCloseCurrent = false) { CocoStudio.Core.Document document1 = !dontCloseCurrent ? (CocoStudio.Core.Document)null : this.ActiveDocument; bool flag = false; List <CocoStudio.Core.Document> documentList1 = new List <CocoStudio.Core.Document>(); List <CocoStudio.Core.Document> documentList2 = new List <CocoStudio.Core.Document>(); foreach (CocoStudio.Core.Document document2 in this.Documents) { if (document2 != document1) { documentList1.Add(document2); if (document2.IsDirty) { flag = true; documentList2.Add(document2); } } } if (flag) { string info; ButtonText btnText; if (documentList2.Count == 1) { info = string.Format(LanguageInfo.MessageBox188_AskSaveCurFile, (object)Path.GetFileName(documentList2[0].Name)); btnText = new ButtonText(LanguageInfo.Command_Save, LanguageInfo.Dialog_ButtonDontSave, LanguageInfo.Dialog_ButtonCancel); } else { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(LanguageInfo.MessageBox189_AskSaveFiles); foreach (CocoStudio.Core.Document document2 in documentList2) { stringBuilder.Append("\r\n " + Path.GetFileName(document2.Name)); } info = stringBuilder.ToString(); btnText = new ButtonText(LanguageInfo.Command_SaveAll, LanguageInfo.Dialog_ButtonDontSave, LanguageInfo.Dialog_ButtonCancel); } switch (MessageBox.Show(info, btnText, (Window)null, (string)null, MessageBoxImage.Info)) { case MessageBoxResult.Yes: foreach (CocoStudio.Core.Document document2 in documentList2) { document2.Save(); } if (document1 != null && document1.Project != null) { using (TaskServiceLock.Lock()) { document1.Project.ReloadReferencedProject(Services.ProgressMonitors.Default); break; } } else { break; } case MessageBoxResult.Cancel: return(false); } } foreach (CocoStudio.Core.Document document2 in documentList1) { document2.Close(true); } return(true); }