/// <summary> /// [See win32 equivalent.] /// Returns null if the returned font was not true type, since GDI+ does not support it. /// </summary> public Font?GetFont(IDeviceContext dc, FontProperty prop) { if (dc is null) { throw new ArgumentNullException(nameof(dc)); } SourceGenerated.EnumValidator.Validate(prop, nameof(prop)); using var hdc = new DeviceContextHdcScope(dc); _lastHResult = GetThemeFont(this, hdc, Part, State, (int)prop, out User32.LOGFONTW logfont); // Check for a failed HR. if (!_lastHResult.Succeeded()) { return(null); } try { return(Font.FromLogFont(logfont)); } catch (Exception e) { if (ClientUtils.IsCriticalException(e)) { throw; } // Looks like the font was not true type return(null); } }
public TableProperties() { Font = new FontProperty() { Size = 14, Name = "Times New Roman" }; Bookmark = "Bookmark"; }
public void VisualStyleRenderer_GetFont_for_InvalidFontProperty(FontProperty value) { var renderer = new VisualStyleRenderer("TEXTSTYLE", 1, 0); using var image = new Bitmap(10, 10); using Graphics graphics = Graphics.FromImage(image); Assert.Throws <InvalidEnumArgumentException>("prop", () => renderer.GetFont(graphics, value)); }
public Font GetFont(IDeviceContext dc, FontProperty prop) { throw new NotImplementedException(); //if (dc == null) // throw new ArgumentNullException ("dc"); //if (!Enum.IsDefined (typeof (FontProperty), prop)) // throw new System.ComponentModel.InvalidEnumArgumentException ("prop", (int)prop, typeof (FontProperty)); //UXTheme.LOGFONT lf = new UXTheme.LOGFONT(); //UXTheme.GetThemeFont (theme, dc.GetHdc (), this.part, this.state, (int)prop, out lf); //IntPtr fontPtr = UXTheme.CreateFontIndirect(lf); //dc.ReleaseHdc(); //return Font.FromLogFont(lf); //return null; }
/// <summary> /// [See win32 equivalent.] /// Returns null if the returned font was not true type, since GDI+ does not support it. /// </summary> public Font GetFont(IDeviceContext dc, FontProperty prop) { if (dc == null) { throw new ArgumentNullException(nameof(dc)); } //valid values are 0xa29 to 0xa29 if (!ClientUtils.IsEnumValid(prop, (int)prop, (int)FontProperty.GlyphFont, (int)FontProperty.GlyphFont)) { throw new InvalidEnumArgumentException(nameof(prop), (int)prop, typeof(FontProperty)); } NativeMethods.LOGFONTW logfont = new NativeMethods.LOGFONTW(); using (WindowsGraphicsWrapper wgr = new WindowsGraphicsWrapper(dc, AllGraphicsProperties)) { HandleRef hdc = new HandleRef(wgr, wgr.WindowsGraphics.DeviceContext.Hdc); lastHResult = SafeNativeMethods.GetThemeFont(new HandleRef(this, Handle), hdc, part, state, (int)prop, ref logfont); } Font font = null; //check for a failed HR. if (NativeMethods.Succeeded(lastHResult)) { try { font = Font.FromLogFont(logfont); } catch (Exception e) { if (ClientUtils.IsSecurityOrCriticalException(e)) { throw; } //Looks like the font was not true type font = null; } } return(font); }
/// <summary> /// [See win32 equivalent.] /// Returns null if the returned font was not true type, since GDI+ does not support it. /// </summary> public Font?GetFont(IDeviceContext dc, FontProperty prop) { if (dc == null) { throw new ArgumentNullException(nameof(dc)); } //valid values are 0xa29 to 0xa29 if (!ClientUtils.IsEnumValid(prop, (int)prop, (int)FontProperty.GlyphFont, (int)FontProperty.GlyphFont)) { throw new InvalidEnumArgumentException(nameof(prop), (int)prop, typeof(FontProperty)); } using var wgr = new WindowsGraphicsWrapper(dc, AllGraphicsProperties); var hdc = new HandleRef(wgr, wgr.WindowsGraphics.DeviceContext.Hdc); lastHResult = GetThemeFont(this, hdc, part, state, (int)prop, out User32.LOGFONTW logfont); // Check for a failed HR. if (!lastHResult.Succeeded()) { return(null); } try { return(Font.FromLogFont(logfont)); } catch (Exception e) { if (ClientUtils.IsSecurityOrCriticalException(e)) { throw; } // Looks like the font was not true type return(null); } }
/// <summary> /// [See win32 equivalent.] /// Returns null if the returned font was not true type, since GDI+ does not support it. /// </summary> public Font?GetFont(IDeviceContext dc, FontProperty prop) { if (dc is null) { throw new ArgumentNullException(nameof(dc)); } if (!ClientUtils.IsEnumValid_NotSequential(prop, (int)prop, (int)FontProperty.TextFont, (int)FontProperty.GlyphFont)) { throw new InvalidEnumArgumentException(nameof(prop), (int)prop, typeof(FontProperty)); } using var hdc = new DeviceContextHdcScope(dc); _lastHResult = GetThemeFont(this, hdc, Part, State, (int)prop, out User32.LOGFONTW logfont); // Check for a failed HR. if (!_lastHResult.Succeeded()) { return(null); } try { return(Font.FromLogFont(logfont)); } catch (Exception e) { if (ClientUtils.IsCriticalException(e)) { throw; } // Looks like the font was not true type return(null); } }
public Font GetFont(IDeviceContext dc, FontProperty prop) { if (dc == null) { throw new ArgumentNullException("dc"); } if (!System.Windows.Forms.ClientUtils.IsEnumValid(prop, (int)prop, 0xa29, 0xa29)) { throw new InvalidEnumArgumentException("prop", (int)prop, typeof(FontProperty)); } System.Windows.Forms.NativeMethods.LOGFONT pFont = new System.Windows.Forms.NativeMethods.LOGFONT(); using (WindowsGraphicsWrapper wrapper = new WindowsGraphicsWrapper(dc, TextFormatFlags.PreserveGraphicsTranslateTransform | TextFormatFlags.PreserveGraphicsClipping)) { HandleRef hdc = new HandleRef(wrapper, wrapper.WindowsGraphics.DeviceContext.Hdc); this.lastHResult = System.Windows.Forms.SafeNativeMethods.GetThemeFont(new HandleRef(this, this.Handle), hdc, this.part, this.state, (int)prop, pFont); } Font font = null; if (!System.Windows.Forms.NativeMethods.Succeeded(this.lastHResult)) { return(font); } System.Windows.Forms.IntSecurity.ObjectFromWin32Handle.Assert(); try { return(Font.FromLogFont(pFont)); } catch (Exception exception) { if (System.Windows.Forms.ClientUtils.IsSecurityOrCriticalException(exception)) { throw; } return(null); } }
set => SetValue(FontProperty, value);
public System.Drawing.Font GetFont(System.Drawing.IDeviceContext dc, FontProperty prop) { }
public Font GetFont(IDeviceContext dc, FontProperty prop) { if( dc == null ){ throw new ArgumentNullException("dc"); } //valid values are 0xa29 to 0xa29 if (!ClientUtils.IsEnumValid(prop, (int)prop, (int)FontProperty.GlyphFont, (int)FontProperty.GlyphFont)) { throw new InvalidEnumArgumentException("prop", (int)prop, typeof(FontProperty)); } NativeMethods.LOGFONT logfont = new NativeMethods.LOGFONT(); using( WindowsGraphicsWrapper wgr = new WindowsGraphicsWrapper( dc, AllGraphicsProperties ) ) { HandleRef hdc = new HandleRef( wgr, wgr.WindowsGraphics.DeviceContext.Hdc ); lastHResult = SafeNativeMethods.GetThemeFont( new HandleRef( this, Handle ), hdc, part, state, (int) prop, logfont ); } Font font = null; //check for a failed HR. if (NativeMethods.Succeeded(lastHResult)) { // SECREVIEW: Safe to assert here, since the logfont comes from a native api and not from the // caller of this method. The system creates the font handle. // IntSecurity.ObjectFromWin32Handle.Assert(); try { font = Font.FromLogFont(logfont); } catch (Exception e) { if (ClientUtils.IsSecurityOrCriticalException(e)) { throw; } //Looks like the font was not true type font = null; } } return font; }
public Font GetFont(IDeviceContext dc, FontProperty prop) { if (dc == null) { throw new ArgumentNullException("dc"); } if (!System.Windows.Forms.ClientUtils.IsEnumValid(prop, (int) prop, 0xa29, 0xa29)) { throw new InvalidEnumArgumentException("prop", (int) prop, typeof(FontProperty)); } System.Windows.Forms.NativeMethods.LOGFONT pFont = new System.Windows.Forms.NativeMethods.LOGFONT(); using (WindowsGraphicsWrapper wrapper = new WindowsGraphicsWrapper(dc, TextFormatFlags.PreserveGraphicsTranslateTransform | TextFormatFlags.PreserveGraphicsClipping)) { HandleRef hdc = new HandleRef(wrapper, wrapper.WindowsGraphics.DeviceContext.Hdc); this.lastHResult = System.Windows.Forms.SafeNativeMethods.GetThemeFont(new HandleRef(this, this.Handle), hdc, this.part, this.state, (int) prop, pFont); } Font font = null; if (!System.Windows.Forms.NativeMethods.Succeeded(this.lastHResult)) { return font; } System.Windows.Forms.IntSecurity.ObjectFromWin32Handle.Assert(); try { return Font.FromLogFont(pFont); } catch (Exception exception) { if (System.Windows.Forms.ClientUtils.IsSecurityOrCriticalException(exception)) { throw; } return null; } }
public Font GetFont (IDeviceContext dc, FontProperty prop) { throw new NotImplementedException(); //if (dc == null) // throw new ArgumentNullException ("dc"); //if (!Enum.IsDefined (typeof (FontProperty), prop)) // throw new System.ComponentModel.InvalidEnumArgumentException ("prop", (int)prop, typeof (FontProperty)); //UXTheme.LOGFONT lf = new UXTheme.LOGFONT(); //UXTheme.GetThemeFont (theme, dc.GetHdc (), this.part, this.state, (int)prop, out lf); //IntPtr fontPtr = UXTheme.CreateFontIndirect(lf); //dc.ReleaseHdc(); //return Font.FromLogFont(lf); //return null; }
public Font GetFont(IDeviceContext dc, FontProperty prop) { throw null; }
set { SetValue(FontProperty, value); }