HatchBrush
Defines a rectangular brush with a hatch style, a foreground color, and a background color. This class cannot be inherited.
using System.Runtime.CompilerServices;
using Windows.Win32;
using Windows.Win32.Graphics.Gdi;
using Windows.Win32.Graphics.GdiPlus;
namespace System.Drawing.Drawing2D
{
public sealed class HatchBrush : Brush
{
public unsafe HatchStyle HatchStyle {
get {
global::Windows.Win32.Graphics.GdiPlus.HatchStyle result = default(global::Windows.Win32.Graphics.GdiPlus.HatchStyle);
PInvokeGdiPlus.GdipGetHatchStyle((GpHatch*)base.NativeBrush, &result).ThrowIfFailed();
GC.KeepAlive(this);
return (HatchStyle)result;
}
}
public unsafe Color ForegroundColor {
get {
ARGB argb = default(ARGB);
PInvokeGdiPlus.GdipGetHatchForegroundColor((GpHatch*)base.NativeBrush, (uint*)(&argb)).ThrowIfFailed();
GC.KeepAlive(this);
return argb;
}
}
public unsafe Color BackgroundColor {
get {
ARGB argb = default(ARGB);
PInvokeGdiPlus.GdipGetHatchBackgroundColor((GpHatch*)base.NativeBrush, (uint*)(&argb)).ThrowIfFailed();
GC.KeepAlive(this);
return argb;
}
}
public HatchBrush(HatchStyle hatchstyle, Color foreColor)
: this(hatchstyle, foreColor, Color.FromArgb(-16777216))
{
}
public unsafe HatchBrush(HatchStyle hatchstyle, Color foreColor, Color backColor)
{
if ((hatchstyle < HatchStyle.Horizontal || hatchstyle > HatchStyle.SolidDiamond) ? true : false)
throw new ArgumentException(System.SR.Format(System.SR.InvalidEnumArgument, "hatchstyle", hatchstyle, "HatchStyle"), "hatchstyle");
GpHatch* nativeBrushInternal = default(GpHatch*);
PInvokeGdiPlus.GdipCreateHatchBrush((global::Windows.Win32.Graphics.GdiPlus.HatchStyle)hatchstyle, (ARGB)ref foreColor, (ARGB)ref backColor, &nativeBrushInternal).ThrowIfFailed();
SetNativeBrushInternal((GpBrush*)nativeBrushInternal);
}
internal unsafe HatchBrush(GpHatch* nativeBrush)
{
SetNativeBrushInternal((GpBrush*)nativeBrush);
}
[NullableContext(1)]
public unsafe override object Clone()
{
GpBrush* nativeBrush = default(GpBrush*);
PInvokeGdiPlus.GdipCloneBrush(base.NativeBrush, &nativeBrush).ThrowIfFailed();
GC.KeepAlive(this);
return new HatchBrush((GpHatch*)nativeBrush);
}
}
}