mirror of https://github.com/dahall/Vanara.git
Fixed LOGPALETTE structure and associated functions
parent
30f7fcc941
commit
ebbe292a91
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -8289,7 +8289,7 @@ namespace Vanara.PInvoke
|
||||||
// https://docs.microsoft.com/en-us/windows/win32/api/oleidl/nf-oleidl-iviewobject-getcolorset HRESULT GetColorSet( DWORD
|
// https://docs.microsoft.com/en-us/windows/win32/api/oleidl/nf-oleidl-iviewobject-getcolorset HRESULT GetColorSet( DWORD
|
||||||
// dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet );
|
// dwDrawAspect, LONG lindex, void *pvAspect, DVTARGETDEVICE *ptd, HDC hicTargetDev, LOGPALETTE **ppColorSet );
|
||||||
new unsafe HRESULT GetColorSet(DVASPECT dwDrawAspect, int lindex, [In, Optional] DVASPECTINFO* pvAspect, [In, Optional] DVTARGETDEVICE* ptd,
|
new unsafe HRESULT GetColorSet(DVASPECT dwDrawAspect, int lindex, [In, Optional] DVASPECTINFO* pvAspect, [In, Optional] DVTARGETDEVICE* ptd,
|
||||||
[In, Optional] HDC hicTargetDev, out LOGPALETTE ppColorSet);
|
[In, Optional] HDC hicTargetDev, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(VanaraCustomMarshaler<LOGPALETTE>))] out LOGPALETTE ppColorSet);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Freezes the drawn representation of an object so that it will not change until the IViewObject::Unfreeze method is called.
|
/// Freezes the drawn representation of an object so that it will not change until the IViewObject::Unfreeze method is called.
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,97 +1,91 @@
|
||||||
using System;
|
#nullable enable
|
||||||
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using Vanara.Extensions;
|
using Vanara.Extensions;
|
||||||
|
using Vanara.InteropServices;
|
||||||
|
|
||||||
namespace Vanara.PInvoke
|
namespace Vanara.PInvoke;
|
||||||
|
|
||||||
|
/// <summary>The alpha intensity value for the palette entry.</summary>
|
||||||
|
[PInvokeData("wingdi.h")]
|
||||||
|
[Flags]
|
||||||
|
public enum PC : byte
|
||||||
{
|
{
|
||||||
/// <summary>The alpha intensity value for the palette entry.</summary>
|
/// <summary>
|
||||||
[PInvokeData("wingdi.h")]
|
/// Specifies that the low-order word of the logical palette entry designates a hardware palette index. This flag allows the
|
||||||
[Flags]
|
/// application to show the contents of the display device palette.
|
||||||
public enum PC : byte
|
/// </summary>
|
||||||
{
|
PC_EXPLICIT = 0x2,
|
||||||
/// <summary>
|
|
||||||
/// Specifies that the low-order word of the logical palette entry designates a hardware palette index. This flag allows the
|
|
||||||
/// application to show the contents of the display device palette.
|
|
||||||
/// </summary>
|
|
||||||
PC_EXPLICIT = 0x2,
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specifies that the color be placed in an unused entry in the system palette instead of being matched to an existing color in
|
/// Specifies that the color be placed in an unused entry in the system palette instead of being matched to an existing color in
|
||||||
/// the system palette. If there are no unused entries in the system palette, the color is matched normally. Once this color is
|
/// the system palette. If there are no unused entries in the system palette, the color is matched normally. Once this color is
|
||||||
/// in the system palette, colors in other logical palettes can be matched to this color.
|
/// in the system palette, colors in other logical palettes can be matched to this color.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
PC_NOCOLLAPSE = 0x4,
|
PC_NOCOLLAPSE = 0x4,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specifies that the logical palette entry be used for palette animation. This flag prevents other windows from matching colors
|
/// Specifies that the logical palette entry be used for palette animation. This flag prevents other windows from matching colors
|
||||||
/// to the palette entry since the color frequently changes. If an unused system-palette entry is available, the color is placed
|
/// to the palette entry since the color frequently changes. If an unused system-palette entry is available, the color is placed
|
||||||
/// in that entry. Otherwise, the color is not available for animation.
|
/// in that entry. Otherwise, the color is not available for animation.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
PC_RESERVED = 0x1,
|
PC_RESERVED = 0x1,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The <c>LOGPALETTE</c> structure defines a logical palette.</summary>
|
/// <summary>The <c>LOGPALETTE</c> structure defines a logical palette.</summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// The colors in the palette-entry table should appear in order of importance because entries earlier in the logical palette are
|
/// The colors in the palette-entry table should appear in order of importance because entries earlier in the logical palette are
|
||||||
/// most likely to be placed in the system palette.
|
/// most likely to be placed in the system palette.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/ns-wingdi-taglogpalette typedef struct tagLOGPALETTE { WORD
|
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/ns-wingdi-taglogpalette typedef struct tagLOGPALETTE { WORD
|
||||||
// palVersion; WORD palNumEntries; PALETTEENTRY palPalEntry[1]; } LOGPALETTE, *PLOGPALETTE, *NPLOGPALETTE, *LPLOGPALETTE;
|
// palVersion; WORD palNumEntries; PALETTEENTRY palPalEntry[1]; } LOGPALETTE, *PLOGPALETTE, *NPLOGPALETTE, *LPLOGPALETTE;
|
||||||
[PInvokeData("wingdi.h", MSDNShortId = "99d70a0e-ac61-4a88-a500-66443e7882ad")]
|
[PInvokeData("wingdi.h", MSDNShortId = "99d70a0e-ac61-4a88-a500-66443e7882ad")]
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[VanaraMarshaler(typeof(SafeAnysizeStructMarshaler<LOGPALETTE>), nameof(palNumEntries))]
|
||||||
public class LOGPALETTE : IDisposable
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
{
|
public class LOGPALETTE
|
||||||
/// <summary>The version number of the system.</summary>
|
{
|
||||||
public ushort palVersion;
|
/// <summary>The version number of the system.</summary>
|
||||||
|
public ushort palVersion;
|
||||||
/// <summary>The number of entries in the logical palette.</summary>
|
|
||||||
public ushort palNumEntries;
|
/// <summary>The number of entries in the logical palette.</summary>
|
||||||
|
public ushort palNumEntries;
|
||||||
private IntPtr _palPalEntry;
|
|
||||||
|
/// <summary>Specifies an array of PALETTEENTRY structures that define the color and usage of each entry in the logical palette.</summary>
|
||||||
/// <summary>Specifies an array of PALETTEENTRY structures that define the color and usage of each entry in the logical palette.</summary>
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)]
|
||||||
public PALETTEENTRY[] palPalEntry
|
public PALETTEENTRY[]? palPalEntry;
|
||||||
{
|
}
|
||||||
get => _palPalEntry.ToArray<PALETTEENTRY>(palNumEntries);
|
|
||||||
set { Marshal.FreeHGlobal(_palPalEntry); value.MarshalToPtr<PALETTEENTRY>(Marshal.AllocHGlobal, out _); }
|
/// <summary>Specifies the color and usage of an entry in a logical palette.</summary>
|
||||||
}
|
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/ns-wingdi-tagpaletteentry typedef struct tagPALETTEENTRY { BYTE peRed;
|
||||||
|
// BYTE peGreen; BYTE peBlue; BYTE peFlags; } PALETTEENTRY, *PPALETTEENTRY, *LPPALETTEENTRY;
|
||||||
/// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
|
[PInvokeData("wingdi.h")]
|
||||||
void IDisposable.Dispose() => Marshal.FreeHGlobal(_palPalEntry);
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
}
|
public struct PALETTEENTRY
|
||||||
|
{
|
||||||
/// <summary>Specifies the color and usage of an entry in a logical palette.</summary>
|
/// <summary>
|
||||||
// https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/ns-wingdi-tagpaletteentry typedef struct tagPALETTEENTRY { BYTE peRed;
|
/// <para>Type: <c>BYTE</c></para>
|
||||||
// BYTE peGreen; BYTE peBlue; BYTE peFlags; } PALETTEENTRY, *PPALETTEENTRY, *LPPALETTEENTRY;
|
/// <para>The red intensity value for the palette entry.</para>
|
||||||
[PInvokeData("wingdi.h")]
|
/// </summary>
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
public byte peRed;
|
||||||
public struct PALETTEENTRY
|
|
||||||
{
|
/// <summary>
|
||||||
/// <summary>
|
/// <para>Type: <c>BYTE</c></para>
|
||||||
/// <para>Type: <c>BYTE</c></para>
|
/// <para>The green intensity value for the palette entry.</para>
|
||||||
/// <para>The red intensity value for the palette entry.</para>
|
/// </summary>
|
||||||
/// </summary>
|
public byte peGreen;
|
||||||
public byte peRed;
|
|
||||||
|
/// <summary>
|
||||||
/// <summary>
|
/// <para>Type: <c>BYTE</c></para>
|
||||||
/// <para>Type: <c>BYTE</c></para>
|
/// <para>The blue intensity value for the palette entry.</para>
|
||||||
/// <para>The green intensity value for the palette entry.</para>
|
/// </summary>
|
||||||
/// </summary>
|
public byte peBlue;
|
||||||
public byte peGreen;
|
|
||||||
|
/// <summary>
|
||||||
/// <summary>
|
/// <para>Type: <c>BYTE</c></para>
|
||||||
/// <para>Type: <c>BYTE</c></para>
|
/// <para>
|
||||||
/// <para>The blue intensity value for the palette entry.</para>
|
/// The alpha intensity value for the palette entry. Note that as of DirectX 8, this member is treated differently than
|
||||||
/// </summary>
|
/// documented for Windows.
|
||||||
public byte peBlue;
|
/// </para>
|
||||||
|
/// </summary>
|
||||||
/// <summary>
|
public PC peFlags;
|
||||||
/// <para>Type: <c>BYTE</c></para>
|
|
||||||
/// <para>
|
|
||||||
/// The alpha intensity value for the palette entry. Note that as of DirectX 8, this member is treated differently than
|
|
||||||
/// documented for Windows.
|
|
||||||
/// </para>
|
|
||||||
/// </summary>
|
|
||||||
public PC peFlags;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -34,6 +34,14 @@ namespace Vanara.PInvoke.Tests
|
||||||
Assert.That(CreateFont(), ResultIs.ValidHandle);
|
Assert.That(CreateFont(), ResultIs.ValidHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CreatePaletteTest()
|
||||||
|
{
|
||||||
|
LOGPALETTE lp = new() { palVersion = 0x300, palNumEntries = 32, palPalEntry = new PALETTEENTRY[32] };
|
||||||
|
for (int i = 0;i < 32; i++) { lp.palPalEntry[i] = new() { peFlags = PC.PC_NOCOLLAPSE }; }
|
||||||
|
Assert.That(CreatePalette(lp), ResultIs.ValidHandle);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: [Test]
|
// TODO: [Test]
|
||||||
public void DeleteDCTest()
|
public void DeleteDCTest()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue