本文整理汇总了C#中GraphicsUnit类的典型用法代码示例。如果您正苦于以下问题:C# GraphicsUnit类的具体用法?C# GraphicsUnit怎么用?C# GraphicsUnit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GraphicsUnit类属于命名空间,在下文中一共展示了GraphicsUnit类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getTableHeaderOffset
internal static float getTableHeaderOffset(GraphicsUnit unit)
{
switch (unit)
{
case GraphicsUnit.Millimeter:
return 3.2f;
case GraphicsUnit.Inch:
return 1.0f / 6;
case GraphicsUnit.Point:
return 72.0f / 6;
case GraphicsUnit.Pixel:
return 12;
case GraphicsUnit.Document:
return 300.0f / 6;
case GraphicsUnit.Display:
return 75.0f / 6;
}
return 2;
}
示例2: Convert
public static float Convert(GraphicsUnit fromUnits, GraphicsUnit toUnits, float dpi, float value) {
float f1 = value;
if (fromUnits != toUnits) {
float f2;
GraphicsUnit graphicsUnit;
if (fromUnits == GraphicsUnit.Pixel) {
graphicsUnit = GraphicsUnit.Inch;
f2 = value / dpi;
} else {
f2 = value;
graphicsUnit = fromUnits;
}
if (graphicsUnit == toUnits) {
f1 = f2;
} else if (toUnits == GraphicsUnit.Pixel) {
if (graphicsUnit != GraphicsUnit.Inch) {
int i = GraphicsUnitIndex(graphicsUnit);
int j = GraphicsUnitIndex(GraphicsUnit.Inch);
f2 *= conversionRatios[i, j];
}
f1 = f2 * dpi;
} else {
int i = GraphicsUnitIndex(graphicsUnit);
int j = GraphicsUnitIndex(toUnits);
f1 = f2 * conversionRatios[i, j];
}
}
return f1;
}
示例3: FeatureSymbolizer
/// <summary>
/// Creates a new instance of FeatureSymbolizer
/// </summary>
protected FeatureSymbolizer()
{
_scaleMode = ScaleModes.Simple;
_smoothing = true;
_isVisible = true;
_unit = GraphicsUnit.Pixel;
}
示例4: GraphicsUnitIndex
private static int GraphicsUnitIndex(GraphicsUnit graphicsUnit) {
int i = -1;
switch (graphicsUnit) {
case GraphicsUnit.Display:
i = 0;
break;
case GraphicsUnit.Document:
i = 1;
break;
case GraphicsUnit.Inch:
i = 2;
break;
case GraphicsUnit.Millimeter:
i = 3;
break;
case GraphicsUnit.Point:
i = 4;
break;
}
return i;
}
示例5: ScaleSizeToDeviceUnits
/// <summary>
/// Scales sizes to device units
/// </summary>
/// <param name="size"></param>
/// <param name="unit"></param>
/// <param name="g"></param>
/// <returns></returns>
public static float ScaleSizeToDeviceUnits(float size, GraphicsUnit unit, Graphics g)
{
if (unit == g.PageUnit)
return size;
switch (unit)
{
case GraphicsUnit.Point:
size *= g.DpiY / 72f;
break;
case GraphicsUnit.Display:
//Heuristic for printer or display needed!
size *= g.DpiY / (g.DpiY < 100 ? 72f : 100f) ;
break;
case GraphicsUnit.Document:
size *= g.DpiY / 300;
break;
case GraphicsUnit.Inch:
size *= g.DpiY;
break;
case GraphicsUnit.Millimeter:
size *= g.DpiY / 25.4f;
break;
case GraphicsUnit.World:
size *= g.DpiY / g.PageScale;
break;
/*
case GraphicsUnit.Pixel:
default:
//do nothing
break;
*/
}
return (float) Math.Round(size, MidpointRounding.AwayFromZero);
}
示例6: FontInfo
public FontInfo(string name, float size, FontStyle style, GraphicsUnit unit)
{
Name = name;
Size = size;
Style = style;
Unit = unit;
}
示例7: CreateFontArgs
public CreateFontArgs(string name, float size, FontStyle style, GraphicsUnit unit)
{
Name = String.IsNullOrWhiteSpace(name) ? FontFactory.GenericSansSerif : name;
Size = size;
Style = style;
Unit = unit;
}
示例8: ConvertValue
public static decimal ConvertValue(GraphicsUnit from, GraphicsUnit to, decimal value)
{
if (from == to)
return value;
// 先转为中立的单位 1/100 英寸
double middle = 0;
// Specifies the unit of measure of the display device. Typically pixels for video displays, and 1/100 inch for printers.
if (from == GraphicsUnit.Display)
middle = (double)value; // 1/100 英寸不变
// Specifies the document unit (1/300 inch) as the unit of measure.
if (from == GraphicsUnit.Document)
middle = (double)value / (double)3; // 1/300 英寸 --> 1/100 英寸不变
if (from == GraphicsUnit.Inch)
middle = (double)value * (double)100; // 1 英寸 --> 1/100 英寸不变
if (from == GraphicsUnit.Millimeter)
middle = (double)value / (double)0.254; // 毫米 --> 1/100 英寸
// Specifies a printer's point (1/72 inch) as the unit of measure.
if (from == GraphicsUnit.Point)
middle = (double)value * (double)72 / (double)100; // 1 / 72 英寸 1/100 英寸
if (to == GraphicsUnit.Display)
return (decimal)middle; // 1/100 英寸 --> 1/100 英寸
if (to == GraphicsUnit.Document)
return (decimal)(middle * (double)3); // 1/100 英寸 -> 1/300 英寸
if (to == GraphicsUnit.Inch)
return (decimal)(middle / (double)100); // 1/100 英寸 --> 英寸
if (to == GraphicsUnit.Millimeter)
return (decimal)(middle * (double)0.254); // 1/100 英寸 --> 毫米
if (to == GraphicsUnit.Point)
return (decimal)(middle * (double)100 / (double)72); // 1/100 英寸 --> 1 / 72 英寸
throw new Exception("尚未实现");
}
示例9: Font
public Font(string familyName, float emSize, FontStyle style, GraphicsUnit unit)
{
this.FontFamily = new FontFamily(familyName); //Drawing.FontFamily.GenericSansSerif;
this.Size = (int)emSize;
this.Style = style;
this.Name = familyName;
}
示例10: Init
private void Init(Font font)
{
FontFamily = font.FontFamily.Name;
GraphicsUnit = font.Unit;
Size = font.Size;
Style = font.Style;
}
示例11: CreateFont
private void CreateFont (string familyName, float emSize, FontStyle style, GraphicsUnit unit, byte charSet, bool isVertical)
{
#if ONLY_1_1
if (familyName == null)
throw new ArgumentNullException ("familyName");
#endif
originalFontName = familyName;
FontFamily family;
// NOTE: If family name is null, empty or invalid,
// MS creates Microsoft Sans Serif font.
try {
family = new FontFamily (familyName);
}
catch (Exception){
family = FontFamily.GenericSansSerif;
}
setProperties (family, emSize, style, unit, charSet, isVertical);
Status status = GDIPlus.GdipCreateFont (family.NativeObject, emSize, style, unit, out fontObject);
if (status == Status.FontStyleNotFound)
throw new ArgumentException (Locale.GetText ("Style {0} isn't supported by font {1}.", style.ToString (), familyName));
GDIPlus.CheckStatus (status);
}
示例12: LoadFont
public Font LoadFont(string fontName, int size, FontStyle style, GraphicsUnit unit)
{
try {
return new Font(fontName, size, style, unit);
} catch (Exception) {
return SystemInformation.MenuFont;
}
}
示例13: CreateFont
public static Font CreateFont(byte[] ByteFont, float emSize, FontStyle Style, GraphicsUnit Unit = GraphicsUnit.Pixel)
{
IntPtr Buffer = Marshal.AllocCoTaskMem(ByteFont.Length);
Marshal.Copy(ByteFont, 0, Buffer, ByteFont.Length);
Fonts.AddMemoryFont(Buffer, ByteFont.Length);
return new Font(Fonts.Families[Fonts.Families.Length - 1], emSize, Style, Unit);
}
示例14: __Font
public __Font(string familyName, float emSize, FontStyle style, GraphicsUnit unit, byte gdiCharSet)
{
this.Name = familyName;
this.Size = emSize;
this._style = style;
this._unit = unit;
this._gdiCharSet = gdiCharSet;
}
示例15: CreateFont
public static Font CreateFont(string strFamily, float fEmSize, FontStyle fs,
GraphicsUnit gu)
{
try { return new Font(strFamily, fEmSize, fs, gu); }
catch(Exception) { Debug.Assert(false); } // Style unsupported?
return new Font(strFamily, fEmSize, gu); // Regular style
}