Exemple #1
0
        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);
            wpfTextView.InitializeLocalZoomLevel();
            SetNewDocument();
        }