using System.Drawing;
namespace Netron.Diagramming.Core {
// ----------------------------------------------------------------------
///
/// The solid paint style.
///
// ----------------------------------------------------------------------
public partial class SolidPaintStyle : IPaintStyle, IVersion {
// ------------------------------------------------------------------
///
/// Event raised when this paint style is changed.
///
// ------------------------------------------------------------------
public event PaintStyleChangedEventHandler PaintStyleChanged;
#region Fields
// ------------------------------------------------------------------
///
/// Implementation of IVersion - the current version of
/// SolidPaintStyle.
///
// ------------------------------------------------------------------
protected const double solidPaintStyleVersion = 1.0;
// ------------------------------------------------------------------
///
/// the SolidColor field
///
// ------------------------------------------------------------------
private Color mSolidColor;
// ------------------------------------------------------------------
///
/// the Alpha field
///
// ------------------------------------------------------------------
private int mAlpha = 255;
#endregion
#region Properties
// ------------------------------------------------------------------
///
/// Gets the current version.
///
// ------------------------------------------------------------------
public virtual double Version {
get {
return solidPaintStyleVersion;
}
}
// ------------------------------------------------------------------
///
/// Gets or sets the SolidColor
///
// ------------------------------------------------------------------
public Color SolidColor {
get {
return mSolidColor;
}
set {
mSolidColor = value;
RaisePaintStyleChanged();
}
}
// ------------------------------------------------------------------
///
/// Gets or sets the Alpha
///
// ------------------------------------------------------------------
public int Alpha {
get {
return mAlpha;
}
set {
mAlpha = value;
RaisePaintStyleChanged();
}
}
#endregion
#region Constructor
// ------------------------------------------------------------------
///
///Default constructor.
///
// ------------------------------------------------------------------
public SolidPaintStyle(Color color) {
mSolidColor = color;
}
// ------------------------------------------------------------------
///
/// Initializes a new instance of the
/// class.
///
// ------------------------------------------------------------------
public SolidPaintStyle() {
mSolidColor = ArtPalette.RandomLowSaturationColor;
}
#endregion
// ------------------------------------------------------------------
///
/// Gets the brush with which an entity can fe painted.
///
/// Rectangle: The rectangle.
/// Brush
// ------------------------------------------------------------------
public Brush GetBrush(Rectangle rectangle) {
return new SolidBrush(Color.FromArgb(mAlpha, mSolidColor));
}
// ------------------------------------------------------------------
///
/// Raises the PaintStyleChanged event.
///
// ------------------------------------------------------------------
protected virtual void RaisePaintStyleChanged() {
if (this.PaintStyleChanged != null) {
// Raise the event
this.PaintStyleChanged(
this,
new PaintStyleChangedEventArgs(this, FillType.Solid));
}
}
}
}