/// <summary>
 /// Called to set the font of the preview control according to the user's preferences.
 /// </summary>
 /// <param name="font"></param>
 protected abstract void SetFont(LogFont font);
        protected override void OnCreateControl()
        {
            base.OnCreateControl();
            // This hack tries to apply the Roboto (24) font to all ListViewItems in this ListView
            // It only succeeds if the font is installed on the system.
            // Otherwise, a default sans serif font is used.
            Font roboto24 = new Font(SkinManager.ROBOTO_MEDIUM_12.FontFamily, 24);
            LogFont roboto24logfont = new LogFont();
            roboto24.ToLogFont(roboto24logfont);

            try
            {
                // Font.FromLogFont is the method used when drawing ListViewItems. I 'test' it in this safer context to avoid unhandled exceptions later.
                Font = Font.FromLogFont(roboto24logfont);
        }
            catch (ArgumentException)
            {
                Font = new Font(FontFamily.GenericSansSerif, 24);
    }
}
 void IPreviewHandlerVisuals.SetFont(ref LogFont plf)
 {
     SetFont(plf);
 }
Exemple #4
0
 /// <summary>
 /// Convert a Direct2D <see cref="Font"/> to a <see cref="System.Drawing.Font"/>.
 /// </summary>
 /// <param name="d2dFont">a Direct2D Font</param>
 /// <param name="font">a <see cref="System.Drawing.Font"/></param>
 /// <returns>true if the specified font object is part of the system font collection; otherwise, false.</returns>
 public bool ToSystemDrawingFont(Font d2dFont, out System.Drawing.Font font)
 {
     var logfontw = new LogFont();
     bool isSystemFont = ToLogFont(d2dFont, logfontw);
     font = System.Drawing.Font.FromLogFont(logfontw);
     return isSystemFont;
 }
Exemple #5
0
 /// <summary>	
 /// Creates a font object that matches the properties specified by the LOGFONT structure. 	
 /// </summary>	
 /// <param name="font">A <see cref="System.Drawing.Font"/> description. </param>
 /// <returns>a reference to a newly created <see cref="SharpDX.DirectWrite.Font"/>. </returns>
 /// <unmanaged>HRESULT IDWriteGdiInterop::CreateFontFromLOGFONT([In] const LOGFONTW* logFont,[Out] IDWriteFont** font)</unmanaged>
 public Font FromSystemDrawingFont(System.Drawing.Font font)
 {
     var logfontw = new LogFont();
     font.ToLogFont(logfontw);
     return FromLogFont(logfontw);
 }
 public static extern IntPtr CreateFontIndirect([In, MarshalAs(UnmanagedType.LPStruct)] LogFont lplf);
Exemple #7
0
 /// <summary>
 /// Called to set the font of the preview control according to the user's preferences.
 /// </summary>
 /// <param name="font"></param>
 protected abstract void SetFont(LogFont font);
Exemple #8
0
 void IPreviewHandlerVisuals.SetFont(ref LogFont plf)
 {
     SetFont(plf);
 }