// "Therefore those skilled at the unorthodox
// are infinite as heaven and earth,
// inexhaustible as the great rivers.
// When they come to an end,
// they begin again,
// like the days and months;
// they die and are reborn,
// like the four seasons."
//
// - Sun Tsu,
// "The Art of War"
using System.Drawing;
using TheArtOfDev.HtmlRenderer.Adapters;
namespace TheArtOfDev.HtmlRenderer.WinForms.Adapters
{
///
/// Adapter for WinForms brushes objects for core.
///
internal sealed class BrushAdapter : RBrush
{
///
/// The actual WinForms brush instance.
///
private readonly Brush _brush;
///
/// If to dispose the brush when is called.
/// Ignore dispose for cached brushes.
///
private readonly bool _dispose;
///
/// Init.
///
public BrushAdapter(Brush brush, bool dispose)
{
_brush = brush;
_dispose = dispose;
}
///
/// The actual WinForms brush instance.
///
public Brush Brush
{
get { return _brush; }
}
public override void Dispose()
{
if (_dispose)
{
_brush.Dispose();
}
}
}
}