System.Windows.Media.Color mediacolor; // your color
var drawingcolor = System.Drawing.Color.FromArgb(
mediacolor.A, mediacolor.R, mediacolor.G, mediacolor.B);
Just for reference... I use this:
using System.Runtime.CompilerServices;
using System.Windows.Media;
namespace HQ.Wpf.Util
{
public static class ColorExtension
{
/// <summary>
/// Convert Media Color (WPF) to Drawing Color (WinForm)
/// </summary>
/// <param name="mediaColor"></param>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static System.Drawing.Color ToDrawingColor(this System.Windows.Media.Color mediaColor)
{
return System.Drawing.Color.FromArgb(mediaColor.A, mediaColor.R, mediaColor.G, mediaColor.B);
}
/// <summary>
/// Convert Drawing Color (WPF) to Media Color (WinForm)
/// </summary>
/// <param name="drawingColor"></param>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static System.Windows.Media.Color ToMediaColor(this System.Drawing.Color drawingColor)
{
return System.Windows.Media.Color.FromArgb(drawingColor.A, drawingColor.R, drawingColor.G, drawingColor.B);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With