转换System.Windows.Media.Brush到System.Drawing.Brush [英] Convert System.Windows.Media.Brush to System.Drawing.Brush
问题描述
我如何能System.Windows.Media.Brush转换为System.Drawing.Brush?
我试图让system.windows的颜色.media.brush格式化为一个System.Drawing.Color对象。
下面的解决方案不起作用,因为它需要的SolidColorBrush对象,而我需要转换的对象是system.windows.media.brush对象:
公开的System.Drawing.Color GETCOLOR(System.Windows.Media.SolidColorBrush oBrush)
{
返回System.Drawing.Color.FromArgb(oBrush.Color.A,
oBrush.Color.R,
oBrush.Color.G,
oBrush.Color.B);
}
我相信你可以只投。它作为一个的SolidColorBrush,使色彩
尝试是这样的:
MyColor =((的SolidColorBrush)MyMediaBrush)。颜色;
How can I convert a System.Windows.Media.Brush to System.Drawing.Brush?
I'm trying to get the color of a system.windows.media.brush formatted to a System.Drawing.Color object.
The below solution doesn't work because it requires a solidcolorbrush object, whereas the object i need converting from is a system.windows.media.brush object:
public System.Drawing.Color GetColor( System.Windows.Media.SolidColorBrush oBrush )
{
return System.Drawing.Color.FromArgb( oBrush.Color.A,
oBrush.Color.R,
oBrush.Color.G,
oBrush.Color.B );
}
I believe you can just cast it as a SolidColorBrush to get the color.
Try something like:
MyColor = ((SolidColorBrush)MyMediaBrush).Color;
这篇关于转换System.Windows.Media.Brush到System.Drawing.Brush的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!