public DocumentViewerControl(ITextBufferFactoryService textBufferFactoryService, IDsTextEditorFactoryService dsTextEditorFactoryService, IDocumentViewerHelper textEditorHelper) { if (textBufferFactoryService == null) { throw new ArgumentNullException(nameof(textBufferFactoryService)); } if (dsTextEditorFactoryService == null) { throw new ArgumentNullException(nameof(dsTextEditorFactoryService)); } this.textEditorHelper = textEditorHelper ?? throw new ArgumentNullException(nameof(textEditorHelper)); defaultContentType = textBufferFactoryService.TextContentType; cachedColorsList = new CachedColorsList(); emptyContent = new DocumentViewerContent(string.Empty, CachedTextColorsCollection.Empty, SpanDataCollection <ReferenceInfo> .Empty, new Dictionary <string, object>()); currentContent = new CurrentContent(emptyContent, defaultContentType); spanReferenceCollection = SpanDataCollection <ReferenceAndId> .Empty; var textBuffer = textBufferFactoryService.CreateTextBuffer(textBufferFactoryService.TextContentType); CachedColorsListTaggerProvider.AddColorizer(textBuffer, cachedColorsList); var roles = dsTextEditorFactoryService.CreateTextViewRoleSet(defaultRoles); var options = new TextViewCreatorOptions { EnableUndoHistory = false }; var textView = dsTextEditorFactoryService.CreateTextView(textBuffer, roles, options); var wpfTextViewHost = dsTextEditorFactoryService.CreateTextViewHost(textView, false); this.wpfTextViewHost = wpfTextViewHost; wpfTextViewHost.TextView.Options.SetOptionValue(DefaultWpfViewOptions.AppearanceCategory, AppearanceCategoryConstants.TextEditor); wpfTextViewHost.TextView.Options.SetOptionValue(DefaultTextViewOptions.ViewProhibitUserInputId, true); wpfTextViewHost.TextView.Options.SetOptionValue(DefaultTextViewHostOptions.GlyphMarginId, true); Children.Add(wpfTextViewHost.HostControl); }
public void Cache(IDecompiler decompiler, DocumentTreeNodeData[] nodes, DocumentViewerContent content, IContentType contentType) { var settings = decompiler.Settings; lock (lockObj) { var key = new Key(decompiler, nodes, settings); cachedItems[key] = new Item(content, contentType); } }
public void Hit() { LastHitUTC = DateTime.UtcNow; if (WeakContent != null) { Content = (DocumentViewerContent)WeakContent.Target; WeakContent = null; } }
public void Cache(ILanguage language, IFileTreeNodeData[] nodes, DocumentViewerContent content, IContentType contentType) { var settings = language.Settings; lock (lockObj) { var key = new Key(language, nodes, settings); cachedItems[key] = new Item(content, contentType); } }
void AddMethodDebugService(IDocumentViewer documentViewer, DocumentViewerContent content) { if (content == null) { return; } var service = new MethodDebugService(content.MethodDebugInfos, documentViewer.TextView.TextSnapshot, moduleIdProvider); documentViewer.AddContentData(MethodDebugServiceConstants.MethodDebugServiceKey, service); }
public void RaiseNewContentEvent(IDocumentViewer documentViewer, DocumentViewerContent content, IContentType contentType) { if (documentViewer == null) throw new ArgumentNullException(nameof(documentViewer)); if (content == null) throw new ArgumentNullException(nameof(content)); if (contentType == null) throw new ArgumentNullException(nameof(contentType)); var e = new DocumentViewerGotNewContentEventArgs(documentViewer, content, contentType); NotifyListeners(e); GotNewContent?.Invoke(this, e); }
void DisassemblyContentProvider_OnContentChanged(object sender, EventArgs e) { if (disposed) { return; } cachedDocumentViewerContent = null; if (isVisible) { Refresh(); } }
public void SetContent(DocumentViewerContent content, IContentType contentType) { if (isDisposed) { throw new ObjectDisposedException(nameof(IDocumentViewer)); } if (content == null) { throw new ArgumentNullException(nameof(content)); } if (documentViewerControl.SetContent(content, contentType)) { outputData.Clear(); var newContentType = documentViewerControl.TextView.TextBuffer.ContentType; GotNewContent?.Invoke(this, new DocumentViewerGotNewContentEventArgs(this, content, newContentType)); documentViewerServiceImpl.RaiseNewContentEvent(this, content, newContentType); } }
public void RaiseNewContentEvent(IDocumentViewer documentViewer, DocumentViewerContent content, IContentType contentType) { if (documentViewer == null) { throw new ArgumentNullException(nameof(documentViewer)); } if (content == null) { throw new ArgumentNullException(nameof(content)); } if (contentType == null) { throw new ArgumentNullException(nameof(contentType)); } var e = new DocumentViewerGotNewContentEventArgs(documentViewer, content, contentType); NotifyListeners(e); GotNewContent?.Invoke(this, e); }
public bool SetContent(DocumentViewerContent content, IContentType contentType) { if (content == null) { throw new ArgumentNullException(nameof(content)); } if (contentType == null) { contentType = defaultContentType; } HideCancelButton(); var newContent = new CurrentContent(content, contentType); if (currentContent.Equals(newContent)) { return(false); } currentContent = newContent; spanReferenceCollection = newContent.Content.GetCustomData <SpanDataCollection <ReferenceAndId> >(DocumentViewerContentDataIds.SpanReference) ?? SpanDataCollection <ReferenceAndId> .Empty; TextView.TextBuffer.ChangeContentType(contentType, null); cachedColorsList.Clear(); cachedColorsList.Add(0, content.ColorCollection); // If it's the same text, don't update text buffer and caret. It can be the same text if // it's not been cached, eg. it's the resources or some other content with UI content. // This simulates the cached code path above which also doesn't move the caret. And as // an added bonus, it will use less memory and CPU. bool sameText = IsSameTextAsCurrentSnapshot(TextView.TextSnapshot, content.Text); if (!sameText) { TextView.TextBuffer.Replace(new Span(0, TextView.TextBuffer.CurrentSnapshot.Length), content.Text); TextView.Caret.MoveTo(new SnapshotPoint(TextView.TextSnapshot, 0)); TextView.Caret.EnsureVisible(); TextView.Selection.Clear(); } return(true); }
public Item(DocumentViewerContent content, IContentType contentType) { Content = content; ContentType = contentType; LastHitUTC = DateTime.UtcNow; }
public CurrentContent(DocumentViewerContent content, IContentType contentType) { Content = content; this.contentType = contentType; }
public bool SetContent(DocumentViewerContent content, IContentType contentType) { if (isDisposed) throw new ObjectDisposedException(nameof(IDocumentViewer)); if (content == null) throw new ArgumentNullException(nameof(content)); if (documentViewerControl.SetContent(content, contentType)) { outputData.Clear(); var newContentType = documentViewerControl.TextView.TextBuffer.ContentType; GotNewContent?.Invoke(this, new DocumentViewerGotNewContentEventArgs(this, content, newContentType)); documentViewerServiceImpl.RaiseNewContentEvent(this, content, newContentType); return true; } else return false; }
/// <summary> /// Constructor /// </summary> /// <param name="documentViewer">Document viewer</param> /// <param name="content">New content</param> /// <param name="contentType">Content type</param> public DocumentViewerGotNewContentEventArgs(IDocumentViewer documentViewer, DocumentViewerContent content, IContentType contentType) : base(documentViewer) { if (content == null) throw new ArgumentNullException(nameof(content)); if (contentType == null) throw new ArgumentNullException(nameof(contentType)); Content = content; ContentType = contentType; }