protected void OnDocumentOpened(Document document) { CheckDocumentIsClosed(document.Id); using (_serializationLock.DisposableWait()) { var oldDocuments = this.CurrentDocuments; var oldDocument = oldDocuments.GetDocument(document.Id); // TODO: If document exists but is not opened (i.e. a previously closed #include'd file), then re-use it. AddToOpenDocumentMap(document.Id); var currentDocuments = oldDocument != null ? oldDocuments.WithDocumentText(document.Id, document.SourceText) : oldDocuments.AddDocument(document); var newSolution = this.SetCurrentDocuments(currentDocuments); SignupForTextChanges(document.Id, document.SourceText.Container, (w, id, text) => w.OnDocumentTextChanged(id, text)); var newDoc = newSolution.GetDocument(document.Id); this.OnDocumentTextChanged(newDoc); DocumentOpened?.Invoke(this, new DocumentEventArgs(newDoc)); } RegisterText(document.SourceText.Container); }
/// <inheritdoc/> public sealed override async Task <bool> Initialize() { var projectWatcher = await StrideAssetsViewModel.Instance.Code.ProjectWatcher; RoslynHost = await projectWatcher.RoslynHost; Workspace = await StrideAssetsViewModel.Instance.Code.Workspace; Workspace.HostDocumentClosed += WorkspaceHostDocumentClosed; if (Asset.DocumentId == null) { return(false); } // Open document DocumentId = Workspace.OpenDocument(SourceTextContainer, await Asset.DocumentId, a => Dispatcher.Invoke(() => ProcessDiagnostics?.Invoke(this, a))); //Workspace.TrackDocument(await Asset.DocumentId, OnTextUpdated); // Failed? let's close editor right away if (DocumentId == null) { return(false); } DocumentOpened?.Invoke(this, EventArgs.Empty); return(true); }
public void OpenProgram(string fullpath) { var openedProgram = OpenedDocuments.FirstOrDefault(op => op.ProgramFullPath == fullpath); if (openedProgram != null) { DocumentOpened?.Invoke(this, new DocumentOpenEventArgs(openedProgram)); return; } var programforOpening = RecentPrograms.FirstOrDefault(p => p.ProgramFullPath == fullpath); if (programforOpening == null) { programforOpening = ProgramViewModel.Create(fullpath, this, TvcStudioSettings); RecentPrograms.Add(programforOpening); } if (programforOpening.ProgramState == ProgramState.NotFound) { TraceEngine.TraceError($"{programforOpening.ProgramFullPath} beolvasása sikertelen, a file nem található!"); return; } openedProgram = programforOpening.GetDocumentViewModel(); openedProgram.DocumentClosedEvent += OnDocumentClose; OpenedDocuments.Add(openedProgram); programforOpening.ProgramState = ProgramState.Opened; DocumentOpened?.Invoke(this, new DocumentOpenEventArgs(openedProgram)); }
// fired when a document is about to be shown on screen for various // reasons // public override int OnBeforeDocumentWindowShow( uint itemCookie, int first, IVsWindowFrame wf) { ThreadHelper.ThrowIfNotOnUIThread(); // this may be called any time after the solution is loaded since // window frames are lazily created when a tab is clicked for the // first time if (first == 0) { // only handle the first time a document is shown return(VSConstants.S_OK); } Trace( "OnBeforeDocumentWindowShow: {0}", VSDocument.DebugWindowFrameName(wf)); var d = VSDocument.DocumentFromWindowFrame(wf); if (d == null) { Error("OnBeforeDocumentWindowShow: frame has no document"); return(VSConstants.S_OK); } DocumentOpened?.Invoke(new VSDocument(d, wf)); return(VSConstants.S_OK); }
private void OnDocumentOpen(EventArgs e) { if (DocumentOpened != null) { DocumentOpened.Invoke(this, e); } }
void OnDocumentOpened(DocumentEventArgs e) { try { DocumentOpened?.Invoke(this, e); } catch (Exception ex) { LoggingService.LogError("Exception while opening documents", ex); } }
private void _HandleTextDocumentOpened(object sender, DidOpenTextDocumentParams e) { WorkspaceDocument document = new WorkspaceDocument(e.TextDocument.LanguageId, e.TextDocument.Text, e.TextDocument.Uri, e.TextDocument.Version); _documents.Add(document); DocumentOpened?.Invoke(this, document); }
public void OpenReadonlyDocument(string fullPath) { var openedProgram = OpenedDocuments.FirstOrDefault(op => op.ProgramFullPath == fullPath); if (openedProgram != null) { DocumentOpened?.Invoke(this, new DocumentOpenEventArgs(openedProgram)); return; } openedProgram = new ReadOnlyDocumentViewModel(fullPath, TvcStudioSettings); openedProgram.DocumentClosedEvent += OnDocumentClose; OpenedDocuments.Add(openedProgram); DocumentOpened?.Invoke(this, new DocumentOpenEventArgs(openedProgram)); }
protected virtual void OnDocumentOpened(VsDocumentEventArgs e) { DocumentOpened?.Invoke(this, e); }
private void DocumentEventsOnDocumentOpened(Document document) { _logger.LogVerbose($"{document.FullName}, {document.Type}"); DocumentOpened?.Invoke(document); }