From 9b1468c2eeaf36c787caca6756ee4e6d1b0f8384 Mon Sep 17 00:00:00 2001 From: dahall Date: Sat, 18 Sep 2021 15:47:10 -0600 Subject: [PATCH] Added ability to set a COLORREF by using a tuple (e.g. `COLORREF c = (255,255,0);`) --- PInvoke/Shared/WinDef/COLORREF.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/PInvoke/Shared/WinDef/COLORREF.cs b/PInvoke/Shared/WinDef/COLORREF.cs index 1ff614f3..19ba0244 100644 --- a/PInvoke/Shared/WinDef/COLORREF.cs +++ b/PInvoke/Shared/WinDef/COLORREF.cs @@ -65,7 +65,12 @@ namespace Vanara.PInvoke /// Performs an implicit conversion from to . /// The value. /// The result of the conversion. - public static implicit operator COLORREF(System.Drawing.Color clr) => new COLORREF(clr); + public static implicit operator COLORREF(System.Drawing.Color clr) => new(clr); + + /// Performs an implicit conversion from to . + /// The tuple containing the R, G, and B values. + /// The resulting instance from the conversion. + public static implicit operator COLORREF((byte r, byte g, byte b) clr) => new(clr.r, clr.g, clr.b); /// Performs an implicit conversion from to . /// The value. @@ -75,13 +80,13 @@ namespace Vanara.PInvoke /// Performs an implicit conversion from to . /// The value. /// The result of the conversion. - public static implicit operator COLORREF(uint value) => new COLORREF(value); + public static implicit operator COLORREF(uint value) => new(value); /// Static reference for CLR_NONE representing no color. - public static COLORREF None = new COLORREF(CLR_NONE); + public static COLORREF None = new(CLR_NONE); /// Static reference for CLR_DEFAULT representing the default color. - public static COLORREF Default = new COLORREF(0xFF000000); + public static COLORREF Default = new(0xFF000000); /// public override string ToString() => ((System.Drawing.Color)this).ToString();