DotNet 4.8.1 build of DotNetBar
This commit is contained in:
1101
PROMS/DotNetBar Source Code/AnalogClock/AnalogClockControl.cs
Normal file
1101
PROMS/DotNetBar Source Code/AnalogClock/AnalogClockControl.cs
Normal file
File diff suppressed because it is too large
Load Diff
305
PROMS/DotNetBar Source Code/AnalogClock/ClockHandStyleData.cs
Normal file
305
PROMS/DotNetBar Source Code/AnalogClock/ClockHandStyleData.cs
Normal file
@@ -0,0 +1,305 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Data storage class for clock hand visual style.
|
||||
/// </summary>
|
||||
[Description("Clock Hand Style"),
|
||||
TypeConverterAttribute(typeof(ExpandableObjectConverter))]
|
||||
public class ClockHandStyleData : INotifyPropertyChanged
|
||||
{
|
||||
private bool _DrawOverCap;
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the hand is drawn over the cap.
|
||||
/// </summary>
|
||||
[DefaultValue(false),
|
||||
Category("Appearance"),
|
||||
Description("Indicates whether the hand is drawn over the cap.")]
|
||||
public bool DrawOverCap
|
||||
{
|
||||
get { return _DrawOverCap; }
|
||||
set { _DrawOverCap = value; }
|
||||
}
|
||||
|
||||
private void ColorPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
OnPropertyChanged(e);
|
||||
}
|
||||
|
||||
private ColorData _HandColor;
|
||||
/// <summary>
|
||||
/// Gets or sets the hand color data for this hand.
|
||||
/// </summary>
|
||||
[Category("Appearance"),
|
||||
Description("The hand color data for this hand.")]
|
||||
public ColorData HandColor
|
||||
{
|
||||
get { return _HandColor; }
|
||||
set
|
||||
{
|
||||
if (value != _HandColor)
|
||||
{
|
||||
if (_HandColor != null) _HandColor.PropertyChanged -= ColorPropertyChanged;
|
||||
_HandColor = value;
|
||||
if (_HandColor != null) _HandColor.PropertyChanged += ColorPropertyChanged;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("HandColor"));
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets the property to default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetHandColor()
|
||||
{
|
||||
HandColor = new ColorData(eBrushTypes.Solid, Color.FromArgb(109, 127, 138), Color.FromArgb(109, 127, 138), Color.FromArgb(128, 109, 127, 138), 0.01f);
|
||||
}
|
||||
|
||||
private eHandStyles _HandStyle;
|
||||
/// <summary>
|
||||
/// Gets or sets the hand style for this clock hand. Default value is Style1.
|
||||
/// </summary>
|
||||
[DefaultValue(eHandStyles.Style1),
|
||||
Category("Appearance"),
|
||||
Description("The hand style for this clock hand.")]
|
||||
public eHandStyles HandStyle
|
||||
{
|
||||
get { return _HandStyle; }
|
||||
set
|
||||
{
|
||||
if (value != _HandStyle)
|
||||
{
|
||||
_HandStyle = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("HandStyle"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private float _Length;
|
||||
/// <summary>
|
||||
/// Gets or sets the length of this clock hand as a percentage value ranging from 0.0 to 1.0, with 1.0 being half the width/height of the bounding rectangle. Default value is 1.0.
|
||||
/// </summary>
|
||||
[DefaultValue(1.0f),
|
||||
Category("Appearance"),
|
||||
Description("The length of this clock hand as a percentage value ranging from 0.0 to 1.0, with 1.0 being half the width/height of the bounding rectangle.")]
|
||||
public float Length
|
||||
{
|
||||
get { return _Length; }
|
||||
set
|
||||
{
|
||||
if (value != _Length)
|
||||
{
|
||||
_Length = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("Length"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private float _Width;
|
||||
/// <summary>
|
||||
/// Gets or sets the width of this clock hand as a percentage value ranging from 0.0 to 1.0, with 1.0 being half the width/height of the bounding rectangle. Default value is 0.1.
|
||||
/// </summary>
|
||||
[DefaultValue(0.1f),
|
||||
Category("Appearance"),
|
||||
Description("The width of this clock hand as a percentage value ranging from 0.0 to 1.0, with 1.0 being half the width/height of the bounding rectangle.")]
|
||||
public float Width
|
||||
{
|
||||
get { return _Width; }
|
||||
set
|
||||
{
|
||||
if (value != _Width)
|
||||
{
|
||||
_Width = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("Width"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when property value has changed.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the ClockHand class.
|
||||
/// </summary>
|
||||
public ClockHandStyleData()
|
||||
{
|
||||
_DrawOverCap = false;
|
||||
_HandColor = new ColorData(eBrushTypes.Solid, Color.FromArgb(109, 127, 138), Color.FromArgb(109, 127, 138), Color.FromArgb(128, 109, 127, 138), 0.01f);
|
||||
_HandStyle = eHandStyles.Style1;
|
||||
_Length = 1.0f;
|
||||
_Width = 0.1f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the ClockHand class.
|
||||
/// </summary>
|
||||
/// <param name="handStyle">The hand style for this item.</param>
|
||||
/// <param name="length">The length of this clock hand as a percentage value ranging from 0.0 to 1.0, with 1.0 being half the width/height of the bounding rectangle</param>
|
||||
/// <param name="width">The width of this clock hand as a percentage value ranging from 0.0 to 1.0, with 1.0 being half the width/height of the bounding rectangle.</param>
|
||||
public ClockHandStyleData(eHandStyles handStyle, float length, float width)
|
||||
{
|
||||
_DrawOverCap = false;
|
||||
_HandColor = new ColorData(eBrushTypes.Solid, Color.FromArgb(109, 127, 138), Color.FromArgb(109, 127, 138), Color.FromArgb(128, 109, 127, 138), 0.01f);
|
||||
_HandStyle = handStyle;
|
||||
_Length = length;
|
||||
_Width = width;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether the specified point is contained within the bounds of this hand.
|
||||
/// </summary>
|
||||
/// <param name="boundingRect">The bounding rectangle of the parent clock control.</param>
|
||||
/// <param name="angle">The clockwise angle for this clock hand in degrees from the 12 o'clock position.</param>
|
||||
/// <param name="pt">A Point that represents the point to test.</param>
|
||||
/// <returns></returns>
|
||||
public virtual bool ContainsPoint(RectangleF boundingRect, float angle, Point pt)
|
||||
{
|
||||
GraphicsPath path;
|
||||
bool ret;
|
||||
|
||||
path = GenerateHandPath(boundingRect, angle);
|
||||
|
||||
ret = path.IsVisible(pt);
|
||||
path.Dispose();
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generates a scaled and rotated graphics path based on the given style, rectangle and angle.
|
||||
/// </summary>
|
||||
/// <param name="boundingRect">The bounding rectangle of the parent clock control.</param>
|
||||
/// <param name="angle">The clockwise angle for this clock hand in degrees from the 12 o'clock position.</param>
|
||||
/// <returns></returns>
|
||||
public GraphicsPath GenerateHandPath(RectangleF boundingRect, float angle)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
RectangleF rect;
|
||||
Matrix matrix;
|
||||
float scaleFactor;
|
||||
PointF[] pts;
|
||||
|
||||
switch (_HandStyle)
|
||||
{
|
||||
case eHandStyles.Style1:
|
||||
pts = new PointF[4];
|
||||
pts[0].X = -0.5f;
|
||||
pts[0].Y = 0.0f;
|
||||
|
||||
pts[1].X = -0.5f;
|
||||
pts[1].Y = -1.0f;
|
||||
|
||||
pts[2].X = 0.5f;
|
||||
pts[2].Y = -1.0f;
|
||||
|
||||
pts[3].X = 0.5f;
|
||||
pts[3].Y = 0.0f;
|
||||
path.AddPolygon(pts);
|
||||
break;
|
||||
case eHandStyles.Style2:
|
||||
pts = new PointF[4];
|
||||
pts[0].X = -0.4f;
|
||||
pts[0].Y = 0.25f;
|
||||
|
||||
pts[1].X = -0.4f;
|
||||
pts[1].Y = -1.0f;
|
||||
|
||||
pts[2].X = 0.4f;
|
||||
pts[2].Y = -1.0f;
|
||||
|
||||
pts[3].X = 0.4f;
|
||||
pts[3].Y = 0.25f;
|
||||
path.AddPolygon(pts);
|
||||
break;
|
||||
case eHandStyles.Style3:
|
||||
pts = new PointF[4];
|
||||
pts[0].X = -0.5f;
|
||||
pts[0].Y = 0.0f;
|
||||
|
||||
pts[1].X = -0.0125f;
|
||||
pts[1].Y = -1.0f;
|
||||
|
||||
pts[2].X = 0.0125f;
|
||||
pts[2].Y = -1.0f;
|
||||
|
||||
pts[3].X = 0.5f;
|
||||
pts[3].Y = 0.0f;
|
||||
|
||||
path.AddPolygon(pts);
|
||||
break;
|
||||
case eHandStyles.Style4:
|
||||
path.FillMode = FillMode.Winding;
|
||||
pts = new PointF[4];
|
||||
pts[0].X = -0.5f;
|
||||
pts[0].Y = -0.05f;
|
||||
|
||||
pts[1].X = -0.5f;
|
||||
pts[1].Y = -1.0f;
|
||||
|
||||
pts[2].X = 0.5f;
|
||||
pts[2].Y = -1.0f;
|
||||
|
||||
pts[3].X = 0.5f;
|
||||
pts[3].Y = -0.05f;
|
||||
path.AddPolygon(pts);
|
||||
|
||||
rect = new RectangleF(-5.0f, -0.06f, 10.0f, 0.12f);
|
||||
path.AddEllipse(rect);
|
||||
break;
|
||||
}
|
||||
scaleFactor = Math.Min(boundingRect.Width, boundingRect.Height) / 2.0f;
|
||||
matrix = new Matrix();
|
||||
matrix.Translate(boundingRect.X + boundingRect.Width * 0.5f, boundingRect.Y + boundingRect.Width * 0.5f);
|
||||
matrix.Rotate(angle);
|
||||
matrix.Scale(scaleFactor * Width, scaleFactor * Length);
|
||||
path.Transform(matrix);
|
||||
matrix.Dispose();
|
||||
return path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the PropertyChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Event arguments</param>
|
||||
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
PropertyChanged(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration containing the available hand styles.
|
||||
/// </summary>
|
||||
public enum eHandStyles
|
||||
{
|
||||
/// <summary>
|
||||
/// Style 1.
|
||||
/// </summary>
|
||||
Style1,
|
||||
|
||||
/// <summary>
|
||||
/// Style 2.
|
||||
/// </summary>
|
||||
Style2,
|
||||
|
||||
/// <summary>
|
||||
/// Style 3.
|
||||
/// </summary>
|
||||
Style3,
|
||||
|
||||
/// <summary>
|
||||
/// Style 4.
|
||||
/// </summary>
|
||||
Style4,
|
||||
}
|
||||
|
||||
}
|
659
PROMS/DotNetBar Source Code/AnalogClock/ClockStyleData.cs
Normal file
659
PROMS/DotNetBar Source Code/AnalogClock/ClockStyleData.cs
Normal file
@@ -0,0 +1,659 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
|
||||
namespace DevComponents.DotNetBar.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Data storage class for clock visual styles.
|
||||
/// </summary>
|
||||
[Description("Clock Style"),
|
||||
TypeConverterAttribute(typeof(ExpandableObjectConverter))]
|
||||
public class ClockStyleData : IDisposable, INotifyPropertyChanged
|
||||
{
|
||||
|
||||
private eClockStyles _Style;
|
||||
/// <summary>
|
||||
/// Gets or sets the PredefinedStyles value for this style.
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public eClockStyles Style
|
||||
{
|
||||
get { return _Style; }
|
||||
set
|
||||
{
|
||||
if (value != _Style)
|
||||
{
|
||||
_Style = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("Style"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private eClockShapes _ClockShape;
|
||||
/// <summary>
|
||||
/// Gets or sets the clock shape value for this style.
|
||||
/// </summary>
|
||||
[DefaultValue(eClockShapes.Round),
|
||||
Category("Appearance"),
|
||||
Description("The clock shape for this style.")]
|
||||
public eClockShapes ClockShape
|
||||
{
|
||||
get { return _ClockShape; }
|
||||
set
|
||||
{
|
||||
if (value != _ClockShape)
|
||||
{
|
||||
_ClockShape = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("ClockShape"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ColorPropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (_Parent != null) _Parent.Invalidate();
|
||||
}
|
||||
|
||||
private ColorData _BezelColor;
|
||||
/// <summary>
|
||||
/// Gets or sets the bezel color data for this style.
|
||||
/// </summary>
|
||||
[Category("Appearance"),
|
||||
Description("The bezel color data for this style.")]
|
||||
public ColorData BezelColor
|
||||
{
|
||||
get { return _BezelColor; }
|
||||
set
|
||||
{
|
||||
if (value != _BezelColor)
|
||||
{
|
||||
if (_BezelColor != null) _BezelColor.PropertyChanged -= ColorPropertyChanged;
|
||||
_BezelColor = value;
|
||||
if (_BezelColor != null) _BezelColor.PropertyChanged += ColorPropertyChanged;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("BezelColor"));
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets the property to default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetBezelColor()
|
||||
{
|
||||
BezelColor = new ColorData(eBrushTypes.Linear, Color.FromArgb(255, 255, 255), Color.FromArgb(152, 152, 152), Color.FromArgb(120, 120, 120), 1.0f, 45.0f);
|
||||
}
|
||||
|
||||
|
||||
private float _BezelWidth;
|
||||
/// <summary>
|
||||
/// Gets or sets the width of clock bezel as a percentage value ranging from 0.0 to 1.0.
|
||||
/// </summary>
|
||||
[DefaultValue(0.03f),
|
||||
Category("Appearance"),
|
||||
Description("The width of clock bezel as a percentage value ranging from 0.0 to 1.0.")]
|
||||
public float BezelWidth
|
||||
{
|
||||
get { return _BezelWidth; }
|
||||
set
|
||||
{
|
||||
if (value != _BezelWidth)
|
||||
{
|
||||
_BezelWidth = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("BezelWidth"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ColorData _FaceColor;
|
||||
/// <summary>
|
||||
/// Gets or sets the face color data for this style.
|
||||
/// </summary>
|
||||
[Category("Appearance"),
|
||||
Description("The face color data for this style.")]
|
||||
public ColorData FaceColor
|
||||
{
|
||||
get { return _FaceColor; }
|
||||
set
|
||||
{
|
||||
if (value != _FaceColor)
|
||||
{
|
||||
if (_FaceColor != null) _FaceColor.PropertyChanged -= ColorPropertyChanged;
|
||||
_FaceColor = value;
|
||||
if (_FaceColor != null) _FaceColor.PropertyChanged += ColorPropertyChanged;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("FaceColor"));
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets the property to default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetFaceColor()
|
||||
{
|
||||
FaceColor = new ColorData(eBrushTypes.Linear, Color.FromArgb(191, 204, 213), Color.FromArgb(255, 255, 255), Color.FromArgb(135, 145, 161), 1.0f, 45.0f);
|
||||
}
|
||||
|
||||
private Image _FaceBackgroundImage;
|
||||
/// <summary>
|
||||
/// Gets or sets the face background image for this style.
|
||||
/// </summary>
|
||||
[DefaultValue(null),
|
||||
Category("Appearance"),
|
||||
Description("The face background image for this style.")]
|
||||
public Image FaceBackgroundImage
|
||||
{
|
||||
get { return _FaceBackgroundImage; }
|
||||
set
|
||||
{
|
||||
if (value != _FaceBackgroundImage)
|
||||
{
|
||||
_FaceBackgroundImage = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("FaceBackgroundImage"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ClockHandStyleData _HourHandStyle;
|
||||
/// <summary>
|
||||
/// Gets or sets the hour hand style for this style.
|
||||
/// </summary>
|
||||
[Category("Appearance"),
|
||||
Description("The hour hand style for this style.")]
|
||||
public ClockHandStyleData HourHandStyle
|
||||
{
|
||||
get { return _HourHandStyle; }
|
||||
set
|
||||
{
|
||||
if (value != _HourHandStyle)
|
||||
{
|
||||
if (_HourHandStyle != null) _HourHandStyle.PropertyChanged -= ColorPropertyChanged;
|
||||
_HourHandStyle = value;
|
||||
if (_HourHandStyle != null) _HourHandStyle.PropertyChanged += ColorPropertyChanged;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("HourHandStyle"));
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets the property to default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetHourHandStyle()
|
||||
{
|
||||
HourHandStyle = new ClockHandStyleData(eHandStyles.Style1, 0.55f, 0.01f);
|
||||
}
|
||||
|
||||
private ClockHandStyleData _MinuteHandStyle;
|
||||
/// <summary>
|
||||
/// Gets or sets the minute hand style for this style.
|
||||
/// </summary>
|
||||
[Category("Appearance"),
|
||||
Description("The minute hand style for this style.")]
|
||||
public ClockHandStyleData MinuteHandStyle
|
||||
{
|
||||
get { return _MinuteHandStyle; }
|
||||
set
|
||||
{
|
||||
if (value != _MinuteHandStyle)
|
||||
{
|
||||
if (_MinuteHandStyle != null) _MinuteHandStyle.PropertyChanged -= ColorPropertyChanged;
|
||||
_MinuteHandStyle = value;
|
||||
if (_MinuteHandStyle != null) _MinuteHandStyle.PropertyChanged += ColorPropertyChanged;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("MinuteHandStyle"));
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets the property to default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetMinuteHandStyle()
|
||||
{
|
||||
MinuteHandStyle = new ClockHandStyleData(eHandStyles.Style1, 0.8f, 0.01f);
|
||||
}
|
||||
|
||||
|
||||
private ClockHandStyleData _SecondHandStyle;
|
||||
/// <summary>
|
||||
/// Gets or sets the second hand style for this style.
|
||||
/// </summary>
|
||||
[Category("Appearance"),
|
||||
Description("The second hand style for this style.")]
|
||||
public ClockHandStyleData SecondHandStyle
|
||||
{
|
||||
get { return _SecondHandStyle; }
|
||||
set
|
||||
{
|
||||
if (value != _SecondHandStyle)
|
||||
{
|
||||
if (_SecondHandStyle != null) _SecondHandStyle.PropertyChanged -= ColorPropertyChanged;
|
||||
_SecondHandStyle = value;
|
||||
if (_SecondHandStyle != null) _SecondHandStyle.PropertyChanged += ColorPropertyChanged;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("SecondHandStyle"));
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets the property to default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetSecondHandStyle()
|
||||
{
|
||||
SecondHandStyle = new ClockHandStyleData(eHandStyles.Style2, 0.8f, 0.005f);
|
||||
}
|
||||
|
||||
|
||||
private ColorData _CapColor;
|
||||
/// <summary>
|
||||
/// Gets or sets the center cap color data for this style.
|
||||
/// </summary>
|
||||
[Category("Appearance"),
|
||||
Description("The center cap color data for this style.")]
|
||||
public ColorData CapColor
|
||||
{
|
||||
get { return _CapColor; }
|
||||
set
|
||||
{
|
||||
if (value != _CapColor)
|
||||
{
|
||||
if (_CapColor != null) _CapColor.PropertyChanged -= ColorPropertyChanged;
|
||||
_CapColor = value;
|
||||
if (_CapColor != null) _CapColor.PropertyChanged += ColorPropertyChanged;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("CapColor"));
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets the property to default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetCapColor()
|
||||
{
|
||||
CapColor = new ColorData(eBrushTypes.Solid, Color.FromArgb(109, 127, 138), Color.FromArgb(109, 127, 138), Color.FromArgb(128, 109, 127, 138), 0.01f);
|
||||
}
|
||||
|
||||
private float _CapSize;
|
||||
/// <summary>
|
||||
/// Gets or sets the center cap diameter as a percentage value ranging from 0.0 to 1.0.
|
||||
/// </summary>
|
||||
[DefaultValue(0.03f),
|
||||
Category("Appearance"),
|
||||
Description("The center cap diameter as a percentage value ranging from 0.0 to 1.0.")]
|
||||
public float CapSize
|
||||
{
|
||||
get { return _CapSize; }
|
||||
set
|
||||
{
|
||||
if (value != _CapSize)
|
||||
{
|
||||
_CapSize = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("CapSize"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Color _NumberColor;
|
||||
/// <summary>
|
||||
/// Gets or sets the face number color for this style.
|
||||
/// </summary>
|
||||
[DefaultValue(typeof(Color), "139, 158, 168"),
|
||||
Category("Appearance"),
|
||||
Description("The face number color for this style.")]
|
||||
public Color NumberColor
|
||||
{
|
||||
get { return _NumberColor; }
|
||||
set
|
||||
{
|
||||
if (value != _NumberColor)
|
||||
{
|
||||
_NumberColor = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("NumberColor"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Font _NumberFont;
|
||||
/// <summary>
|
||||
/// Gets or sets the center cap color data for this style.
|
||||
/// </summary>
|
||||
[Category("Appearance"),
|
||||
Description("The face number font for this style.")]
|
||||
public Font NumberFont
|
||||
{
|
||||
get { return _NumberFont; }
|
||||
set
|
||||
{
|
||||
if (value != _NumberFont)
|
||||
{
|
||||
_NumberFont = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("NumberFont"));
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets the property to default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetNumberFont()
|
||||
{
|
||||
_NumberFont = new Font("Microsoft Sans Serif", 8, FontStyle.Regular, GraphicsUnit.Pixel);
|
||||
}
|
||||
|
||||
private ColorData _LargeTickColor;
|
||||
/// <summary>
|
||||
/// Gets or sets the large tick color data for this style.
|
||||
/// </summary>
|
||||
[Category("Appearance"),
|
||||
Description("The large tick color data for this style.")]
|
||||
public ColorData LargeTickColor
|
||||
{
|
||||
get { return _LargeTickColor; }
|
||||
set
|
||||
{
|
||||
if (value != _LargeTickColor)
|
||||
{
|
||||
if (_LargeTickColor != null) _LargeTickColor.PropertyChanged -= ColorPropertyChanged;
|
||||
_LargeTickColor = value;
|
||||
if (_LargeTickColor != null) _LargeTickColor.PropertyChanged += ColorPropertyChanged;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("LargeTickColor"));
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets the property to default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetLargeTickColor()
|
||||
{
|
||||
LargeTickColor = new ColorData(eBrushTypes.Centered, Color.FromArgb(122, 142, 154), Color.FromArgb(122, 142, 154), Color.FromArgb(255, 255, 255), 1.0f);
|
||||
}
|
||||
|
||||
private float _LargeTickLength;
|
||||
/// <summary>
|
||||
/// Gets or sets the large tick length as a percentage value ranging from 0.0 to 1.0.
|
||||
/// </summary>
|
||||
[DefaultValue(0.06f),
|
||||
Category("Appearance"),
|
||||
Description("The large tick length as a percentage value ranging from 0.0 to 1.0.")]
|
||||
public float LargeTickLength
|
||||
{
|
||||
get { return _LargeTickLength; }
|
||||
set
|
||||
{
|
||||
if (value != _LargeTickLength)
|
||||
{
|
||||
_LargeTickLength = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("LargeTickLength"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private float _LargeTickWidth;
|
||||
/// <summary>
|
||||
/// Gets or sets the large tick width as a percentage value ranging from 0.0 to 1.0.
|
||||
/// </summary>
|
||||
[DefaultValue(0.02f),
|
||||
Category("Appearance"),
|
||||
Description("The large tick width as a percentage value ranging from 0.0 to 1.0.")]
|
||||
public float LargeTickWidth
|
||||
{
|
||||
get { return _LargeTickWidth; }
|
||||
set
|
||||
{
|
||||
if (value != _LargeTickWidth)
|
||||
{
|
||||
_LargeTickWidth = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("LargeTickWidth"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ColorData _SmallTickColor;
|
||||
/// <summary>
|
||||
/// Gets or sets the small tick color data for this style.
|
||||
/// </summary>
|
||||
[Category("Appearance"),
|
||||
Description("The small tick color data for this style.")]
|
||||
public ColorData SmallTickColor
|
||||
{
|
||||
get { return _SmallTickColor; }
|
||||
set
|
||||
{
|
||||
if (value != _SmallTickColor)
|
||||
{
|
||||
if (_SmallTickColor != null) _SmallTickColor.PropertyChanged -= ColorPropertyChanged;
|
||||
_SmallTickColor = value;
|
||||
if (_SmallTickColor != null) _SmallTickColor.PropertyChanged += ColorPropertyChanged;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("SmallTickColor"));
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Resets the property to default value.
|
||||
/// </summary>
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetSmallTickColor()
|
||||
{
|
||||
SmallTickColor = new ColorData(eBrushTypes.Centered, Color.FromArgb(122, 142, 154), Color.FromArgb(122, 142, 154), Color.FromArgb(255, 255, 255), 1.0f);
|
||||
}
|
||||
|
||||
private float _SmallTickLength;
|
||||
/// <summary>
|
||||
/// Gets or sets the small tick length as a percentage value ranging from 0.0 to 1.0.
|
||||
/// </summary>
|
||||
[DefaultValue(0.02f),
|
||||
Category("Appearance"),
|
||||
Description("The small tick length as a percentage value ranging from 0.0 to 1.0.")]
|
||||
public float SmallTickLength
|
||||
{
|
||||
get { return _SmallTickLength; }
|
||||
set
|
||||
{
|
||||
if (value != _SmallTickLength)
|
||||
{
|
||||
_SmallTickLength = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("SmallTickLength"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private float _SmallTickWidth;
|
||||
/// <summary>
|
||||
/// Gets or sets the small tick width as a percentage value ranging from 0.0 to 1.0.
|
||||
/// </summary>
|
||||
[DefaultValue(0.02f),
|
||||
Category("Appearance"),
|
||||
Description("The small tick width as a percentage value ranging from 0.0 to 1.0.")]
|
||||
public float SmallTickWidth
|
||||
{
|
||||
get { return _SmallTickWidth; }
|
||||
set
|
||||
{
|
||||
if (value != _SmallTickWidth)
|
||||
{
|
||||
_SmallTickWidth = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("SmallTickWidth"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int _GlassAngle;
|
||||
/// <summary>
|
||||
/// Gets or sets the overlay glass angle, in degrees for this style.
|
||||
/// </summary>
|
||||
[DefaultValue(20),
|
||||
Category("Appearance"),
|
||||
Description("The overlay angle, in degrees for this style.")]
|
||||
public int GlassAngle
|
||||
{
|
||||
get { return _GlassAngle; }
|
||||
set
|
||||
{
|
||||
if (value != _GlassAngle)
|
||||
{
|
||||
_GlassAngle = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("_GlassAngle"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when property value has changed.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the ClockStyle class.
|
||||
/// </summary>
|
||||
public ClockStyleData()
|
||||
{
|
||||
LoadStyle(eClockStyles.Style1);
|
||||
}
|
||||
|
||||
private AnalogClockControl _Parent = null;
|
||||
/// <summary>
|
||||
/// Gets the parent of the style.
|
||||
/// </summary>
|
||||
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public AnalogClockControl Parent
|
||||
{
|
||||
get { return _Parent; }
|
||||
internal set { _Parent = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the ClockStyle class.
|
||||
/// </summary>
|
||||
/// <param name="style">Predefined style from the PredefinedStyles enum.</param>
|
||||
public ClockStyleData(eClockStyles style)
|
||||
{
|
||||
LoadStyle(style);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the ClockStyle class.
|
||||
/// </summary>
|
||||
/// <param name="style">Predefined style from the PredefinedStyles enum.</param>
|
||||
public ClockStyleData(eClockStyles style, AnalogClockControl parent)
|
||||
{
|
||||
LoadStyle(style);
|
||||
_Parent = parent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases all resources used by the class.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (_FaceBackgroundImage != null)
|
||||
_FaceBackgroundImage.Dispose();
|
||||
if (_NumberFont != null)
|
||||
_NumberFont.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads a predefined style
|
||||
/// </summary>
|
||||
/// <param name="style">The predefined style to load.</param>
|
||||
private void LoadStyle(eClockStyles style)
|
||||
{
|
||||
_Style = style;
|
||||
switch (style)
|
||||
{
|
||||
case eClockStyles.Style1:
|
||||
case eClockStyles.Custom:
|
||||
_ClockShape = eClockShapes.Round;
|
||||
BezelColor = new ColorData(eBrushTypes.Linear, Color.FromArgb(255, 255, 255), Color.FromArgb(152, 152, 152), Color.FromArgb(120, 120, 120), 0.01f);
|
||||
_BezelWidth = 0.03f;
|
||||
FaceColor = new ColorData(eBrushTypes.Linear, Color.FromArgb(191, 204, 213), Color.FromArgb(255, 255, 255), Color.FromArgb(135, 145, 161), 0.01f, 45.0f);
|
||||
_FaceBackgroundImage = null;
|
||||
HourHandStyle = new ClockHandStyleData(eHandStyles.Style1, 0.55f, 0.015f);
|
||||
MinuteHandStyle = new ClockHandStyleData(eHandStyles.Style1, 0.8f, 0.01f);
|
||||
SecondHandStyle = new ClockHandStyleData(eHandStyles.Style2, 0.8f, 0.005f);
|
||||
CapColor = new ColorData(eBrushTypes.Solid, Color.FromArgb(109, 127, 138), Color.FromArgb(109, 127, 138), Color.FromArgb(128, 109, 127, 138), 0.01f);
|
||||
_CapSize = 0.03f;
|
||||
_NumberColor = Color.FromArgb(139, 158, 168);
|
||||
_NumberFont = new Font("Microsoft Sans Serif", 12, FontStyle.Regular, GraphicsUnit.Pixel);
|
||||
LargeTickColor = new ColorData(eBrushTypes.Linear, Color.FromArgb(122, 142, 154), Color.FromArgb(122, 142, 154), Color.FromArgb(128, 255, 255, 255), 0.01f);
|
||||
_LargeTickLength = 0.06f;
|
||||
_LargeTickWidth = 0.02f;
|
||||
SmallTickColor = new ColorData(eBrushTypes.Linear, Color.FromArgb(122, 142, 154), Color.FromArgb(122, 142, 154), Color.FromArgb(128, 255, 255, 255), 0.01f);
|
||||
_SmallTickLength = 0.02f;
|
||||
_SmallTickWidth = 0.02f;
|
||||
_GlassAngle = -20;
|
||||
break;
|
||||
case eClockStyles.Style2:
|
||||
_ClockShape = eClockShapes.Round;
|
||||
BezelColor = new ColorData(eBrushTypes.Linear, Color.FromArgb(80, 80, 80), Color.FromArgb(0, 0, 0), Color.FromArgb(0, 0, 0), 0.0f, 90.0f);
|
||||
_BezelWidth = 0.03f;
|
||||
FaceColor = new ColorData(eBrushTypes.Linear, Color.FromArgb(225, 225, 225), Color.FromArgb(240, 240, 240), Color.FromArgb(0, 0, 0), 0.0f, 90.0f);
|
||||
_FaceBackgroundImage = null;
|
||||
HourHandStyle = new ClockHandStyleData(eHandStyles.Style3, 0.45f, 0.175f);
|
||||
HourHandStyle.HandColor = new ColorData(eBrushTypes.Linear, Color.FromArgb(0, 0, 0), Color.FromArgb(80, 80, 80), Color.FromArgb(64, 0, 0, 0), 0.01f, 90.0f);
|
||||
MinuteHandStyle = new ClockHandStyleData(eHandStyles.Style3, 0.75f, 0.175f);
|
||||
MinuteHandStyle.HandColor = new ColorData(eBrushTypes.Linear, Color.FromArgb(0, 0, 0), Color.FromArgb(80, 80, 80), Color.FromArgb(64, 0, 0, 0), 0.01f, 90.0f);
|
||||
SecondHandStyle = new ClockHandStyleData(eHandStyles.Style4, 0.9f, 0.01f);
|
||||
SecondHandStyle.HandColor = new ColorData(eBrushTypes.Solid, Color.FromArgb(255, 0, 0), Color.FromArgb(255, 0, 0), Color.FromArgb(128, 192, 0, 0), 0.01f);
|
||||
_SecondHandStyle.DrawOverCap = true;
|
||||
CapColor = new ColorData(eBrushTypes.Solid, Color.FromArgb(255, 255, 255), Color.FromArgb(255, 255, 255), Color.FromArgb(223, 0, 0, 0), 0.01f);
|
||||
_CapSize = 0.1f;
|
||||
_NumberColor = Color.FromArgb(0, 0, 0);
|
||||
_NumberFont = new Font("Trebuchet MS", 12, FontStyle.Regular, GraphicsUnit.Pixel);
|
||||
LargeTickColor = new ColorData(eBrushTypes.Solid, Color.FromArgb(0, 0, 0), Color.FromArgb(0, 0, 0), Color.FromArgb(64, 0, 0, 0), 0.01f);
|
||||
_LargeTickLength = 0.06f;
|
||||
_LargeTickWidth = 0.01f;
|
||||
SmallTickColor = new ColorData(eBrushTypes.Solid, Color.FromArgb(0, 0, 0), Color.FromArgb(0, 0, 0), Color.FromArgb(64, 0, 0, 0), 0.01f);
|
||||
_SmallTickLength = 0.01f;
|
||||
_SmallTickWidth = 0.01f;
|
||||
_GlassAngle = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the PropertyChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Event arguments</param>
|
||||
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
PropertyChanged(this, e);
|
||||
if (_Parent != null) _Parent.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration containing the predefined clock styles.
|
||||
/// </summary>
|
||||
public enum eClockStyles
|
||||
{
|
||||
/// <summary>
|
||||
/// Style 1. Default style,
|
||||
/// </summary>
|
||||
Style1,
|
||||
|
||||
/// <summary>
|
||||
/// Style 2.
|
||||
/// </summary>
|
||||
Style2,
|
||||
|
||||
/// <summary>
|
||||
/// No predefined style.
|
||||
/// </summary>
|
||||
Custom
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration containing the predefined clock shapes.
|
||||
/// </summary>
|
||||
public enum eClockShapes
|
||||
{
|
||||
/// <summary>
|
||||
/// Round clock shape.
|
||||
/// </summary>
|
||||
Round
|
||||
}
|
||||
}
|
442
PROMS/DotNetBar Source Code/AnalogClock/ColorData.cs
Normal file
442
PROMS/DotNetBar Source Code/AnalogClock/ColorData.cs
Normal file
@@ -0,0 +1,442 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace DevComponents.DotNetBar.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Data storage and utility class for defining gradient colors.
|
||||
/// </summary>
|
||||
[Description("Color Data Class"),
|
||||
TypeConverterAttribute(typeof(ExpandableObjectConverter))]
|
||||
public class ColorData : INotifyPropertyChanged
|
||||
{
|
||||
private Color _BorderColor;
|
||||
/// <summary>
|
||||
/// Gets or sets the border color for this item. Default value is white.
|
||||
/// </summary>
|
||||
[DefaultValue(typeof(Color), "255, 255, 255"),
|
||||
Category("Appearance"),
|
||||
Description("The border color for this item.")]
|
||||
public Color BorderColor
|
||||
{
|
||||
get { return _BorderColor; }
|
||||
set
|
||||
{
|
||||
if (value != _BorderColor)
|
||||
{
|
||||
_BorderColor = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("BorderColor"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private float _BorderWidth;
|
||||
/// <summary>
|
||||
/// Gets or sets the border width for this item. Default value is 0.
|
||||
/// </summary>
|
||||
[DefaultValue(0.0f),
|
||||
Category("Appearance"),
|
||||
Description("The border width for this item.")]
|
||||
public float BorderWidth
|
||||
{
|
||||
get { return _BorderWidth; }
|
||||
set
|
||||
{
|
||||
if (value != _BorderWidth)
|
||||
{
|
||||
_BorderWidth = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("BorderWidth"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private float _BrushAngle;
|
||||
/// <summary>
|
||||
/// Gets or sets the brush angle for this item. Only applies to Linear and Reflected brush types. Default value is 0.
|
||||
/// </summary>
|
||||
[DefaultValue(0.0f),
|
||||
Category("Appearance"),
|
||||
Description("The brush angle for this item. Only applies to Linear and Reflected brush types.")]
|
||||
public float BrushAngle
|
||||
{
|
||||
get { return _BrushAngle; }
|
||||
set
|
||||
{
|
||||
if (value != _BrushAngle)
|
||||
{
|
||||
_BrushAngle = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("BrushAngle"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private float _BrushSBSFocus;
|
||||
/// <summary>
|
||||
/// Gets or sets the brush SigmaBellShape focus for this item. Only applies to Reflected brush types. Default value is 0.5.
|
||||
/// </summary>
|
||||
[DefaultValue(0.5f),
|
||||
Category("Appearance"),
|
||||
Description("The brush SigmaBellShape focus for this item. Only applies to Linear and Reflected brush types.")]
|
||||
public float BrushSBSFocus
|
||||
{
|
||||
get { return _BrushSBSFocus; }
|
||||
set
|
||||
{
|
||||
if (value != _BrushSBSFocus)
|
||||
{
|
||||
_BrushSBSFocus = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("BrushSBSFocus"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private float _BrushSBSScale;
|
||||
/// <summary>
|
||||
/// Gets or sets the brush SigmaBellShape scale for this item. Only applies to Reflected brush types. Default value is 0.5.
|
||||
/// </summary>
|
||||
[DefaultValue(0.5f),
|
||||
Category("Appearance"),
|
||||
Description("The brush SigmaBellShape scale for this item. Only applies to Linear and Reflected brush types.")]
|
||||
public float BrushSBSScale
|
||||
{
|
||||
get { return _BrushSBSScale; }
|
||||
set
|
||||
{
|
||||
if (value != _BrushSBSScale)
|
||||
{
|
||||
_BrushSBSScale = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("BrushSBSScale"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private eBrushTypes _BrushType;
|
||||
/// <summary>
|
||||
/// Gets or sets the brush type for this item. Default value is Solid.
|
||||
/// </summary>
|
||||
[DefaultValue(eBrushTypes.Solid),
|
||||
Category("Appearance"),
|
||||
Description("The brush type for this item.")]
|
||||
public eBrushTypes BrushType
|
||||
{
|
||||
get { return _BrushType; }
|
||||
set
|
||||
{
|
||||
if (value != _BrushType)
|
||||
{
|
||||
_BrushType = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("BrushType"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Color _Color1;
|
||||
/// <summary>
|
||||
/// Gets or sets the first color for this item. Default value is white.
|
||||
/// </summary>
|
||||
[DefaultValue(typeof(Color), "255, 255, 255"),
|
||||
Category("Appearance"),
|
||||
Description("The first color for this item.")]
|
||||
public Color Color1
|
||||
{
|
||||
get { return _Color1; }
|
||||
set
|
||||
{
|
||||
if (value != _Color1)
|
||||
{
|
||||
_Color1 = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("Color1"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Color _Color2;
|
||||
/// <summary>
|
||||
/// Gets or sets the second color for this item. Default value is white.
|
||||
/// </summary>
|
||||
[DefaultValue(typeof(Color), "255, 255, 255"),
|
||||
Category("Appearance"),
|
||||
Description("The second color for this item.")]
|
||||
public Color Color2
|
||||
{
|
||||
get { return _Color2; }
|
||||
set
|
||||
{
|
||||
if (value != _Color2)
|
||||
{
|
||||
_Color2 = value;
|
||||
OnPropertyChanged(new PropertyChangedEventArgs("Color2"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when property value has changed.
|
||||
/// </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the object.
|
||||
/// </summary>
|
||||
public ColorData()
|
||||
{
|
||||
LoadData(eBrushTypes.Solid, Color.White, Color.White, Color.White, 0.0f, 0.0f, 0.5f, 1.0f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the object.
|
||||
/// </summary>
|
||||
/// <param name="color1">The first color for this entry.</param>
|
||||
/// <param name="color2">The second color for this entry.</param>
|
||||
public ColorData(eBrushTypes brushType, Color color1, Color color2)
|
||||
{
|
||||
LoadData(brushType, color1, color2, Color.White, 0.0f, 0.0f, 0.5f, 1.0f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the object.
|
||||
/// </summary>
|
||||
/// <param name="color1">The first color for this entry.</param>
|
||||
/// <param name="color2">The second color for this entry.</param>
|
||||
/// <param name="borderColor">The border color for this entry.</param>
|
||||
/// <param name="borderWidth">The border width for this entry.</param>
|
||||
public ColorData(eBrushTypes brushType, Color color1, Color color2, Color borderColor, float borderWidth)
|
||||
{
|
||||
LoadData(brushType, color1, color2, borderColor, borderWidth, 0.0f, 0.5f, 1.0f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the object.
|
||||
/// </summary>
|
||||
/// <param name="color1">The first color for this entry.</param>
|
||||
/// <param name="color2">The second color for this entry.</param>
|
||||
/// <param name="borderColor">The border color for this entry.</param>
|
||||
/// <param name="borderWidth">The border width for this entry.</param>
|
||||
/// <param name="brushAngle">The gradient angle.</param>
|
||||
public ColorData(eBrushTypes brushType, Color color1, Color color2, Color borderColor, float borderWidth, float brushAngle)
|
||||
{
|
||||
LoadData(brushType, color1, color2, borderColor, borderWidth, brushAngle, 0.5f, 1.0f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates new instance of the object.
|
||||
/// </summary>
|
||||
/// <param name="color1">The first color for this entry.</param>
|
||||
/// <param name="color2">The second color for this entry.</param>
|
||||
/// <param name="borderColor">The border color for this entry.</param>
|
||||
/// <param name="borderWidth">The border width for this entry.</param>
|
||||
/// <param name="brushSBSFocus">The focus for the SigmaBellShape.</param>
|
||||
/// <param name="brushSBSScale">The scale for the SigmaBellShape.</param>
|
||||
public ColorData(eBrushTypes brushType, Color color1, Color color2, Color borderColor, float borderWidth, float brushSBSFocus, float brushSBSScale)
|
||||
{
|
||||
LoadData(brushType, color1, color2, borderColor, borderWidth, 0.0f, brushSBSFocus, brushSBSScale);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads data into the class, called by constructors.
|
||||
/// </summary>
|
||||
/// <param name="color1">The first color for this entry.</param>
|
||||
/// <param name="color2">The second color for this entry.</param>
|
||||
/// <param name="borderColor">The border color for this entry.</param>
|
||||
/// <param name="borderWidth">The border width for this entry.</param>
|
||||
/// <param name="brushSBSFocus">The focus for the SigmaBellShape.</param>
|
||||
/// <param name="brushSBSScale">The scale for the SigmaBellShape.</param>
|
||||
protected void LoadData(eBrushTypes brushType, Color color1, Color color2, Color borderColor, float borderWidth, float brushAngle, float brushSBSFocus, float brushSBSScale)
|
||||
{
|
||||
_BorderColor = borderColor;
|
||||
_BorderWidth = borderWidth;
|
||||
_Color1 = color1;
|
||||
_Color2 = color2;
|
||||
_BrushType = brushType;
|
||||
_BrushAngle = brushAngle;
|
||||
_BrushSBSFocus = brushSBSFocus;
|
||||
_BrushSBSScale = brushSBSScale;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates Pen object using the BorderColor and BorderWidth properties.
|
||||
/// </summary>
|
||||
public Pen GetBorderPen(float scaleFactor, PenAlignment penAlignment)
|
||||
{
|
||||
Pen pen = new Pen(_BorderColor, (float)Math.Round(_BorderWidth * scaleFactor, 0));
|
||||
pen.Alignment = penAlignment;
|
||||
return pen;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a brush of the type specified by BrushType.
|
||||
/// </summary>
|
||||
/// <param name="path">The graphics path used to construct the brush.</param>
|
||||
public Brush GetBrush(GraphicsPath path)
|
||||
{
|
||||
return GetBrush(path, new PointF(0.5f, 0.5f), _BrushAngle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a brush of the type specified by BrushType.
|
||||
/// </summary>
|
||||
/// <param name="path">The graphics path used to construct the brush.</param>
|
||||
/// <param name="angle">The angle used for the gradients, allowing an override of BrushAngle</param>
|
||||
public Brush GetBrush(GraphicsPath path, float angle)
|
||||
{
|
||||
return GetBrush(path, new PointF(0.5f, 0.5f), angle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a brush of the type specified by BrushType.
|
||||
/// </summary>
|
||||
/// <param name="path">The graphics path used to construct the brush.</param>
|
||||
/// <param name="center">The center point of the gradient as a percentage value typically ranging from 0.0 to 1.0.</param>
|
||||
public Brush GetBrush(GraphicsPath path, PointF center)
|
||||
{
|
||||
return GetBrush(path, center, _BrushAngle);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a brush of the type specified by BrushType.
|
||||
/// </summary>
|
||||
/// <param name="path">The graphics path used to construct the brush.</param>
|
||||
/// <param name="center">The center point of the gradient as a percentage value typically ranging from 0.0 to 1.0.</param>
|
||||
/// <param name="angle">The angle used for the gradients, allowing an override of BrushAngle</param>
|
||||
public Brush GetBrush(GraphicsPath path, PointF center, float angle)
|
||||
{
|
||||
RectangleF rect;
|
||||
switch (_BrushType)
|
||||
{
|
||||
case eBrushTypes.Solid:
|
||||
return new SolidBrush(_Color1);
|
||||
case eBrushTypes.Linear:
|
||||
path.Flatten();
|
||||
rect = path.GetBounds();
|
||||
if (rect.Width > 0.0f && rect.Height > 0.0f)
|
||||
return new LinearGradientBrush(path.GetBounds(), _Color1, _Color2, angle, false);
|
||||
else
|
||||
return null;
|
||||
case eBrushTypes.Reflected:
|
||||
LinearGradientBrush lBrush = new LinearGradientBrush(path.GetBounds(), _Color1, _Color2, angle, false);
|
||||
lBrush.SetSigmaBellShape(_BrushSBSFocus, _BrushSBSScale);
|
||||
return lBrush;
|
||||
case eBrushTypes.Centered:
|
||||
PointF pt = new PointF();
|
||||
rect = path.GetBounds();
|
||||
PathGradientBrush pBrush = new PathGradientBrush(path);
|
||||
pt.X = rect.X + rect.Width * center.X;
|
||||
pt.Y = rect.Y + rect.Height * center.Y;
|
||||
pBrush.CenterPoint = pt;
|
||||
pBrush.CenterColor = _Color1;
|
||||
pBrush.SurroundColors = new Color[] { _Color2 };
|
||||
return pBrush;
|
||||
default:
|
||||
return new SolidBrush(_Color1);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates SolidBrushObject using Color1.
|
||||
/// </summary>
|
||||
public Brush GetSolidBrush()
|
||||
{
|
||||
return new SolidBrush(_Color1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a LinearGradientBrush object.
|
||||
/// </summary>
|
||||
/// <param name="path">The graphics path used to construct the brush.</param>
|
||||
/// <param name="angle">The gradient angle.</param>
|
||||
public LinearGradientBrush GetLinearBrush(GraphicsPath path, int angle)
|
||||
{
|
||||
return new LinearGradientBrush(path.GetBounds(), _Color1, _Color2, angle, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a PathGradientBrush object.
|
||||
/// </summary>
|
||||
/// <param name="path">The graphics path used to construct the brush.</param>
|
||||
/// <param name="center">The center point of the gradient.</param>
|
||||
public PathGradientBrush GetCenteredBrush(GraphicsPath path, PointF center)
|
||||
{
|
||||
PathGradientBrush brush;
|
||||
|
||||
brush = new PathGradientBrush(path);
|
||||
brush.CenterPoint = center;
|
||||
brush.CenterColor = _Color1;
|
||||
brush.SurroundColors = new Color[] { _Color2 };
|
||||
|
||||
return brush;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a LinearGradientBrush object.
|
||||
/// </summary>
|
||||
/// <param name="path">The graphics path used to construct the brush.</param>
|
||||
/// <param name="angle">The gradient angle.</param>
|
||||
public LinearGradientBrush GetReflectedBrush(GraphicsPath path, int angle)
|
||||
{
|
||||
return GetReflectedBrush(path, angle, 0.5f, 1.0f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a LinearGradientBrush object.
|
||||
/// </summary>
|
||||
/// <param name="path">The graphics path used to construct the brush.</param>
|
||||
/// <param name="angle">The gradient angle.</param>
|
||||
/// <param name="focus">The focus for the SigmaBellShape.</param>
|
||||
public LinearGradientBrush GetReflectedBrush(GraphicsPath path, int angle, float focus)
|
||||
{
|
||||
return GetReflectedBrush(path, angle, focus, 1.0f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a LinearGradientBrush object.
|
||||
/// </summary>
|
||||
/// <param name="path">The graphics path used to construct the brush.</param>
|
||||
/// <param name="angle">The gradient angle.</param>
|
||||
/// <param name="focus">The focus for the SigmaBellShape.</param>
|
||||
/// <param name="scale">The scale for the SigmaBellShape.</param>
|
||||
public LinearGradientBrush GetReflectedBrush(GraphicsPath path, int angle, float focus, float scale)
|
||||
{
|
||||
LinearGradientBrush brush = new LinearGradientBrush(path.GetBounds(), _Color1, _Color2, angle, false);
|
||||
brush.SetSigmaBellShape(focus, scale);
|
||||
return brush;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the PropertyChanged event.
|
||||
/// </summary>
|
||||
/// <param name="e">Event arguments</param>
|
||||
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
|
||||
{
|
||||
if (PropertyChanged != null)
|
||||
PropertyChanged(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enumeration containing predefined brush types for the ColorData class.
|
||||
/// </summary>
|
||||
public enum eBrushTypes
|
||||
{
|
||||
/// <summary>
|
||||
/// Solid brush.
|
||||
/// </summary>
|
||||
Solid,
|
||||
/// <summary>
|
||||
/// Linear gradient brush.
|
||||
/// </summary>
|
||||
Linear,
|
||||
|
||||
/// <summary>
|
||||
/// Centered path gradient brush.
|
||||
/// </summary>
|
||||
Centered,
|
||||
|
||||
/// <summary>
|
||||
/// Reflected linear gradient brush.
|
||||
/// </summary>
|
||||
Reflected
|
||||
}
|
||||
|
||||
}
|
30
PROMS/DotNetBar Source Code/AnalogClock/MathHelper.cs
Normal file
30
PROMS/DotNetBar Source Code/AnalogClock/MathHelper.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
|
||||
namespace DevComponents.DotNetBar
|
||||
{
|
||||
/// <summary>
|
||||
/// Math helper class
|
||||
/// </summary>
|
||||
internal static class MathHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts radians to degrees.
|
||||
/// </summary>
|
||||
/// <param name="radians">Value to be converted in radians.</param>
|
||||
/// <returns>Converted value in degrees.</returns>
|
||||
public static double GetDegrees(double radians)
|
||||
{
|
||||
return radians * (180.0 / Math.PI);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts degrees to radians.
|
||||
/// </summary>
|
||||
/// <param name="degrees">Value to be converted in degrees.</param>
|
||||
/// <returns>Converted value in radians.</returns>
|
||||
public static double GetRadians(double degrees)
|
||||
{
|
||||
return degrees * (Math.PI / 180.0);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user