Esempio n. 1
0
        private IWpfTextViewHost CreateTextViewHost(string contentType)
        {
            var componentModel = ProjectHelpers.GetComponentModel();
            var service        = componentModel.GetService <IContentTypeRegistryService>();
            var type           = service.GetContentType(contentType);

            var              textBufferFactory = componentModel.GetService <ITextBufferFactoryService>();
            var              textViewFactory   = componentModel.GetService <ITextEditorFactoryService>();
            var              textRoles         = contentType == "JavaScript" ? new[] { PredefinedTextViewRoles.Document } : new[] { PredefinedTextViewRoles.Document, PredefinedTextViewRoles.Interactive };
            ITextBuffer      textBuffer        = textBufferFactory.CreateTextBuffer(string.Empty, type);
            ITextViewRoleSet roles             = textViewFactory.CreateTextViewRoleSet(textRoles);
            IWpfTextView     textView          = textViewFactory.CreateTextView(textBuffer, roles);
            IWpfTextViewHost host = textViewFactory.CreateTextViewHost(textView, false);

            return(host);
        }