conversionhelper.cs

来自「Magic Library 1.7,有说明文档」· CS 代码 · 共 46 行

CS
46
字号
// *****************************************************************************
// 
//  (c) Crownwood Consulting Limited 2002 
//  All rights reserved. The software and associated documentation 
//  supplied hereunder are the proprietary information of Crownwood Consulting 
//	Limited, Haxey, North Lincolnshire, England and are supplied subject to 
//	licence terms.
// 
//  Magic Version 1.7 	www.dotnetmagic.com
// *****************************************************************************

using System;
using System.Text;
using System.Drawing;

namespace Crownwood.Magic.Common
{
    public class ConversionHelper
    {
		// Faster performance to cache the converters and type objects, rather
		// than keep recreating them each time a conversion is required
		protected static SizeConverter _sc = new SizeConverter();
		protected static PointConverter _pc = new PointConverter();
		protected static Type _stringType = Type.GetType("System.String");

		public static string SizeToString(Size size)
		{
			return (string)_sc.ConvertTo(size, _stringType);
		}

		public static Size StringToSize(string str)
		{
			return (Size)_sc.ConvertFrom(str);
		}

		public static string PointToString(Point point)
		{
			return (string)_pc.ConvertTo(point, _stringType);
		}

		public static Point StringToPoint(string str)
		{
			return (Point)_pc.ConvertFrom(str);
		}
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?