版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/huangli321456/article/details/52956846
/// <summary>/// 将wpf的颜色对象转换为整型的Winform颜色值
/// </summary>
/// <param name="brush"></param>
/// <returns></returns>
public static String ConvertWpfBrushToWFColorArgb(media.SolidColorBrush brush)
{
return (brush.Color.A << 24 | brush.Color.R << 16 | brush.Color.G << 8 | brush.Color.B).ToString();
}
/// <summary>
/// 将来自winform的argb整型颜色值转换为wpf颜色对象
/// </summary>
/// <param name="wfargb"></param>
/// <returns></returns>
public static System.Windows.Media.SolidColorBrush ConvertWFColorToWfpBrush(int wfargb)
{
return new System.Windows.Media.SolidColorBrush()
{
Color = new media.Color()
{
A = (byte)((wfargb >> 24) & 0xFF),
R = (byte)((wfargb >> 16) & 0xFF),
G = (byte)((wfargb >> 8) & 0xFF),
B = (byte)(wfargb & 0xFF)
}
};
}