当前位置: 首页>>代码示例>>C#>>正文


C# GraphicsUnit类代码示例

本文整理汇总了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;
		}
开发者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


注:本文中的GraphicsUnit类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。