/// <include file='doc\StyleBuilderSite.uex' path='docs/doc[@for="StyleBuilderSite.GetUIFont"]/*' /> /// <devdoc> /// </devdoc> public Font GetUIFont() { Font uiFont = null; if (site != null) { try { IUIHostLocale uiService = (IUIHostLocale)QueryService(typeof(IUIHostLocale)); _LOGFONTW lfUnicode = new _LOGFONTW(); uiService.GetDialogFont(lfUnicode); NativeMethods.LOGFONT lfAuto = lfUnicode.ToLOGFONT_Internal(); uiFont = Font.FromLogFont(lfAuto); } catch (Exception e) { Debug.Fail(e.ToString()); } } if (uiFont == null) { try { // this is what VS returns... uiFont = new Font("Tahoma", 11, FontStyle.Regular, GraphicsUnit.World); } catch { uiFont = Control.DefaultFont; } } return(uiFont); }
/// <summary> /// Gets the font provided by the VS environment for dialog UI. /// </summary> /// <returns>Dialog font, or null if it is not available.</returns> public static Font GetDialogFont() { IUIHostLocale uiHostLocale = WixHelperMethods.GetServiceNoThrow <IUIHostLocale, IUIHostLocale>(WixPackage.Instance); if (uiHostLocale != null) { UIDLGLOGFONT[] pLOGFONT = new UIDLGLOGFONT[1]; if (uiHostLocale.GetDialogFont(pLOGFONT) == 0) { return(Font.FromLogFont(pLOGFONT[0])); } } return(null); }
Font GetVSFont() { IUIHostLocale hostLocale = _serviceProvider.GetService(typeof(IUIHostLocale)) as IUIHostLocale; if (hostLocale != null) { UIDLGLOGFONT[] dlgFont = new UIDLGLOGFONT[] { new UIDLGLOGFONT() }; hostLocale.GetDialogFont(dlgFont); return(Font.FromLogFont(dlgFont[0])); } else { return(base.Font); } }
/// <summary> /// This is used to get the current dialog font for use in property pages, etc. /// </summary> /// <returns>The current dialog font or a Segoe UI 9pt font if it is not available</returns> public static Font GetDialogFont() { IUIHostLocale host = GetServiceFromPackage <IUIHostLocale, IUIHostLocale>(false); if (host != null) { UIDLGLOGFONT[] pLOGFONT = new UIDLGLOGFONT[1]; if (host.GetDialogFont(pLOGFONT) == 0) { return(Font.FromLogFont(pLOGFONT[0])); } } return(new Font("Segoe UI", 9.0f)); }
/// <summary> /// Gets the font provided by the VS environment for dialog UI. /// </summary> /// <returns>Dialog font, or null if it is not available.</returns> public static Font GetDialogFont() { IUIHostLocale uiHostLocale = XHelperMethods.GetServiceNoThrow <IUIHostLocale, IUIHostLocale>(AsyncProjectPackage.Instance); ThreadHelper.ThrowIfNotOnUIThread(); if (uiHostLocale != null) { UIDLGLOGFONT[] pLOGFONT = new UIDLGLOGFONT[1]; if (uiHostLocale.GetDialogFont(pLOGFONT) == 0) { return(Font.FromLogFont(pLOGFONT[0])); } } return(null); }
/// <summary> /// Returns the current VS font from the provider /// </summary> /// <param name="provider">An IServiceProvider that contains IUIHostLocale</param> /// <returns>The current VS font</returns> internal static Font GetVsFont(IServiceProvider provider) { if (provider != null) { IUIHostLocale service = (IUIHostLocale)provider.GetService(typeof(IUIHostLocale)); UIDLGLOGFONT[] dlgFont = new UIDLGLOGFONT[1]; if (service != null && 0 == service.GetDialogFont(dlgFont)) { try { return(Font.FromLogFont(dlgFont[0])); } catch (ArgumentException) { // This can happen if a non-TrueType font is set as the system Icon font. // Eat the exception and use the system dialog font. } } } return(SystemFonts.DialogFont); }
internal static Font GetFontFromShell(IUIHostLocale locale) { _LOGFONTW font = new _LOGFONTW(); locale.GetDialogFont(font); NativeMethods.LOGFONT lfAuto = font.ToLOGFONT_Internal(); Font shellFont = null; if (lfAuto != null) { try { shellFont = Font.FromLogFont(lfAuto); } catch (ArgumentException) { } } if (shellFont == null) { shellFont = Control.DefaultFont; } return(shellFont); }