using System;
using System.Text;
using System.Drawing;
using System.ComponentModel;
namespace DevComponents.WinForms.Drawing
{
public class SolidFill : Fill
{
#region Constructor
///
/// Initializes a new instance of the SolidFill class.
///
///
public SolidFill(Color color)
{
_Color = color;
}
///
/// Initializes a new instance of the SolidFill class.
///
public SolidFill()
{
}
#endregion
#region Internal Implementation
///
/// Creates the brush for fill.
///
/// Bounds for the brush
/// Returns brush or null if brush cannot be created for given bounds or colors are not set. It is responsibility of caller to Dispose the brush.
public override Brush CreateBrush(Rectangle bounds)
{
if (_Color.IsEmpty) return null;
return new SolidBrush(_Color);
}
private Color _Color = Color.Empty;
///
/// Gets or sets the fill color.
///
[Description("Indicates the fill color.")]
public Color Color
{
get { return _Color; }
set { _Color = value; }
}
///
/// Gets whether property should be serialized.
///
/// true if property should be serialized
[EditorBrowsable(EditorBrowsableState.Never)]
public bool ShouldSerializeColor()
{
return !_Color.IsEmpty;
}
///
/// Sets the property to its default value.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public void ResetColor()
{
Color = Color.Empty;
}
public override Pen CreatePen(int width)
{
if (!_Color.IsEmpty)
return new Pen(_Color, width);
return null;
}
#endregion
}
}