Пример #1
0
        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);
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
 public void Hit()
 {
     LastHitUTC = DateTime.UtcNow;
     if (WeakContent != null)
     {
         Content     = (DocumentViewerContent)WeakContent.Target;
         WeakContent = null;
     }
 }
Пример #4
0
        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);
            }
        }
Пример #5
0
        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);
        }
Пример #6
0
		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();
     }
 }
Пример #8
0
 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);
     }
 }
Пример #9
0
        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);
        }
Пример #10
0
        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);
        }
Пример #11
0
 public Item(DocumentViewerContent content, IContentType contentType)
 {
     Content     = content;
     ContentType = contentType;
     LastHitUTC  = DateTime.UtcNow;
 }
Пример #12
0
 public CurrentContent(DocumentViewerContent content, IContentType contentType)
 {
     Content          = content;
     this.contentType = contentType;
 }
Пример #13
0
		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;
		}
Пример #14
0
		/// <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;
		}