Esempio n. 1
0
        public static void SetFontSize(this EnvDTE.DTE dte, DependencyObject view)
        {
            Contract.Requires(dte != null);
            Contract.Requires(view != null);

            const string CATEGORY_FONTS_AND_COLORS = "FontsAndColors";
            const string PAGE_TEXT_EDITOR          = "TextEditor";
            const string PROPERTY_FONT_SIZE        = "FontSize";

            try
            {
                var fontSize = dte.Maybe()
                               .Select(x => x.Properties[CATEGORY_FONTS_AND_COLORS, PAGE_TEXT_EDITOR])
                               .Select(x => x.Item(PROPERTY_FONT_SIZE))
                               .Select(x => x.Value)
                               .Return(x => Convert.ToDouble(x, CultureInfo.InvariantCulture));

                if (fontSize > 1)
                {
                    // Default in VS is 10, but looks like 12 in WPF
                    view.SetValue(Appearance.TextFontSizeProperty, fontSize * 1.2);
                }
            }
            catch
            {
            }
        }