本文整理匯總了C#中System.Drawing.ColorConverter.ConvertTo方法的典型用法代碼示例。如果您正苦於以下問題:C# ColorConverter.ConvertTo方法的具體用法?C# ColorConverter.ConvertTo怎麽用?C# ColorConverter.ConvertTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Drawing.ColorConverter
的用法示例。
在下文中一共展示了ColorConverter.ConvertTo方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ConvertTo_NotSupported
public void ConvertTo_NotSupported(Type type)
{
var conv = new ColorConverter();
var col = Color.Red;
Assert.Throws<NotSupportedException>(() =>
{
conv.ConvertTo(null, CultureInfo.InvariantCulture, col, type);
});
}
示例2: ConvertTo_Named
public void ConvertTo_Named(string name)
{
var conv = new ColorConverter();
Assert.Equal(name,
(string) conv.ConvertTo(null, CultureInfo.InvariantCulture, Color.FromName(name), typeof(string)));
}
示例3: ConvertTo_Empty
public void ConvertTo_Empty()
{
var conv = new ColorConverter();
Assert.Equal(string.Empty,
(string) conv.ConvertTo(null, CultureInfo.InvariantCulture, Color.Empty, typeof(string)));
}
示例4: ConvertTo
public void ConvertTo(int a, int r, int g, int b)
{
var conv = new ColorConverter();
Assert.Equal($"{a}, {r}, {g}, {b}",
(string) conv.ConvertTo(null, CultureInfo.InvariantCulture, Color.FromArgb(a, r, g, b), typeof(string)));
}