From 0d92eb39b8a5678c9e58fcf630d9ed8cd5c28465 Mon Sep 17 00:00:00 2001 From: David Hall Date: Wed, 25 Sep 2019 14:13:54 -0500 Subject: [PATCH] Added HCOLORSPACE --- PInvoke/Shared/Handles.cs | 68 +++++++++++++++++++++++++++++ PInvoke/Shared/Vanara.PInvoke.Shared.csproj | 2 +- 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/PInvoke/Shared/Handles.cs b/PInvoke/Shared/Handles.cs index d37a082f..00259290 100644 --- a/PInvoke/Shared/Handles.cs +++ b/PInvoke/Shared/Handles.cs @@ -239,6 +239,54 @@ namespace Vanara.PInvoke public IntPtr DangerousGetHandle() => handle; } + /// Provides a handle to a color space. + [StructLayout(LayoutKind.Sequential)] + public struct HCOLORSPACE : IGraphicsObjectHandle + { + private IntPtr handle; + + /// Initializes a new instance of the struct. + /// An object that represents the pre-existing handle to use. + public HCOLORSPACE(IntPtr preexistingHandle) => handle = preexistingHandle; + + /// Returns an invalid handle by instantiating a object with . + public static HCOLORSPACE NULL => new HCOLORSPACE(IntPtr.Zero); + + /// Gets a value indicating whether this instance is a null handle. + public bool IsNull => handle == IntPtr.Zero; + + /// Performs an explicit conversion from to . + /// The handle. + /// The result of the conversion. + public static explicit operator IntPtr(HCOLORSPACE h) => h.handle; + + /// Performs an implicit conversion from to . + /// The pointer to a handle. + /// The result of the conversion. + public static implicit operator HCOLORSPACE(IntPtr h) => new HCOLORSPACE(h); + + /// Implements the operator !=. + /// The first handle. + /// The second handle. + /// The result of the operator. + public static bool operator !=(HCOLORSPACE h1, HCOLORSPACE h2) => !(h1 == h2); + + /// Implements the operator ==. + /// The first handle. + /// The second handle. + /// The result of the operator. + public static bool operator ==(HCOLORSPACE h1, HCOLORSPACE h2) => h1.Equals(h2); + + /// + public override bool Equals(object obj) => obj is HCOLORSPACE h ? handle == h.handle : false; + + /// + public override int GetHashCode() => handle.GetHashCode(); + + /// + public IntPtr DangerousGetHandle() => handle; + } + /// Provides a handle to a Windows cursor. [StructLayout(LayoutKind.Sequential), DebuggerDisplay("{handle}")] public struct HCURSOR : IGraphicsObjectHandle @@ -774,11 +822,31 @@ namespace Vanara.PInvoke /// The result of the conversion. public static implicit operator HGDIOBJ(HBRUSH h) => new HGDIOBJ((IntPtr)h); + /// Performs an implicit conversion from to . + /// The pointer to a handle. + /// The result of the conversion. + public static implicit operator HGDIOBJ(HCOLORSPACE h) => new HGDIOBJ((IntPtr)h); + + /// Performs an implicit conversion from to . + /// The pointer to a handle. + /// The result of the conversion. + public static implicit operator HGDIOBJ(HDC h) => new HGDIOBJ((IntPtr)h); + /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HGDIOBJ(HFONT h) => new HGDIOBJ((IntPtr)h); + /// Performs an implicit conversion from to . + /// The pointer to a handle. + /// The result of the conversion. + public static implicit operator HGDIOBJ(HMETAFILE h) => new HGDIOBJ((IntPtr)h); + + /// Performs an implicit conversion from to . + /// The pointer to a handle. + /// The result of the conversion. + public static implicit operator HGDIOBJ(HENHMETAFILE h) => new HGDIOBJ((IntPtr)h); + /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. diff --git a/PInvoke/Shared/Vanara.PInvoke.Shared.csproj b/PInvoke/Shared/Vanara.PInvoke.Shared.csproj index e721e370..75f345df 100644 --- a/PInvoke/Shared/Vanara.PInvoke.Shared.csproj +++ b/PInvoke/Shared/Vanara.PInvoke.Shared.csproj @@ -35,7 +35,7 @@ Classes IErrorProvider, IGraphicsObjectHandle, IHandle, IKernelHandle, ISecurityObject, IShellHandle, ISyncHandle, IUserHandle, AssociateAttribute, ComTryGetNext, CoTaskMemStringMarshaler, FunctionHelper, IEnumFromCom<T>, IEnumFromIndexer<T>, IEnumFromNext<T>, Lib, Macros, NullTermStringArrayMarshaler, OverlappedAsync, OverlappedAsyncResult, PInvokeClientExtensions, PInvokeDataAttribute, PRECT, PtrFunc<T>, RegistryTypeExt, SafeElementArray<T>, SafeHANDLE, SafeNativeArray<T>, SafeNativeArrayBase<T>, SafeNativeLinkedList<T>, SafeResourceId, SBFunc<T>, SECURITY_ATTRIBUTES, SizeFunc<T>, StringPtrArrayMarshaler, StructHelper, TryGetNext Structures -ACCESS_MASK, BusNumber, CLIPFORMAT, CM_FULL_RESOURCE_DESCRIPTOR, CM_PARTIAL_RESOURCE_DESCRIPTOR, CM_PARTIAL_RESOURCE_LIST, CM_RESOURCE_LIST, COLORREF, Connection, DevicePrivate, DeviceSpecificData, Dma, DmaV3, Generic, HACCEL, HANDLE, HBITMAP, HBRUSH, HCURSOR, HDC, HDESK, HDPA, HDROP, HDSA, HDWP, HENHMETAFILE, HFILE, HFONT, HGDIOBJ, HICON, HIMAGELIST, HINSTANCE, HKEY, HMENU, HMETAFILE, HMONITOR, HPALETTE, HPEN, HPROCESS, HPROPSHEET, HPROPSHEETPAGE, HRESULT, HRGN, HTASK, HTHEME, HTHREAD, HTHUMBNAIL, HTOKEN, HWINSTA, HWND, Interrupt, LCID, LOGFONT, Memory40, Memory48, Memory64, MessageInterruptRaw, MSG, NTStatus, OBJECT_TYPE_LIST, PACE, PACL, POINTS, PRECT, PSECURITY_DESCRIPTOR, PSID, RECT, ResourceId, SECURITY_ATTRIBUTES, SIZE, SYSTEMTIME, union, WIN32_FIND_DATA, Win32Error +ACCESS_MASK, BusNumber, CLIPFORMAT, CM_FULL_RESOURCE_DESCRIPTOR, CM_PARTIAL_RESOURCE_DESCRIPTOR, CM_PARTIAL_RESOURCE_LIST, CM_RESOURCE_LIST, COLORREF, Connection, DevicePrivate, DeviceSpecificData, Dma, DmaV3, Generic, HACCEL, HANDLE, HBITMAP, HBRUSH, HCOLORSPACE, HCURSOR, HDC, HDESK, HDPA, HDROP, HDSA, HDWP, HENHMETAFILE, HFILE, HFONT, HGDIOBJ, HICON, HIMAGELIST, HINSTANCE, HKEY, HMENU, HMETAFILE, HMONITOR, HPALETTE, HPEN, HPROCESS, HPROPSHEET, HPROPSHEETPAGE, HRESULT, HRGN, HTASK, HTHEME, HTHREAD, HTHUMBNAIL, HTOKEN, HWINSTA, HWND, Interrupt, LCID, LOGFONT, Memory40, Memory48, Memory64, MessageInterruptRaw, MSG, NTStatus, OBJECT_TYPE_LIST, PACE, PACL, POINTS, PRECT, PSECURITY_DESCRIPTOR, PSID, RECT, ResourceId, SECURITY_ATTRIBUTES, SIZE, SYSTEMTIME, union, WIN32_FIND_DATA, Win32Error Enumerations CM_RESOURCE, CM_SHARE_DISPOSITION, CmResourceType, DrawTextFlags, FacilityCode, FacilityCode, FileFlagsAndAttributes, FontFamily, FontPitch, INTERFACE_TYPE, LogFontCharSet, LogFontClippingPrecision, LogFontOutputPrecision, LogFontOutputQuality, NTDDI, ObjectTypeListLevel, PInvokeClient, ProcessorArchitecture, REG_VALUE_TYPE, ResourceType, SECURITY_INFORMATION, SeverityLevel, SeverityLevel, ShowWindowCommand, STGM, SystemColorIndex, SystemShutDownReason, URLZONE, WIN32_WINNT