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