本文整理汇总了C#中UnsafeNativeMethods.GetBold方法的典型用法代码示例。如果您正苦于以下问题:C# UnsafeNativeMethods.GetBold方法的具体用法?C# UnsafeNativeMethods.GetBold怎么用?C# UnsafeNativeMethods.GetBold使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnsafeNativeMethods
的用法示例。
在下文中一共展示了UnsafeNativeMethods.GetBold方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FontToIFont
// Returns whether or not target was changed
internal static bool FontToIFont(Font source, UnsafeNativeMethods.IFont target) {
bool changed = false;
// we need to go through all the pain of the diff here because
// it looks like setting them all has different results based on the
// order and each individual IFont implementor...
//
string fontName = target.GetName();
if (!source.Name.Equals(fontName)) {
target.SetName(source.Name);
changed = true;
}
// [....], Review: this always seems to come back as
// the point size * 10000 (HIMETRIC?), regardless
// or ratio or mapping mode, and despite what
// the documentation says...
//
// Either figure out what's going on here or
// do the process that the windows forms FONT object does here
// or, worse case, just create another Font object
// from the handle, but that's pretty heavy...
//
float fontSize = (float)target.GetSize() / 10000;
// size must be in points
float winformsSize = source.SizeInPoints;
if (winformsSize != fontSize) {
target.SetSize((long)(winformsSize * 10000));
changed = true;
}
NativeMethods.LOGFONT logfont = new NativeMethods.LOGFONT();
IntSecurity.ObjectFromWin32Handle.Assert();
try {
source.ToLogFont(logfont);
}
finally {
CodeAccessPermission.RevertAssert();
}
short fontWeight = target.GetWeight();
if (fontWeight != logfont.lfWeight) {
target.SetWeight((short)logfont.lfWeight);
changed = true;
}
bool fontBold = target.GetBold();
if (fontBold != (logfont.lfWeight >= 700)) {
target.SetBold(logfont.lfWeight >= 700);
changed = true;
}
bool fontItalic = target.GetItalic();
if (fontItalic != (0 != logfont.lfItalic)) {
target.SetItalic(0 != logfont.lfItalic);
changed = true;
}
bool fontUnderline = target.GetUnderline();
if (fontUnderline != (0 != logfont.lfUnderline)) {
target.SetUnderline(0 != logfont.lfUnderline);
changed = true;
}
bool fontStrike = target.GetStrikethrough();
if (fontStrike != (0 != logfont.lfStrikeOut)) {
target.SetStrikethrough(0 != logfont.lfStrikeOut);
changed = true;
}
short fontCharset = target.GetCharset();
if (fontCharset != logfont.lfCharSet) {
target.SetCharset(logfont.lfCharSet);
changed = true;
}
return changed;
}