public bool CloseDocument(Document doc, bool force = false) { int currentIndex = documents.IndexOf(Document.Current); string systemPath; if (force || doc.Close()) { SceneCache.InvalidateEntryFromOpenedDocumentChanged(doc.Path, null); SceneCache.Clear(doc.Path); documents.Remove(doc); if (GetFullPath(AutosaveProcessor.GetTemporaryFilePath(doc.Path), out systemPath)) { File.Delete(systemPath); } if (doc == Document.Current) { if (documents.Count > 0) { documents[currentIndex.Min(Documents.Count - 1)].MakeCurrent(); } else { Document.SetCurrent(null); ProjectUserPreferences.Instance.CurrentDocument = null; } } return(true); } return(false); }
public bool CloseDocument(Document doc) { int currentIndex = documents.IndexOf(Document.Current); string systemPath; if (doc.Close()) { documents.Remove(doc); if (GetSystemPath(AutosaveProcessor.GetTemporalFilePath(doc.Path), out systemPath)) { File.Delete(systemPath); } if (doc == Document.Current) { if (documents.Count > 0) { documents[currentIndex.Min(Documents.Count - 1)].MakeCurrent(); } else { Document.SetCurrent(null); } } return(true); } return(false); }
public Document OpenDocument(string path, bool pathIsGlobal = false) { string localPath = path; if (pathIsGlobal) { if (this == Null || !Current.TryGetAssetPath(path, out localPath)) { OpenFileOutsideProjectAttempt(path); return(null); } } localPath = AssetPath.CorrectSlashes(localPath); var doc = Documents.FirstOrDefault(i => i.Path == localPath); if (doc == null) { var tmpFile = AutosaveProcessor.GetTemporalFilePath(localPath); string systemPath; if (GetSystemPath(tmpFile, out systemPath) && TempFileLoadConfirmation.Invoke(localPath)) { doc = new Document(tmpFile); doc.SaveAs(localPath); } else { doc = new Document(localPath); } if (systemPath != null) { File.Delete(systemPath); } documents.Add(doc); } doc.MakeCurrent(); AddRecentDocument(doc.Path); return(doc); }
public Document OpenDocument(string path, bool pathIsAbsolute = false, bool delayLoad = false) { var localPath = GetLocalDocumentPath(path, pathIsAbsolute); if (string.IsNullOrEmpty(localPath)) { OpenFileOutsideProjectAttempt(path); return(null); } var doc = Documents.FirstOrDefault(i => i.Path == localPath); if (doc == null) { var tmpFile = AutosaveProcessor.GetTemporaryFilePath(localPath); string systemPath; if (GetFullPath(tmpFile, out systemPath) && TempFileLoadConfirmation.Invoke(localPath)) { doc = new Document(tmpFile); doc.SaveAs(localPath); } else { doc = new Document(localPath, delayLoad); } if (systemPath != null) { File.Delete(systemPath); } documents.Add(doc); } if (!delayLoad) { doc.MakeCurrent(); } AddRecentDocument(doc.Path); return(doc); }