public DocumentViewerControl(ITextBufferFactoryService textBufferFactoryService, IDnSpyTextEditorFactoryService dnSpyTextEditorFactoryService, IDocumentViewerHelper textEditorHelper) { if (textBufferFactoryService == null) { throw new ArgumentNullException(nameof(textBufferFactoryService)); } if (dnSpyTextEditorFactoryService == null) { throw new ArgumentNullException(nameof(dnSpyTextEditorFactoryService)); } if (textEditorHelper == null) { throw new ArgumentNullException(nameof(textEditorHelper)); } this.textEditorHelper = textEditorHelper; this.defaultContentType = textBufferFactoryService.TextContentType; this.cachedColorsList = new CachedColorsList(); this.emptyContent = new DocumentViewerContent(string.Empty, CachedTextColorsCollection.Empty, SpanDataCollection <ReferenceInfo> .Empty, new Dictionary <string, object>()); this.currentContent = new CurrentContent(emptyContent, defaultContentType); this.spanReferenceCollection = SpanDataCollection <ReferenceAndId> .Empty; var textBuffer = textBufferFactoryService.CreateTextBuffer(textBufferFactoryService.TextContentType); CachedColorsListTaggerProvider.AddColorizer(textBuffer, cachedColorsList); var roles = dnSpyTextEditorFactoryService.CreateTextViewRoleSet(defaultRoles); var textView = dnSpyTextEditorFactoryService.CreateTextView(textBuffer, roles, (TextViewCreatorOptions)null); var wpfTextViewHost = dnSpyTextEditorFactoryService.CreateTextViewHost(textView, false); this.wpfTextViewHost = wpfTextViewHost; wpfTextViewHost.TextView.Options.SetOptionValue(DefaultWpfViewOptions.AppearanceCategory, AppearanceCategoryConstants.Viewer); wpfTextViewHost.TextView.Options.SetOptionValue(DefaultTextViewOptions.ViewProhibitUserInputId, true); wpfTextViewHost.TextView.Options.SetOptionValue(DefaultTextViewHostOptions.GlyphMarginId, true); Children.Add(wpfTextViewHost.HostControl); }
public LogEditor(LogEditorOptions options, IDnSpyTextEditorFactoryService dnSpyTextEditorFactoryService, IContentTypeRegistryService contentTypeRegistryService, ITextBufferFactoryService textBufferFactoryService, IEditorOptionsFactoryService editorOptionsFactoryService) { this.dispatcher = Dispatcher.CurrentDispatcher; this.cachedColorsList = new CachedColorsList(); options = options?.Clone() ?? new LogEditorOptions(); options.CreateGuidObjects = CommonGuidObjectsProvider.Create(options.CreateGuidObjects, new GuidObjectsProvider(this)); var contentType = contentTypeRegistryService.GetContentType(options.ContentType, options.ContentTypeString) ?? textBufferFactoryService.TextContentType; var textBuffer = textBufferFactoryService.CreateTextBuffer(contentType); CachedColorsListTaggerProvider.AddColorizer(textBuffer, cachedColorsList); var rolesList = new List <string>(defaultRoles); rolesList.AddRange(options.ExtraRoles); var roles = dnSpyTextEditorFactoryService.CreateTextViewRoleSet(rolesList); var textView = dnSpyTextEditorFactoryService.CreateTextView(textBuffer, roles, editorOptionsFactoryService.GlobalOptions, options); var wpfTextViewHost = dnSpyTextEditorFactoryService.CreateTextViewHost(textView, false); this.wpfTextViewHost = wpfTextViewHost; this.wpfTextView = wpfTextViewHost.TextView; wpfTextView.Options.SetOptionValue(DefaultTextViewHostOptions.LineNumberMarginId, false); wpfTextView.Options.SetOptionValue(DefaultTextViewOptions.DragDropEditingId, false); wpfTextView.Options.SetOptionValue(DefaultTextViewOptions.ViewProhibitUserInputId, true); wpfTextView.Options.SetOptionValue(DefaultTextViewHostOptions.GlyphMarginId, false); wpfTextView.Options.SetOptionValue(DefaultTextViewOptions.WordWrapStyleId, WordWrapStylesConstants.DefaultValue); wpfTextView.Options.SetOptionValue(DefaultTextViewOptions.AutoScrollId, true); SetNewDocument(); }