Пример #1
0
        private IWpfTextViewHost CreateTextViewHost()
        {
            // Create buffer

            var contentType = ContentTypeRegistryService.GetContentType("NQuery");
            var textBuffer  = TextBufferFactoryService.CreateTextBuffer(contentType);

            var textView     = TextEditorFactoryService.CreateTextView(textBuffer);
            var textViewHost = TextEditorFactoryService.CreateTextViewHost(textView, false);

            // Set the appearance of collapsed text
            textViewHost.TextView.VisualElement.Resources["CollapsedTextForeground"] = new SolidColorBrush(Color.FromRgb(0xA5, 0xA5, 0xA5));
            textViewHost.HostControl.Resources["outlining.verticalrule.foreground"]  = new SolidColorBrush(Color.FromRgb(0xA5, 0xA5, 0xA5));

            // Set the background color of glyph margin
            const string indicatorMargin    = "Indicator Margin";
            var          backgroundColor    = Color.FromRgb(0xF0, 0xF0, 0xF0);
            var          editorFormatMap    = EditorFormatMapService.GetEditorFormatMap(textViewHost.TextView);
            var          resourceDictionary = editorFormatMap.GetProperties(indicatorMargin);

            resourceDictionary["BackgroundColor"] = backgroundColor;
            resourceDictionary["Background"]      = new SolidColorBrush(backgroundColor);
            editorFormatMap.SetProperties(indicatorMargin, resourceDictionary);

            return(textViewHost);
        }
Пример #2
0
        public IQuickInfoSource TryCreateQuickInfoSource(ITextBuffer textBuffer)
        {
            var classificationFormatMap = ClassificationFormatMapService.GetClassificationFormatMap(@"text");
            var editorFormatMap         = EditorFormatMapService.GetEditorFormatMap(@"text");

            return(new NQueryQuickInfoSource(classificationFormatMap, editorFormatMap, ClassificationService));
        }
Пример #3
0
        /// <summary>
        /// Instantiates a ColumnGuide manager when a textView is created.
        /// </summary>
        /// <param name="textView">The <see cref="IWpfTextView"/> upon which the adornment should be placed</param>
        public void TextViewCreated(IWpfTextView textView)
        {
            // Always create the adornment, even if there are no guidelines, since we
            // respond to dynamic changes.
            var formatMap = EditorFormatMapService.GetEditorFormatMap(textView);

            new ColumnGuide(textView, TextEditorGuidesSettings, formatMap);
        }
Пример #4
0
        /// <summary>
        /// Instantiates a ColumnGuide manager when a textView is created.
        /// </summary>
        /// <param name="textView">The <see cref="IWpfTextView"/> upon which the adornment should be placed</param>
        public void TextViewCreated(IWpfTextView textView)
        {
            // Always create the adornment, even if there are no guidelines, since we
            // respond to dynamic changes.
            var formatMap = EditorFormatMapService.GetEditorFormatMap(textView);

            new ColumnGuide(textView, TextEditorGuidesSettings, formatMap, Telemetry);

            // To reduce the amount of telemetry, only report the color for the first instance.
            if (!_colorReported)
            {
                _colorReported = true;
                var brush = GetGuidelineBrushFromFontsAndColors(formatMap);
                if (brush != null)
                {
                    Telemetry.Client.TrackEvent("CreateGuidelines", new Dictionary <string, string> {
                        ["Color"] = brush.ToString()
                    });
                }
            }
        }