本文整理匯總了C#中System.Windows.Media.BrushConverter.ConvertFromInvariantString方法的典型用法代碼示例。如果您正苦於以下問題:C# BrushConverter.ConvertFromInvariantString方法的具體用法?C# BrushConverter.ConvertFromInvariantString怎麽用?C# BrushConverter.ConvertFromInvariantString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Media.BrushConverter
的用法示例。
在下文中一共展示了BrushConverter.ConvertFromInvariantString方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ToBrush
private static Brush ToBrush(this string value, Brush defaultValue)
{
try
{
if (string.IsNullOrWhiteSpace(value))
return defaultValue;
var converter = new BrushConverter();
return (Brush)converter.ConvertFromInvariantString(value);
}
catch (Exception e)
{
Logger.Error("Could not convert {0} to valid brush: {1}", value, e.Message);
return defaultValue;
}
}
示例2: DeserializeFrom
internal static object DeserializeFrom(BinaryReader reader, ITypeDescriptorContext context)
{
SerializationBrushType brushType = (SerializationBrushType)reader.ReadByte();
if (brushType == SerializationBrushType.KnownSolidColor)
{
uint knownColorUint = reader.ReadUInt32();
return KnownColors.SolidColorBrushFromUint(knownColorUint);
}
else if (brushType == SerializationBrushType.OtherColor)
{
string colorValue = reader.ReadString();
BrushConverter converter = new BrushConverter();
return converter.ConvertFromInvariantString(context, colorValue);
}
else
{
throw new Exception(SR.Get(SRID.BrushUnknownBamlType));
}
}