// Generated API outline. Implementation bodies omitted.
#nullable enable
namespace Xui.GPU.Hardware.D3D11
{
using System.Runtime.InteropServices;
using System;
using Xui.Runtime.Windows;
using static Xui.Runtime.Windows.D3D11;
///
/// Direct3D 11 hardware GPU device implementation.
/// Provides hardware-accelerated shader compilation and rendering on Windows.
///
///
/// This backend uses D3D11 for rendering and D3DCompiler for HLSL compilation.
/// Rendering is done off-screen to a texture that can be read back to CPU memory
/// for display via the software/2D canvas pipeline.
///
public sealed class DirectXGpuDevice : IGpuDevice
{
/// Gets the name of this GPU backend (e.g., "D3D11", "Metal").
public string BackendName { get; }
/// Gets whether this device has been disposed.
public bool IsDisposed { get; }
///
/// Creates a new Direct3D 11 GPU device.
///
/// Thrown if device creation fails.
public unsafe DirectXGpuDevice();
///
/// Compiles a vertex shader from native shader source code.
///
/// The shader source (HLSL for D3D11, MSL for Metal).
/// The name of the entry point function.
/// A compiled vertex shader.
public unsafe IGpuVertexShader CompileVertexShader(string source, string entryPoint);
///
/// Compiles a fragment (pixel) shader from native shader source code.
///
/// The shader source (HLSL for D3D11, MSL for Metal).
/// The name of the entry point function.
/// A compiled fragment shader.
public unsafe IGpuFragmentShader CompileFragmentShader(string source, string entryPoint);
///
/// Creates a render target texture.
///
/// Width in pixels.
/// Height in pixels.
/// A render target that can be used with a command list.
public unsafe IGpuRenderTarget CreateRenderTarget(int width, int height);
///
/// Creates a command list for recording rendering commands.
///
public unsafe IGpuCommandList CreateCommandList();
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public unsafe void Dispose();
}
}
namespace Xui.Runtime.Windows
{
using System.Diagnostics;
using System.Runtime.InteropServices;
using System;
public static partial class COM
{
public unsafe class Unknown : IDisposable
{
public static uint AddRef(void* ptr);
public static uint Release(void* ptr);
public static readonly Guid IID;
public readonly void* Ptr;
public Unknown(void* ptr);
public void* QueryInterface(in Guid refId);
public static void* QueryInterface(void* comPtr, in Guid refId);
public uint AddRef();
public uint Release();
public static implicit operator void*(Unknown? unknown);
public void* this[uint slot] { get; }
public void Dispose();
}
}
}
namespace Xui.Runtime.Windows
{
public static partial class COM
{
}
public static partial class D2D1
{
public enum AlphaMode : uint
{
Unknown = 0,
Premultiplied = 1,
Straight = 2,
Ignore = 3,
}
}
public static partial class D2D1
{
public enum AntialiasMode : uint
{
PerPrimitive = 0,
Aliased = 1,
}
}
public static partial class D2D1
{
public struct ArcSegment
{
public Point2F Point;
public SizeF Size;
public float RotationAngle;
public SweepDirection SweepDirection;
public ArcSize ArcSize;
}
}
public static partial class D2D1
{
public enum ArcSize : uint
{
Small = 0,
Large = 1,
}
}
public static partial class D2D1
{
public struct BezierSegment
{
public Point2F Point1;
public Point2F Point2;
public Point2F Point3;
}
}
public static partial class D2D1
{
public enum BitmapOptions : uint
{
None = 0x00000000,
Target = 0x00000001,
CannotDraw = 0x00000002,
CpuRead = 0x00000004,
GdiCompatible = 0x00000008,
}
}
public static partial class D2D1
{
public struct BrushProperties
{
public float Opacity;
public Matrix3X2F Transform;
}
}
public static partial class D2D1
{
public enum CapStyle : uint
{
Flat = 0,
Square = 1,
Round = 2,
Triangle = 3
}
}
public static partial class D2D1
{
public enum DashStyle : uint
{
Solid = 0,
Dash = 1,
Dot = 2,
DashDot = 3,
DashDotDot = 4,
Custom = 5,
}
}
public static partial class D2D1
{
public enum DebugLevel : uint
{
None = 0,
Error = 1,
Warning = 2,
Information = 3
}
}
public static partial class D2D1
{
public enum DeviceContextOptions : uint
{
None = 0,
EnableMultithreadedOptimizations = 1
}
}
public static partial class D2D1
{
public enum ExtendMode
{
Clamp = 0,
Wrap = 1,
Mirror = 2
}
}
public static partial class D2D1
{
/// https://learn.microsoft.com/en-us/windows/win32/api/d2d1/ns-d2d1-d2d1_factory_options
public struct FactoryOptions
{
public DebugLevel DebugLevel;
public FactoryOptions(DebugLevel debugLevel);
}
}
public static partial class D2D1
{
/// https://learn.microsoft.com/en-us/windows/win32/api/d2d1/ne-d2d1-d2d1_factory_type
public enum FactoryType : uint
{
SingleThreaded = 0,
MultiThreaded = 1,
ForceDword = 0xffffffff
}
}
public static partial class D2D1
{
public enum FigureBegin : uint
{
Filled = 0,
Hollow = 1,
}
}
public static partial class D2D1
{
public enum FigureEnd : uint
{
Open = 0,
Closed = 1,
}
}
public static partial class D2D1
{
public enum FillMode : uint
{
Alternate = 0,
Winding = 1,
}
}
public static partial class D2D1
{
public enum Gamma : uint
{
Gamma_2_2 = 0,
Gamma_1_0 = 1,
}
}
public static partial class D2D1
{
public struct GradientStop
{
public float Position;
public ColorF Color;
}
}
public static partial class D2D1
{
public enum LayerOptions : uint
{
None = 0,
InitializeForClearType = 1
}
}
public static partial class D2D1
{
public unsafe struct LayerParameters
{
public RectF ContentRect;
public void* GeometricMask;
public AntialiasMode MaskAntialiasMode;
public Matrix3X2F MaskTransform;
public float Opacity;
public void* OpacityBrush;
public LayerOptions LayerOptions;
public LayerParameters();
}
}
public static partial class D2D1
{
public enum LineJoin : uint
{
Miter = 0,
Bevel = 1,
Round = 2,
MiterOrBevel = 3,
}
}
public static partial class D2D1
{
public unsafe partial class LinearGradientBrush
{
public struct Properties
{
public Point2F StartPoint;
public Point2F EndPoint;
}
}
}
public static partial class D2D1
{
public struct QuadraticBezierSegment
{
public Point2F Point1;
public Point2F Point2;
}
}
public static partial class D2D1
{
public unsafe partial class RadialGradientBrush
{
public struct Properties
{
public Point2F Center;
public Point2F GradientOriginOffset;
public Point2F Radius;
public float RadiusX;
public float RadiusY;
}
}
}
public static partial class D2D1
{
public struct SizeF
{
public float Width;
public float Height;
public SizeF(float radius);
public SizeF(float width, float height);
}
}
public static partial class D2D1
{
public struct SizeU
{
public uint Width;
public uint Height;
}
}
public static partial class D2D1
{
public struct StrokeStyleProperties
{
public CapStyle StartCap;
public CapStyle EndCap;
public CapStyle DashCap;
public LineJoin LineJoin;
public float MiterLimit;
public DashStyle DashStyle;
public float DashOffset;
}
}
public static partial class D2D1
{
public enum SweepDirection : uint
{
CounterClockwise = 0,
Clockwise = 1,
}
}
public static unsafe partial class D2D1
{
public unsafe partial class Factory
{
}
}
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static partial class D3D11
{
public enum DriverType : uint
{
Unknown = 0,
Hardware = 1,
Reference = 2,
Null = 3,
Software = 4,
Warp = 5
}
}
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static partial class D3D11
{
public enum FeatureLevel : uint
{
D3D_FEATURE_LEVEL_1_0_CORE = 0x1000,
D3D_FEATURE_LEVEL_9_1 = 0x9100,
D3D_FEATURE_LEVEL_9_2 = 0x9200,
D3D_FEATURE_LEVEL_9_3 = 0x9300,
D3D_FEATURE_LEVEL_10_0 = 0xa000,
D3D_FEATURE_LEVEL_10_1 = 0xa100,
D3D_FEATURE_LEVEL_11_0 = 0xb000,
D3D_FEATURE_LEVEL_11_1 = 0xb100,
D3D_FEATURE_LEVEL_12_0 = 0xc000,
D3D_FEATURE_LEVEL_12_1 = 0xc100,
D3D_FEATURE_LEVEL_12_2 = 0xc200
}
}
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static partial class D3D11
{
///
/// Identifies a resource to be accessed for reading and/or writing by the CPU.
/// Mirrors D3D11_MAP.
///
public enum Map : uint
{
Read = 1,
Write = 2,
ReadWrite = 3,
WriteDiscard = 4,
WriteNoOverwrite = 5,
}
}
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static partial class D3D11
{
///
/// Identifies expected resource use during rendering.
/// Mirrors D3D11_USAGE.
///
public enum Usage : uint
{
Default = 0,
Immutable = 1,
Dynamic = 2,
Staging = 3,
}
}
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static unsafe partial class D3D11
{
}
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static unsafe partial class D3D11
{
}
public static unsafe partial class DComp
{
[global::System.Runtime.InteropServices.DllImportAttribute("dcomp.dll", EntryPoint = "DCompositionWaitForCompositorClock", ExactSpelling = true)]
public static extern partial uint DCompositionWaitForCompositorClock(uint handleCount, nint handlesArrPtr, uint timeoutInMs);
}
public static unsafe partial class DComp
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static unsafe partial global::Xui.Runtime.Windows.Win32.Types.HRESULT DCompositionCreateDevice(void* dxgiDevice, in global::System.Guid iid, out void* dcompositionDevice);
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public enum FactoryType : uint
{
Shared = 0,
Isolated = 1
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public enum FontStretch : uint
{
Undefined = 0,
UltraCondensed = 1,
ExtraCondensed = 2,
Condensed = 3,
SemiCondensed = 4,
Normal = 5,
Medium = 5,
SemiExpanded = 6,
Expanded = 7,
ExtraExpanded = 8,
UltraExpanded = 9
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public enum FontStyle : uint
{
Normal = 0,
Oblique = 1,
Italic = 2,
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public enum FontWeight : uint
{
Thin = 100,
ExtraLight = 200,
UltraLight = 200,
Light = 300,
SemiLight = 350,
Normal = 400,
Regular = 400,
Medium = 500,
DemiBold = 600,
SemiBold = 600,
Bold = 700,
ExtraBold = 800,
UltraBold = 800,
Black = 900,
Heavy = 900,
ExtraBlack = 950,
UltraBlack = 950
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public enum MeasuringMode : uint
{
Natural,
GdiClassic,
GdiNatural,
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public enum TextAlignment : uint
{
Leading = 0,
Trailing = 1,
Center = 2,
Justified = 3
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public struct TextMetrics
{
public float Left;
public float Top;
public float Width;
public float WidthIncludingTrailingWhitespace;
public float Height;
public float LayoutWidth;
public float LayoutHeight;
public int MaxBidiReorderingDepth;
public int LineCount;
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static unsafe partial class DWrite
{
public unsafe partial class Factory
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial global::Xui.Runtime.Windows.Win32.Types.HRESULT DWriteCreateFactory(global::Xui.Runtime.Windows.DWrite.FactoryType factoryType, in global::System.Guid iid, out void* ppIFactory);
}
}
public static partial class DXGI
{
public enum AlphaMode : uint
{
Unspecified = 0,
Premultiplied = 1,
Straight = 2,
Ignore = 3,
}
}
public static partial class DXGI
{
public enum Format : uint
{
UNKNOWN = 0,
R32G32B32A32_TYPELESS = 1,
R32G32B32A32_FLOAT = 2,
R32G32B32A32_UINT = 3,
R32G32B32A32_SINT = 4,
R32G32B32_TYPELESS = 5,
R32G32B32_FLOAT = 6,
R32G32B32_UINT = 7,
R32G32B32_SINT = 8,
R16G16B16A16_TYPELESS = 9,
R16G16B16A16_FLOAT = 10,
R16G16B16A16_UNORM = 11,
R16G16B16A16_UINT = 12,
R16G16B16A16_SNORM = 13,
R16G16B16A16_SINT = 14,
R32G32_TYPELESS = 15,
R32G32_FLOAT = 16,
R32G32_UINT = 17,
R32G32_SINT = 18,
R32G8X24_TYPELESS = 19,
D32_FLOAT_S8X24_UINT = 20,
R32_FLOAT_X8X24_TYPELESS = 21,
X32_TYPELESS_G8X24_UINT = 22,
R10G10B10A2_TYPELESS = 23,
R10G10B10A2_UNORM = 24,
R10G10B10A2_UINT = 25,
R11G11B10_FLOAT = 26,
R8G8B8A8_TYPELESS = 27,
R8G8B8A8_UNORM = 28,
R8G8B8A8_UNORM_SRGB = 29,
R8G8B8A8_UINT = 30,
R8G8B8A8_SNORM = 31,
R8G8B8A8_SINT = 32,
R16G16_TYPELESS = 33,
R16G16_FLOAT = 34,
R16G16_UNORM = 35,
R16G16_UINT = 36,
R16G16_SNORM = 37,
R16G16_SINT = 38,
R32_TYPELESS = 39,
D32_FLOAT = 40,
R32_FLOAT = 41,
R32_UINT = 42,
R32_SINT = 43,
R24G8_TYPELESS = 44,
D24_UNORM_S8_UINT = 45,
R24_UNORM_X8_TYPELESS = 46,
X24_TYPELESS_G8_UINT = 47,
R8G8_TYPELESS = 48,
R8G8_UNORM = 49,
R8G8_UINT = 50,
R8G8_SNORM = 51,
R8G8_SINT = 52,
R16_TYPELESS = 53,
R16_FLOAT = 54,
D16_UNORM = 55,
R16_UNORM = 56,
R16_UINT = 57,
R16_SNORM = 58,
R16_SINT = 59,
R8_TYPELESS = 60,
R8_UNORM = 61,
R8_UINT = 62,
R8_SNORM = 63,
R8_SINT = 64,
A8_UNORM = 65,
R1_UNORM = 66,
R9G9B9E5_SHAREDEXP = 67,
R8G8_B8G8_UNORM = 68,
G8R8_G8B8_UNORM = 69,
BC1_TYPELESS = 70,
BC1_UNORM = 71,
BC1_UNORM_SRGB = 72,
BC2_TYPELESS = 73,
BC2_UNORM = 74,
BC2_UNORM_SRGB = 75,
BC3_TYPELESS = 76,
BC3_UNORM = 77,
BC3_UNORM_SRGB = 78,
BC4_TYPELESS = 79,
BC4_UNORM = 80,
BC4_SNORM = 81,
BC5_TYPELESS = 82,
BC5_UNORM = 83,
BC5_SNORM = 84,
B5G6R5_UNORM = 85,
B5G5R5A1_UNORM = 86,
B8G8R8A8_UNORM = 87,
B8G8R8X8_UNORM = 88,
R10G10B10_XR_BIAS_A2_UNORM = 89,
B8G8R8A8_TYPELESS = 90,
B8G8R8A8_UNORM_SRGB = 91,
B8G8R8X8_TYPELESS = 92,
B8G8R8X8_UNORM_SRGB = 93,
BC6H_TYPELESS = 94,
BC6H_UF16 = 95,
BC6H_SF16 = 96,
BC7_TYPELESS = 97,
BC7_UNORM = 98,
BC7_UNORM_SRGB = 99,
AYUV = 100,
Y410 = 101,
Y416 = 102,
NV12 = 103,
P010 = 104,
P016 = 105,
_420_OPAQUE = 106,
YUY2 = 107,
Y210 = 108,
Y216 = 109,
NV11 = 110,
AI44 = 111,
IA44 = 112,
P8 = 113,
A8P8 = 114,
B4G4R4A4_UNORM = 115,
P208 = 130,
V208 = 131,
V408 = 132,
SAMPLER_FEEDBACK_MIN_MIP_OPAQUE,
SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE,
}
}
public static partial class DXGI
{
public struct FrameStatistics
{
public uint PresentCount;
public uint PresentRefreshCount;
public uint SyncRefreshCount;
public long SyncQPCTime;
public long SyncGPUTime;
}
}
public static partial class DXGI
{
public struct ModeDesc
{
public uint Width;
public uint Height;
public Rational RefreshRate;
public Format Format;
public ModeScanlineOrder ScanlineOrdering;
public ModeScaling Scaling;
}
}
public static partial class DXGI
{
public enum ModeScaling : uint
{
Unspecified = 0,
Centered = 1,
Stretched = 2,
}
}
public static partial class DXGI
{
public enum ModeScanlineOrder : uint
{
Unspecified = 0,
Progressive = 1,
UpperFieldFirst = 2,
LowerFieldFirst = 3,
}
}
public static partial class DXGI
{
public struct Rational
{
public uint Numerator;
public uint Denominator;
}
}
public static partial class DXGI
{
public struct SampleDesc
{
public uint Count;
public uint Quality;
}
}
public static partial class DXGI
{
public enum SwapEffect : uint
{
Discard = 0,
Sequential = 1,
FlipSequential = 3,
FlipDiscard = 4,
}
}
public static unsafe partial class DXGI
{
public unsafe partial class Factory2
{
}
}
///
/// Entry point for the Windows Imaging Component (WIC).
/// Wraps IWICImagingFactory creation via CoCreateInstance.
///
public static unsafe partial class WIC
{
}
}
namespace Xui.Runtime.Windows
{
using System;
public static partial class D2D1
{
public unsafe class Bitmap : Image
{
public static new readonly Guid IID;
public Bitmap(void* ptr);
}
}
public static partial class D2D1
{
public unsafe class Bitmap1 : Bitmap
{
public static new readonly Guid IID;
public Bitmap1(void* ptr);
}
}
public static partial class D2D1
{
///
/// Wraps ID2D1BitmapBrush — a brush that paints with a tiled or clamped bitmap.
/// Obtained via ID2D1RenderTarget::CreateBitmapBrush (vtable [7]).
/// For drawing, the brush is used through the handle.
///
public unsafe class BitmapBrush : Brush
{
public static new readonly Guid IID;
public BitmapBrush(void* ptr);
}
}
public static partial class D2D1
{
public unsafe partial class Brush : Resource
{
public new struct Ptr : IDisposable
{
public Ptr(void* ptr);
public static implicit operator void*(Ptr p);
public bool IsNull { get; }
public void Dispose();
}
}
}
public static partial class D2D1
{
public unsafe partial class Brush : Resource
{
public static new readonly Guid IID;
public Brush(void* ptr);
public static void SetOpacity(void* brush, float opacity);
public static float GetOpacity(void* brush);
}
}
public static partial class D2D1
{
public unsafe class Device1 : Device
{
public static new readonly Guid IID;
public Device1(void* ptr);
}
}
public static partial class D2D1
{
public unsafe class Device2 : Device1
{
public static new readonly Guid IID;
public Device2(void* ptr);
}
}
public static partial class D2D1
{
[Flags]
public enum DrawTextOptions
{
None = 0x00000000,
NoSnap = 0x00000001,
Clip = 0x00000002,
EnableColorFont = 0x00000004,
DisableColorBitmapSnapping = 0x00000008,
}
}
public static partial class D2D1
{
public unsafe partial class DrawingStateBlock : Resource
{
public new struct Ptr : IDisposable
{
public Ptr(void* ptr);
public static implicit operator void*(Ptr p);
public bool IsNull { get; }
public void Dispose();
}
}
}
public static partial class D2D1
{
public unsafe class Factory1 : Factory
{
public static new readonly Guid IID;
public Factory1();
public Factory1(void* ptr);
}
}
public static partial class D2D1
{
public unsafe class Geometry : Resource
{
public static new readonly Guid IID;
public Geometry(void* ptr);
}
}
public static partial class D2D1
{
public unsafe partial class GeometrySink : SimplifiedGeometrySink
{
public new struct Ptr : IDisposable
{
public Ptr(void* ptr);
public static implicit operator void*(Ptr p);
public bool IsNull { get; }
public void SetFillMode(FillMode fillMode);
public void BeginFigure(Point2F startPoint, FigureBegin figureBegin = FigureBegin.Filled);
public void EndFigure(FigureEnd figureEnd = FigureEnd.Closed);
public void Close();
public void AddLine(Point2F point);
public void AddBezier(BezierSegment bezierSegment);
public void AddQuadraticBezier(QuadraticBezierSegment quadraticBezierSegment);
public void AddArc(in ArcSegment arcSegment);
public void Dispose();
}
}
}
public static partial class D2D1
{
public unsafe partial class GeometrySink : SimplifiedGeometrySink
{
public static new readonly Guid IID;
public GeometrySink(void* ptr);
public void AddLine(Point2F point);
public void AddBezier(BezierSegment bezierSegment);
public void AddQuadraticBezier(QuadraticBezierSegment quadraticBezierSegment);
public void AddQuadraticBeziers(ReadOnlySpan quadraticBezierSegments);
public void AddArc(in ArcSegment arcSegment);
}
}
public static partial class D2D1
{
public unsafe partial class GradientStopCollection : Resource
{
public static new readonly Guid IID;
public GradientStopCollection(void* ptr);
}
}
public static partial class D2D1
{
public unsafe class Image : Resource
{
public static new readonly Guid IID;
public Image(void* ptr);
}
}
public static partial class D2D1
{
public unsafe partial class LinearGradientBrush : Brush
{
public static new readonly Guid IID;
public readonly void* GradientStopCollectionPtr;
public LinearGradientBrush(void* ptr, void* gradientStopCollectionPtr);
}
}
public static partial class D2D1
{
[Flags]
public enum PathSegment : uint
{
None = 0x00000000,
ForceUnstroked = 0x00000001,
ForceRoundLineJoin = 0x00000002,
}
}
public static partial class D2D1
{
public unsafe partial class RadialGradientBrush : Brush
{
public static new readonly Guid IID;
public readonly void* GradientStopCollectionPtr;
public RadialGradientBrush(void* ptr, void* gradientStopCollectionPtr);
}
}
public static partial class D2D1
{
public unsafe class SolidColorBrush : Brush
{
public static new readonly Guid IID;
public SolidColorBrush(void* ptr);
public ColorF Color { get; set; }
}
}
public static partial class D2D1
{
public unsafe partial class StrokeStyle : Resource
{
public new struct Ptr : IDisposable
{
public Ptr(void* ptr);
public static implicit operator void*(Ptr p);
public bool IsNull { get; }
public void Dispose();
}
}
}
public static partial class D2D1
{
public unsafe partial class StrokeStyle : Resource
{
public static new readonly Guid IID;
public StrokeStyle(void* ptr);
}
}
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static partial class D3D11
{
///
/// Identifies how a D3D11 resource is bound to the pipeline.
/// Mirrors D3D11_BIND_FLAG.
///
[Flags]
public enum BindFlags : uint
{
VertexBuffer = 0x1,
IndexBuffer = 0x2,
ConstantBuffer = 0x4,
ShaderResource = 0x8,
StreamOutput = 0x10,
RenderTarget = 0x20,
DepthStencil = 0x40,
UnorderedAccess = 0x80,
Decoder = 0x200,
VideoEncoder = 0x400,
}
}
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static partial class D3D11
{
///
/// Specifies the types of CPU access allowed for a resource.
/// Mirrors D3D11_CPU_ACCESS_FLAG.
///
[Flags]
public enum CpuAccessFlags : uint
{
None = 0,
Write = 0x10000,
Read = 0x20000,
}
}
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static partial class D3D11
{
[Flags]
public enum CreteDeviceFlags : uint
{
SingleThreaded = 0x1,
Debug = 0x2,
SwitchToRef = 0x4,
PreventInternalThreadingOptimizations = 0x8,
BGRASupport = 0x20,
Debuggable = 0x40,
PreventAlteringLayerSettingsFromRegistry = 0x80,
DisableGpuTimeout = 0x100,
VideoSupport = 0x800
}
}
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static unsafe partial class D3D11
{
public struct DeviceAndSwapChain : IDisposable
{
public DXGI.SwapChain? DxgiSwapChain;
public D3D11.Device? D3D11Device;
public D3D11.FeatureLevel D3d11FeatureLevel;
public D3D11.DeviceContext? D3D11ImmediateContext;
public DXGI.Device? DxgiDevice;
public void Dispose();
}
}
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static partial class D3D11
{
///
/// Wraps ID3D11Texture2D.
/// After creation, query via
/// to obtain an IDXGISurface
/// usable with ID2D1DeviceContext::CreateBitmapFromDxgiSurface.
///
public unsafe class Texture2D : COM.Unknown
{
public static new readonly Guid IID;
public Texture2D(void* ptr);
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public unsafe partial class FontFace1 : FontFace
{
public new ref struct Ref : IDisposable
{
public Ref(void* ptr);
public static implicit operator void*(Ref r);
public static FontFace1.Ref FromFontFace(FontFace.Ref face);
public void GetMetrics(out FontMetrics1 metrics);
public void Dispose();
}
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public unsafe partial class FontFace1 : FontFace
{
public static new readonly Guid IID;
public FontFace1(void* ptr);
public static FontFace1 FromFontFace(FontFace face);
public void GetMetrics(out FontMetrics1 metrics);
public bool IsMonospacedFont();
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public unsafe partial class TextFormat : COM.Unknown
{
public new struct Ptr : IDisposable
{
public Ptr(void* ptr);
public static implicit operator void*(Ptr p);
public bool IsNull { get; }
public void Dispose();
}
}
}
public static partial class DXGI
{
public unsafe class Factory : DXGI.Object
{
public static new readonly Guid IID;
public Factory(void* ptr);
}
}
public static partial class DXGI
{
public unsafe class Factory1 : Factory
{
public static new readonly Guid IID;
public Factory1(void* ptr);
}
}
public static partial class DXGI
{
public unsafe class Output : DXGI.Object
{
public static new readonly Guid IID;
public Output(void* ptr);
}
}
public static partial class DXGI
{
[Flags]
public enum Present : uint
{
Test = 0x00000001U,
DoNotSequence = 0x00000002U,
Restart = 0x00000004U,
DoNotWait = 0x00000008U,
StereoPreferRight = 0x00000010U,
StereoTemporaryMono = 0x00000020U,
RestrictToOutput = 0x00000040U,
UseDuration = 0x00000100U,
AllowTearing = 0x00000200U
}
}
public static partial class DXGI
{
public unsafe class SwapChain1 : SwapChain
{
public static new readonly Guid IID;
public SwapChain1(void* ptr);
}
}
public static partial class DXGI
{
[Flags]
public enum SwapChainFlags : uint
{
NonInterpolated = 1,
AllowModeSwitch = 2,
GdiCompatible = 4,
RestrictedContent = 8,
RestrictSharedResourceDriver = 16,
DisplayOnly = 32,
FrameLatencyWaitableObject = 64,
ForegroundLayet = 128,
FullscreenVideo = 256,
YUVVideo = 512,
HWProtected = 1024,
AllowTearing = 2048,
RestrictedToAllHolographicDisplays = 4096
}
}
public static partial class DXGI
{
[Flags]
public enum Usage : uint
{
ShaderInput = 0x00000010U,
RenderTargetOutput = 0x00000020U,
BackBuffer = 0x00000040U,
Shared = 0x00000080U,
ReadOnly = 0x00000100U,
DiscardOnPresent = 0x00000200U,
UnorderedAccess = 0x00000400U
}
}
///
/// Entry point for the Windows Imaging Component (WIC).
/// Wraps IWICImagingFactory creation via CoCreateInstance.
///
public static partial class WIC
{
///
/// Well-known WIC pixel format GUIDs.
///
public static class PixelFormats
{
///
/// 32-bit premultiplied BGRA — the target format for all image decoding in this pipeline.
/// GUID_WICPixelFormat32bppPBGRA {6fddc324-4e03-4bfe-b185-3d77768dc910}
///
public static readonly Guid Pbgra32;
}
}
public class Win32Exception : Exception
{
public Win32Exception(string? message);
}
}
namespace Xui.Runtime.Windows
{
using System.Runtime.InteropServices;
public static partial class D2D1
{
///
/// Configures how a ID2D1BitmapBrush tiles and samples the source bitmap.
/// Mirrors D2D1_BITMAP_BRUSH_PROPERTIES (12 bytes, sequential).
///
[StructLayout(LayoutKind.Sequential)]
public struct BitmapBrushProperties
{
///
/// How the bitmap is extended horizontally beyond its bounds.
/// D2D1_EXTEND_MODE: Clamp=0, Wrap=1, Mirror=2.
///
public uint ExtendModeX;
///
/// How the bitmap is extended vertically beyond its bounds.
/// D2D1_EXTEND_MODE: Clamp=0, Wrap=1, Mirror=2.
///
public uint ExtendModeY;
///
/// Sampling quality.
/// D2D1_BITMAP_INTERPOLATION_MODE: NearestNeighbor=0, Linear=1.
///
public uint InterpolationMode;
}
}
public static partial class D2D1
{
[StructLayout(LayoutKind.Explicit, Size = 32)]
public struct BitmapProperties1
{
[FieldOffset(0)]
public PixelFormat PixelFormat;
[FieldOffset(8)]
public float DpiX;
[FieldOffset(12)]
public float DpiY;
[FieldOffset(16)]
public BitmapOptions BitmapOptions;
[FieldOffset(16)]
public nint ColorContext;
[FieldOffset(24)]
public nint __TODO;
}
}
public static partial class D2D1
{
/// ID2D1CommandList: resolution-independent Direct2D drawing instructions.
public unsafe class CommandList(void* ptr) : Image
{
public void Close();
}
}
public static partial class D2D1
{
public const string D2D1Lib = "d2d1.dll";
public static readonly nint Lib;
}
public static partial class D2D1
{
[StructLayout(LayoutKind.Sequential)]
public struct PixelFormat
{
public DXGI.Format Format;
public AlphaMode AlphaMode;
}
}
public static partial class D2D1
{
public struct RoundRect
{
public RectF Rect;
public float RadiusX;
public float RadiusY;
public RoundRect(RectF rect, float radius);
}
}
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static partial class D3D11
{
///
/// Describes the blend state.
/// Mirrors D3D11_BLEND_DESC.
///
[StructLayout(LayoutKind.Sequential)]
public unsafe struct BlendDesc
{
public int AlphaToCoverageEnable;
public int IndependentBlendEnable;
public fixed byte RenderTarget[8 * 32];
}
}
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static partial class D3D11
{
///
/// Describes a buffer resource.
/// Mirrors D3D11_BUFFER_DESC.
///
[StructLayout(LayoutKind.Sequential)]
public struct BufferDesc
{
public uint ByteWidth;
public Usage Usage;
public uint BindFlags;
public uint CPUAccessFlags;
public uint MiscFlags;
public uint StructureByteStride;
}
}
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static partial class D3D11
{
///
/// Describes depth-stencil state.
/// Mirrors D3D11_DEPTH_STENCIL_DESC.
///
[StructLayout(LayoutKind.Sequential)]
public struct DepthStencilDesc
{
public int DepthEnable;
public uint DepthWriteMask;
public uint DepthFunc;
public int StencilEnable;
public byte StencilReadMask;
public byte StencilWriteMask;
public DepthStencilOpDesc FrontFace;
public DepthStencilOpDesc BackFace;
}
}
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static partial class D3D11
{
///
/// Describes stencil operations that can be performed based on the results of stencil test.
/// Mirrors D3D11_DEPTH_STENCILOP_DESC.
///
[StructLayout(LayoutKind.Sequential)]
public struct DepthStencilOpDesc
{
public uint StencilFailOp;
public uint StencilDepthFailOp;
public uint StencilPassOp;
public uint StencilFunc;
}
}
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static partial class D3D11
{
///
/// Describes a single element for the input-assembler stage.
/// Mirrors D3D11_INPUT_ELEMENT_DESC.
///
[StructLayout(LayoutKind.Sequential)]
public unsafe struct InputElementDesc
{
public byte* SemanticName;
public uint SemanticIndex;
public DXGI.Format Format;
public uint InputSlot;
public uint AlignedByteOffset;
public uint InputSlotClass;
public uint InstanceDataStepRate;
}
}
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static partial class D3D11
{
///
/// Provides access to subresource data.
/// Mirrors D3D11_MAPPED_SUBRESOURCE.
///
[StructLayout(LayoutKind.Sequential)]
public unsafe struct MappedSubresource
{
public void* pData;
public uint RowPitch;
public uint DepthPitch;
}
}
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static partial class D3D11
{
///
/// Describes rasterizer state.
/// Mirrors D3D11_RASTERIZER_DESC.
///
[StructLayout(LayoutKind.Sequential)]
public struct RasterizerDesc
{
public uint FillMode;
public uint CullMode;
public int FrontCounterClockwise;
public int DepthBias;
public float DepthBiasClamp;
public float SlopeScaledDepthBias;
public int DepthClipEnable;
public int ScissorEnable;
public int MultisampleEnable;
public int AntialiasedLineEnable;
}
}
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static partial class D3D11
{
///
/// Describes the blend state for a render target.
/// Mirrors D3D11_RENDER_TARGET_BLEND_DESC.
///
[StructLayout(LayoutKind.Sequential)]
public struct RenderTargetBlendDesc
{
public int BlendEnable;
public uint SrcBlend;
public uint DestBlend;
public uint BlendOp;
public uint SrcBlendAlpha;
public uint DestBlendAlpha;
public uint BlendOpAlpha;
public byte RenderTargetWriteMask;
}
}
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static partial class D3D11
{
///
/// Specifies data for initialising a subresource (e.g. initial pixel data for a texture).
/// Mirrors D3D11_SUBRESOURCE_DATA.
///
[StructLayout(LayoutKind.Sequential)]
public unsafe struct SubresourceData
{
/// Pointer to the initialisation data.
public void* pSysMem;
/// Row stride in bytes (width × bytes-per-pixel for a 2D texture).
public uint SysMemPitch;
/// Slice stride in bytes (unused for 2D textures — set to 0).
public uint SysMemSlicePitch;
}
}
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static partial class D3D11
{
///
/// Describes a 2D texture resource.
/// Mirrors D3D11_TEXTURE2D_DESC (44 bytes, fully sequential).
///
[StructLayout(LayoutKind.Sequential)]
public struct Texture2DDesc
{
public uint Width;
public uint Height;
/// Number of mip levels. 1 = no mipmaps.
public uint MipLevels;
/// Number of textures in the array. Use 1 for a single texture.
public uint ArraySize;
public DXGI.Format Format;
public DXGI.SampleDesc SampleDesc;
///
/// Resource usage. 0 = D3D11_USAGE_DEFAULT (GPU read/write, no CPU access).
///
public uint Usage;
public uint BindFlags;
public uint CPUAccessFlags;
public uint MiscFlags;
}
}
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static partial class D3D11
{
///
/// Defines the dimensions of a viewport.
/// Mirrors D3D11_VIEWPORT.
///
[StructLayout(LayoutKind.Sequential)]
public struct Viewport
{
public float TopLeftX;
public float TopLeftY;
public float Width;
public float Height;
public float MinDepth;
public float MaxDepth;
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public const string DWriteLib = "dwrite.dll";
public static readonly nint Lib;
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
[StructLayout(LayoutKind.Explicit, Pack = 2, Size = 48)]
public struct FontMetrics1
{
[FieldOffset(0)]
public ushort DesignUnitsPerEm;
[FieldOffset(2)]
public ushort Ascent;
[FieldOffset(4)]
public ushort Descent;
[FieldOffset(6)]
public short LineGap;
[FieldOffset(8)]
public ushort CapHeight;
[FieldOffset(10)]
public ushort XHeight;
[FieldOffset(12)]
public short UnderlinePosition;
[FieldOffset(14)]
public ushort UnderlineThickness;
[FieldOffset(16)]
public short StrikethroughPosition;
[FieldOffset(18)]
public ushort StrikethroughThickness;
[FieldOffset(20)]
public short GlyphBoxLeft;
[FieldOffset(22)]
public short GlyphBoxTop;
[FieldOffset(24)]
public short GlyphBoxRight;
[FieldOffset(26)]
public short GlyphBoxBottom;
[FieldOffset(28)]
public short SubscriptPositionX;
[FieldOffset(30)]
public short SubscriptPositionY;
[FieldOffset(32)]
public short SubscriptSizeX;
[FieldOffset(34)]
public short SubscriptSizeY;
[FieldOffset(36)]
public short SuperscriptPositionX;
[FieldOffset(38)]
public short SuperscriptPositionY;
[FieldOffset(40)]
public short SuperscriptSizeX;
[FieldOffset(42)]
public short SuperscriptSizeY;
[FieldOffset(44)]
public int HasTypographicMetrics;
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
[StructLayout(LayoutKind.Explicit, Size = 16)]
public struct OverhangMetrics
{
[FieldOffset(0)]
public float Left;
[FieldOffset(4)]
public float Top;
[FieldOffset(8)]
public float Right;
[FieldOffset(12)]
public float Bottom;
}
}
public static partial class DXGI
{
public const string DXGILib = "dxgi.dll";
public static readonly nint Lib;
}
}
namespace Xui.Runtime.Windows
{
using System.Runtime.InteropServices;
using Xui.Core.Canvas;
public static partial class D2D1
{
[StructLayout(LayoutKind.Explicit, Size = 16)]
public struct ColorF
{
[FieldOffset(0)]
public float R;
[FieldOffset(4)]
public float G;
[FieldOffset(8)]
public float B;
[FieldOffset(12)]
public float A;
public static implicit operator ColorF(Color color);
public static implicit operator ColorF(uint rgbaHex);
}
}
}
namespace Xui.Runtime.Windows
{
using System.Runtime.InteropServices;
using System;
using static Xui.Runtime.Windows.COM;
public static partial class D2D1
{
public unsafe class Device : Unknown
{
public static new readonly Guid IID;
public Device(void* ptr);
public unsafe DeviceContext CreateDeviceContext(DeviceContextOptions deviceContextOptions);
}
}
public static partial class D2D1
{
public unsafe class SimplifiedGeometrySink : Unknown
{
public static new readonly Guid IID;
public SimplifiedGeometrySink(void* ptr);
public void SetFillMode(FillMode fillMode);
public void SetSegmentFlags(PathSegment pathSegment);
public void BeginFigure(Point2F startPoint, FigureBegin figureBegin = FigureBegin.Filled);
public void AddLines(ReadOnlySpan points);
public void AddBeziers(ReadOnlySpan bezierSegments);
public void EndFigure(FigureEnd figureEnd = FigureEnd.Closed);
public void Close();
}
}
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static partial class D3D11
{
public unsafe class Device : Unknown
{
public static new readonly Guid IID;
public Device(void* ptr);
///
/// Creates a buffer resource.
/// Wraps ID3D11Device::CreateBuffer (vtable [3]).
///
public void* CreateBuffer(in BufferDesc desc, SubresourceData* pInitialData);
///
/// Creates a 2D texture resource.
/// Wraps ID3D11Device::CreateTexture2D (vtable [5]).
///
public Texture2D CreateTexture2D(in Texture2DDesc desc, in SubresourceData initialData);
///
/// Creates a 2D texture resource (no initial data).
/// Wraps ID3D11Device::CreateTexture2D (vtable [5]).
///
public void* CreateTexture2D(in Texture2DDesc desc);
///
/// Creates a render-target view.
/// Wraps ID3D11Device::CreateRenderTargetView (vtable [9]).
///
public void* CreateRenderTargetView(void* pResource, void* pDesc);
///
/// Creates a depth-stencil view.
/// Wraps ID3D11Device::CreateDepthStencilView (vtable [10]).
///
public void* CreateDepthStencilView(void* pResource, void* pDesc);
///
/// Creates an input-layout object.
/// Wraps ID3D11Device::CreateInputLayout (vtable [11]).
///
public void* CreateInputLayout(InputElementDesc* pInputElementDescs, uint numElements, void* pShaderBytecode, nuint bytecodeLength);
///
/// Creates a vertex-shader object.
/// Wraps ID3D11Device::CreateVertexShader (vtable [12]).
///
public void* CreateVertexShader(void* pShaderBytecode, nuint bytecodeLength, void* pClassLinkage);
///
/// Creates a pixel-shader object.
/// Wraps ID3D11Device::CreatePixelShader (vtable [15]).
///
public void* CreatePixelShader(void* pShaderBytecode, nuint bytecodeLength, void* pClassLinkage);
///
/// Creates a depth-stencil state object.
/// Wraps ID3D11Device::CreateDepthStencilState (vtable [21]).
///
public void* CreateDepthStencilState(in DepthStencilDesc desc);
///
/// Creates a rasterizer state object.
/// Wraps ID3D11Device::CreateRasterizerState (vtable [22]).
///
public void* CreateRasterizerState(in RasterizerDesc desc);
}
}
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static unsafe partial class D3D11
{
public unsafe class DeviceContext : DeviceChild
{
public static new readonly Guid IID;
public DeviceContext(void* ptr);
///
/// Sets constant buffers for the vertex shader stage.
/// Wraps ID3D11DeviceContext::VSSetConstantBuffers (vtable [7]).
///
public void VSSetConstantBuffers(uint startSlot, uint numBuffers, void** ppConstantBuffers);
///
/// Sets a pixel shader.
/// Wraps ID3D11DeviceContext::PSSetShader (vtable [9]).
///
public void PSSetShader(void* pPixelShader, void** ppClassInstances, uint numClassInstances);
///
/// Sets a vertex shader.
/// Wraps ID3D11DeviceContext::VSSetShader (vtable [11]).
///
public void VSSetShader(void* pVertexShader, void** ppClassInstances, uint numClassInstances);
///
/// Maps a subresource for CPU access.
/// Wraps ID3D11DeviceContext::Map (vtable [14]).
///
public void Map(void* pResource, uint subresource, Map mapType, uint mapFlags, MappedSubresource* pMappedResource);
///
/// Unmaps a previously mapped subresource.
/// Wraps ID3D11DeviceContext::Unmap (vtable [15]).
///
public void Unmap(void* pResource, uint subresource);
///
/// Sets constant buffers for the pixel shader stage.
/// Wraps ID3D11DeviceContext::PSSetConstantBuffers (vtable [16]).
///
public void PSSetConstantBuffers(uint startSlot, uint numBuffers, void** ppConstantBuffers);
///
/// Sets the input layout.
/// Wraps ID3D11DeviceContext::IASetInputLayout (vtable [17]).
///
public void IASetInputLayout(void* pInputLayout);
///
/// Binds vertex buffers to the input-assembler stage.
/// Wraps ID3D11DeviceContext::IASetVertexBuffers (vtable [18]).
///
public void IASetVertexBuffers(uint startSlot, uint numBuffers, void** ppVertexBuffers, uint* pStrides, uint* pOffsets);
///
/// Sets the primitive topology.
/// Wraps ID3D11DeviceContext::IASetPrimitiveTopology (vtable [24]).
///
public void IASetPrimitiveTopology(uint topology);
///
/// Sets render targets and the depth-stencil buffer.
/// Wraps ID3D11DeviceContext::OMSetRenderTargets (vtable [33]).
///
public void OMSetRenderTargets(uint numViews, void** ppRenderTargetViews, void* pDepthStencilView);
///
/// Sets the depth-stencil state.
/// Wraps ID3D11DeviceContext::OMSetDepthStencilState (vtable [36]).
///
public void OMSetDepthStencilState(void* pDepthStencilState, uint stencilRef);
///
/// Sets the rasterizer state.
/// Wraps ID3D11DeviceContext::RSSetState (vtable [43]).
///
public void RSSetState(void* pRasterizerState);
///
/// Sets the viewports.
/// Wraps ID3D11DeviceContext::RSSetViewports (vtable [44]).
///
public void RSSetViewports(uint numViewports, Viewport* pViewports);
///
/// Copies a resource.
/// Wraps ID3D11DeviceContext::CopyResource (vtable [47]).
///
public void CopyResource(void* pDstResource, void* pSrcResource);
///
/// Clears a render target view to a specified color.
/// Wraps ID3D11DeviceContext::ClearRenderTargetView (vtable [50]).
///
public void ClearRenderTargetView(void* pRenderTargetView, float* colorRGBA);
///
/// Clears a depth-stencil view.
/// Wraps ID3D11DeviceContext::ClearDepthStencilView (vtable [53]).
///
public void ClearDepthStencilView(void* pDepthStencilView, uint clearFlags, float depth, byte stencil);
///
/// Updates a subresource.
/// Wraps ID3D11DeviceContext::UpdateSubresource (vtable [48]).
///
public void UpdateSubresource(void* pDstResource, uint dstSubresource, void* pDstBox, void* pSrcData, uint srcRowPitch, uint srcDepthPitch);
///
/// Draws non-indexed, non-instanced primitives.
/// Wraps ID3D11DeviceContext::Draw (vtable [13]).
///
public void DrawPrimitive(uint vertexCount, uint startVertexLocation);
///
/// Clears all device state to defaults.
/// Wraps ID3D11DeviceContext::ClearState (vtable [110]).
///
public void ClearState();
///
/// Sends queued commands to the GPU.
/// Wraps ID3D11DeviceContext::Flush (vtable [111]).
///
public void Flush();
}
}
public static partial class DComp
{
public unsafe class Target : Unknown
{
public static new readonly Guid IID;
public Target(void* ptr);
public void SetRoot(Visual visual);
}
}
public static partial class DComp
{
public unsafe class Visual : Unknown
{
public static new readonly Guid IID;
public Visual(void* ptr);
public void SetContent(Unknown content);
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public unsafe partial class Font : Unknown
{
public Font(void* ptr);
public FontFace CreateFontFace();
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public unsafe partial class FontCollection : Unknown
{
public FontCollection(void* ptr);
public uint Count { get; }
public uint GetFontFamilyCount();
public FontFamily GetFontFamily(uint index);
public void FindFamilyName(string familyName, out uint index, out bool exists);
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public unsafe partial class FontFamily : Unknown
{
public FontFamily(void* ptr);
public Font GetFirstMatchingFont(FontWeight fontWeight, FontStretch fontStretch, FontStyle fontStyle);
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public unsafe partial class TextFormat : Unknown
{
public TextFormat(void* ptr);
public void SetTextAlignment(TextAlignment alignment);
}
}
public static partial class DXGI
{
public unsafe class Adapter : Unknown
{
public static new readonly Guid IID;
public Adapter(void* ptr);
public DXGI.Factory2 GetParentFactory2();
}
}
public static partial class DXGI
{
public unsafe class Device : Unknown
{
public static new readonly Guid IID;
public Device(void* ptr);
public DXGI.Adapter GetAdapter();
}
}
public static partial class DXGI
{
public unsafe class SwapChain : Unknown
{
public static new readonly Guid IID;
public static unsafe nint GetBuffer(nint dxgiSwapChainPtr, uint buffer, in Guid IID);
public SwapChain(void* ptr);
public void Present(uint syncInterval = 0, Present flags = 0);
public Surface GetBufferAsSurface(uint buffer = 0);
public void ResizeBuffers(uint bufferCount, uint width, uint height, Format newFormat, SwapChainFlags swapChainFlags);
public FrameStatistics GetFrameStatistics();
}
}
public static partial class DXGI
{
public unsafe class SwapChain2 : SwapChain1
{
public static new readonly Guid IID;
public SwapChain2(void* ptr);
///
/// Limits the number of frames the swap chain can queue for rendering.
/// Use 1 for tight "render once per frame" pacing.
///
///
/// https://learn.microsoft.com/en-us/windows/win32/api/dxgi1_2/nf-dxgi1_2-idxgiswapchain2-setmaximumframelatency
///
public void SetMaximumFrameLatency(uint maxLatency);
///
/// Returns a waitable handle that becomes signaled when the swap chain is ready
/// to accept a new frame (used for frame pacing).
///
///
/// Requires the swap chain to be created with .
/// https://learn.microsoft.com/en-us/windows/win32/api/dxgi1_3/nf-dxgi1_3-idxgiswapchain2-getframelatencywaitableobject
///
public nint GetFrameLatencyWaitableObject();
}
}
}
namespace Xui.Runtime.Windows
{
using System.Runtime.InteropServices;
using System;
public static partial class D2D1
{
public unsafe class DeviceContext : RenderTarget
{
public static new readonly Guid IID;
public DeviceContext(void* ptr);
///
/// Creates a ID2D1Bitmap1 by letting D2D1 decode and upload a IWICBitmapSource directly.
/// D2D1 handles format conversion internally — no manual pixel copy required.
/// vtable [58] — ID2D1DeviceContext::CreateBitmapFromWicBitmap
///
public Bitmap1 CreateBitmapFromWicBitmap(COM.Unknown wicBitmapSource);
public Bitmap1 CreateBitmapFromDxgiSurface(DXGI.Surface surface, in BitmapProperties1 bitmapProperties1);
public void SetTarget(Bitmap1? d2dTargetBitmap);
public void SetImageTarget(Image? image);
public Device GetDevice();
public CommandList CreateCommandList();
public void DrawImage(Image image);
}
}
public static partial class D2D1
{
public unsafe partial class DrawingStateBlock : Resource
{
public static new readonly Guid IID;
public DrawingStateBlock(void* ptr);
}
}
public static partial class D2D1
{
public unsafe class Factory2 : Factory1
{
public static new readonly Guid IID;
public Factory2();
public Factory2(void* ptr);
}
}
public static partial class D2D1
{
public unsafe class Factory3 : Factory2
{
public static new readonly Guid IID;
public Factory3();
public Factory3(void* ptr);
public new D2D1.Device2 CreateDevice(DXGI.Device device);
}
}
public static partial class D2D1
{
public unsafe partial class PathGeometry : Geometry
{
public new struct Ptr : IDisposable
{
public Ptr(void* ptr);
public static implicit operator void*(Ptr p);
public bool IsNull { get; }
public GeometrySink.Ptr Open();
public void Dispose();
}
}
}
public static partial class D2D1
{
public unsafe partial class PathGeometry : Geometry
{
public static new readonly Guid IID;
public PathGeometry(void* ptr);
public GeometrySink Open();
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public unsafe partial class Factory1 : Factory
{
public Factory1();
public Factory1(void* ptr);
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public unsafe partial class Font : COM.Unknown
{
public ref struct Ref : IDisposable
{
public Ref(void* ptr);
public static implicit operator void*(Ref r);
public FontFace.Ref CreateFontFace();
public void Dispose();
}
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public unsafe partial class FontCollection : COM.Unknown
{
public ref struct Ref : IDisposable
{
public Ref(void* ptr);
public static implicit operator void*(Ref r);
public void FindFamilyName(string familyName, out uint index, out bool exists);
public FontFamily.Ref GetFontFamily(uint index);
public void Dispose();
}
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public unsafe partial class FontFace : COM.Unknown
{
public ref struct Ref : IDisposable
{
public Ref(void* ptr);
public static implicit operator void*(Ref r);
public void* QueryInterface(in Guid refId);
public void Dispose();
}
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public unsafe partial class FontFamily : COM.Unknown
{
public ref struct Ref : IDisposable
{
public Ref(void* ptr);
public static implicit operator void*(Ref r);
public Font.Ref GetFirstMatchingFont(FontWeight fontWeight, FontStretch fontStretch, FontStyle fontStyle);
public void Dispose();
}
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public unsafe partial class TextLayout : TextFormat
{
public ref struct Ref : IDisposable
{
public Ref(void* ptr);
public static implicit operator void*(Ref r);
public TextMetrics GetTextMetrics();
public OverhangMetrics GetOverhangMetrics();
public LineMetrics[] GetLineMetrics();
public bool TryGetFirstLineMetrics(out LineMetrics lineMetrics);
public void Dispose();
}
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public unsafe partial class TextLayout : TextFormat
{
public TextLayout(void* ptr);
public TextMetrics GetTextMetrics();
public OverhangMetrics GetOverhangMetrics();
public LineMetrics[] GetLineMetrics();
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public unsafe partial class TextLayout1 : TextLayout
{
public static new readonly Guid IID;
public TextLayout1(void* ptr);
public static TextLayout1 FromTextLayout(TextLayout layout);
}
}
///
/// Entry point for the Windows Imaging Component (WIC).
/// Wraps IWICImagingFactory creation via CoCreateInstance.
///
public static partial class WIC
{
///
/// Wraps IWICBitmapDecoder — a container for one or more image frames.
///
public unsafe class BitmapDecoder : COM.Unknown
{
public static new readonly Guid IID;
public BitmapDecoder(void* ptr);
///
/// Returns the decoded frame at the given index (0 for most formats).
/// vtable [13] — GetFrame
///
public BitmapFrameDecode GetFrame(uint index = 0);
}
}
///
/// Entry point for the Windows Imaging Component (WIC).
/// Wraps IWICImagingFactory creation via CoCreateInstance.
///
public static partial class WIC
{
///
/// Wraps IWICBitmapFrameDecode — a single decoded image frame.
/// Inherits IWICBitmapSource methods (GetSize, CopyPixels) at vtable [3] and [7].
///
public unsafe class BitmapFrameDecode : COM.Unknown
{
public static new readonly Guid IID;
public BitmapFrameDecode(void* ptr);
///
/// Returns the pixel dimensions of the frame.
/// vtable [3] — IWICBitmapSource::GetSize
///
public void GetSize(out uint width, out uint height);
///
/// Copies decoded pixels into (full image, no rect clipping).
/// vtable [7] — IWICBitmapSource::CopyPixels
///
public void CopyPixels(uint stride, uint bufferSize, byte* buffer);
}
}
///
/// Entry point for the Windows Imaging Component (WIC).
/// Wraps IWICImagingFactory creation via CoCreateInstance.
///
public static partial class WIC
{
///
/// Wraps IWICFormatConverter — converts a to a
/// target pixel format (typically ).
/// Inherits IWICBitmapSource methods at the same vtable slots as
/// .
///
public unsafe class FormatConverter : COM.Unknown
{
public static new readonly Guid IID;
public FormatConverter(void* ptr);
///
/// Configures the converter to produce pixels in .
/// vtable [8] — IWICFormatConverter::Initialize
///
public void Initialize(BitmapFrameDecode source, in Guid dstFormat);
///
/// Returns the pixel dimensions after conversion.
/// vtable [3] — IWICBitmapSource::GetSize
///
public void GetSize(out uint width, out uint height);
///
/// Copies converted pixels into (full image, no rect clipping).
/// vtable [7] — IWICBitmapSource::CopyPixels
///
public void CopyPixels(uint stride, uint bufferSize, byte* buffer);
}
}
///
/// Entry point for the Windows Imaging Component (WIC).
/// Wraps IWICImagingFactory creation via CoCreateInstance.
///
public static partial class WIC
{
///
/// Wraps IWICImagingFactory — the entry point for all WIC operations.
///
public unsafe class ImagingFactory : COM.Unknown
{
public static new readonly Guid IID;
public ImagingFactory(void* ptr);
///
/// Opens and decodes an image file.
/// vtable [3] — CreateDecoderFromFilename
///
public BitmapDecoder CreateDecoderFromFilename(string path);
///
/// Creates a format converter for pixel-format conversion.
/// vtable [10] — CreateFormatConverter
///
public FormatConverter CreateFormatConverter();
}
}
///
/// Entry point for the Windows Imaging Component (WIC).
/// Wraps IWICImagingFactory creation via CoCreateInstance.
///
public static partial class WIC
{
///
/// Creates and returns the WIC imaging factory.
/// Dispose when done (releases the COM reference).
///
public static unsafe ImagingFactory CreateImagingFactory();
}
}
namespace Xui.Runtime.Windows
{
using System.Runtime.InteropServices;
using System;
using static Xui.Runtime.Windows.COM;
using static Xui.Runtime.Windows.Win32.Types;
public static partial class D2D1
{
public unsafe partial class Factory : Unknown
{
public static new readonly Guid IID;
protected static void* CreateFactory(in Guid iid);
public Factory();
public Factory(void* ptr);
public void GetDesktopDpi(out float dpiX, out float dpiY);
public PathGeometry CreatePathGeometry();
public PathGeometry.Ptr CreatePathGeometryPtr();
public StrokeStyle CreateStrokeStyle(in StrokeStyleProperties strokeStyleProperties, ReadOnlySpan dashes);
public StrokeStyle.Ptr CreateStrokeStylePtr(in StrokeStyleProperties strokeStyleProperties, ReadOnlySpan dashes);
public DrawingStateBlock CreateDrawingStateBlock();
public DrawingStateBlock.Ptr CreateDrawingStateBlockPtr();
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public unsafe partial class Factory : Unknown
{
[LibraryImport("DWrite.dll")]
public static partial HRESULT DWriteCreateFactory(FactoryType factoryType, in Guid iid, out void* ppIFactory);
public Factory();
public Factory(void* ptr);
public FontCollection GetSystemFontCollection(bool checkForUpdates = false);
public FontCollection.Ref GetSystemFontCollectionRef(bool checkForUpdates = false);
public TextFormat CreateTextFormat(string fontFamilyName, FontCollection? fontCollection, FontWeight fontWeight, FontStyle fontStyle, FontStretch fontStretch, float fontSize, string localeName);
public TextFormat.Ptr CreateTextFormatPtr(string fontFamilyName, FontCollection? fontCollection, FontWeight fontWeight, FontStyle fontStyle, FontStretch fontStretch, float fontSize, string localeName);
public TextLayout CreateTextLayout(string text, TextFormat textFormat, float maxWidth, float maxHeight);
public TextLayout.Ref CreateTextLayoutRef(string text, TextFormat textFormat, float maxWidth, float maxHeight);
public TextLayout.Ref CreateTextLayoutRef(ReadOnlySpan text, TextFormat textFormat, float maxWidth, float maxHeight);
public TextLayout.Ref CreateTextLayoutRef(string text, TextFormat.Ptr textFormat, float maxWidth, float maxHeight);
public TextLayout.Ref CreateTextLayoutRef(ReadOnlySpan text, TextFormat.Ptr textFormat, float maxWidth, float maxHeight);
}
}
}
namespace Xui.Runtime.Windows
{
using System.Runtime.InteropServices;
using Xui.Core.Math2D;
public static partial class D2D1
{
[StructLayout(LayoutKind.Explicit, Size = 24)]
public struct Matrix3X2F
{
[FieldOffset(0)]
public float _11;
[FieldOffset(4)]
public float _12;
[FieldOffset(8)]
public float _21;
[FieldOffset(12)]
public float _22;
[FieldOffset(16)]
public float _31;
[FieldOffset(20)]
public float _32;
public static readonly Matrix3X2F Identity;
public static implicit operator AffineTransform(Matrix3X2F m);
public static implicit operator Matrix3X2F(AffineTransform t);
}
}
public static partial class D2D1
{
[StructLayout(LayoutKind.Sequential)]
public struct RectF
{
public float Left;
public float Top;
public float Right;
public float Bottom;
public static readonly RectF Inifinity;
public RectF(float left, float top, float right, float bottom);
public static implicit operator RectF(Rect rect);
}
}
}
namespace Xui.Runtime.Windows
{
using System;
using Xui.Core.Math2D;
public static partial class D2D1
{
public struct Point2F
{
public float X;
public float Y;
public static implicit operator Point2F(Point point);
public static implicit operator Point2F(Vector vector);
public static implicit operator Point(Point2F point);
public static implicit operator Point2F(ValueTuple tuple);
}
}
}
namespace Xui.Runtime.Windows
{
using System.Runtime.InteropServices;
using System;
using static Xui.Runtime.Windows.DWrite;
public static partial class D2D1
{
public unsafe class RenderTarget : Resource
{
public static new readonly Guid IID;
public RenderTarget(void* ptr);
///
/// Creates a bitmap brush that paints with a tiled or clamped bitmap.
/// Wraps ID2D1RenderTarget::CreateBitmapBrush (vtable [7]).
///
public Brush.Ptr CreateBitmapBrushPtr(Bitmap1 bitmap, in BitmapBrushProperties bbProps, in BrushProperties brushProps);
public SolidColorBrush CreateSolidColorBrush(in ColorF color);
public Brush.Ptr CreateSolidColorBrushPtr(in ColorF color);
public void* CreateGradientStopCollectionPtr(ReadOnlySpan gradientStops, Gamma gamma = Gamma.Gamma_2_2, ExtendMode extendMode = ExtendMode.Clamp);
public GradientStopCollection CreateGradientStopCollection(ReadOnlySpan gradientStops, Gamma gamma = Gamma.Gamma_2_2, ExtendMode extendMode = ExtendMode.Clamp);
public LinearGradientBrush CreateLinearGradientBrush(in LinearGradientBrush.Properties linearGradientBrushProperties, in BrushProperties brushProperties, ReadOnlySpan gradientStops, Gamma gamma = Gamma.Gamma_2_2, ExtendMode extendMode = ExtendMode.Clamp);
public RadialGradientBrush CreateRadialGradientBrush(in RadialGradientBrush.Properties radialGradientBrushProperties, in BrushProperties brushProperties, ReadOnlySpan gradientStops, Gamma gamma = Gamma.Gamma_2_2, ExtendMode extendMode = ExtendMode.Clamp);
public Brush.Ptr CreateLinearGradientBrushPtr(in LinearGradientBrush.Properties linearGradientBrushProperties, in BrushProperties brushProperties, ReadOnlySpan gradientStops, Gamma gamma = Gamma.Gamma_2_2, ExtendMode extendMode = ExtendMode.Clamp);
public Brush.Ptr CreateRadialGradientBrushPtr(in RadialGradientBrush.Properties radialGradientBrushProperties, in BrushProperties brushProperties, ReadOnlySpan gradientStops, Gamma gamma = Gamma.Gamma_2_2, ExtendMode extendMode = ExtendMode.Clamp);
public void DrawRectangle(in RectF rect, Brush brush, float strokeWidth = 1.0f, StrokeStyle? strokeStyle = null);
public void DrawRectangle(in RectF rect, Brush.Ptr brush, float strokeWidth = 1.0f, StrokeStyle? strokeStyle = null);
public void DrawRectangle(in RectF rect, Brush.Ptr brush, float strokeWidth, StrokeStyle.Ptr strokeStyle);
public void FillRectangle(in RectF rect, Brush brush);
public void FillRectangle(in RectF rect, Brush.Ptr brush);
public void DrawRoundedRectangle(in RoundRect roundRect, Brush brush, float strokeWidth = 1f, StrokeStyle? strokeStyle = null);
public void DrawRoundedRectangle(in RoundRect roundRect, Brush.Ptr brush, float strokeWidth = 1f, StrokeStyle? strokeStyle = null);
public void FillRoundedRectangle(in RoundRect roundRect, Brush brush);
public void FillRoundedRectangle(in RoundRect roundRect, Brush.Ptr brush);
public void DrawGeometry(Geometry geometry, Brush brush, float strokeWidth = 1f, StrokeStyle? strokeStyle = null);
public void DrawGeometry(Geometry geometry, Brush.Ptr brush, float strokeWidth = 1f, StrokeStyle? strokeStyle = null);
public void DrawGeometry(PathGeometry.Ptr geometry, Brush.Ptr brush, float strokeWidth = 1f, StrokeStyle.Ptr strokeStyle = default);
public void FillGeometry(Geometry geometry, Brush brush, Brush? opacityBrush = null);
public void FillGeometry(Geometry geometry, Brush.Ptr brush);
public void FillGeometry(PathGeometry.Ptr geometry, Brush.Ptr brush);
///
/// Draws a bitmap with the given opacity onto the render target.
/// Wraps ID2D1RenderTarget::DrawBitmap (vtable [26]).
/// Interpolation mode is always Linear (1).
///
public void DrawBitmap(Bitmap1 bitmap, in RectF dest, float opacity);
///
/// Draws a sub-region of a bitmap with the given opacity onto the render target.
/// Wraps ID2D1RenderTarget::DrawBitmap (vtable [26]).
/// Interpolation mode is always Linear (1).
///
public void DrawBitmap(Bitmap1 bitmap, in RectF dest, float opacity, in RectF source);
public void DrawText(string text, TextFormat textFormat, in RectF layoutRect, Brush defaultFillBrush, DrawTextOptions options = DrawTextOptions.None, MeasuringMode measuringMode = MeasuringMode.Natural);
public void DrawTextLayout(Point2F origin, DWrite.TextLayout textLayout, Brush defaultFillBrush, DrawTextOptions options = DrawTextOptions.None);
public void DrawTextLayout(Point2F origin, DWrite.TextLayout.Ref textLayout, Brush defaultFillBrush, DrawTextOptions options = DrawTextOptions.None);
public void DrawTextLayout(Point2F origin, DWrite.TextLayout textLayout, Brush.Ptr defaultFillBrush, DrawTextOptions options = DrawTextOptions.None);
public void DrawTextLayout(Point2F origin, DWrite.TextLayout.Ref textLayout, Brush.Ptr defaultFillBrush, DrawTextOptions options = DrawTextOptions.None);
public void SetTransform(in Matrix3X2F transform);
public void GetTransform(out Matrix3X2F transform);
public void PushLayer(in LayerParameters layoutParameters);
public void PopLayer();
public void SaveDrawingState(DrawingStateBlock drawingStateBlock);
public void SaveDrawingState(DrawingStateBlock.Ptr drawingStateBlock);
public void RestoreDrawingState(DrawingStateBlock drawingStateBlock);
public void RestoreDrawingState(DrawingStateBlock.Ptr drawingStateBlock);
public void Clear(ColorF color);
public void BeginDraw();
public void EndDraw();
///
/// Draws a bitmap into the given destination rectangle (vtable slot 26).
/// Sits between FillOpacityMask (25) and DrawText (27) in the ID2D1RenderTarget vtable.
/// interpolationMode: 0 = NearestNeighbor, 1 = Linear.
///
public void DrawBitmap(Bitmap1 bitmap, in RectF destRect, float opacity = 1.0f, uint interpolationMode = 1);
///
/// Draws a cropped region of a bitmap (vtable slot 26 with source rect).
///
public void DrawBitmap(Bitmap1 bitmap, in RectF destRect, in RectF srcRect, float opacity = 1.0f, uint interpolationMode = 1);
}
}
}
namespace Xui.Runtime.Windows
{
using System;
using static Xui.Runtime.Windows.COM;
public static partial class D2D1
{
public unsafe class Resource : Unknown
{
public static new readonly Guid IID;
public Resource(void* ptr);
}
}
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static unsafe partial class D3D11
{
public unsafe class DeviceChild : Unknown
{
public static new readonly Guid IID;
public DeviceChild(void* ptr);
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public unsafe partial class FontFace : Unknown
{
public FontFace(void* ptr);
public FontFaceType GetFaceType();
public ushort GetGlyphCount();
}
}
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public enum FontFaceType : int
{
Cff = 0,
Truetype = 1,
OpenTypeCollection = 2,
Type1 = 3,
Vector = 4,
Bitmap = 5,
Unknown = 6,
RawCff = 7,
}
}
public static partial class DXGI
{
public unsafe class Object : Unknown
{
public static new readonly Guid IID;
public Object(void* ptr);
}
}
public static partial class DXGI
{
public unsafe class Surface : Unknown
{
public static new readonly Guid IID;
public Surface(void* ptr);
}
}
}
namespace Xui.Runtime.Windows
{
using System.Runtime.InteropServices;
using System;
using static Xui.Runtime.Windows.DXGI;
using static Xui.Runtime.Windows.Win32.Types;
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
///
/// Code from <d3d11.h> in the d3d11.dll lib.
///
public static partial class D3D11
{
public const string D3D11Lib = "d3d11.dll";
public static readonly nint Lib;
public const uint D3D11_SDK_VERSION = 7;
public static unsafe DeviceAndSwapChain CreateDeviceAndSwapChain(nint hWnd, uint width, uint height);
public static unsafe void CreateDevice(out D3D11.Device device, out FeatureLevel featureLevel, out DeviceContext deviceContext);
}
}
namespace Xui.Runtime.Windows
{
using System.Runtime.InteropServices;
using System;
using static Xui.Runtime.Windows.Win32.Types;
public static partial class DComp
{
public const string DCompLib = "dcomp.dll";
public static readonly nint Lib;
[LibraryImport(DCompLib)]
public static partial uint DCompositionWaitForCompositorClock(uint handleCount, nint handlesArrPtr, uint timeoutInMs);
[LibraryImport(DCompLib)]
public static unsafe partial HRESULT DCompositionCreateDevice(void* dxgiDevice, in Guid iid, out void* dcompositionDevice);
}
}
namespace Xui.Runtime.Windows
{
using System.Runtime.InteropServices;
using System;
using static Xui.Runtime.Windows.COM;
using static Xui.Runtime.Windows.Win32.Types;
using static Xui.Runtime.Windows.Win32.User32.Types;
public static partial class DComp
{
public unsafe class Device : Unknown
{
public static new readonly Guid IID;
public static Device Create(DXGI.Device dxgiDevice);
public Device(void* ptr);
public void Commit();
public FrameStatistics GetFrameStatistics();
public Target CreateTargetForHwnd(HWND hwnd, bool topmost = false);
public Visual CreateVisual();
}
}
}
namespace Xui.Runtime.Windows
{
using System;
using static Xui.Runtime.Windows.DXGI;
public static partial class DComp
{
public struct FrameStatistics
{
public long LastFrameTime;
public Rational CurrentCompositionRate;
public long CurrentTime;
public long TimeFrequency;
public long NextEstimatedFrameTime;
public TimeSpan LastFrameTimeSpan { get; }
public TimeSpan CurrentTimeSpan { get; }
public TimeSpan NextEstimatedFrameTimeSpan { get; }
public TimeSpan EstimatedFrameInterval { get; }
}
}
}
namespace Xui.Runtime.Windows
{
using static Xui.Runtime.Windows.Win32.Types;
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
///
/// Code from <dwrite.h> in the dwrite.dll lib.
///
public static partial class DWrite
{
public struct LineMetrics
{
public uint Length;
public uint TrailingWhitespaceLength;
public uint NewlineLength;
public float Height;
public float Baseline;
public BOOL IsTrimmed;
}
}
public static partial class DXGI
{
public enum Scaling : uint
{
Stretch = 0,
None = 1,
AspectRatioStretch = 2
}
}
public static partial class DXGI
{
public struct SwapChainDesc
{
public ModeDesc BufferDesc;
public SampleDesc SampleDesc;
public Usage BufferUsage;
public uint BufferCount;
public nint OutputWindow;
public BOOL Windowed;
public SwapEffect SwapEffect;
public SwapChainFlags Flags;
}
}
public static partial class DXGI
{
public struct SwapChainDesc1
{
public uint Width;
public uint Height;
public Format Format;
public BOOL Stereo;
public SampleDesc SampleDesc;
public Usage BufferUsage;
public uint BufferCount;
public Scaling Scaling;
public SwapEffect SwapEffect;
public AlphaMode AlphaMode;
public uint Flags;
}
}
}
namespace Xui.Runtime.Windows
{
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System;
using static Xui.Runtime.Windows.Win32.Types;
public static partial class DXGI
{
public unsafe partial class Factory2 : Factory1
{
public static new readonly Guid IID;
public static Factory2 Create();
public Factory2(void* ptr);
public SwapChain1 CreateSwapChainForComposition(DXGI.Device device, in SwapChainDesc1 desc, Output? restrictToOutput = null);
}
}
}
namespace Xui.Runtime.Windows.Actual
{
using System.Runtime.InteropServices;
using Xui.Core.Canvas;
using Xui.Core.Curves2D;
using Xui.Core.Math2D;
using static Xui.Runtime.Windows.D2D1;
public partial class Direct2DContext
{
}
}
namespace Xui.Runtime.Windows.Actual
{
using System.Runtime.CompilerServices;
using System;
using Xui.Core.Canvas.Symbols;
using Xui.Core.Canvas;
using static Xui.Runtime.Windows.D2D1;
public partial class Direct2DContext
{
public void DrawSymbol(SymbolContent content);
}
}
namespace Xui.Runtime.Windows.Actual
{
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System;
using Xui.Core.Canvas.Composition.Graphics;
using Xui.Core.Canvas.Filter;
using Xui.Core.Canvas;
using Xui.Core.Curves2D;
using Xui.Core.Math2D;
using static Xui.Runtime.Windows.D2D1;
using static Xui.Runtime.Windows.DWrite;
public partial class Direct2DContext : IContext
{
public CompositionGroup Group(scoped in GroupOptions options);
public void EndGroup();
public void SetFilter();
public void SetFilter(Brightness brightness);
public Direct2DContext(RenderTarget renderTarget, D2D1.Factory3 d2d1Factory, DWrite.Factory dWriteFactory);
public TextAlign TextAlign { get; set; }
public TextBaseline TextBaseline { get; set; }
public void Dispose();
public void BeginDraw();
public void EndDraw();
}
}
namespace Xui.Runtime.Windows.Actual
{
using System;
using Xui.Core.Canvas;
using Xui.Core.Math2D;
///
/// A lightweight implementation backed by DirectWrite.
/// Unlike , this does not require a RenderTarget —
/// only a — making it suitable for use outside render passes
/// (e.g., during pointer event hit-testing for text selection).
///
public class DirectWriteContext : ITextMeasureContext
{
public DirectWriteContext(DWrite.Factory dwriteFactory);
}
}
namespace Xui.Runtime.Windows.Actual
{
using System;
using Xui.Core.Abstract.Events;
using Xui.Core.Debug;
using Xui.Core.Math2D;
using Xui.Runtime.Windows.Win32;
using static Xui.Runtime.Windows.D2D1;
using static Xui.Runtime.Windows.DXGI;
using static Xui.Runtime.Windows.Win32.User32.Types;
using static Xui.Runtime.Windows.Win32.User32;
public sealed class DirectXContext
{
///
/// IDXGISwapChain2::GetFrameLatencyWaitableObject() handle.
///
public nint FrameLatencyHandle { get; }
///
/// Initializes the swapchain + D2D target + DComp visual tree.
/// Must not be done in WM_PAINT (we validate there only).
///
public void EnsureInitialized(HWND hWnd);
public void ResizeBuffers(HWND hWnd, uint physicalW, uint physicalH);
public void Render();
}
}
namespace Xui.Runtime.Windows.Actual
{
using System.Collections.Generic;
using System;
using Xui.Core.Actual;
using Xui.Core.Canvas;
public class Win32Platform : IRuntime
{
public Win32Platform();
public IDispatcher MainDispatcher { get; }
public IRunLoop CreateRunloop(Xui.Core.Abstract.Application applicationAbstract);
public Xui.Core.Actual.IWindow CreateWindow(Xui.Core.Abstract.IWindow windowAbstract, IServiceProvider applicationServices);
}
}
namespace Xui.Runtime.Windows.Actual
{
using System.Collections.Concurrent;
using System.Threading;
using System;
using Xui.Core.Abstract.Events;
using Xui.Core.Debug;
using static Xui.Runtime.Windows.Win32.User32;
public class Win32RunLoop : Xui.Core.Actual.IRunLoop, Xui.Core.Actual.IDispatcher
{
public const uint PM_REMOVE = 0x0001;
protected Win32Platform Platform { get; }
protected Xui.Core.Abstract.Application Application { get; }
public Win32RunLoop(Win32Platform platform, Xui.Core.Abstract.Application application);
public void Post(Action callback);
public int Run();
public void Quit();
}
}
namespace Xui.Runtime.Windows.Actual
{
using System.Diagnostics;
using System.Threading;
using System;
public class Win32SynchronizationContext : SynchronizationContext
{
public Win32SynchronizationContext(Win32RunLoop win32RunLoop);
public override void OperationStarted();
public override void OperationCompleted();
public override void Post(SendOrPostCallback d, object? state);
public override void Send(SendOrPostCallback d, object? state);
public override int Wait(nint[] waitHandles, bool waitAll, int millisecondsTimeout);
public override System.Threading.SynchronizationContext CreateCopy();
}
}
namespace Xui.Runtime.Windows.Actual
{
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System;
using Xui.Core.Abstract.Events;
using Xui.Core.Canvas;
using Xui.Core.DI;
using Xui.Core.Debug;
using Xui.Core.Math2D;
using Xui.Core.UI;
using Xui.Runtime.Windows.Win32;
using static Xui.Core.Abstract.IWindow.IDesktopStyle;
using static Xui.Runtime.Windows.Win32.Types;
using static Xui.Runtime.Windows.Win32.User32.Types;
using static Xui.Runtime.Windows.Win32.User32;
public partial class Win32Window : Xui.Core.Actual.IWindow, IDirectXHost
{
public const uint WM_ANIMATION_FRAME_MSG = 0x0401;
public bool NeedsFrame { get; }
public nint CompositionFrameHandle { get; }
public Win32Window(Win32Platform platform, Xui.Core.Abstract.IWindow @abstract, IServiceProvider nextServiceProvider);
public HWND Hwnd { get; }
public Xui.Core.Abstract.IWindow Abstract { get; }
public DirectXContext Renderer { get; }
public string Title { get; set; }
public bool RequireKeyboard { get; set; }
public ITextMeasureContext? TextMeasureContext { get; }
public IServiceProvider NextServiceProvider { get; }
public object? GetService(Type serviceType);
public int OnMessage(HWND hWnd, WindowMessage uMsg, WPARAM wParam, LPARAM lParam);
protected virtual void OnScrollWheel(ScrollWheelEventRef scrollWheelEventRef);
public void Show();
public void Close();
public virtual void Invalidate();
public void OnAnimationFrame(ref FrameEventRef @event);
public void Render();
public static float PrimaryMonitorDPIScale { get; }
}
}
namespace Xui.Runtime.Windows.Win32
{
using System.Runtime.InteropServices;
using static Xui.Runtime.Windows.Win32.Types;
public static partial class Dwmapi
{
public const string DwmapiLib = "dwmapi.dll";
public const uint DWMWA_CAPTION_COLOR = 35;
public const uint DWMWA_TEXT_COLOR = 36;
public const uint DWMWA_SYSTEMBACKDROP_TYPE = 38;
/// COLORREF value that indicates "no color" / transparent for DWM attributes.
public const int DWMWA_COLOR_NONE = unchecked((int)0xFFFFFFFE);
/// Mica backdrop (Windows 11 22H2+).
public const int DWMSBT_MAINWINDOW = 2;
/// Acrylic backdrop (Windows 11 22H2+).
public const int DWMSBT_TRANSIENTWINDOW = 3;
/// Mica Alt / Tabbed backdrop (Windows 11 22H2+).
public const int DWMSBT_TABBEDWINDOW = 4;
[StructLayout(LayoutKind.Sequential)]
public struct MARGINS
{
public int Left;
public int Right;
public int Top;
public int Bottom;
}
[LibraryImport(DwmapiLib)]
public static partial int DwmExtendFrameIntoClientArea(nint hwnd, ref MARGINS pMarInset);
[LibraryImport(DwmapiLib)]
public static partial int DwmSetWindowAttribute(nint hwnd, uint dwAttribute, ref int pvAttribute, int cbAttribute);
[LibraryImport(DwmapiLib)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool DwmDefWindowProc(nint hwnd, User32.WindowMessage msg, WPARAM wParam, LPARAM lParam, out LRESULT plResult);
[DllImport("dwmapi.dll")]
public static extern int DwmFlush();
}
public static partial class User32
{
/// https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-msg
[StructLayout(LayoutKind.Sequential)]
public struct MSG
{
public nint hWnd;
public WindowMessage message;
public WPARAM wParam;
public LPARAM lParam;
public DWORD time;
public POINT pt;
public DWORD lPrivate;
}
}
}
namespace Xui.Runtime.Windows.Win32
{
public static unsafe partial class Dwmapi
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial int DwmExtendFrameIntoClientArea(nint hwnd, ref global::Xui.Runtime.Windows.Win32.Dwmapi.MARGINS pMarInset);
}
public static unsafe partial class Dwmapi
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial int DwmSetWindowAttribute(nint hwnd, uint dwAttribute, ref int pvAttribute, int cbAttribute);
}
public static unsafe partial class Dwmapi
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial bool DwmDefWindowProc(nint hwnd, global::Xui.Runtime.Windows.Win32.User32.WindowMessage msg, global::Xui.Runtime.Windows.Win32.Types.WPARAM wParam, global::Xui.Runtime.Windows.Win32.Types.LPARAM lParam, out global::Xui.Runtime.Windows.Win32.Types.LRESULT plResult);
}
public static unsafe partial class Kernel32
{
[global::System.Runtime.InteropServices.DllImportAttribute("kernel32.dll", EntryPoint = "GetCurrentThreadId", ExactSpelling = true)]
public static extern partial uint GetCurrentThreadId();
}
public static partial class Types
{
public partial struct COLORREF
{
public uint __BBGGRR;
public COLORREF(uint v);
}
}
public static unsafe partial class Types
{
public unsafe partial struct HDC
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial global::Xui.Runtime.Windows.Win32.Types.BOOL HDCFillRect(nint hDC, ref global::Xui.Runtime.Windows.Win32.User32.RECT lprc, nint hbr);
}
}
public static unsafe partial class Types
{
public unsafe partial struct HDC
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial global::Xui.Runtime.Windows.Win32.Types.BOOL HDCFrameRect(nint hDC, ref global::Xui.Runtime.Windows.Win32.User32.RECT lprc, nint hbr);
}
}
public partial class User32
{
public enum HitTest : int
{
HTERROR = -2,
HTTRANSPARENT = -1,
HTNOWHERE = 0,
HTCLIENT = 1,
HTCAPTION = 2,
HTSYSMENU = 3,
HTGROWBOX = 4,
HTSIZE = HTGROWBOX,
HTMENU = 5,
HTHSCROLL = 6,
HTVSCROLL = 7,
HTMINBUTTON = 8,
HTMAXBUTTON = 9,
HTLEFT = 10,
HTRIGHT = 11,
HTTOP = 12,
HTTOPLEFT = 13,
HTTOPRIGHT = 14,
HTBOTTOM = 15,
HTBOTTOMLEFT = 16,
HTBOTTOMRIGHT = 17,
HTBORDER = 18,
HTREDUCE = HTMINBUTTON,
HTZOOM = HTMAXBUTTON,
HTSIZEFIRST = HTLEFT,
HTSIZELAST = HTBOTTOMRIGHT,
HTOBJECT = 19,
HTCLOSE = 20,
HTHELP = 21,
}
}
public static partial class User32
{
public unsafe struct NCCALCSIZE_PARAMS
{
public RECT r1;
public RECT r2;
public RECT r3;
public WINDOWPOS* lppos;
}
}
public static partial class User32
{
public enum SystemCursor : int
{
/// Standard arrow cursor (IDC_ARROW)
Arrow = 32512,
/// I-beam text cursor (IDC_IBEAM)
IBeam = 32513,
/// Hourglass / wait (legacy) (IDC_WAIT)
Wait = 32514,
/// Crosshair (IDC_CROSS)
Cross = 32515,
/// Up arrow (rarely used) (IDC_UPARROW)
UpArrow = 32516,
/// Resize NW-SE / diagonal (IDC_SIZENWSE)
SizeNWSE = 32642,
/// Resize NE-SW / diagonal (IDC_SIZENESW)
SizeNESW = 32643,
/// Resize horizontal (IDC_SIZEWE)
SizeWE = 32644,
/// Resize vertical (IDC_SIZENS)
SizeNS = 32645,
/// Resize all directions (IDC_SIZEALL)
SizeAll = 32646,
/// Slashed circle (not allowed) (IDC_NO)
No = 32648,
/// Hand / link cursor (IDC_HAND)
Hand = 32649,
/// Application starting (arrow + wait) (IDC_APPSTARTING)
AppStarting = 32650,
/// Help cursor (arrow + question) (IDC_HELP)
Help = 32651,
}
}
public static partial class User32
{
/// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsyscolor#parameters
public enum WindowColor : int
{
COLOR_WINDOW = 5,
COLOR_3DFACE = 15
}
}
public static partial class User32
{
/// https://learn.microsoft.com/en-us/windows/win32/winmsg/about-messages-and-message-queues#system-defined-messages
public enum WindowMessage : uint
{
WM_NULL = 0x0000,
WM_CREATE = 0x0001,
WM_DESTROY = 0x0002,
WM_MOVE = 0x0003,
WM_SIZE = 0x0005,
WM_ERASEBKGND = 0x0014,
WM_SETCURSOR = 0x0020,
WM_ACTIVATEAPP = 0x001C,
WM_CANCELMODE = 0x001F,
WM_CHILDACTIVATE = 0x0022,
WM_CLOSE = 0x0010,
WM_COMPACTING = 0x0041,
WM_ENABLE = 0x000A,
WM_ENTERSIZEMOVE = 0x0231,
WM_EXITSIZEMOVE = 0x0232,
WM_GETICON = 0x007F,
WM_GETMINMAXINFO = 0x0024,
WM_INPUTLANGCHANGE = 0x0051,
WM_INPUTLANGCHANGEREQUEST = 0x0050,
WM_MOVING = 0x0216,
WM_NCACTIVATE = 0x0086,
WM_NCCALCSIZE = 0x0083,
WM_NCCREATE = 0x0081,
WM_NCDESTROY = 0x0082,
WM_QUERYDRAGICON = 0x0037,
WM_QUERYOPEN = 0x0013,
WM_QUIT = 0x0012,
WM_SHOWWINDOW = 0x0018,
WM_SIZING = 0x0214,
WM_STYLECHANGED = 0x007D,
WM_STYLECHANGING = 0x007C,
WM_THEMECHANGED = 0x031A,
WM_USERCHANGED = 0x0054,
WM_WINDOWPOSCHANGED = 0x0047,
WM_WINDOWPOSCHANGING = 0x0046,
WM_CAPTURECHANGED = 0x0215,
WM_LBUTTONDBLCLK = 0x0203,
WM_LBUTTONDOWN = 0x0201,
WM_LBUTTONUP = 0x0202,
WM_MBUTTONDBLCLK = 0x0209,
WM_MBUTTONDOWN = 0x0207,
WM_MBUTTONUP = 0x0208,
WM_MOUSEACTIVATE = 0x0021,
WM_MOUSEHOVER = 0x02A1,
WM_MOUSEHWHEEL = 0x020E,
WM_MOUSELEAVE = 0x02A3,
WM_MOUSEMOVE = 0x0200,
WM_MOUSEWHEEL = 0x020A,
WM_NCHITTEST = 0x0084,
WM_NCLBUTTONDBLCLK = 0x00A3,
WM_NCLBUTTONDOWN = 0x00A1,
WM_NCLBUTTONUP = 0x00A2,
WM_NCMBUTTONDBLCLK = 0x00A9,
WM_NCMBUTTONDOWN = 0x00A7,
WM_NCMBUTTONUP = 0x00A8,
WM_NCMOUSEHOVER = 0x02A0,
WM_NCMOUSELEAVE = 0x02A2,
WM_NCMOUSEMOVE = 0x00A0,
WM_NCRBUTTONDBLCLK = 0x00A6,
WM_NCRBUTTONDOWN = 0x00A4,
WM_NCRBUTTONUP = 0x00A5,
WM_NCXBUTTONDBLCLK = 0x00AD,
WM_NCXBUTTONDOWN = 0x00AB,
WM_NCXBUTTONUP = 0x00AC,
WM_RBUTTONDBLCLK = 0x0206,
WM_RBUTTONDOWN = 0x0204,
WM_RBUTTONUP = 0x0205,
WM_XBUTTONDBLCLK = 0x020D,
WM_XBUTTONDOWN = 0x020B,
WM_XBUTTONUP = 0x020C,
WM_ACTIVATE = 0x0006,
WM_APPCOMMAND = 0x0319,
WM_CHAR = 0x0102,
WM_DEADCHAR = 0x0103,
WM_HOTKEY = 0x0312,
WM_KEYDOWN = 0x0100,
WM_KEYUP = 0x0101,
WM_KILLFOCUS = 0x0008,
WM_SETFOCUS = 0x0007,
WM_SYSDEADCHAR = 0x0107,
WM_SYSKEYDOWN = 0x0104,
WM_SYSKEYUP = 0x0105,
WM_UNICHAR = 0x0109,
WM_DISPLAYCHANGE = 0x7E,
WM_NCPAINT = 0x85,
WM_PAINT = 0xF,
WM_PRINT = 0x317,
WM_PRINTCLIENT = 0x318,
WM_SETREDRAW = 0xB,
WM_SYNCPAINT = 0x88,
WM_INITMENUPOPUP = 0x0117,
WM_MENUCHAR = 0x0120,
WM_MENUSELECT = 0x011F,
WM_SYSCHAR = 0x0106,
WM_SYSCOMMAND = 0x0112,
WM_TIMER = 0x0113,
WM_DPICHANGED = 0x02E0,
WM_SETICON = 0x0080,
}
}
public static unsafe partial class User32
{
public static unsafe partial class Types
{
public unsafe partial struct HWND
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial bool ShowWindow(global::Xui.Runtime.Windows.Win32.User32.Types.HWND hWnd, int nCmdShow);
}
}
}
public static unsafe partial class User32
{
public static unsafe partial class Types
{
public unsafe partial struct HWND
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial bool UpdateWindow(global::Xui.Runtime.Windows.Win32.User32.Types.HWND hWnd);
}
}
}
public static unsafe partial class User32
{
public static unsafe partial class Types
{
public unsafe partial struct HWND
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial bool SetWindowText(global::Xui.Runtime.Windows.Win32.User32.Types.HWND hWnd, string lpString);
}
}
}
public static unsafe partial class User32
{
public static unsafe partial class Types
{
public unsafe partial struct HWND
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial int GetWindowText(global::Xui.Runtime.Windows.Win32.User32.Types.HWND hWnd, out string lpString, int maxLength);
}
}
}
public static unsafe partial class User32
{
public static unsafe partial class Types
{
public unsafe partial struct HWND
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial bool SetWindowPos(global::Xui.Runtime.Windows.Win32.User32.Types.HWND hWnd, global::Xui.Runtime.Windows.Win32.User32.Types.HWND hWndInsertAfter, int X, int Y, int cx, int cy, global::Xui.Runtime.Windows.Win32.User32.Types.SetWindowPosFlags uFlags);
}
}
}
public static unsafe partial class User32
{
public static unsafe partial class Types
{
public unsafe partial struct HWND
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial bool GetClientRect(global::Xui.Runtime.Windows.Win32.User32.Types.HWND hWnd, out global::Xui.Runtime.Windows.Win32.User32.RECT rc);
}
}
}
public static unsafe partial class User32
{
public static unsafe partial class Types
{
public unsafe partial struct HWND
{
[global::System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint = "DefWindowProcW", ExactSpelling = true)]
public static extern partial global::Xui.Runtime.Windows.Win32.Types.LRESULT DefWindowProc(global::Xui.Runtime.Windows.Win32.User32.Types.HWND hWnd, global::Xui.Runtime.Windows.Win32.User32.WindowMessage uMsg, global::Xui.Runtime.Windows.Win32.Types.WPARAM wParam, global::Xui.Runtime.Windows.Win32.Types.LPARAM lParam);
}
}
}
public static unsafe partial class User32
{
public static unsafe partial class Types
{
public unsafe partial struct HWND
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial bool InvalidateRect(global::Xui.Runtime.Windows.Win32.User32.Types.HWND hWnd, ref global::Xui.Runtime.Windows.Win32.User32.RECT rect, bool erase);
}
}
}
public static unsafe partial class User32
{
public static unsafe partial class Types
{
public unsafe partial struct HWND
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial bool InvalidateRect(global::Xui.Runtime.Windows.Win32.User32.Types.HWND hWnd, nint rectPtr, bool erase);
}
}
}
public static unsafe partial class User32
{
public static unsafe partial class Types
{
public unsafe partial struct HWND
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial global::Xui.Runtime.Windows.Win32.Types.HDC BeginPaint(global::Xui.Runtime.Windows.Win32.User32.Types.HWND hWnd, ref global::Xui.Runtime.Windows.Win32.User32.PAINTSTRUCT lpPaint);
}
}
}
public static unsafe partial class User32
{
public static unsafe partial class Types
{
public unsafe partial struct HWND
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial global::Xui.Runtime.Windows.Win32.Types.BOOL EndPaint(global::Xui.Runtime.Windows.Win32.User32.Types.HWND hWnd, ref global::Xui.Runtime.Windows.Win32.User32.PAINTSTRUCT lpPaint);
}
}
}
public static unsafe partial class User32
{
public static unsafe partial class Types
{
public unsafe partial struct HWND
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial global::Xui.Runtime.Windows.Win32.Types.BOOL ScreenToClient(global::Xui.Runtime.Windows.Win32.User32.Types.HWND hWnd, ref global::Xui.Runtime.Windows.Win32.User32.POINT lpPoint);
}
}
}
public static unsafe partial class User32
{
public static unsafe partial class Types
{
public unsafe partial struct HWND
{
[global::System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint = "GetDpiForWindow", ExactSpelling = true)]
public static extern partial uint GetDpiForWindow(global::Xui.Runtime.Windows.Win32.User32.Types.HWND hwnd);
}
}
}
public static unsafe partial class User32
{
public static unsafe partial class Types
{
public unsafe partial struct HWND
{
[global::System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint = "SetCapture", ExactSpelling = true)]
public static extern partial global::Xui.Runtime.Windows.Win32.User32.Types.HWND SetCapture(global::Xui.Runtime.Windows.Win32.User32.Types.HWND hWnd);
}
}
}
public static unsafe partial class User32
{
public static unsafe partial class Types
{
public unsafe partial struct HWND
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial bool ReleaseCapture();
}
}
}
public static unsafe partial class User32
{
public static unsafe partial class Types
{
public unsafe partial struct HWND
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial bool GetWindowRect(global::Xui.Runtime.Windows.Win32.User32.Types.HWND hWnd, out global::Xui.Runtime.Windows.Win32.User32.RECT lpRect);
}
}
}
public static unsafe partial class User32
{
public static unsafe partial class Types
{
public unsafe partial struct HWND
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial bool IsZoomed(global::Xui.Runtime.Windows.Win32.User32.Types.HWND hWnd);
}
}
}
public static unsafe partial class User32
{
[global::System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint = "GetSysColorBrush", ExactSpelling = true)]
public static extern partial nint GetSysColorBrush(int nIndex);
}
public static unsafe partial class User32
{
[global::System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint = "RegisterClassExW", ExactSpelling = true)]
public static extern partial ushort RegisterClassEx(global::Xui.Runtime.Windows.Win32.User32.WNDCLASSEXW p);
}
public static unsafe partial class User32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial nint CreateWindowEx(uint dwExStyle, ushort atom, string lpWindowName, uint dwStyle, int X, int Y, int nWidth, int nHeight, global::Xui.Runtime.Windows.Win32.User32.Types.HWND hWndParent, nint hMenu, nint hInstance, nint lpParam);
}
public static unsafe partial class User32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial bool SetProcessDpiAwarenessContext(nint dpiContext);
}
public static unsafe partial class User32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial int TranslateMessage(ref global::Xui.Runtime.Windows.Win32.User32.MSG msg);
}
public static unsafe partial class User32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial nint DispatchMessage(ref global::Xui.Runtime.Windows.Win32.User32.MSG msg);
}
public static unsafe partial class User32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial bool GetMessage(ref global::Xui.Runtime.Windows.Win32.User32.MSG msg, global::Xui.Runtime.Windows.Win32.User32.Types.HWND hWnd, uint wMsgFilterMin, uint wMsgFilterMax);
}
public static unsafe partial class User32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial bool PeekMessage(ref global::Xui.Runtime.Windows.Win32.User32.MSG msg, global::Xui.Runtime.Windows.Win32.User32.Types.HWND hWnd, uint wMsgFilterMin, uint wMsgFilterMax, uint wRemoveMsg);
}
public static unsafe partial class User32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial bool PostMessage(global::Xui.Runtime.Windows.Win32.User32.Types.HWND hWnd, global::Xui.Runtime.Windows.Win32.User32.WindowMessage Msg, global::Xui.Runtime.Windows.Win32.Types.WPARAM wParam, global::Xui.Runtime.Windows.Win32.Types.LPARAM lParam);
}
public static unsafe partial class User32
{
[global::System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint = "SetTimer", ExactSpelling = true)]
public static extern partial nuint SetTimer(global::Xui.Runtime.Windows.Win32.User32.Types.HWND hWnd, nuint nIDEvent, uint uElapse, nint lpTimerFunc);
}
public static unsafe partial class User32
{
[global::System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint = "SendMessageW", ExactSpelling = true)]
public static extern partial nint SendMessage(global::Xui.Runtime.Windows.Win32.User32.Types.HWND hWnd, uint Msg, nuint wParam, nint lParam);
}
public static unsafe partial class User32
{
[global::System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint = "SetLayeredWindowAttributes", ExactSpelling = true)]
public static unsafe extern partial global::Xui.Runtime.Windows.Win32.Types.BOOL SetLayeredWindowAttributes(global::Xui.Runtime.Windows.Win32.User32.Types.HWND hWnd, global::Xui.Runtime.Windows.Win32.Types.COLORREF crKey, byte bAlpha, global::Xui.Runtime.Windows.Win32.User32.LayeredWindowAttribute dwFlags);
}
public static unsafe partial class User32
{
[global::System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint = "GetDpiForSystem", ExactSpelling = true)]
public static extern partial uint GetDpiForSystem();
}
public static unsafe partial class User32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial nint LoadCursor(nint hInstance, int lpCursorName);
}
public static unsafe partial class User32
{
[global::System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint = "SetCursor", ExactSpelling = true)]
public static extern partial nint SetCursor(nint hCursor);
}
public static unsafe partial class User32
{
[global::System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint = "GetKeyState", ExactSpelling = true)]
public static extern partial short GetKeyState(int nVirtKey);
}
public static unsafe partial class User32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial bool PostThreadMessage(uint idThread, uint Msg, nuint wParam, nint lParam);
}
public static unsafe partial class User32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial uint MsgWaitForMultipleObjectsEx(uint nCount, nint[] pHandles, uint dwMilliseconds, uint dwWakeMask, uint dwFlags);
}
public static unsafe partial class User32
{
[global::System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint = "GetSystemMetricsForDpi", ExactSpelling = true)]
public static extern partial int GetSystemMetricsForDpi(global::Xui.Runtime.Windows.Win32.User32.SystemMetric nIndex, uint dpi);
}
public static unsafe partial class User32
{
[global::System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint = "GetSystemMetrics", ExactSpelling = true)]
public static extern partial int GetSystemMetrics(global::Xui.Runtime.Windows.Win32.User32.SystemMetric nIndex);
}
public static unsafe partial class User32
{
[global::System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint = "PostQuitMessage", ExactSpelling = true)]
public static extern partial void PostQuitMessage(int nExitCode);
}
public static unsafe partial class User32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial bool DestroyWindow(global::Xui.Runtime.Windows.Win32.User32.Types.HWND hWnd);
}
public static unsafe partial class User32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial bool ClientToScreen(global::Xui.Runtime.Windows.Win32.User32.Types.HWND hWnd, ref global::Xui.Runtime.Windows.Win32.User32.POINT lpPoint);
}
public static unsafe partial class User32
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Interop.LibraryImportGenerator", "10.0.15.3008")]
[global::System.Runtime.CompilerServices.SkipLocalsInitAttribute]
public static partial bool GetCursorPos(out global::Xui.Runtime.Windows.Win32.User32.POINT lpPoint);
}
}
namespace Xui.Runtime.Windows.Win32
{
using System.Runtime.InteropServices;
public static partial class Kernel32
{
public const string Kernel32Lib = "kernel32.dll";
/// https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getcurrentthreadid
[LibraryImport(Kernel32Lib)]
public static partial uint GetCurrentThreadId();
}
public static partial class User32
{
[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
public int X;
public int Y;
}
}
public static partial class User32
{
public enum SystemMetric : int
{
SM_CYCAPTION = 4,
SM_CXSIZE = 30,
SM_CYSIZE = 31,
SM_CXSIZEFRAME = 32,
SM_CYSIZEFRAME = 33,
SM_CXPADDEDBORDER = 92,
}
}
public static partial class User32
{
[StructLayout(LayoutKind.Sequential)]
public struct WINDOWPOS
{
public nint hwnd;
public nint hwndInsertAfter;
public int x;
public int y;
public int cx;
public int cy;
public uint flags;
}
}
public static partial class User32
{
///
/// https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-wndclassexa
///
[StructLayout(LayoutKind.Sequential)]
public struct WNDCLASSEXW
{
public uint cbSize;
public WindowClassStyles styles;
public nint lpfnWndProc;
public int cbClsExtra;
public int cbWndExtra;
public nint hInstance;
public nint hIcon;
public nint hCursor;
public nint hbrBackground;
public nint lpszMenuName;
public nint lpszClassName;
public nint hIconSm;
}
}
}
namespace Xui.Runtime.Windows.Win32
{
using System.Diagnostics;
public static partial class Types
{
[DebuggerDisplay("{Value}")]
public struct BOOL
{
public int value;
public BOOL(bool v);
public bool Value { get; }
public static implicit operator bool (BOOL v);
public static implicit operator BOOL(bool v);
}
}
public static partial class Types
{
[DebuggerDisplay("{Value}")]
public struct HRESULT
{
public int value;
public HRESULT(int value);
public int Value { get; }
public bool Failed { get; }
public bool Succeeded { get; }
public static implicit operator bool (HRESULT res);
public static implicit operator int (HRESULT res);
}
}
}
namespace Xui.Runtime.Windows.Win32
{
using System.Diagnostics;
using System.Runtime.CompilerServices;
public static partial class Types
{
[DebuggerDisplay("{Value}")]
public struct DWORD
{
public uint value;
public DWORD(uint value);
public uint Value { get; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator uint (DWORD v);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator DWORD(uint v);
}
}
public static partial class Types
{
[DebuggerDisplay("{Value}")]
public struct LRESULT
{
public int value;
public LRESULT(int value);
public int Value { get; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator int (LRESULT v);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator LRESULT(int v);
}
}
}
namespace Xui.Runtime.Windows.Win32
{
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Xui.Core.Math2D;
using static Xui.Runtime.Windows.Win32.User32;
public static partial class Types
{
[DebuggerDisplay("{Value}")]
public partial struct HDC
{
[LibraryImport(User32Lib, EntryPoint = "FillRect")]
public static partial BOOL HDCFillRect(nint hDC, ref RECT lprc, nint hbr);
[LibraryImport(User32Lib, EntryPoint = "FrameRect")]
public static partial BOOL HDCFrameRect(nint hDC, ref RECT lprc, nint hbr);
public nint value;
public HDC(nint value);
public bool FillRect(Rect rect, nint brush);
public bool FrameRect(Rect rect, nint brush);
public nint Value { get; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator nint(HDC v);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator HDC(nint v);
}
}
}
namespace Xui.Runtime.Windows.Win32
{
using System.Diagnostics;
using System.Runtime.CompilerServices;
using Xui.Core.Math2D;
public static partial class Types
{
[DebuggerDisplay("{Value}")]
public struct LPARAM
{
public ulong value;
public LPARAM(ulong value);
public ulong Value { get; }
public short LoWord { get; }
public short HiWord { get; }
public Point MousePosition { get; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator ulong (LPARAM v);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator LPARAM(ulong v);
}
}
public static partial class Types
{
[DebuggerDisplay("{Value}")]
public struct WPARAM
{
public ulong value;
public WPARAM(ulong value);
public ulong Value { get; }
public short HiWord { get; }
public short LoWord { get; }
public Vector WheelDelta { get; }
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator ulong (WPARAM v);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator WPARAM(ulong v);
}
}
}
namespace Xui.Runtime.Windows.Win32
{
using System;
public static partial class User32
{
[Flags]
public enum DPIAwarenessContext : long
{
DPI_AWARENESS_CONTEXT_UNAWARE = -1,
DPI_AWARENESS_CONTEXT_SYSTEM_AWARE = -2,
DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE = -3,
DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 = -4,
DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED = -5
}
}
public static partial class User32
{
///
/// https://learn.microsoft.com/en-us/windows/win32/winmsg/extended-window-styles
///
[Flags]
public enum ExtendedWindowStyles : long
{
WS_EX_ACCEPTFILES = 0x00000010L,
WS_EX_APPWINDOW = 0x00040000L,
WS_EX_CLIENTEDGE = 0x00000200L,
WS_EX_COMPOSITED = 0x02000000L,
WS_EX_CONTEXTHELP = 0x00000400L,
WS_EX_CONTROLPARENT = 0x00010000L,
WS_EX_DLGMODALFRAME = 0x00000001L,
WS_EX_LAYERED = 0x00080000,
WS_EX_LAYOUTRTL = 0x00400000L,
WS_EX_LEFT = 0x00000000L,
WS_EX_LEFTSCROLLBAR = 0x00004000L,
WS_EX_LTRREADING = 0x00000000L,
WS_EX_MDICHILD = 0x00000040L,
WS_EX_NOACTIVATE = 0x08000000L,
WS_EX_NOINHERITLAYOUT = 0x00100000L,
WS_EX_NOPARENTNOTIFY = 0x00000004L,
WS_EX_NOREDIRECTIONBITMAP = 0x00200000L,
WS_EX_OVERLAPPEDWINDOW = (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE),
WS_EX_PALETTEWINDOW = (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST),
WS_EX_RIGHT = 0x00001000L,
WS_EX_RIGHTSCROLLBAR = 0x00000000L,
WS_EX_RTLREADING = 0x00002000L,
WS_EX_STATICEDGE = 0x00020000L,
WS_EX_TOOLWINDOW = 0x00000080L,
WS_EX_TOPMOST = 0x00000008L,
WS_EX_TRANSPARENT = 0x00000020L,
WS_EX_WINDOWEDGE = 0x00000100L,
}
}
public static partial class User32
{
[Flags]
public enum LayeredWindowAttribute : long
{
LWA_COLORKEY = 0x00000001,
LWA_ALPHA = 0x00000002,
}
}
public static partial class User32
{
public static partial class Types
{
[Flags]
public enum SetWindowPosFlags : uint
{
SWP_NOSIZE = 0x0001,
SWP_NOMOVE = 0x0002,
SWP_NOZORDER = 0x0004,
SWP_NOREDRAW = 0x0008,
SWP_NOACTIVATE = 0x0010,
SWP_FRAMECHANGED = 0x0020,
SWP_SHOWWINDOW = 0x0040,
SWP_HIDEWINDOW = 0x0080,
SWP_NOCOPYBITS = 0x0100,
SWP_NOOWNERZORDER = 0x0200,
SWP_NOSENDCHANGING = 0x0400,
SWP_DEFERERASE = 0x2000,
SWP_ASYNCWINDOWPOS = 0x4000
}
}
}
public static partial class User32
{
[Flags]
public enum TrackMouseEventFlags : uint
{
TME_HOVER = 0x00000001,
TME_LEAVE = 0x00000002,
TME_CANCEL = 0x80000000
}
}
public static partial class User32
{
///
/// https://learn.microsoft.com/en-us/windows/win32/winmsg/window-class-styles#constants
///
[Flags]
public enum WindowClassStyles : uint
{
CS_BYTEALIGNCLIENT = 0x1000,
CS_BYTEALIGNWINDOW = 0x2000,
CS_CLASSDC = 0x0040,
CS_DBLCLKS = 0x0008,
CS_DROPSHADOW = 0x00020000,
CS_GLOBALCLASS = 0x4000,
CS_HREDRAW = 0x0002,
CS_NOCLOSE = 0x0200,
CS_OWNDC = 0x0020,
CS_PARENTDC = 0x0080,
CS_SAVEBITS = 0x0800,
CS_VREDRAW = 0x0001,
}
}
public static partial class User32
{
///
/// https://learn.microsoft.com/en-us/windows/win32/winmsg/window-class-styles#constants
///
[Flags]
public enum WindowStyles : long
{
WS_BORDER = 0x00800000L,
WS_CAPTION = 0x00C00000L,
WS_CHILD = 0x40000000L,
WS_CHILDWINDOW = 0x40000000L,
WS_CLIPCHILDREN = 0x02000000L,
WS_CLIPSIBLINGS = 0x04000000L,
WS_DISABLED = 0x08000000L,
WS_DLGFRAME = 0x00400000L,
WS_GROUP = 0x00020000L,
WS_HSCROLL = 0x00100000L,
WS_ICONIC = 0x20000000L,
WS_MAXIMIZE = 0x01000000L,
WS_MAXIMIZEBOX = 0x00010000L,
WS_MINIMIZE = 0x20000000L,
WS_MINIMIZEBOX = 0x00020000L,
WS_OVERLAPPED = 0x00000000L,
WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX),
WS_POPUP = 0x80000000L,
WS_POPUPWINDOW = (WS_POPUP | WS_BORDER | WS_SYSMENU),
WS_SIZEBOX = 0x00040000L,
WS_SYSMENU = 0x00080000L,
WS_TABSTOP = 0x00010000L,
WS_THICKFRAME = 0x00040000L,
WS_TILED = 0x00000000L,
WS_TILEDWINDOW = (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX),
WS_VISIBLE = 0x10000000L,
WS_VSCROLL = 0x00200000L,
}
}
}
namespace Xui.Runtime.Windows.Win32
{
using System.Runtime.InteropServices;
using System;
using static Xui.Runtime.Windows.Win32.Types;
public static partial class User32
{
/// https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-paintstruct
[StructLayout(LayoutKind.Explicit, Size = 72)]
public struct PAINTSTRUCT
{
[FieldOffset(0)]
public uint hdc;
[FieldOffset(8)]
public BOOL fErase;
[FieldOffset(12)]
public RECT rcPaint;
[FieldOffset(28)]
public BOOL fRestore;
[FieldOffset(32)]
public BOOL fIncUpdate;
[FieldOffset(36)]
public UInt64 rgbReserved1, rgbReserved2, rgbReserved3, rgbReserved4;
}
}
}
namespace Xui.Runtime.Windows.Win32
{
using System.Runtime.InteropServices;
using Xui.Core.Math2D;
public static partial class User32
{
[StructLayout(LayoutKind.Explicit)]
public struct RECT
{
[FieldOffset(0)]
public int Left;
[FieldOffset(4)]
public int Top;
[FieldOffset(8)]
public int Right;
[FieldOffset(12)]
public int Bottom;
public RECT(Rect rect);
}
}
}
namespace Xui.Runtime.Windows.Win32
{
using System.Runtime.InteropServices;
using System;
using static Xui.Runtime.Windows.Win32.Types;
using static Xui.Runtime.Windows.Win32.User32.Types;
public static partial class User32
{
///
/// https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-trackmouseevent
///
[StructLayout(LayoutKind.Explicit, Size = 24)]
public struct TRACKMOUSEEVENT
{
[FieldOffset(0)]
public uint cbSize;
[FieldOffset(4)]
public TrackMouseEventFlags dwFlags;
[FieldOffset(8)]
public HWND hwndTrack;
[FieldOffset(16)]
public uint dwHoverTime;
}
}
public static partial class User32
{
public const string User32Lib = "user32.dll";
public static readonly nint Lib;
[LibraryImport(User32Lib)]
public static partial nint GetSysColorBrush(int nIndex);
///
/// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-registerclassexw
///
[LibraryImport(User32Lib, EntryPoint = "RegisterClassExW")]
public static partial ushort RegisterClassEx(WNDCLASSEXW p);
[LibraryImport(User32Lib, EntryPoint = "CreateWindowExW")]
public static partial nint CreateWindowEx(uint dwExStyle, ushort atom, [MarshalAs(UnmanagedType.LPUTF8Str)] string lpWindowName, uint dwStyle, int X, int Y, int nWidth, int nHeight, HWND hWndParent, nint hMenu, nint hInstance, nint lpParam);
[LibraryImport(User32Lib)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool SetProcessDpiAwarenessContext(nint dpiContext);
/// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-translatemessage
[LibraryImport(User32Lib)]
public static partial int TranslateMessage(ref MSG msg);
/// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-dispatchmessagew
[LibraryImport(User32Lib, EntryPoint = "DispatchMessageW")]
public static partial nint DispatchMessage(ref MSG msg);
/// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-dispatchmessagew
[LibraryImport(User32Lib, EntryPoint = "GetMessageW")]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool GetMessage(ref MSG msg, HWND hWnd, uint wMsgFilterMin, uint wMsgFilterMax);
/// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-dispatchmessagew
[LibraryImport(User32Lib, EntryPoint = "PeekMessageW")]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool PeekMessage(ref MSG msg, HWND hWnd, uint wMsgFilterMin, uint wMsgFilterMax, uint wRemoveMsg);
/// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-postmessagew
[LibraryImport(User32Lib, EntryPoint = "PostMessageW")]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool PostMessage(HWND hWnd, WindowMessage Msg, WPARAM wParam, LPARAM lParam);
[LibraryImport(User32Lib)]
public static partial nuint SetTimer(HWND hWnd, nuint nIDEvent, uint uElapse, nint lpTimerFunc);
/// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendmessagew
[LibraryImport(User32Lib, EntryPoint = "SendMessageW")]
public static partial nint SendMessage(HWND hWnd, uint Msg, nuint wParam, nint lParam);
[LibraryImport(User32Lib)]
public static unsafe partial BOOL SetLayeredWindowAttributes(HWND hWnd, COLORREF crKey, byte bAlpha, LayeredWindowAttribute dwFlags);
[LibraryImport(User32Lib)]
public static partial uint GetDpiForSystem();
[DllImport(User32Lib, SetLastError = true)]
public static extern BOOL TrackMouseEvent(ref TRACKMOUSEEVENT lpEventTrack);
[LibraryImport(User32Lib, EntryPoint = "LoadCursorW", SetLastError = true)]
public static partial nint LoadCursor(nint hInstance, int lpCursorName);
[LibraryImport(User32Lib)]
public static partial nint SetCursor(nint hCursor);
[LibraryImport(User32Lib)]
public static partial short GetKeyState(int nVirtKey);
/// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-postthreadmessagew
[LibraryImport(User32Lib, EntryPoint = "PostThreadMessageW", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool PostThreadMessage(uint idThread, uint Msg, nuint wParam, nint lParam);
/// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-msgwaitformultipleobjectsex
[LibraryImport(User32Lib, SetLastError = true)]
public static partial uint MsgWaitForMultipleObjectsEx(uint nCount, nint[]? pHandles, uint dwMilliseconds, uint dwWakeMask, uint dwFlags);
[LibraryImport(User32Lib)]
public static partial int GetSystemMetricsForDpi(SystemMetric nIndex, uint dpi);
[LibraryImport(User32Lib, EntryPoint = "GetSystemMetrics")]
public static partial int GetSystemMetrics(SystemMetric nIndex);
/// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-postquitmessage
[LibraryImport(User32Lib)]
public static partial void PostQuitMessage(int nExitCode);
/// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-destroywindow
[LibraryImport(User32Lib)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool DestroyWindow(HWND hWnd);
[LibraryImport(User32Lib)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool ClientToScreen(HWND hWnd, ref POINT lpPoint);
[LibraryImport(User32Lib)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool GetCursorPos(out POINT lpPoint);
}
}
namespace Xui.Runtime.Windows.Win32
{
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System;
using static Xui.Runtime.Windows.Win32.Types;
public static partial class User32
{
public static partial class Types
{
[DebuggerDisplay("{Value}")]
public partial struct HWND : IEquatable
{
public static readonly HWND HWND_TOPMOST;
public static readonly HWND HWND_NOTOPMOST;
[LibraryImport(User32Lib)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool ShowWindow(HWND hWnd, int nCmdShow);
[LibraryImport(User32Lib)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool UpdateWindow(HWND hWnd);
[LibraryImport(User32Lib, EntryPoint = "SetWindowTextW")]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool SetWindowText(HWND hWnd, [MarshalAs(UnmanagedType.LPWStr)] string lpString);
[LibraryImport(User32Lib, EntryPoint = "GetWindowTextW")]
public static partial int GetWindowText(HWND hWnd, [MarshalAs(UnmanagedType.LPWStr)] out string lpString, int maxLength);
[LibraryImport(User32Lib, EntryPoint = "SetWindowPos")]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int X, int Y, int cx, int cy, Types.SetWindowPosFlags uFlags);
[LibraryImport(User32Lib, EntryPoint = "GetClientRect")]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool GetClientRect(HWND hWnd, out RECT rc);
[LibraryImport(User32Lib, EntryPoint = "DefWindowProcW")]
public static partial LRESULT DefWindowProc(HWND hWnd, WindowMessage uMsg, WPARAM wParam, LPARAM lParam);
[LibraryImport(User32Lib)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool InvalidateRect(HWND hWnd, ref RECT rect, [MarshalAs(UnmanagedType.Bool)] bool erase);
[LibraryImport(User32Lib)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool InvalidateRect(HWND hWnd, nint rectPtr, [MarshalAs(UnmanagedType.Bool)] bool erase);
[LibraryImport(User32Lib)]
public static partial HDC BeginPaint(HWND hWnd, ref PAINTSTRUCT lpPaint);
[LibraryImport(User32Lib)]
public static partial BOOL EndPaint(HWND hWnd, ref PAINTSTRUCT lpPaint);
[LibraryImport(User32Lib)]
public static partial BOOL ScreenToClient(HWND hWnd, ref POINT lpPoint);
[LibraryImport(User32Lib)]
public static partial uint GetDpiForWindow(HWND hwnd);
[LibraryImport(User32Lib, EntryPoint = "SetCapture")]
public static partial HWND SetCapture(HWND hWnd);
[LibraryImport(User32Lib, EntryPoint = "ReleaseCapture")]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool ReleaseCapture();
[LibraryImport(User32Lib, EntryPoint = "GetWindowRect")]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool GetWindowRect(HWND hWnd, out RECT lpRect);
[LibraryImport(User32Lib)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool IsZoomed(HWND hWnd);
public nint value;
public HWND(nint value);
public bool SetWindowText(string text);
public int GetWindowText(out string text, int maxLength);
public bool GetClientRect(out RECT rect);
public void ShowWindow(int nCmdShow = 1);
public bool UpdateWindow();
public void Invalidate();
public bool ScreenToClient(ref POINT point);
public bool GetWindowRect(out RECT rect);
public bool IsMaximized { get; }
public LRESULT DefWindowProc(WindowMessage uMsg, WPARAM wParam, LPARAM lParam);
public HDC BeginPaint(ref PAINTSTRUCT lpPaint);
public bool EndPaint(ref PAINTSTRUCT lpPaint);
public nint Value { get; }
public bool Equals(HWND other);
public override bool Equals(object? obj);
public override int GetHashCode();
public static bool operator ==(HWND left, HWND right);
public static bool operator !=(HWND left, HWND right);
///
/// Gets the DPI scale for this window.
/// 1.0 = 100% DPI (96 DPI), 2.0 = 200% DPI (192 DPI).
///
public uint DPI { get; }
public NFloat DPIScale { get; }
public HWND CaptureMouse();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator nint(HWND v);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator HWND(nint v);
}
}
}
}
namespace Xui.Runtime.Windows.Win32
{
using System.Runtime.InteropServices;
using static Xui.Runtime.Windows.Win32.Types;
using static Xui.Runtime.Windows.Win32.User32.Types;
public static partial class User32
{
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
public delegate int WNDPROC(HWND hwnd, WindowMessage uMsg, WPARAM wParam, LPARAM lParam);
}
}
namespace Xui.Runtime.Windows.Win32
{
using System.Runtime.InteropServices;
using System;
public static partial class User32
{
[Flags]
public enum WindowPosFlags : uint
{
None = 0,
NoSize = 0x0001,
NoMove = 0x0002,
NoZOrder = 0x0004,
NoRedraw = 0x0008,
NoActivate = 0x0010,
FrameChanged = 0x0020,
ShowWindow = 0x0040,
HideWindow = 0x0080,
NoCopyBits = 0x0100,
NoOwnerZOrder = 0x0200,
NoSendChanging = 0x0400,
DeferErase = 0x2000,
AsyncWindowPos = 0x4000,
}
}
}