本文整理汇总了C#中GraphicsUnit类的典型用法代码示例。如果您正苦于以下问题:C# GraphicsUnit类的具体用法?C# GraphicsUnit怎么用?C# GraphicsUnit使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GraphicsUnit类属于命名空间,在下文中一共展示了GraphicsUnit类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:27,代码来源:Constants.cs
示例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;
}
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:31,代码来源:Measurements.cs
示例3: FeatureSymbolizer
/// <summary>
/// Creates a new instance of FeatureSymbolizer
/// </summary>
protected FeatureSymbolizer()
{
_scaleMode = ScaleModes.Simple;
_smoothing = true;
_isVisible = true;
_unit = GraphicsUnit.Pixel;
}
开发者ID:zhongshuiyuan,项目名称:mapwindowsix,代码行数:10,代码来源:FeatureSymbolizer.cs
示例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;
}
开发者ID:thunder176,项目名称:HeuristicLab,代码行数:25,代码来源:Measurements.cs
示例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);
}
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:42,代码来源:Utility.cs
示例6: FontInfo
public FontInfo(string name, float size, FontStyle style, GraphicsUnit unit)
{
Name = name;
Size = size;
Style = style;
Unit = unit;
}
开发者ID:Rafael-Lin,项目名称:TypingPractice,代码行数:7,代码来源:FontInfo.cs
示例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;
}
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:7,代码来源:FontFactory.cs
示例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("尚未实现");
}
开发者ID:renyh1013,项目名称:dp2,代码行数:35,代码来源:UniverseNumericUpDown.cs
示例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;
}
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:7,代码来源:Font.jvm.cs
示例10: Init
private void Init(Font font)
{
FontFamily = font.FontFamily.Name;
GraphicsUnit = font.Unit;
Size = font.Size;
Style = font.Style;
}
开发者ID:dmitriydel,项目名称:sharexmod,代码行数:7,代码来源:SerializationHelper.cs
示例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);
}
开发者ID:LevNNN,项目名称:mono,代码行数:25,代码来源:Font.cs
示例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;
}
}
开发者ID:tangxuehua,项目名称:DataStructure,代码行数:8,代码来源:ResourceService.cs
示例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);
}
开发者ID:Shirasho,项目名称:CascadeMediaTool,代码行数:8,代码来源:FontManager.cs
示例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;
}
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:8,代码来源:Font.cs
示例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
}
开发者ID:joshuadugie,项目名称:KeePass-2.x,代码行数:8,代码来源:FontUtil.cs
示例16: ItemKey
public ItemKey(string name, float size, FontStyle style, GraphicsUnit unit)
{
Name = name;
//So we don't end up with an insane # of items.
Size = (float) Math.Round(size*10)/10;
Style = style;
Unit = unit;
}
开发者ID:jfphilbin,项目名称:ClearCanvas,代码行数:8,代码来源:FontFactory.cs
示例17: DrawImage
public void DrawImage(Bitmap bitmap, Rectangle target, Rectangle source, GraphicsUnit gu)
{
this.paint.Flags = 0;
using (Rect sa = source.ToRect())
using (Rect ta = target.ToRect())
{
this.canvas.DrawBitmap(bitmap, sa, ta, this.paint);
}
}
开发者ID:majorsilence,项目名称:System.Drawing.Wrappers,代码行数:9,代码来源:Graphics.Android.cs
示例18: Create
public static Font Create(
string family,
float emSize,
FontStyle style = FontStyle.Regular,
GraphicsUnit unit = GraphicsUnit.Pixel)
{
var fam = GetFamily(family);
return new Font(family, emSize, style, unit);
}
开发者ID:jarrettv,项目名称:ChapterGrabber,代码行数:9,代码来源:FontHelper.cs
示例19: GetUnitString
public static string GetUnitString(GraphicsUnit unit)
{
if (unit == GraphicsUnit.Display)
return "1/100 英寸";
if (unit == GraphicsUnit.Millimeter)
return "毫米";
return unit.ToString();
}
开发者ID:renyh1013,项目名称:dp2,代码行数:9,代码来源:UniverseNumericUpDown.cs
示例20: ConvertEmToPixels
public static float ConvertEmToPixels(float em, GraphicsUnit unit, double dpi)
{
switch (unit)
{
case GraphicsUnit.Point: //pt
return (float) ConvertPtToPixel(em/72f, dpi);
default:
return em;
}
}
开发者ID:podlipensky,项目名称:sharpcanvas,代码行数:10,代码来源:FontUtils.cs
注:本文中的GraphicsUnit类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论