/// <summary> /// Creates a new instance of CBRTagger /// </summary> /// <param name="provider">the CBETaggerProvider that created the tagger</param> /// <param name="textView">the WpfTextView this tagger is assigned to</param> /// <param name="sourceBuffer">the TextBuffer this tagger should work with</param> internal CBETagger(CBETaggerProvider provider, IWpfTextView textView) { if (provider == null || textView == null) { throw new ArgumentNullException("The arguments of CBETagger can't be null"); } _TextView = textView; // Getting services provided by VisualStudio _TextStructureNavigator = provider.GetTextStructureNavigator(_TextView.TextBuffer); _TextSearchService = provider.TextSearchService; _VSFontsInformation = TryGetFontAndColorInfo(provider.VsFontsAndColorsInformationService); // Hook up events _TextView.TextBuffer.Changed += TextBuffer_Changed; _TextView.LayoutChanged += OnTextViewLayoutChanged; _TextView.Caret.PositionChanged += Caret_PositionChanged; // Listen for package events InitializePackage(); if (_VSFontsInformation != null) { ReloadFontSize(); _VSFontsInformation.Updated += _VSFontsInformation_Updated; } }
private void ReloadFontSize(IVsFontsAndColorsInformation _VSFontsInformation) { var pref = _VSFontsInformation.GetFontAndColorPreferences(); var font = System.Drawing.Font.FromHfont(pref.hRegularViewFont); _FontSize = font?.Size ?? _FontSize; }