File: HdcDeviceContextAdapter.cs
Web Access
Project: src\src\System.Windows.Forms.Primitives\tests\TestUtilities\System.Windows.Forms.Primitives.TestUtilities.csproj (System.Windows.Forms.Primitives.TestUtilities)
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
 
using System.Drawing;
 
namespace System;
 
/// <summary>
///  Simple adapter for passing <see cref="HDC"/> as <see cref="IDeviceContext"/>. Does not manage HDC
///  lifetime.
/// </summary>
internal class HdcDeviceContextAdapter : IDeviceContext
{
    private readonly HDC _hdc;
 
    public HdcDeviceContextAdapter(HDC hdc) => _hdc = hdc;
 
    public IntPtr GetHdc() => (IntPtr)_hdc;
    public void ReleaseHdc() { }
    public void Dispose() { }
}