DotNet 4.8.1 build of DotNetBar
This commit is contained in:
@@ -0,0 +1,367 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.Instrumentation
|
||||
{
|
||||
public class DigitalElement : NumericElement
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private int _ElemWidth;
|
||||
private int _ElemHeight;
|
||||
private int _ElemWidthHalf;
|
||||
private int _ElemHeightHalf;
|
||||
|
||||
private int _SegStep;
|
||||
private int _SegWidth;
|
||||
private int _SegWidthHalf;
|
||||
|
||||
private bool _NeedRecalcSegments;
|
||||
private bool _NeedSegments;
|
||||
|
||||
private Point[][] _SegPoints;
|
||||
private int _Segments;
|
||||
|
||||
#endregion
|
||||
|
||||
public DigitalElement(NumericIndicator numIndicator, int segments, int points)
|
||||
: base(numIndicator)
|
||||
{
|
||||
_SegPoints = new Point[segments][];
|
||||
|
||||
for (int i = 0; i < segments; i++)
|
||||
_SegPoints[i] = new Point[points];
|
||||
|
||||
_NeedRecalcSegments = true;
|
||||
_NeedSegments = true;
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region Value
|
||||
|
||||
public override char Value
|
||||
{
|
||||
get { return (base.Value); }
|
||||
|
||||
set
|
||||
{
|
||||
if (base.Value != value)
|
||||
{
|
||||
base.Value = value;
|
||||
|
||||
_NeedSegments = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal properties
|
||||
|
||||
#region ElemWidth
|
||||
|
||||
internal int ElemWidth
|
||||
{
|
||||
get { return (_ElemWidth); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ElemWidthHalf
|
||||
|
||||
internal int ElemWidthHalf
|
||||
{
|
||||
get { return (_ElemWidthHalf); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ElemHeight
|
||||
|
||||
internal int ElemHeight
|
||||
{
|
||||
get { return (_ElemHeight); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ElemHeightHalf
|
||||
|
||||
internal int ElemHeightHalf
|
||||
{
|
||||
get { return (_ElemHeightHalf); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region NeedRecalcSegments
|
||||
|
||||
internal bool NeedRecalcSegments
|
||||
{
|
||||
get { return (_NeedRecalcSegments); }
|
||||
set { _NeedRecalcSegments = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Segments
|
||||
|
||||
internal int Segments
|
||||
{
|
||||
get { return (_Segments); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Segments != value)
|
||||
{
|
||||
_Segments = value;
|
||||
|
||||
NumIndicator.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SegPoints
|
||||
|
||||
internal Point[][] SegPoints
|
||||
{
|
||||
get { return (_SegPoints); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SegStep
|
||||
|
||||
internal int SegStep
|
||||
{
|
||||
get { return (_SegStep); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SegWidth
|
||||
|
||||
internal int SegWidth
|
||||
{
|
||||
get { return (_SegWidth); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SegWidthHalf
|
||||
|
||||
internal int SegWidthHalf
|
||||
{
|
||||
get { return (_SegWidthHalf); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region RecalcLayout
|
||||
|
||||
public override void RecalcLayout()
|
||||
{
|
||||
if (NeedRecalcLayout == true)
|
||||
{
|
||||
base.RecalcLayout();
|
||||
|
||||
if (_NeedRecalcSegments == true)
|
||||
{
|
||||
_NeedRecalcSegments = false;
|
||||
|
||||
_ElemWidth = 50;
|
||||
_ElemHeight = 100;
|
||||
|
||||
_ElemWidthHalf = _ElemWidth / 2;
|
||||
_ElemHeightHalf = _ElemHeight / 2;
|
||||
|
||||
_SegWidth = (int)(_ElemWidth * NumIndicator.SegmentWidth / 4);
|
||||
_SegWidth = Math.Max(2, _SegWidth);
|
||||
|
||||
_SegWidthHalf = _SegWidth / 2;
|
||||
_SegStep = _SegWidth / 3;
|
||||
|
||||
RecalcSegments();
|
||||
}
|
||||
}
|
||||
|
||||
if (_NeedSegments == true)
|
||||
{
|
||||
_NeedSegments = false;
|
||||
|
||||
_Segments = NumIndicator.GaugeControl.
|
||||
OnGetDigitSegments(NumIndicator, Value, GetDigitSegments(Value));
|
||||
}
|
||||
}
|
||||
|
||||
#region RecalcSegments
|
||||
|
||||
public virtual void RecalcSegments()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnGetDigitSegments
|
||||
|
||||
public virtual int GetDigitSegments(char value)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RefreshElements
|
||||
|
||||
internal override void RefreshElements()
|
||||
{
|
||||
_NeedSegments = true;
|
||||
|
||||
NeedRecalcLayout = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnPaint
|
||||
|
||||
public override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
if (Bounds.Width > 0 && Bounds.Height > 0)
|
||||
{
|
||||
RenderBackground(g, Bounds);
|
||||
|
||||
int dx = (int)(Bounds.Width * .2f);
|
||||
int dy = (int)(Bounds.Height * .2f);
|
||||
|
||||
Rectangle r = Bounds;
|
||||
r.Inflate(-dx, -dy);
|
||||
|
||||
Rectangle srcRect = new Rectangle(0, 0, _ElemWidth, _ElemHeight);
|
||||
GraphicsContainer containerState = g.BeginContainer(r, srcRect, GraphicsUnit.Pixel);
|
||||
|
||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
g.PixelOffsetMode = PixelOffsetMode.Default;
|
||||
|
||||
if (NumIndicator.ShearFactor != 0)
|
||||
{
|
||||
Matrix trans = new Matrix();
|
||||
trans.Shear(NumIndicator.ShearFactor, 0.0F);
|
||||
|
||||
g.Transform = trans;
|
||||
}
|
||||
|
||||
Brush brushOn = BrushOn;
|
||||
Brush brushOff = BrushOff;
|
||||
|
||||
RenderSegments(g, brushOn, brushOff);
|
||||
RenderPoints(g, brushOn, brushOff);
|
||||
|
||||
g.EndContainer(containerState);
|
||||
}
|
||||
}
|
||||
|
||||
#region RenderBackground
|
||||
|
||||
private void RenderBackground(Graphics g, Rectangle r)
|
||||
{
|
||||
if (NumIndicator.ShearFactor == 0)
|
||||
{
|
||||
if (BackColor != null && BackColor.IsEmpty == false)
|
||||
{
|
||||
using (Brush br = BackColor.GetBrush(r))
|
||||
g.FillRectangle(br, r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RenderSegments
|
||||
|
||||
private void RenderSegments(Graphics g, Brush brushOn, Brush brushOff)
|
||||
{
|
||||
for (int i = 0; i < _SegPoints.Length; i++)
|
||||
{
|
||||
if ((_Segments & (1 << i)) != 0)
|
||||
{
|
||||
if (brushOn != null)
|
||||
g.FillPolygon(brushOn, _SegPoints[i]);
|
||||
}
|
||||
else if (ShowDimSegments == true)
|
||||
{
|
||||
if (brushOff != null)
|
||||
g.FillPolygon(brushOff, _SegPoints[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RenderPoints
|
||||
|
||||
private void RenderPoints(Graphics g, Brush brushOn, Brush brushOff)
|
||||
{
|
||||
int dpWidth = (_SegWidth * 3) / 2;
|
||||
|
||||
if (ColonPointsOn == true)
|
||||
RenderColonPoints(g, brushOn, dpWidth);
|
||||
|
||||
else if (ShowDimColonPoints == true)
|
||||
RenderColonPoints(g, brushOff, dpWidth);
|
||||
|
||||
if (DecimalPointOn == true)
|
||||
RenderDecimalPoint(g, brushOn, dpWidth);
|
||||
|
||||
else if (ShowDimDecimalPoint == true)
|
||||
RenderDecimalPoint(g, brushOff, dpWidth);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RenderDecimalPoint
|
||||
|
||||
private void RenderDecimalPoint(Graphics g, Brush br, int dpWidth)
|
||||
{
|
||||
if (br != null)
|
||||
{
|
||||
g.FillEllipse(br, _ElemWidth + _SegWidth,
|
||||
_ElemHeight - dpWidth, dpWidth, dpWidth);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RenderColonPoints
|
||||
|
||||
private void RenderColonPoints(Graphics g, Brush br, int dpWidth)
|
||||
{
|
||||
if (br != null)
|
||||
{
|
||||
g.FillEllipse(br, _ElemWidth + _SegWidth,
|
||||
_ElemHeightHalf - _SegWidth * 3, dpWidth, dpWidth);
|
||||
|
||||
g.FillEllipse(br, _ElemWidth + _SegWidth,
|
||||
_ElemHeightHalf + _SegWidth * 2, dpWidth, dpWidth);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,847 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.Text;
|
||||
using DevComponents.Instrumentation.Primitives;
|
||||
|
||||
namespace DevComponents.Instrumentation
|
||||
{
|
||||
public class GaugeIndicator : GaugeItem
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private bool _AutoSize;
|
||||
private bool _UnderScale;
|
||||
private int _RefreshRate;
|
||||
|
||||
private double _MinValue;
|
||||
private double _MaxValue;
|
||||
private double _Value;
|
||||
|
||||
private GradientFillColor _BackColor;
|
||||
|
||||
private SizeF _Size;
|
||||
private PointF _Location;
|
||||
private Rectangle _Bounds;
|
||||
private Point _Center;
|
||||
|
||||
private Font _Font;
|
||||
private string _Text;
|
||||
private string _EmptyString;
|
||||
private string _OverRangeString;
|
||||
private string _UnderRangeString;
|
||||
|
||||
private bool _Dampening;
|
||||
private double _DampeningSweepTime;
|
||||
|
||||
private double _DValue;
|
||||
private double _DeltaValue;
|
||||
private double _DStartValue;
|
||||
private double _DEndValue;
|
||||
|
||||
private long _DStartTicks;
|
||||
private long _DRefreshTicks;
|
||||
|
||||
private GaugeControl _GaugeControl;
|
||||
|
||||
#endregion
|
||||
|
||||
public GaugeIndicator()
|
||||
{
|
||||
_AutoSize = true;
|
||||
|
||||
BackColor.BorderColor = Color.Black;
|
||||
|
||||
_Size = new SizeF(.07f, .07f);
|
||||
_Location = new PointF(.5f, .7f);
|
||||
|
||||
_UnderScale = true;
|
||||
_RefreshRate = 10;
|
||||
|
||||
_EmptyString = "-";
|
||||
_OverRangeString = "Error";
|
||||
_UnderRangeString = "Error";
|
||||
|
||||
_MinValue = 0;
|
||||
_MaxValue = 100;
|
||||
_Value = double.NaN;
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region AutoSize
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the indicator contents are auto sized
|
||||
/// </summary>
|
||||
[Browsable(true)]
|
||||
[Category("Behavior"), DefaultValue(true)]
|
||||
[Editor("DevComponents.Instrumentation.Design.AngleRangeValueEditor, DevComponents.Instrumentation.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=76cb4c6eb576bca5", typeof(UITypeEditor))]
|
||||
[Description("Indicates whether the indicator contents are auto sized.")]
|
||||
public bool AutoSize
|
||||
{
|
||||
get { return (_AutoSize); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_AutoSize != value)
|
||||
{
|
||||
_AutoSize = value;
|
||||
|
||||
OnGaugeItemChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BackColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the BackColor
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Appearance")]
|
||||
[Description("Indicates the BackColor.")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public GradientFillColor BackColor
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_BackColor == null)
|
||||
{
|
||||
_BackColor = new GradientFillColor();
|
||||
_BackColor.ColorTableChanged += BackColorColorTableChanged;
|
||||
}
|
||||
|
||||
return (_BackColor);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_BackColor != null)
|
||||
_BackColor.ColorTableChanged -= BackColorColorTableChanged;
|
||||
|
||||
_BackColor = value;
|
||||
|
||||
if (_BackColor != null)
|
||||
_BackColor.ColorTableChanged += BackColorColorTableChanged;
|
||||
|
||||
OnGaugeItemChanged();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Bounds
|
||||
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public Rectangle Bounds
|
||||
{
|
||||
get { return (_Bounds); }
|
||||
internal set { _Bounds = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DampeningSweepTime
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time it takes for the indicator to
|
||||
/// change from its minimum to maximum value, measured in seconds
|
||||
/// </summary>
|
||||
[Browsable(true)]
|
||||
[Category("Behavior"), DefaultValue(0d)]
|
||||
[Description("Indicates the time it takes for the indicator to change from its minimum to maximum value, measured in seconds.")]
|
||||
public double DampeningSweepTime
|
||||
{
|
||||
get { return (_DampeningSweepTime); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_DampeningSweepTime != value)
|
||||
{
|
||||
_DampeningSweepTime = value;
|
||||
|
||||
OnGaugeItemChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region EmptyString
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the text string to display when the Indicator Value is empty (double.NaN)
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Behavior"), DefaultValue("-")]
|
||||
[Description("Indicates the text string to display when the Indicator Value is empty (double.NaN).")]
|
||||
public string EmptyString
|
||||
{
|
||||
get { return (_EmptyString); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_EmptyString != value)
|
||||
{
|
||||
_EmptyString = value;
|
||||
|
||||
OnGaugeItemChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Font
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the text Font
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Appearance")]
|
||||
[Description("Indicates the text Font.")]
|
||||
public Font Font
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Font == null)
|
||||
_Font = new Font("Microsoft SanSerif", 12);
|
||||
|
||||
return (_Font);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_Font != null)
|
||||
_Font.Dispose();
|
||||
|
||||
_Font = value;
|
||||
|
||||
AbsFont = null;
|
||||
|
||||
OnGaugeItemChanged(true);
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
internal virtual bool ShouldSerializeFont()
|
||||
{
|
||||
if (_Font == null)
|
||||
return (false);
|
||||
|
||||
using (Font font = new Font("Microsoft SanSerif", 12))
|
||||
return (_Font.Equals(font) == false);
|
||||
}
|
||||
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
internal virtual void ResetFont()
|
||||
{
|
||||
Font = new Font("Microsoft SanSerif", 12);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GaugeControl
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the owning GaugeControl
|
||||
/// </summary>
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public GaugeControl GaugeControl
|
||||
{
|
||||
get { return (_GaugeControl); }
|
||||
internal set { _GaugeControl = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Location
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the location of the image area, specified as a percentage
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Layout")]
|
||||
[Editor("DevComponents.Instrumentation.Design.LocationEditor, DevComponents.Instrumentation.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=76cb4c6eb576bca5", typeof(UITypeEditor))]
|
||||
[Description("Indicates the location of the image area, specified as a percentage.")]
|
||||
[TypeConverter(typeof(PointFConverter))]
|
||||
public PointF Location
|
||||
{
|
||||
get { return (_Location); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Location != value)
|
||||
{
|
||||
_Location = value;
|
||||
|
||||
OnGaugeItemChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeLocation()
|
||||
{
|
||||
return (_Location.X != .5f || _Location.Y != .7f);
|
||||
}
|
||||
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetLocation()
|
||||
{
|
||||
_Location = new PointF(.5f, .7f);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MaxValue
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Maximum value for the Indicator
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Behavior"), DefaultValue(100d)]
|
||||
[Description("Indicates the Maximum value for the Indicator.")]
|
||||
public double MaxValue
|
||||
{
|
||||
get { return (_MaxValue); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_MaxValue != value)
|
||||
{
|
||||
_MaxValue = value;
|
||||
|
||||
DValue = _Value;
|
||||
|
||||
OnGaugeItemChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MinValue
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Minimum value for the Indicator
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Behavior"), DefaultValue(0d)]
|
||||
[Description("Indicates the Minimum value for the Indicator.")]
|
||||
public double MinValue
|
||||
{
|
||||
get { return (_MinValue); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_MinValue != value)
|
||||
{
|
||||
_MinValue = value;
|
||||
|
||||
DValue = _Value;
|
||||
|
||||
OnGaugeItemChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OverRangeString
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the text string to display when the Indicator Value is over the set MaxValue range
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Behavior"), DefaultValue("Error")]
|
||||
[Description("Indicates the text string to display when the Indicator Value is over the set MaxValue range.")]
|
||||
public string OverRangeString
|
||||
{
|
||||
get { return (_OverRangeString); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_OverRangeString != value)
|
||||
{
|
||||
_OverRangeString = value;
|
||||
|
||||
OnGaugeItemChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RefreshRate
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets how often the indicator is refreshed per second
|
||||
/// </summary>
|
||||
[Browsable(true)]
|
||||
[Category("Behavior"), DefaultValue(10)]
|
||||
[Editor("DevComponents.Instrumentation.Design.AngleRangeValueEditor, DevComponents.Instrumentation.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=76cb4c6eb576bca5", typeof(UITypeEditor))]
|
||||
[Description("Indicates how often the indicator is refreshed per second.")]
|
||||
public int RefreshRate
|
||||
{
|
||||
get { return (_RefreshRate); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_RefreshRate != value)
|
||||
{
|
||||
if (value <= 0 || value > 1000)
|
||||
throw new ArgumentException("Value must be between 1 and 100");
|
||||
|
||||
_RefreshRate = value;
|
||||
|
||||
OnGaugeItemChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Size
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the size of the indicator, specified as a percentage
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Layout")]
|
||||
[Editor("DevComponents.Instrumentation.Design.SizeEditor, DevComponents.Instrumentation.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=76cb4c6eb576bca5", typeof(UITypeEditor))]
|
||||
[Description("Determines the size of the indicator, specified as a percentage.")]
|
||||
public SizeF Size
|
||||
{
|
||||
get { return (_Size); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Size != value)
|
||||
{
|
||||
_Size = value;
|
||||
|
||||
OnGaugeItemChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public bool ShouldSerializeSize()
|
||||
{
|
||||
return (_Size.Width != .07f || _Size.Height != .07f);
|
||||
}
|
||||
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public void ResetSize()
|
||||
{
|
||||
_Size = new SizeF(.07f, .07f);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Text
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the text to be displayed
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Behavior"), DefaultValue(null)]
|
||||
[Description("Indicates the text to be displayed.")]
|
||||
public string Text
|
||||
{
|
||||
get { return (_Text); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Text != value)
|
||||
{
|
||||
_Text = value;
|
||||
|
||||
OnGaugeItemChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UnderRangeString
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the text string to display when the Indicator Value is under the set MinValue range
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Behavior"), DefaultValue("Error")]
|
||||
[Description("Indicates the text string to display when the Indicator Value is under the set MinValue range.")]
|
||||
public string UnderRangeString
|
||||
{
|
||||
get { return (_UnderRangeString); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_UnderRangeString != value)
|
||||
{
|
||||
_UnderRangeString = value;
|
||||
|
||||
OnGaugeItemChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UnderScale
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the indicator is displayed under the scale
|
||||
/// </summary>
|
||||
[Browsable(true)]
|
||||
[Category("Layout"), DefaultValue(true)]
|
||||
[Editor("DevComponents.Instrumentation.Design.AngleRangeValueEditor, DevComponents.Instrumentation.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=76cb4c6eb576bca5", typeof(UITypeEditor))]
|
||||
[Description("Indicates whether the indicator is displayed under the scale.")]
|
||||
public bool UnderScale
|
||||
{
|
||||
get { return (_UnderScale); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_UnderScale != value)
|
||||
{
|
||||
_UnderScale = value;
|
||||
|
||||
OnGaugeItemChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Value
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the indicator value
|
||||
/// </summary>
|
||||
[Browsable(true)]
|
||||
[Category("Behavior"), DefaultValue(double.NaN)]
|
||||
[Description("Indicates the indicator value.")]
|
||||
public double Value
|
||||
{
|
||||
get { return (_Value); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Value != value)
|
||||
{
|
||||
_Value = value;
|
||||
|
||||
OnValueChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ValueEx
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value of the indicator - but with no dampening
|
||||
/// </summary>
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public double ValueEx
|
||||
{
|
||||
get { return (_Value); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Value != value)
|
||||
{
|
||||
_Value = value;
|
||||
|
||||
OnValueChanged(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal properties
|
||||
|
||||
#region AbsFont
|
||||
|
||||
// ReSharper disable ValueParameterNotUsed
|
||||
internal virtual Font AbsFont
|
||||
{
|
||||
get { return (Font); }
|
||||
set { }
|
||||
}
|
||||
// ReSharper restore ValueParameterNotUsed
|
||||
|
||||
#endregion
|
||||
|
||||
#region Center
|
||||
|
||||
internal Point Center
|
||||
{
|
||||
get { return (_Center); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DValue
|
||||
|
||||
internal double DValue
|
||||
{
|
||||
get { return (_DValue); }
|
||||
|
||||
set
|
||||
{
|
||||
_DValue = value;
|
||||
|
||||
if (GaugeControl != null)
|
||||
GaugeControl.DValueChange = true;
|
||||
|
||||
OnGaugeItemChanged(true);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event processing
|
||||
|
||||
#region BackColor processing
|
||||
|
||||
void BackColorColorTableChanged(object sender, EventArgs e)
|
||||
{
|
||||
OnGaugeItemChanged(true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnValueChanged
|
||||
|
||||
internal virtual void OnValueChanged(bool dampen)
|
||||
{
|
||||
if (GaugeControl != null && Visible == true)
|
||||
{
|
||||
if (GaugeControl.InDesignMode == false)
|
||||
{
|
||||
if (_DValue < _Value)
|
||||
{
|
||||
double start = Math.Max(_MinValue, _DValue);
|
||||
|
||||
if (start < _MaxValue)
|
||||
{
|
||||
if (StartDampening(dampen, start, Math.Min(_MaxValue, _Value)))
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (_DValue > _Value)
|
||||
{
|
||||
double start = Math.Min(_MaxValue, _DValue);
|
||||
|
||||
if (start > _MinValue)
|
||||
{
|
||||
if (StartDampening(dampen, start, Math.Max(_MinValue, _Value)))
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DValue = _Value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Dampening support
|
||||
|
||||
#region StartDampening
|
||||
|
||||
private bool StartDampening(bool dampen, double start, double end)
|
||||
{
|
||||
double dampenTime = _DampeningSweepTime;
|
||||
|
||||
if (GaugeControl.IsHandleCreated &&
|
||||
dampen == true && dampenTime > 0)
|
||||
{
|
||||
_DStartValue = start;
|
||||
_DEndValue = end;
|
||||
_DeltaValue = (_MaxValue - _MinValue) / (dampenTime * 1000);
|
||||
|
||||
_DStartTicks = DateTime.Now.Ticks;
|
||||
|
||||
if (_Dampening == false)
|
||||
{
|
||||
_Dampening = true;
|
||||
_DRefreshTicks = _DStartTicks;
|
||||
|
||||
_GaugeControl.DampeningUpdate += DampeningUpdate;
|
||||
_GaugeControl.StartDampening();
|
||||
}
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
return (false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DampeningUpdate
|
||||
|
||||
void DampeningUpdate(object sender, EventArgs e)
|
||||
{
|
||||
SetIndicatorValue();
|
||||
|
||||
if (_DValue == _DEndValue)
|
||||
{
|
||||
if (_Dampening == true)
|
||||
{
|
||||
_GaugeControl.DampeningUpdate -= DampeningUpdate;
|
||||
_GaugeControl.StopDampening();
|
||||
|
||||
_Dampening = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetIndicatorValue
|
||||
|
||||
private void SetIndicatorValue()
|
||||
{
|
||||
long now = DateTime.Now.Ticks;
|
||||
|
||||
double ms = new TimeSpan(now - _DStartTicks).TotalMilliseconds;
|
||||
double delta = _DeltaValue * ms;
|
||||
|
||||
if (delta > 0)
|
||||
{
|
||||
double n = (_DValue <= _Value)
|
||||
? Math.Min(_DStartValue + delta, _DEndValue)
|
||||
: Math.Max(_DStartValue - delta, _DEndValue);
|
||||
|
||||
if (n == _DEndValue ||
|
||||
new TimeSpan(now - _DRefreshTicks).TotalMilliseconds > 1000 / _RefreshRate)
|
||||
{
|
||||
_DRefreshTicks = now;
|
||||
|
||||
DValue = n;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region RecalcLayout
|
||||
|
||||
public override void RecalcLayout()
|
||||
{
|
||||
base.RecalcLayout();
|
||||
|
||||
bool autoCenter = _GaugeControl.Frame.AutoCenter;
|
||||
_Center = _GaugeControl.GetAbsPoint(_Location, autoCenter);
|
||||
|
||||
Size size = _GaugeControl.GetAbsSize(_Size, autoCenter);
|
||||
|
||||
_Bounds = new Rectangle(
|
||||
_Center.X - size.Width / 2, _Center.Y - size.Height / 2,
|
||||
size.Width, size.Height);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Contains
|
||||
|
||||
internal virtual bool Contains(Point pt)
|
||||
{
|
||||
return (Bounds.Contains(pt));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetOverrideString
|
||||
|
||||
protected string GetOverrideString()
|
||||
{
|
||||
string s = null;
|
||||
|
||||
if (String.IsNullOrEmpty(Text) == false)
|
||||
s = Text;
|
||||
|
||||
else if (Value.Equals(double.NaN) == true)
|
||||
s = _EmptyString ?? "";
|
||||
|
||||
else if (Value < MinValue)
|
||||
s = _UnderRangeString;
|
||||
|
||||
else if (Value > MaxValue)
|
||||
s = _OverRangeString ?? "";
|
||||
|
||||
return (s);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ProcessTemplateText
|
||||
|
||||
protected override void ProcessTemplateText(
|
||||
GaugeControl gauge, StringBuilder sb, string key, string data)
|
||||
{
|
||||
if (key.Equals("Value") == true)
|
||||
{
|
||||
sb.Append(string.IsNullOrEmpty(data)
|
||||
? _Value.ToString()
|
||||
: String.Format("{0:" + data + "}", _Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
base.ProcessTemplateText(gauge, sb, key, data);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyToItem
|
||||
|
||||
public override void CopyToItem(GaugeItem copy)
|
||||
{
|
||||
GaugeIndicator c = copy as GaugeIndicator;
|
||||
|
||||
if (c != null)
|
||||
{
|
||||
base.CopyToItem(c);
|
||||
|
||||
c.AutoSize = _AutoSize;
|
||||
|
||||
if (_BackColor != null)
|
||||
c.BackColor = (GradientFillColor)_BackColor.Clone();
|
||||
|
||||
c.DampeningSweepTime = _DampeningSweepTime;
|
||||
c.EmptyString = _EmptyString;
|
||||
|
||||
if (_Font != null)
|
||||
c.Font = (Font)_Font.Clone();
|
||||
|
||||
c.Location = _Location;
|
||||
c.MaxValue = _MaxValue;
|
||||
c.MinValue = _MinValue;
|
||||
c.OverRangeString = _OverRangeString;
|
||||
c.RefreshRate = _RefreshRate;
|
||||
c.Size = _Size;
|
||||
c.Text = _Text;
|
||||
c.UnderRangeString = _UnderRangeString;
|
||||
c.UnderScale = _UnderScale;
|
||||
c.Value = _Value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,231 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using DevComponents.Instrumentation.Primitives;
|
||||
|
||||
namespace DevComponents.Instrumentation
|
||||
{
|
||||
public class IndicatorRangeCollection : GenericCollection<IndicatorRange>
|
||||
{
|
||||
#region ICloneable Members
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
IndicatorRangeCollection copy = new IndicatorRangeCollection();
|
||||
|
||||
CopyToItem(copy);
|
||||
|
||||
return (copy);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyToItem
|
||||
|
||||
internal void CopyToItem(IndicatorRangeCollection copy)
|
||||
{
|
||||
foreach (IndicatorRange item in this)
|
||||
{
|
||||
IndicatorRange ic = new IndicatorRange();
|
||||
|
||||
item.CopyToItem(ic);
|
||||
|
||||
copy.Add(ic);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class IndicatorRange : GaugeItem
|
||||
{
|
||||
#region Events
|
||||
|
||||
[Description("Occurs when the IndicatorRange changes.")]
|
||||
public event EventHandler<EventArgs> IndicatorRangeChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private variables
|
||||
|
||||
private double _StartValue;
|
||||
private double _EndValue;
|
||||
|
||||
private GradientFillColor _BackColor;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Hidden properties
|
||||
|
||||
#region Tooltip
|
||||
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new string Tooltip
|
||||
{
|
||||
get { return (base.Tooltip); }
|
||||
set { base.Tooltip = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Visible
|
||||
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public new bool Visible
|
||||
{
|
||||
get { return (base.Visible); }
|
||||
set { base.Visible = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region BackColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the BackColor
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Appearance")]
|
||||
[Description("Indicates the BackColor.")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
public GradientFillColor BackColor
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_BackColor == null)
|
||||
{
|
||||
_BackColor = new GradientFillColor();
|
||||
_BackColor.ColorTableChanged += BackColor_ColorTableChanged;
|
||||
}
|
||||
|
||||
return (_BackColor);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_BackColor != null)
|
||||
_BackColor.ColorTableChanged -= BackColor_ColorTableChanged;
|
||||
|
||||
_BackColor = value;
|
||||
|
||||
if (_BackColor != null)
|
||||
_BackColor.ColorTableChanged += BackColor_ColorTableChanged;
|
||||
|
||||
OnIndicatorRangeChanged();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region EndValue
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Ending range value
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Behavior"), DefaultValue(double.NaN)]
|
||||
[Description("Indicates the Ending range value.")]
|
||||
public double EndValue
|
||||
{
|
||||
get { return (_EndValue); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_EndValue != value)
|
||||
{
|
||||
_EndValue = value;
|
||||
|
||||
OnIndicatorRangeChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region StartValue
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Starting range value
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Behavior"), DefaultValue(double.NaN)]
|
||||
[Description("Indicates the Starting range value.")]
|
||||
public double StartValue
|
||||
{
|
||||
get { return (_StartValue); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_StartValue != value)
|
||||
{
|
||||
_StartValue = value;
|
||||
|
||||
OnIndicatorRangeChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event processing
|
||||
|
||||
#region BackColor processing
|
||||
|
||||
void BackColor_ColorTableChanged(object sender, EventArgs e)
|
||||
{
|
||||
OnIndicatorRangeChanged();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnIndicatorRangeChanged
|
||||
|
||||
internal void OnIndicatorRangeChanged()
|
||||
{
|
||||
if (IndicatorRangeChanged != null)
|
||||
IndicatorRangeChanged(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
IndicatorRange copy = new IndicatorRange();
|
||||
|
||||
CopyToItem(copy);
|
||||
|
||||
return (copy);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyToItem
|
||||
|
||||
public override void CopyToItem(GaugeItem copy)
|
||||
{
|
||||
IndicatorRange c = copy as IndicatorRange;
|
||||
|
||||
if (c != null)
|
||||
{
|
||||
base.CopyToItem(c);
|
||||
|
||||
c.EndValue = _EndValue;
|
||||
c.StartValue = _StartValue;
|
||||
|
||||
if (_BackColor != null)
|
||||
c.BackColor = (GradientFillColor) _BackColor.Clone();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.Instrumentation
|
||||
{
|
||||
public class MechanicalElement : NumericElement
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private int _Descent;
|
||||
|
||||
#endregion
|
||||
|
||||
public MechanicalElement(NumericIndicator numIndicator)
|
||||
: base(numIndicator)
|
||||
{
|
||||
}
|
||||
|
||||
#region RecalcLayout
|
||||
|
||||
public override void RecalcLayout()
|
||||
{
|
||||
base.RecalcLayout();
|
||||
|
||||
Font font = NumIndicator.AbsFont;
|
||||
FontFamily family = new FontFamily(font.Name);
|
||||
|
||||
int descent = family.GetCellDescent(font.Style);
|
||||
float descentPixel = font.Size * descent / family.GetEmHeight(font.Style);
|
||||
|
||||
_Descent = (int)(descentPixel / 2) + 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnPaint
|
||||
|
||||
public override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
|
||||
if (Bounds.Width > 0 && Bounds.Height > 0)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
if (BackColor != null && BackColor.IsEmpty == false)
|
||||
{
|
||||
Rectangle r = GetPaddedRect(Bounds);
|
||||
|
||||
using (Brush br = BackColor.GetBrush(r))
|
||||
g.FillRectangle(br, r);
|
||||
}
|
||||
|
||||
using (StringFormat sf = new StringFormat())
|
||||
{
|
||||
sf.Alignment = StringAlignment.Center;
|
||||
sf.LineAlignment = StringAlignment.Center;
|
||||
|
||||
Rectangle r = Bounds;
|
||||
r.Y += _Descent;
|
||||
|
||||
g.DrawString(Value.ToString(), NumIndicator.AbsFont, BrushOn, r, sf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,441 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.Instrumentation
|
||||
{
|
||||
public class NumericElement : IDisposable
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private Rectangle _Bounds;
|
||||
private NumericIndicator _NumIndicator;
|
||||
|
||||
private char _Value;
|
||||
private bool _ColonPointsOn;
|
||||
private bool _DecimalPointOn;
|
||||
private bool _ShowDimColonPoints;
|
||||
private bool _ShowDimDecimalPoint;
|
||||
private bool _ShowDimSegments;
|
||||
|
||||
private Color _DigitColor;
|
||||
private Color _DigitDimColor;
|
||||
private GradientFillColor _BackColor;
|
||||
|
||||
private Brush _BrushOn;
|
||||
private Brush _BrushOff;
|
||||
|
||||
private bool _NeedRecalcLayout;
|
||||
|
||||
private bool _InRender;
|
||||
|
||||
#endregion
|
||||
|
||||
public NumericElement(NumericIndicator numIndicator)
|
||||
{
|
||||
_NumIndicator = numIndicator;
|
||||
|
||||
_ShowDimColonPoints = true;
|
||||
_ShowDimDecimalPoint = true;
|
||||
_ShowDimSegments = true;
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region BackColor
|
||||
|
||||
public GradientFillColor BackColor
|
||||
{
|
||||
get { return (_BackColor); }
|
||||
|
||||
set
|
||||
{
|
||||
_BackColor = value;
|
||||
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Bounds
|
||||
|
||||
public Rectangle Bounds
|
||||
{
|
||||
get { return (_Bounds); }
|
||||
|
||||
internal set
|
||||
{
|
||||
if (_Bounds.Equals(value) == false)
|
||||
{
|
||||
_Bounds = value;
|
||||
|
||||
_NeedRecalcLayout = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ColonPointsOn
|
||||
|
||||
public bool ColonPointsOn
|
||||
{
|
||||
get { return (_ColonPointsOn); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_ColonPointsOn != value)
|
||||
{
|
||||
_ColonPointsOn = value;
|
||||
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DecimalPointOn
|
||||
|
||||
public bool DecimalPointOn
|
||||
{
|
||||
get { return (_DecimalPointOn); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_DecimalPointOn != value)
|
||||
{
|
||||
_DecimalPointOn = value;
|
||||
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DigitColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Digit Color
|
||||
/// </summary>
|
||||
public Color DigitColor
|
||||
{
|
||||
get { return (_DigitColor); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_DigitColor != value)
|
||||
{
|
||||
BrushOn = null;
|
||||
_DigitColor = value;
|
||||
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DigitDimColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default Digit Dim Color (Dim LED color)
|
||||
/// </summary>
|
||||
public Color DigitDimColor
|
||||
{
|
||||
get { return (_DigitDimColor); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_DigitDimColor != value)
|
||||
{
|
||||
BrushOff = null;
|
||||
_DigitDimColor = value;
|
||||
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowDimColonPoints
|
||||
|
||||
public bool ShowDimColonPoints
|
||||
{
|
||||
get { return (_ShowDimColonPoints); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_ShowDimColonPoints != value)
|
||||
{
|
||||
_ShowDimColonPoints = value;
|
||||
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowDimDecimalPoint
|
||||
|
||||
public bool ShowDimDecimalPoint
|
||||
{
|
||||
get { return (_ShowDimDecimalPoint); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_ShowDimDecimalPoint != value)
|
||||
{
|
||||
_ShowDimDecimalPoint = value;
|
||||
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ShowDimSegments
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the whether dim segments are displayed
|
||||
/// </summary>
|
||||
public bool ShowDimSegments
|
||||
{
|
||||
get { return (_ShowDimSegments); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_ShowDimSegments != value)
|
||||
{
|
||||
BrushOff = null;
|
||||
_ShowDimSegments = value;
|
||||
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Value
|
||||
|
||||
public virtual char Value
|
||||
{
|
||||
get { return (_Value); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Value != value)
|
||||
{
|
||||
_Value = value;
|
||||
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal properties
|
||||
|
||||
#region AbsSegmentWidth
|
||||
|
||||
internal int AbsSegmentWidth
|
||||
{
|
||||
get { return ((int)(Bounds.Width * _NumIndicator.SegmentWidth)); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BrushOn
|
||||
|
||||
internal Brush BrushOn
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_BrushOn == null)
|
||||
{
|
||||
if (_DigitColor.IsEmpty == false)
|
||||
_BrushOn = new SolidBrush(_DigitColor);
|
||||
}
|
||||
|
||||
return (_BrushOn);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_BrushOn != null)
|
||||
_BrushOn.Dispose();
|
||||
|
||||
_BrushOn = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region BrushOff
|
||||
|
||||
internal Brush BrushOff
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_BrushOff == null)
|
||||
{
|
||||
if (DigitDimColor.IsEmpty == false)
|
||||
_BrushOff = new SolidBrush(_DigitDimColor);
|
||||
}
|
||||
|
||||
return (_BrushOff);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_BrushOff != null)
|
||||
_BrushOff.Dispose();
|
||||
|
||||
_BrushOff = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CanRefresh
|
||||
|
||||
internal bool CanRefresh
|
||||
{
|
||||
get { return (_InRender == false); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InPaint
|
||||
|
||||
internal bool InRenderCallout
|
||||
{
|
||||
get { return (_InRender); }
|
||||
set { _InRender = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region NeedRecalcLayout
|
||||
|
||||
internal bool NeedRecalcLayout
|
||||
{
|
||||
get { return (_NeedRecalcLayout); }
|
||||
set { _NeedRecalcLayout = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region NumIndicator
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the owning NumericIndicator
|
||||
/// </summary>
|
||||
internal NumericIndicator NumIndicator
|
||||
{
|
||||
get { return (_NumIndicator); }
|
||||
set { _NumIndicator = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region RecalcLayout
|
||||
|
||||
public virtual void RecalcLayout()
|
||||
{
|
||||
if (_NeedRecalcLayout == true)
|
||||
_NeedRecalcLayout = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnPaint
|
||||
|
||||
public virtual void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
RecalcLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Refresh
|
||||
|
||||
internal void Refresh()
|
||||
{
|
||||
if (CanRefresh == true)
|
||||
NumIndicator.Refresh();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RefreshElements
|
||||
|
||||
internal virtual void RefreshElements()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetPaddedRect
|
||||
|
||||
internal Rectangle GetPaddedRect(Rectangle r)
|
||||
{
|
||||
Padding padding = _NumIndicator.Padding;
|
||||
|
||||
r.Y -= padding.Top;
|
||||
r.Height += (padding.Top + padding.Bottom);
|
||||
|
||||
if (_NumIndicator.Digits[0] == this)
|
||||
{
|
||||
r.X -= padding.Left;
|
||||
r.Width += padding.Left;
|
||||
}
|
||||
|
||||
if (_NumIndicator.Digits[_NumIndicator.Digits.Length - 1] == this)
|
||||
r.Width += padding.Right;
|
||||
|
||||
return (r);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
public virtual void Dispose()
|
||||
{
|
||||
BrushOn = null;
|
||||
BrushOff = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyToItem
|
||||
|
||||
public virtual void CopyToItem(NumericElement copy)
|
||||
{
|
||||
copy.BackColor = _BackColor;
|
||||
copy.Bounds = _Bounds;
|
||||
copy.DigitDimColor = _DigitDimColor;
|
||||
copy.ColonPointsOn = _ColonPointsOn;
|
||||
copy.DigitColor = _DigitColor;
|
||||
copy.DigitDimColor = _DigitDimColor;
|
||||
copy.ShowDimColonPoints = _ShowDimColonPoints;
|
||||
copy.ShowDimDecimalPoint = _ShowDimDecimalPoint;
|
||||
copy.ShowDimSegments = _ShowDimSegments;
|
||||
copy.Value = _Value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,215 @@
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using DevComponents.Instrumentation.Primitives;
|
||||
|
||||
namespace DevComponents.Instrumentation
|
||||
{
|
||||
public class NumericRangeCollection : GenericCollection<NumericRange>
|
||||
{
|
||||
#region GetValueRange
|
||||
|
||||
public NumericRange GetValueRange(double value)
|
||||
{
|
||||
foreach (NumericRange range in this)
|
||||
{
|
||||
if (value >= range.StartValue && value <= range.EndValue)
|
||||
return (range);
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
NumericRangeCollection copy = new NumericRangeCollection();
|
||||
|
||||
CopyToItem(copy);
|
||||
|
||||
return (copy);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyToItem
|
||||
|
||||
internal void CopyToItem(NumericRangeCollection copy)
|
||||
{
|
||||
foreach (NumericRange item in this)
|
||||
{
|
||||
NumericRange ic = new NumericRange();
|
||||
|
||||
item.CopyToItem(ic);
|
||||
|
||||
copy.Add(ic);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class NumericRange : IndicatorRange
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private Color _DigitColor;
|
||||
private Color _DigitDimColor;
|
||||
private Color _DecimalColor;
|
||||
private Color _DecimalDimColor;
|
||||
|
||||
private NumericIndicator _NumericIndicator;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region DecimalColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default Decimal Color
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Appearance"), DefaultValue(typeof(Color), "FireBrick")]
|
||||
[Description("Indicates the default Decimal Color.")]
|
||||
public Color DecimalColor
|
||||
{
|
||||
get { return (_DecimalColor); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_DecimalColor != value)
|
||||
{
|
||||
_DecimalColor = value;
|
||||
|
||||
OnIndicatorRangeChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DecimalDimColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default Decimal Dim Color (Dim LED color)
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Appearance"), DefaultValue(typeof(Color), "Empty")]
|
||||
[Description("Indicates the default Decimal Dim Color (Dim LED color).")]
|
||||
public Color DecimalDimColor
|
||||
{
|
||||
get { return (_DecimalDimColor); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_DecimalDimColor != value)
|
||||
{
|
||||
_DecimalDimColor = value;
|
||||
|
||||
OnIndicatorRangeChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DigitColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default Digit Color
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Appearance"), DefaultValue(typeof(Color), "SteelBlue")]
|
||||
[Description("Indicates the default Digit Color.")]
|
||||
public Color DigitColor
|
||||
{
|
||||
get { return (_DigitColor); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_DigitColor != value)
|
||||
{
|
||||
_DigitColor = value;
|
||||
|
||||
OnIndicatorRangeChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DigitDimColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default Digit Dim Color (Dim LED color)
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Appearance"), DefaultValue(typeof(Color), "Empty")]
|
||||
[Description("Indicates the default Digit Dim Color (Dim LED color).")]
|
||||
public Color DigitDimColor
|
||||
{
|
||||
get { return (_DigitDimColor); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_DigitDimColor != value)
|
||||
{
|
||||
_DigitDimColor = value;
|
||||
|
||||
OnIndicatorRangeChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region NumericIndicator
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the NumericIndicator
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public NumericIndicator NumericIndicator
|
||||
{
|
||||
get { return (_NumericIndicator); }
|
||||
internal set { _NumericIndicator = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
NumericRange copy = new NumericRange();
|
||||
|
||||
CopyToItem(copy);
|
||||
|
||||
return (copy);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyToItem
|
||||
|
||||
public override void CopyToItem(GaugeItem copy)
|
||||
{
|
||||
NumericRange c = copy as NumericRange;
|
||||
|
||||
if (c != null)
|
||||
{
|
||||
base.CopyToItem(c);
|
||||
|
||||
c.DecimalColor = _DecimalColor;
|
||||
c.DecimalDimColor = _DecimalDimColor;
|
||||
c.DigitColor = _DigitColor;
|
||||
c.DigitDimColor = _DigitDimColor;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,572 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.Instrumentation
|
||||
{
|
||||
public class Seg16Element : DigitalElement
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private int _DiagSlant;
|
||||
private int _DiagWidth;
|
||||
|
||||
#endregion
|
||||
|
||||
public Seg16Element(NumericIndicator numIndicator)
|
||||
: base(numIndicator, 16, 6)
|
||||
{
|
||||
}
|
||||
|
||||
#region RecalcSegments
|
||||
|
||||
public override void RecalcSegments()
|
||||
{
|
||||
double d = (ElemWidth * NumIndicator.SegmentWidth) / 8;
|
||||
|
||||
_DiagWidth = (int)(Math.Sqrt((d * d) * 2));
|
||||
_DiagWidth = Math.Max(1, _DiagWidth);
|
||||
|
||||
d = Math.Sqrt(ElemHeight * ElemHeight + ElemWidth * ElemWidth) / 2;
|
||||
|
||||
_DiagSlant = (int)((SegWidth * d) / ElemWidthHalf);
|
||||
|
||||
CalcSegment0();
|
||||
CalcSegment1();
|
||||
CalcSegment2();
|
||||
CalcSegment3();
|
||||
CalcSegment4();
|
||||
CalcSegment5();
|
||||
CalcSegment6();
|
||||
CalcSegment7();
|
||||
CalcSegment8();
|
||||
CalcSegment9();
|
||||
CalcSegment10();
|
||||
CalcSegment11();
|
||||
CalcSegment12();
|
||||
CalcSegment13();
|
||||
CalcSegment14();
|
||||
CalcSegment15();
|
||||
}
|
||||
|
||||
#region CalcSegment0
|
||||
|
||||
private void CalcSegment0()
|
||||
{
|
||||
Point[] pts = SegPoints[0];
|
||||
|
||||
pts[0].X = SegWidth + 1; pts[0].Y = 0;
|
||||
pts[1].X = ElemWidthHalf - 1; pts[1].Y = 0;
|
||||
pts[2].X = ElemWidthHalf - 1; pts[2].Y = SegStep;
|
||||
pts[3].X = ElemWidthHalf - SegWidthHalf - 1; pts[3].Y = SegWidth;
|
||||
pts[4].X = SegWidth + 1; pts[4].Y = SegWidth;
|
||||
pts[5].X = SegWidthHalf + 1; pts[5].Y = SegWidthHalf;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalcSegment1
|
||||
|
||||
private void CalcSegment1()
|
||||
{
|
||||
Point[] pts = SegPoints[1];
|
||||
|
||||
pts[0].X = ElemWidthHalf + 1; pts[0].Y = 0;
|
||||
pts[1].X = ElemWidth - SegWidth - 1; pts[1].Y = 0;
|
||||
pts[2].X = ElemWidth - SegWidthHalf - 1; pts[2].Y = SegWidthHalf;
|
||||
pts[3].X = ElemWidth - SegWidth - 1; pts[3].Y = SegWidth;
|
||||
pts[4].X = ElemWidthHalf + SegWidthHalf + 1; pts[4].Y = SegWidth;
|
||||
pts[5].X = ElemWidthHalf + 1; pts[5].Y = SegStep;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalcSegment2
|
||||
|
||||
private void CalcSegment2()
|
||||
{
|
||||
Point[] pts = SegPoints[2];
|
||||
|
||||
pts[0].X = 0; pts[0].Y = SegWidth + 1;
|
||||
pts[1].X = SegWidthHalf; pts[1].Y = SegWidthHalf + 1;
|
||||
pts[2].X = SegWidth; pts[2].Y = pts[0].Y;
|
||||
pts[3].X = pts[2].X; pts[3].Y = ElemHeightHalf - SegWidthHalf - 1;
|
||||
pts[4].X = SegStep; pts[4].Y = ElemHeightHalf - 1;
|
||||
pts[5].X = 0; pts[5].Y = pts[4].Y;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalcSegment3
|
||||
|
||||
private void CalcSegment3()
|
||||
{
|
||||
Point[] pts = SegPoints[3];
|
||||
|
||||
pts[0].X = SegWidth + 1; pts[0].Y = pts[0].X;
|
||||
pts[1].X = pts[0].X + _DiagWidth; pts[1].Y = pts[0].Y;
|
||||
pts[2].X = ElemWidthHalf - SegWidthHalf - 1; pts[2].Y = ElemHeightHalf - SegWidthHalf - _DiagSlant;
|
||||
pts[3].X = pts[2].X; pts[3].Y = pts[2].Y + _DiagSlant;
|
||||
pts[4].X = pts[0].X; pts[4].Y = pts[0].Y + _DiagWidth;
|
||||
pts[5].X = pts[0].X; pts[5].Y = pts[0].Y;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalcSegment4
|
||||
|
||||
private void CalcSegment4()
|
||||
{
|
||||
Point[] pts = SegPoints[4];
|
||||
|
||||
pts[0].X = ElemWidthHalf - SegWidthHalf; pts[0].Y = SegWidth + 1;
|
||||
pts[1].X = ElemWidthHalf; pts[1].Y = SegStep + 1;
|
||||
pts[2].X = ElemWidthHalf + SegWidthHalf; pts[2].Y = pts[0].Y;
|
||||
pts[3].X = pts[2].X; pts[3].Y = ElemHeightHalf - SegWidthHalf - 1;
|
||||
pts[4].X = pts[1].X; pts[4].Y = ElemHeightHalf - 1;
|
||||
pts[5].X = pts[0].X; pts[5].Y = pts[3].Y;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalcSegment5
|
||||
|
||||
private void CalcSegment5()
|
||||
{
|
||||
Point[] pts = SegPoints[5];
|
||||
|
||||
pts[0].X = ElemWidth - SegWidth - _DiagWidth - 1; pts[0].Y = SegWidth + 1;
|
||||
pts[1].X = pts[0].X + _DiagWidth; pts[1].Y = pts[0].Y;
|
||||
pts[2].X = pts[1].X; pts[2].Y = pts[1].Y + _DiagWidth;
|
||||
pts[3].X = ElemWidthHalf + SegWidthHalf + 1; pts[3].Y = ElemHeightHalf - SegWidthHalf;
|
||||
pts[4].X = pts[3].X; pts[4].Y = pts[3].Y - _DiagSlant;
|
||||
pts[5].X = pts[0].X; pts[5].Y = pts[0].Y;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalcSegment6
|
||||
|
||||
private void CalcSegment6()
|
||||
{
|
||||
Point[] pts = SegPoints[6];
|
||||
|
||||
pts[0].X = ElemWidth - SegWidth; pts[0].Y = SegWidth + 1;
|
||||
pts[1].X = pts[0].X + SegWidthHalf; pts[1].Y = SegWidthHalf + 1;
|
||||
pts[2].X = ElemWidth; pts[2].Y = pts[0].Y;
|
||||
pts[3].X = pts[2].X; pts[3].Y = ElemHeightHalf - 1;
|
||||
pts[4].X = pts[3].X - SegStep; pts[4].Y = pts[3].Y;
|
||||
pts[5].X = ElemWidth - SegWidth; pts[5].Y = pts[3].Y - SegWidthHalf;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalcSegment7
|
||||
|
||||
private void CalcSegment7()
|
||||
{
|
||||
Point[] pts = SegPoints[7];
|
||||
|
||||
pts[0].X = SegWidth + 1; pts[0].Y = ElemHeightHalf - SegWidthHalf;
|
||||
pts[1].X = ElemWidthHalf - SegWidthHalf - 1; pts[1].Y = pts[0].Y;
|
||||
pts[2].X = ElemWidthHalf - 1; pts[2].Y = ElemHeightHalf;
|
||||
pts[3].X = pts[1].X; pts[3].Y = ElemHeightHalf + SegWidthHalf;
|
||||
pts[4].X = pts[0].X; pts[4].Y = pts[3].Y;
|
||||
pts[5].X = SegStep + 1; pts[5].Y = pts[2].Y;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalcSegment8
|
||||
|
||||
private void CalcSegment8()
|
||||
{
|
||||
Point[] pts = SegPoints[8];
|
||||
|
||||
pts[0].X = ElemWidthHalf + SegWidthHalf + 1; pts[0].Y = ElemHeightHalf - SegWidthHalf;
|
||||
pts[1].X = ElemWidth - SegWidth - 1; pts[1].Y = pts[0].Y;
|
||||
pts[2].X = ElemWidth - SegStep - 1; pts[2].Y = ElemHeightHalf;
|
||||
pts[3].X = pts[1].X; pts[3].Y = ElemHeightHalf + SegWidthHalf;
|
||||
pts[4].X = pts[0].X; pts[4].Y = pts[3].Y;
|
||||
pts[5].X = ElemWidthHalf + 1; pts[5].Y = pts[2].Y;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalcSegment9
|
||||
|
||||
private void CalcSegment9()
|
||||
{
|
||||
Point[] pts = SegPoints[9];
|
||||
|
||||
pts[0].X = 0; pts[0].Y = ElemHeightHalf + 1;
|
||||
pts[1].X = SegStep; pts[1].Y = pts[0].Y;
|
||||
pts[2].X = SegWidth; pts[2].Y = pts[1].Y + SegWidthHalf;
|
||||
pts[3].X = pts[2].X; pts[3].Y = ElemHeight - SegWidth - 1;
|
||||
pts[4].X = SegWidthHalf; pts[4].Y = ElemHeight - SegWidthHalf - 1;
|
||||
pts[5].X = 0; pts[5].Y = pts[3].Y;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalcSegment10
|
||||
|
||||
private void CalcSegment10()
|
||||
{
|
||||
Point[] pts = SegPoints[10];
|
||||
|
||||
pts[0].X = ElemWidthHalf - SegWidthHalf - 1; pts[0].Y = ElemHeightHalf + SegWidthHalf;
|
||||
pts[1].X = pts[0].X; pts[1].Y = pts[0].Y + _DiagSlant;
|
||||
pts[2].X = SegWidth + _DiagWidth + 1; pts[2].Y = ElemHeight - SegWidth - 1;
|
||||
pts[3].X = SegWidth + 1; pts[3].Y = ElemHeight - SegWidth - 1;
|
||||
pts[4].X = pts[3].X; pts[4].Y = pts[3].Y - _DiagWidth;
|
||||
pts[5].X = pts[0].X; pts[5].Y = pts[0].Y;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalcSegment11
|
||||
|
||||
private void CalcSegment11()
|
||||
{
|
||||
Point[] pts = SegPoints[11];
|
||||
|
||||
pts[0].X = ElemWidthHalf - SegWidthHalf; pts[0].Y = ElemHeightHalf + SegWidthHalf + 1;
|
||||
pts[1].X = ElemWidthHalf; pts[1].Y = ElemHeightHalf + 1;
|
||||
pts[2].X = ElemWidthHalf + SegWidthHalf; pts[2].Y = pts[0].Y;
|
||||
pts[3].X = pts[2].X; pts[3].Y = ElemHeight - SegWidth - 1;
|
||||
pts[4].X = pts[1].X; pts[4].Y = ElemHeight - SegStep - 1;
|
||||
pts[5].X = pts[0].X; pts[5].Y = pts[3].Y;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalcSegment12
|
||||
|
||||
private void CalcSegment12()
|
||||
{
|
||||
Point[] pts = SegPoints[12];
|
||||
|
||||
pts[0].X = ElemWidthHalf + SegWidthHalf + 1; pts[0].Y = ElemHeightHalf + SegWidthHalf;
|
||||
pts[1].X = ElemWidth - SegWidth - 1; pts[1].Y = ElemHeight - SegWidth - _DiagWidth - 1;
|
||||
pts[2].X = pts[1].X; pts[2].Y = pts[1].Y + _DiagWidth;
|
||||
pts[3].X = pts[2].X - _DiagWidth; pts[3].Y = pts[2].Y;
|
||||
pts[4].X = pts[0].X; pts[4].Y = pts[0].Y + _DiagSlant;
|
||||
pts[5].X = pts[0].X; pts[5].Y = pts[0].Y;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalcSegment13
|
||||
|
||||
private void CalcSegment13()
|
||||
{
|
||||
Point[] pts = SegPoints[13];
|
||||
|
||||
pts[0].X = ElemWidth - SegStep; pts[0].Y = ElemHeightHalf + 1;
|
||||
pts[1].X = ElemWidth; pts[1].Y = pts[0].Y;
|
||||
pts[2].X = pts[1].X; pts[2].Y = ElemHeight - SegWidth - 1;
|
||||
pts[3].X = ElemWidth - SegWidthHalf; pts[3].Y = ElemHeight - SegWidthHalf - 1;
|
||||
pts[4].X = ElemWidth - SegWidth; pts[4].Y = pts[2].Y;
|
||||
pts[5].X = pts[4].X; pts[5].Y = ElemHeightHalf + SegWidthHalf + 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalcSegment14
|
||||
|
||||
private void CalcSegment14()
|
||||
{
|
||||
Point[] pts = SegPoints[14];
|
||||
|
||||
pts[0].X = SegWidth + 1; pts[0].Y = ElemHeight - SegWidth;
|
||||
pts[1].X = ElemWidthHalf - SegWidthHalf - 1; pts[1].Y = pts[0].Y;
|
||||
pts[2].X = ElemWidthHalf - 1; pts[2].Y = ElemHeight - SegStep;
|
||||
pts[3].X = pts[2].X; pts[3].Y = ElemHeight;
|
||||
pts[4].X = pts[0].X; pts[4].Y = pts[3].Y;
|
||||
pts[5].X = SegWidthHalf + 1; pts[5].Y = ElemHeight - SegWidthHalf;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalcSegment15
|
||||
|
||||
private void CalcSegment15()
|
||||
{
|
||||
Point[] pts = SegPoints[15];
|
||||
|
||||
pts[0].X = ElemWidthHalf + SegWidthHalf + 1; pts[0].Y = ElemHeight - SegWidth;
|
||||
pts[1].X = ElemWidth - SegWidth - 1; pts[1].Y = pts[0].Y;
|
||||
pts[2].X = ElemWidth - SegWidthHalf - 1; pts[2].Y = ElemHeight - SegWidthHalf;
|
||||
pts[3].X = pts[1].X; pts[3].Y = ElemHeight;
|
||||
pts[4].X = ElemWidthHalf + 1; pts[4].Y = ElemHeight;
|
||||
pts[5].X = pts[4].X; pts[5].Y = ElemHeight - SegStep;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetDigitSegments
|
||||
|
||||
public override int GetDigitSegments(char digit)
|
||||
{
|
||||
switch (digit)
|
||||
{
|
||||
#region Numeric
|
||||
|
||||
case '0': return ((int)Seg16Segments.Zero);
|
||||
case '1': return ((int)Seg16Segments.One);
|
||||
case '2': return ((int)Seg16Segments.Two);
|
||||
case '3': return ((int)Seg16Segments.Three);
|
||||
case '4': return ((int)Seg16Segments.Four);
|
||||
case '5': return ((int)Seg16Segments.Five);
|
||||
case '6': return ((int)Seg16Segments.Six);
|
||||
case '7': return ((int)Seg16Segments.Seven);
|
||||
case '8': return ((int)Seg16Segments.Eight);
|
||||
case '9': return ((int)Seg16Segments.Nine);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Lowercase Alpha
|
||||
|
||||
case 'a': return ((int)Seg16Segments.a);
|
||||
case 'b': return ((int)Seg16Segments.b);
|
||||
case 'c': return ((int)Seg16Segments.c);
|
||||
case 'd': return ((int)Seg16Segments.d);
|
||||
case 'e': return ((int)Seg16Segments.e);
|
||||
case 'f': return ((int)Seg16Segments.f);
|
||||
case 'g': return ((int)Seg16Segments.g);
|
||||
case 'h': return ((int)Seg16Segments.h);
|
||||
case 'i': return ((int)Seg16Segments.i);
|
||||
case 'j': return ((int)Seg16Segments.j);
|
||||
case 'k': return ((int)Seg16Segments.k);
|
||||
case 'l': return ((int)Seg16Segments.l);
|
||||
case 'm': return ((int)Seg16Segments.m);
|
||||
case 'n': return ((int)Seg16Segments.n);
|
||||
case 'o': return ((int)Seg16Segments.o);
|
||||
case 'p': return ((int)Seg16Segments.p);
|
||||
case 'q': return ((int)Seg16Segments.q);
|
||||
case 'r': return ((int)Seg16Segments.r);
|
||||
case 's': return ((int)Seg16Segments.s);
|
||||
case 't': return ((int)Seg16Segments.t);
|
||||
case 'u': return ((int)Seg16Segments.u);
|
||||
case 'v': return ((int)Seg16Segments.v);
|
||||
case 'w': return ((int)Seg16Segments.w);
|
||||
case 'x': return ((int)Seg16Segments.x);
|
||||
case 'y': return ((int)Seg16Segments.y);
|
||||
case 'z': return ((int)Seg16Segments.z);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Uppercase alpha
|
||||
|
||||
case 'A': return ((int)Seg16Segments.A);
|
||||
case 'B': return ((int)Seg16Segments.B);
|
||||
case 'C': return ((int)Seg16Segments.C);
|
||||
case 'D': return ((int)Seg16Segments.D);
|
||||
case 'E': return ((int)Seg16Segments.E);
|
||||
case 'F': return ((int)Seg16Segments.F);
|
||||
case 'G': return ((int)Seg16Segments.G);
|
||||
case 'H': return ((int)Seg16Segments.H);
|
||||
case 'I': return ((int)Seg16Segments.I);
|
||||
case 'J': return ((int)Seg16Segments.J);
|
||||
case 'K': return ((int)Seg16Segments.K);
|
||||
case 'L': return ((int)Seg16Segments.L);
|
||||
case 'M': return ((int)Seg16Segments.M);
|
||||
case 'N': return ((int)Seg16Segments.N);
|
||||
case 'O': return ((int)Seg16Segments.O);
|
||||
case 'P': return ((int)Seg16Segments.P);
|
||||
case 'Q': return ((int)Seg16Segments.Q);
|
||||
case 'R': return ((int)Seg16Segments.R);
|
||||
case 'S': return ((int)Seg16Segments.S);
|
||||
case 'T': return ((int)Seg16Segments.T);
|
||||
case 'U': return ((int)Seg16Segments.U);
|
||||
case 'V': return ((int)Seg16Segments.V);
|
||||
case 'W': return ((int)Seg16Segments.W);
|
||||
case 'X': return ((int)Seg16Segments.X);
|
||||
case 'Y': return ((int)Seg16Segments.Y);
|
||||
case 'Z': return ((int)Seg16Segments.Z);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Extended chars
|
||||
|
||||
case ' ': return ((int)Seg16Segments.Space);
|
||||
case '!': return ((int)Seg16Segments.ExPoint);
|
||||
case '"': return ((int)Seg16Segments.DQuote);
|
||||
case '#': return ((int)Seg16Segments.PoundSign);
|
||||
case '$': return ((int)Seg16Segments.DollarSign);
|
||||
case '%': return ((int)Seg16Segments.PercentSign);
|
||||
case '&': return ((int)Seg16Segments.Ampersand);
|
||||
case '\'': return ((int)Seg16Segments.SQuote);
|
||||
case '(': return ((int)Seg16Segments.LParen);
|
||||
case ')': return ((int)Seg16Segments.RParen);
|
||||
case '*': return ((int)Seg16Segments.Asterisk);
|
||||
case '+': return ((int)Seg16Segments.PlusSign);
|
||||
case ',': return ((int)Seg16Segments.Comma);
|
||||
case '-': return ((int)Seg16Segments.Dash);
|
||||
case '/': return ((int)Seg16Segments.FSlash);
|
||||
case ':': return ((int)Seg16Segments.Colon);
|
||||
case ';': return ((int)Seg16Segments.Semicolon);
|
||||
case '<': return ((int)Seg16Segments.LessThan);
|
||||
case '=': return ((int)Seg16Segments.Equals);
|
||||
case '>': return ((int)Seg16Segments.GreaterThan);
|
||||
case '?': return ((int)Seg16Segments.QuestionMark);
|
||||
case '@': return ((int)Seg16Segments.Atsign);
|
||||
case '[': return ((int)Seg16Segments.LBracket);
|
||||
case '\\': return ((int)Seg16Segments.BackSlash);
|
||||
case ']': return ((int)Seg16Segments.RBracket);
|
||||
case '^': return ((int)Seg16Segments.Caret);
|
||||
case '_': return ((int)Seg16Segments.Underline);
|
||||
case '`': return ((int)Seg16Segments.Apostrophe);
|
||||
case '{': return ((int)Seg16Segments.LBrace);
|
||||
case '|': return ((int)Seg16Segments.Pipe);
|
||||
case '}': return ((int)Seg16Segments.RBrace);
|
||||
case '~': return ((int)Seg16Segments.Tilde);
|
||||
case '<27>': return ((int)Seg16Segments.Pound);
|
||||
case '<27>': return ((int)Seg16Segments.Degree);
|
||||
case '<27>': return ((int)Seg16Segments.PlusMinus);
|
||||
|
||||
#endregion
|
||||
|
||||
default: return ((int)Seg16Segments.None);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region Enums
|
||||
|
||||
#region Seg16Segments
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
public enum Seg16Segments : int
|
||||
{
|
||||
None = 0,
|
||||
|
||||
#region Numeric
|
||||
|
||||
Zero = 0xE667,
|
||||
One = 0x810,
|
||||
Two = 0xC3C3,
|
||||
Three = 0xE1C3,
|
||||
Four = 0x21C4,
|
||||
Five = 0xE187,
|
||||
Six = 0xE387,
|
||||
Seven = 0x2043,
|
||||
Eight = 0xE3C7,
|
||||
Nine = 0xE1C7,
|
||||
|
||||
#endregion
|
||||
|
||||
#region Lowercase alpha
|
||||
|
||||
a = 0xCA80,
|
||||
b = 0xA910,
|
||||
c = 0x8900,
|
||||
d = 0xA940,
|
||||
e = 0x4680,
|
||||
f = 0x912,
|
||||
g = 0xB100,
|
||||
h = 0x2910,
|
||||
i = 0x8820,
|
||||
j = 0xA840,
|
||||
k = 0x1830,
|
||||
l = 0x8810,
|
||||
m = 0x2B80,
|
||||
n = 0x2900,
|
||||
o = 0xA900,
|
||||
p = 0x28C,
|
||||
q = 0x8895,
|
||||
r = 0x900,
|
||||
s = 0x9100,
|
||||
t = 0x8990,
|
||||
u = 0xA800,
|
||||
v = 0x3000,
|
||||
w = 0x3600,
|
||||
x = 0x1580,
|
||||
y = 0xB000,
|
||||
z = 0x4480,
|
||||
|
||||
#endregion
|
||||
|
||||
#region Uppercase alpha
|
||||
|
||||
A = 0x23C7,
|
||||
B = 0xE953,
|
||||
C = 0xC207,
|
||||
D = 0xE853,
|
||||
E = 0xC387,
|
||||
F = 0x387,
|
||||
G = 0xE307,
|
||||
H = 0x23C4,
|
||||
I = 0xC813,
|
||||
J = 0xE240,
|
||||
K = 0x12A4,
|
||||
L = 0xC204,
|
||||
M = 0x226C,
|
||||
N = 0x324C,
|
||||
O = 0xE247,
|
||||
P = 0x3C7,
|
||||
Q = 0xF247,
|
||||
R = 0x13C7,
|
||||
S = 0xE187,
|
||||
T = 0x813,
|
||||
U = 0xE244,
|
||||
V = 0x3048,
|
||||
W = 0xEA44,
|
||||
X = 0x1428,
|
||||
Y = 0x828,
|
||||
Z = 0xC423,
|
||||
|
||||
#endregion
|
||||
|
||||
#region Extended chars
|
||||
|
||||
Space = 0x00,
|
||||
ExPoint = 0x8152,
|
||||
DQuote = 0x50,
|
||||
PoundSign = 0xE9D0,
|
||||
DollarSign = 0xE997,
|
||||
PercentSign = 0xADB5,
|
||||
Ampersand = 0xD299,
|
||||
SQuote = 0x10,
|
||||
LParen = 0x4205,
|
||||
RParen = 0xA042,
|
||||
Asterisk = 0x1DB8,
|
||||
PlusSign = 0x990,
|
||||
Comma = 0x400,
|
||||
Dash = 0x180,
|
||||
FSlash = 0x420,
|
||||
Colon = 0x810,
|
||||
Semicolon = 0x410,
|
||||
LessThan = 0x1020,
|
||||
Equals = 0xC180,
|
||||
GreaterThan = 0x408,
|
||||
QuestionMark = 0x943,
|
||||
Atsign = 0xAB47,
|
||||
LBracket = 0x4205,
|
||||
BackSlash = 0x1008,
|
||||
RBracket = 0xA042,
|
||||
Caret = 0x1400,
|
||||
Underline = 0xC000,
|
||||
Apostrophe = 0x8,
|
||||
LBrace = 0x8892,
|
||||
Pipe = 0x810,
|
||||
RBrace = 0x4911,
|
||||
Tilde = 0x2C,
|
||||
Pound = 0xAB14,
|
||||
Degree = 0x152,
|
||||
PlusMinus = 0xC990,
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
// ReSharper restore InconsistentNaming
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
@@ -0,0 +1,318 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace DevComponents.Instrumentation
|
||||
{
|
||||
public class Seg7Element : DigitalElement
|
||||
{
|
||||
public Seg7Element(NumericIndicator numIndicator)
|
||||
: base(numIndicator, 7, 6)
|
||||
{
|
||||
}
|
||||
|
||||
#region RecalcSegments
|
||||
|
||||
public override void RecalcSegments()
|
||||
{
|
||||
CalcSegment0();
|
||||
CalcSegment1();
|
||||
CalcSegment2();
|
||||
CalcSegment3();
|
||||
CalcSegment4();
|
||||
CalcSegment5();
|
||||
CalcSegment6();
|
||||
}
|
||||
|
||||
#region CalcSegment0
|
||||
|
||||
private void CalcSegment0()
|
||||
{
|
||||
Point[] pts = SegPoints[0];
|
||||
|
||||
pts[0].X = SegWidth + 1; pts[0].Y = 0;
|
||||
pts[1].X = ElemWidth - SegWidth - 1; pts[1].Y = 0;
|
||||
pts[2].X = ElemWidth - SegWidthHalf - 1; pts[2].Y = SegWidthHalf;
|
||||
pts[3].X = pts[1].X; pts[3].Y = SegWidth;
|
||||
pts[4].X = pts[0].X; pts[4].Y = SegWidth;
|
||||
pts[5].X = SegWidthHalf + 1; pts[5].Y = pts[2].Y;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalcSegment1
|
||||
|
||||
private void CalcSegment1()
|
||||
{
|
||||
Point[] pts = SegPoints[1];
|
||||
|
||||
pts[0].X = 0; pts[0].Y = SegWidth + 1;
|
||||
pts[1].X = SegWidthHalf; pts[1].Y = SegWidthHalf + 1;
|
||||
pts[2].X = SegWidth; pts[2].Y = SegWidth + 1;
|
||||
pts[3].X = SegWidth; pts[3].Y = ElemHeightHalf - SegWidthHalf - 1;
|
||||
pts[4].X = 4; pts[4].Y = ElemHeightHalf - 1;
|
||||
pts[5].X = 0; pts[5].Y = ElemHeightHalf - 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalcSegment2
|
||||
|
||||
private void CalcSegment2()
|
||||
{
|
||||
Point[] pts = SegPoints[2];
|
||||
|
||||
pts[0].X = ElemWidth - SegWidth; pts[0].Y = SegWidth + 1;
|
||||
pts[1].X = ElemWidth - SegWidthHalf; pts[1].Y = SegWidthHalf + 1;
|
||||
pts[2].X = ElemWidth; pts[2].Y = SegWidth + 1;
|
||||
pts[3].X = ElemWidth; pts[3].Y = ElemHeightHalf - 1;
|
||||
pts[4].X = ElemWidth - 4; pts[4].Y = ElemHeightHalf - 1;
|
||||
pts[5].X = ElemWidth - SegWidth; pts[5].Y = ElemHeightHalf - SegWidthHalf - 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalcSegment3
|
||||
|
||||
private void CalcSegment3()
|
||||
{
|
||||
Point[] pts = SegPoints[3];
|
||||
|
||||
pts[0].X = SegWidth + 1; pts[0].Y = ElemHeightHalf - SegWidthHalf;
|
||||
pts[1].X = ElemWidth - SegWidth - 1; pts[1].Y = ElemHeightHalf - SegWidthHalf;
|
||||
pts[2].X = ElemWidth - 5; pts[2].Y = ElemHeightHalf;
|
||||
pts[3].X = ElemWidth - SegWidth - 1; pts[3].Y = ElemHeightHalf + SegWidthHalf;
|
||||
pts[4].X = SegWidth + 1; pts[4].Y = ElemHeightHalf + SegWidthHalf;
|
||||
pts[5].X = 5; pts[5].Y = ElemHeightHalf;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalcSegment4
|
||||
|
||||
private void CalcSegment4()
|
||||
{
|
||||
Point[] pts = SegPoints[4];
|
||||
|
||||
pts[0].X = 0; pts[0].Y = ElemHeightHalf + 1;
|
||||
pts[1].X = 4; pts[1].Y = ElemHeightHalf + 1;
|
||||
pts[2].X = SegWidth; pts[2].Y = ElemHeightHalf + SegWidthHalf + 1;
|
||||
pts[3].X = SegWidth; pts[3].Y = ElemHeight - SegWidth - 1;
|
||||
pts[4].X = SegWidthHalf; pts[4].Y = ElemHeight - SegWidthHalf - 1;
|
||||
pts[5].X = 0; pts[5].Y = ElemHeight - SegWidth - 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalcSegment5
|
||||
|
||||
private void CalcSegment5()
|
||||
{
|
||||
Point[] pts = SegPoints[5];
|
||||
|
||||
pts[0].X = ElemWidth - SegWidth; pts[0].Y = ElemHeightHalf + SegWidthHalf + 1;
|
||||
pts[1].X = ElemWidth - 4; pts[1].Y = ElemHeightHalf + 1;
|
||||
pts[2].X = ElemWidth; pts[2].Y = ElemHeightHalf + 1;
|
||||
pts[3].X = ElemWidth; pts[3].Y = ElemHeight - SegWidth - 1;
|
||||
pts[4].X = ElemWidth - SegWidthHalf; pts[4].Y = ElemHeight - SegWidthHalf - 1;
|
||||
pts[5].X = ElemWidth - SegWidth; pts[5].Y = ElemHeight - SegWidth - 1;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CalcSegment6
|
||||
|
||||
private void CalcSegment6()
|
||||
{
|
||||
Point[] pts = SegPoints[6];
|
||||
|
||||
pts[0].X = SegWidth + 1; pts[0].Y = ElemHeight - SegWidth;
|
||||
pts[1].X = ElemWidth - SegWidth - 1; pts[1].Y = ElemHeight - SegWidth;
|
||||
pts[2].X = ElemWidth - SegWidthHalf - 1; pts[2].Y = ElemHeight - SegWidthHalf;
|
||||
pts[3].X = ElemWidth - SegWidth - 1; pts[3].Y = ElemHeight;
|
||||
pts[4].X = SegWidth + 1; pts[4].Y = ElemHeight;
|
||||
pts[5].X = SegWidthHalf + 1; pts[5].Y = ElemHeight - SegWidthHalf;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetCharSegments
|
||||
|
||||
public override int GetDigitSegments(char value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case '0': return ((int)Seg7Segments.Zero);
|
||||
case '1': return ((int)Seg7Segments.One);
|
||||
case '2': return ((int)Seg7Segments.Two);
|
||||
case '3': return ((int)Seg7Segments.Three);
|
||||
case '4': return ((int)Seg7Segments.Four);
|
||||
case '5': return ((int)Seg7Segments.Five);
|
||||
case '6': return ((int)Seg7Segments.Six);
|
||||
case '7': return ((int)Seg7Segments.Seven);
|
||||
case '8': return ((int)Seg7Segments.Eight);
|
||||
case '9': return ((int)Seg7Segments.Nine);
|
||||
|
||||
case 'a': return ((int)Seg7Segments.a);
|
||||
case 'b': return ((int)Seg7Segments.b);
|
||||
case 'c': return ((int)Seg7Segments.c);
|
||||
case 'd': return ((int)Seg7Segments.d);
|
||||
case 'e': return ((int)Seg7Segments.e);
|
||||
case 'f': return ((int)Seg7Segments.f);
|
||||
case 'g': return ((int)Seg7Segments.g);
|
||||
case 'h': return ((int)Seg7Segments.h);
|
||||
case 'i': return ((int)Seg7Segments.i);
|
||||
case 'j': return ((int)Seg7Segments.j);
|
||||
case 'k': return ((int)Seg7Segments.k);
|
||||
case 'l': return ((int)Seg7Segments.l);
|
||||
case 'm': return ((int)Seg7Segments.m);
|
||||
case 'n': return ((int)Seg7Segments.n);
|
||||
case 'o': return ((int)Seg7Segments.o);
|
||||
case 'p': return ((int)Seg7Segments.p);
|
||||
case 'q': return ((int)Seg7Segments.q);
|
||||
case 'r': return ((int)Seg7Segments.r);
|
||||
case 's': return ((int)Seg7Segments.s);
|
||||
case 't': return ((int)Seg7Segments.t);
|
||||
case 'u': return ((int)Seg7Segments.u);
|
||||
case 'v': return ((int)Seg7Segments.v);
|
||||
case 'w': return ((int)Seg7Segments.w);
|
||||
case 'x': return ((int)Seg7Segments.x);
|
||||
case 'y': return ((int)Seg7Segments.y);
|
||||
case 'z': return ((int)Seg7Segments.z);
|
||||
|
||||
case 'A': return ((int)Seg7Segments.A);
|
||||
case 'B': return ((int)Seg7Segments.B);
|
||||
case 'C': return ((int)Seg7Segments.C);
|
||||
case 'D': return ((int)Seg7Segments.D);
|
||||
case 'E': return ((int)Seg7Segments.E);
|
||||
case 'F': return ((int)Seg7Segments.F);
|
||||
case 'G': return ((int)Seg7Segments.G);
|
||||
case 'H': return ((int)Seg7Segments.H);
|
||||
case 'I': return ((int)Seg7Segments.I);
|
||||
case 'J': return ((int)Seg7Segments.J);
|
||||
case 'K': return ((int)Seg7Segments.K);
|
||||
case 'L': return ((int)Seg7Segments.L);
|
||||
case 'M': return ((int)Seg7Segments.M);
|
||||
case 'N': return ((int)Seg7Segments.N);
|
||||
case 'O': return ((int)Seg7Segments.O);
|
||||
case 'P': return ((int)Seg7Segments.P);
|
||||
case 'Q': return ((int)Seg7Segments.Q);
|
||||
case 'R': return ((int)Seg7Segments.R);
|
||||
case 'S': return ((int)Seg7Segments.S);
|
||||
case 'T': return ((int)Seg7Segments.T);
|
||||
case 'U': return ((int)Seg7Segments.U);
|
||||
case 'V': return ((int)Seg7Segments.V);
|
||||
case 'W': return ((int)Seg7Segments.W);
|
||||
case 'X': return ((int)Seg7Segments.X);
|
||||
case 'Y': return ((int)Seg7Segments.Y);
|
||||
case 'Z': return ((int)Seg7Segments.Z);
|
||||
|
||||
case ' ': return ((int)Seg7Segments.Space);
|
||||
case '-': return ((int)Seg7Segments.Dash);
|
||||
case '=': return ((int)Seg7Segments.Equals);
|
||||
case '(': return ((int)Seg7Segments.LParen);
|
||||
case '}': return ((int)Seg7Segments.RParen);
|
||||
case '[': return ((int)Seg7Segments.LBracket);
|
||||
case ']': return ((int)Seg7Segments.RBracket);
|
||||
case '_': return ((int)Seg7Segments.Underline);
|
||||
|
||||
// Add callout code to get pattern
|
||||
|
||||
default: return ((int)Seg7Segments.None);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region Enums
|
||||
|
||||
#region Seg7Segments
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
public enum Seg7Segments : int
|
||||
{
|
||||
None = 0x0,
|
||||
|
||||
Zero = 0x77,
|
||||
One = 0x24,
|
||||
Two = 0x5D,
|
||||
Three = 0x6D,
|
||||
Four = 0x2E,
|
||||
Five = 0x6B,
|
||||
Six = 0x7B,
|
||||
Seven = 0x25,
|
||||
Eight = 0x7F,
|
||||
Nine = 0x6F,
|
||||
|
||||
a = 0x7D,
|
||||
b = 0x7A,
|
||||
c = 0x58,
|
||||
d = 0x7C,
|
||||
e = 0x5F,
|
||||
f = 0x1B,
|
||||
g = 0x6F,
|
||||
h = 0x3A,
|
||||
i = 0x51,
|
||||
j = 0x61,
|
||||
k = 0x3E,
|
||||
l = 0x50,
|
||||
m = 0x31,
|
||||
n = 0x38,
|
||||
o = 0x78,
|
||||
p = 0x1F,
|
||||
q = 0x2F,
|
||||
r = 0x18,
|
||||
s = 0x6B,
|
||||
t = 0x5A,
|
||||
u = 0x70,
|
||||
v = 0x70,
|
||||
w = 0x46,
|
||||
x = 0x3E,
|
||||
y = 0x6E,
|
||||
z = 0x5D,
|
||||
|
||||
A = 0x3F,
|
||||
B = 0x7F,
|
||||
C = 0x53,
|
||||
D = 0x77,
|
||||
E = 0x5B,
|
||||
F = 0x1B,
|
||||
G = 0x73,
|
||||
H = 0x3E,
|
||||
I = 0x24,
|
||||
J = 0x74,
|
||||
K = 0x3E,
|
||||
L = 0x52,
|
||||
M = 0x31,
|
||||
N = 0x38,
|
||||
O = 0x77,
|
||||
P = 0x1F,
|
||||
Q = 0x2F,
|
||||
R = 0x13,
|
||||
S = 0x6B,
|
||||
T = 0x13,
|
||||
U = 0x76,
|
||||
V = 0x76,
|
||||
W = 0x46,
|
||||
X = 0x3E,
|
||||
Y = 0x6E,
|
||||
Z = 0x5D,
|
||||
|
||||
Space = 0x00,
|
||||
Dash = 0x08,
|
||||
Equals = 0x48,
|
||||
LParen = 0x63,
|
||||
RParen = 0x65,
|
||||
LBracket = 0x63,
|
||||
RBracket = 0x65,
|
||||
Underline = 0x40,
|
||||
}
|
||||
|
||||
// ReSharper restore InconsistentNaming
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
@@ -0,0 +1,797 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.Instrumentation
|
||||
{
|
||||
public class StateIndicator : GaugeIndicator
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private StateIndicatorStyle _Style;
|
||||
private StateRangeCollection _Ranges;
|
||||
|
||||
private Image _Image;
|
||||
private float _Angle;
|
||||
private float _RoundRectangleArc;
|
||||
|
||||
private Color _TextColor;
|
||||
private TextAlignment _TextAlignment;
|
||||
private float _TextVerticalOffset;
|
||||
private float _TextHorizontalOffset;
|
||||
|
||||
private Font _AbsFont;
|
||||
|
||||
#endregion
|
||||
|
||||
public StateIndicator()
|
||||
{
|
||||
InitIndicator();
|
||||
}
|
||||
|
||||
#region InitIndicator
|
||||
|
||||
private void InitIndicator()
|
||||
{
|
||||
_Style = StateIndicatorStyle.Circular;
|
||||
|
||||
_RoundRectangleArc = .75f;
|
||||
|
||||
_TextColor = Color.Black;
|
||||
_TextAlignment = TextAlignment.MiddleCenter;
|
||||
|
||||
BackColor.Color1 = Color.PaleGreen;
|
||||
BackColor.Color2 = Color.DarkGreen;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region Angle
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the amount to rotate the indicator, specified in degrees.
|
||||
/// </summary>
|
||||
[Browsable(true)]
|
||||
[Category("Layout"), DefaultValue(0f)]
|
||||
[Editor("DevComponents.Instrumentation.Design.AngleRangeValueEditor, DevComponents.Instrumentation.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=76cb4c6eb576bca5", typeof(UITypeEditor))]
|
||||
[Description("Determines the amount to rotate the indicator, specified in degrees.")]
|
||||
public float Angle
|
||||
{
|
||||
get { return (_Angle); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Angle != value)
|
||||
{
|
||||
_Angle = value;
|
||||
|
||||
OnGaugeItemChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Image
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Image to use
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Appearance"), DefaultValue(null)]
|
||||
[Description("Indicates the Image to use.")]
|
||||
public Image Image
|
||||
{
|
||||
get { return (_Image); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Image != value)
|
||||
{
|
||||
_Image = value;
|
||||
|
||||
OnGaugeItemChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Ranges
|
||||
|
||||
/// <summary>
|
||||
/// Gets the collection of Ranges associated with the Indicator
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Behavior")]
|
||||
[Description("Indicates the collection of Ranges associated with the Indicator.")]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
|
||||
[Editor("DevComponents.Instrumentation.Design.GaugeCollectionEditor, DevComponents.Instrumentation.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=76cb4c6eb576bca5", typeof(UITypeEditor))]
|
||||
public StateRangeCollection Ranges
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_Ranges == null)
|
||||
{
|
||||
_Ranges = new StateRangeCollection();
|
||||
_Ranges.CollectionChanged += StateRanges_CollectionChanged;
|
||||
}
|
||||
|
||||
return (_Ranges);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_Ranges != null)
|
||||
_Ranges.CollectionChanged -= StateRanges_CollectionChanged;
|
||||
|
||||
_Ranges = value;
|
||||
|
||||
if (_Ranges != null)
|
||||
_Ranges.CollectionChanged += StateRanges_CollectionChanged;
|
||||
|
||||
OnGaugeItemChanged(true);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RoundRectangleArc
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the RoundRectangle corner radius,
|
||||
/// measured as a percentage of the width/height.
|
||||
/// </summary>
|
||||
[Browsable(true)]
|
||||
[Category("Appearance"), DefaultValue(.75f)]
|
||||
[Description("Indicates the RoundRectangle corner radius, measured as a percentage of the width/height.")]
|
||||
[Editor("DevComponents.Instrumentation.Design.WidthMaxRangeValueEditor, DevComponents.Instrumentation.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=76cb4c6eb576bca5", typeof(UITypeEditor))]
|
||||
public float RoundRectangleArc
|
||||
{
|
||||
get { return (_RoundRectangleArc); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_RoundRectangleArc != value)
|
||||
{
|
||||
if (value < 0 || value > 1f)
|
||||
throw new ArgumentException("Radius must be between 0 and 1");
|
||||
|
||||
_RoundRectangleArc = value;
|
||||
|
||||
OnGaugeItemChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Style
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Indicator Style
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Behavior"), DefaultValue(StateIndicatorStyle.Circular)]
|
||||
[Description("Indicates the Indicator Style.")]
|
||||
public StateIndicatorStyle Style
|
||||
{
|
||||
get { return (_Style); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Style != value)
|
||||
{
|
||||
_Style = value;
|
||||
|
||||
OnGaugeItemChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TextAlignment
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the alignment of the text
|
||||
/// </summary>
|
||||
[Browsable(true)]
|
||||
[Category("Layout"), DefaultValue(TextAlignment.MiddleCenter)]
|
||||
[Description("Indicates the alignment of the text.")]
|
||||
public TextAlignment TextAlignment
|
||||
{
|
||||
get { return (_TextAlignment); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_TextAlignment != value)
|
||||
{
|
||||
_TextAlignment = value;
|
||||
|
||||
OnGaugeItemChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TextColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the text Color
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Appearance"), DefaultValue(typeof(Color), "Black")]
|
||||
[Description("Indicates the text Color.")]
|
||||
public Color TextColor
|
||||
{
|
||||
get { return (_TextColor); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_TextColor != value)
|
||||
{
|
||||
_TextColor = value;
|
||||
|
||||
OnGaugeItemChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TextHorizontalOffset
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the horizontal distance to offset the Indicator Text, measured as a percentage
|
||||
/// </summary>
|
||||
[Browsable(true)]
|
||||
[Category("Layout"), DefaultValue(0f)]
|
||||
[Editor("DevComponents.Instrumentation.Design.OffsetRangeValueEditor, DevComponents.Instrumentation.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=76cb4c6eb576bca5", typeof(UITypeEditor))]
|
||||
[Description("Indicates the horizontal distance to offset the Indicator Text, measured as a percentage.")]
|
||||
public float TextHorizontalOffset
|
||||
{
|
||||
get { return (_TextHorizontalOffset); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_TextHorizontalOffset != value)
|
||||
{
|
||||
_TextHorizontalOffset = value;
|
||||
|
||||
OnGaugeItemChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TextVerticalOffset
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the vertical distance to offset the Indicator Text, measured as a percentage
|
||||
/// </summary>
|
||||
[Browsable(true)]
|
||||
[Category("Layout"), DefaultValue(0f)]
|
||||
[Editor("DevComponents.Instrumentation.Design.OffsetRangeValueEditor, DevComponents.Instrumentation.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=76cb4c6eb576bca5", typeof(UITypeEditor))]
|
||||
[Description("Indicates the vertical distance to offset the Indicator Text, measured as a percentage.")]
|
||||
public float TextVerticalOffset
|
||||
{
|
||||
get { return (_TextVerticalOffset); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_TextVerticalOffset != value)
|
||||
{
|
||||
_TextVerticalOffset = value;
|
||||
|
||||
OnGaugeItemChanged(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Internal properties
|
||||
|
||||
#region AbsFont
|
||||
|
||||
internal override Font AbsFont
|
||||
{
|
||||
get
|
||||
{
|
||||
if (AutoSize == false)
|
||||
return (Font);
|
||||
|
||||
if (_AbsFont == null)
|
||||
{
|
||||
int n = Math.Min(Bounds.Width, Bounds.Height);
|
||||
|
||||
float emSize = Font.SizeInPoints;
|
||||
emSize = (emSize / 40) * n;
|
||||
|
||||
AbsFont = new Font(Font.FontFamily, emSize, Font.Style);
|
||||
}
|
||||
|
||||
return (_AbsFont);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_AbsFont != null)
|
||||
_AbsFont.Dispose();
|
||||
|
||||
_AbsFont = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event processing
|
||||
|
||||
#region StateRange processing
|
||||
|
||||
void StateRanges_CollectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
foreach (StateRange range in _Ranges)
|
||||
{
|
||||
range.StateIndicator = this;
|
||||
|
||||
range.IndicatorRangeChanged -= StateRange_ItemChanged;
|
||||
range.IndicatorRangeChanged += StateRange_ItemChanged;
|
||||
}
|
||||
}
|
||||
|
||||
void StateRange_ItemChanged(object sender, EventArgs e)
|
||||
{
|
||||
OnGaugeItemChanged(true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region RecalcLayout
|
||||
|
||||
public override void RecalcLayout()
|
||||
{
|
||||
if (NeedRecalcLayout == true)
|
||||
{
|
||||
Size size = Bounds.Size;
|
||||
|
||||
base.RecalcLayout();
|
||||
|
||||
if (size.Equals(Bounds.Size) == false)
|
||||
AbsFont = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region OnPaint
|
||||
|
||||
#region OnPaint
|
||||
|
||||
public override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
RecalcLayout();
|
||||
|
||||
if (GaugeControl.OnPreRenderIndicator(e, this) == false)
|
||||
{
|
||||
InterpolationMode im = g.InterpolationMode;
|
||||
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
|
||||
g.TranslateTransform(Center.X, Center.Y);
|
||||
g.RotateTransform(_Angle % 360);
|
||||
|
||||
Rectangle r = new Rectangle(0, 0, Bounds.Width, Bounds.Height);
|
||||
|
||||
r.X -= Bounds.Width / 2;
|
||||
r.Y -= Bounds.Height / 2;
|
||||
|
||||
StateRange range = GetStateRange();
|
||||
|
||||
DrawStateImage(g, r, range);
|
||||
DrawStateText(g, r, range);
|
||||
|
||||
GaugeControl.OnPostRenderIndicator(e, this);
|
||||
|
||||
g.ResetTransform();
|
||||
|
||||
g.InterpolationMode = im;
|
||||
}
|
||||
}
|
||||
|
||||
#region GetStateRange
|
||||
|
||||
private StateRange GetStateRange()
|
||||
{
|
||||
return (_Ranges != null ? _Ranges.GetValueRange(DValue) : null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region DrawStateImage
|
||||
|
||||
private void DrawStateImage(Graphics g, Rectangle r, StateRange range)
|
||||
{
|
||||
Image image = (range != null) ? range.Image : _Image;
|
||||
|
||||
if (image != null)
|
||||
{
|
||||
if (AutoSize == true)
|
||||
{
|
||||
g.DrawImage(image, r);
|
||||
}
|
||||
else
|
||||
{
|
||||
r.X += (r.Width - image.Width) / 2;
|
||||
r.Y += (r.Height - image.Height) / 2;
|
||||
|
||||
g.DrawImageUnscaled(image, r);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GradientFillColor fillColor =
|
||||
(range != null) ? range.BackColor : BackColor;
|
||||
|
||||
using (GraphicsPath path = GetStatePath(r))
|
||||
RenderBackPath(g, path, r, fillColor);
|
||||
}
|
||||
}
|
||||
|
||||
#region GetStatePath
|
||||
|
||||
private GraphicsPath GetStatePath(Rectangle r)
|
||||
{
|
||||
switch (_Style)
|
||||
{
|
||||
case StateIndicatorStyle.Circular:
|
||||
return (GetCircularState(r));
|
||||
|
||||
case StateIndicatorStyle.Rectangular:
|
||||
return (GetRectState(r));
|
||||
|
||||
default:
|
||||
return (GetRoundRectState(r));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetCircularState
|
||||
|
||||
private GraphicsPath GetCircularState(Rectangle bounds)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
|
||||
path.AddEllipse(bounds);
|
||||
|
||||
return (path);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetRectState
|
||||
|
||||
private GraphicsPath GetRectState(Rectangle bounds)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
|
||||
path.AddRectangle(bounds);
|
||||
|
||||
return (path);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetRoundRectState
|
||||
|
||||
private GraphicsPath GetRoundRectState(Rectangle bounds)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
|
||||
int m = Math.Min(bounds.Width, bounds.Height);
|
||||
int n = (int)(m * _RoundRectangleArc) + 1;
|
||||
|
||||
Rectangle t = new Rectangle(bounds.Right - n, bounds.Bottom - n, n, n);
|
||||
path.AddArc(t, 0, 90);
|
||||
|
||||
t.X = bounds.X;
|
||||
path.AddArc(t, 90, 90);
|
||||
|
||||
t.Y = bounds.Y;
|
||||
path.AddArc(t, 180, 90);
|
||||
|
||||
t.X = bounds.Right - n;
|
||||
path.AddArc(t, 270, 90);
|
||||
|
||||
path.CloseAllFigures();
|
||||
|
||||
return (path);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region RenderBackPath
|
||||
|
||||
private void RenderBackPath(Graphics g,
|
||||
GraphicsPath path, Rectangle bounds, GradientFillColor fillColor)
|
||||
{
|
||||
Rectangle r = bounds;
|
||||
GradientFillType fillType = fillColor.GradientFillType;
|
||||
|
||||
if (fillColor.End.IsEmpty)
|
||||
{
|
||||
fillType = GradientFillType.None;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fillColor.GradientFillType == GradientFillType.Auto)
|
||||
fillType = GradientFillType.Center;
|
||||
}
|
||||
|
||||
switch (fillType)
|
||||
{
|
||||
case GradientFillType.Angle:
|
||||
using (Brush br = fillColor.GetBrush(r))
|
||||
{
|
||||
if (br is LinearGradientBrush)
|
||||
((LinearGradientBrush)br).WrapMode = WrapMode.TileFlipXY;
|
||||
|
||||
g.FillPath(br, path);
|
||||
}
|
||||
break;
|
||||
|
||||
case GradientFillType.StartToEnd:
|
||||
using (Brush br = fillColor.GetBrush(r, 90))
|
||||
{
|
||||
if (br is LinearGradientBrush)
|
||||
((LinearGradientBrush)br).WrapMode = WrapMode.TileFlipXY;
|
||||
|
||||
g.FillPath(br, path);
|
||||
}
|
||||
break;
|
||||
|
||||
case GradientFillType.HorizontalCenter:
|
||||
r.Height /= 2;
|
||||
|
||||
if (r.Height <= 0)
|
||||
r.Height = 1;
|
||||
|
||||
using (LinearGradientBrush br = new
|
||||
LinearGradientBrush(r, fillColor.Start, fillColor.End, 90))
|
||||
{
|
||||
br.WrapMode = WrapMode.TileFlipXY;
|
||||
|
||||
g.FillPath(br, path);
|
||||
}
|
||||
break;
|
||||
|
||||
case GradientFillType.VerticalCenter:
|
||||
r.Width /= 2;
|
||||
|
||||
if (r.Width <= 0)
|
||||
r.Width = 1;
|
||||
|
||||
using (LinearGradientBrush br = new
|
||||
LinearGradientBrush(r, fillColor.Start, fillColor.End, 0f))
|
||||
{
|
||||
br.WrapMode = WrapMode.TileFlipXY;
|
||||
|
||||
g.FillPath(br, path);
|
||||
}
|
||||
break;
|
||||
|
||||
case GradientFillType.Center:
|
||||
using (PathGradientBrush br = new PathGradientBrush(path))
|
||||
{
|
||||
br.CenterPoint = new PointF(bounds.X + bounds.Width / 2, bounds.Y + bounds.Height / 2);
|
||||
br.CenterColor = fillColor.Start;
|
||||
br.SurroundColors = new Color[] { fillColor.End };
|
||||
|
||||
g.FillPath(br, path);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
using (Brush br = new SolidBrush(fillColor.Start))
|
||||
g.FillPath(br, path);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (fillColor.BorderWidth > 0 && fillColor.BorderColor.IsEmpty == false)
|
||||
{
|
||||
using (Pen pen = new Pen(fillColor.BorderColor, fillColor.BorderWidth))
|
||||
g.DrawPath(pen, path);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fillType == GradientFillType.Center)
|
||||
{
|
||||
using (Pen pen = new Pen(fillColor.End))
|
||||
g.DrawPath(pen, path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region DrawStateText
|
||||
|
||||
private void DrawStateText(Graphics g, Rectangle r, StateRange range)
|
||||
{
|
||||
string text = (range != null)
|
||||
? range.Text : GetOverrideString();
|
||||
|
||||
if (string.IsNullOrEmpty(text) == false)
|
||||
{
|
||||
using (StringFormat sf = new StringFormat())
|
||||
{
|
||||
SetStringAlignment(sf);
|
||||
|
||||
Color color = _TextColor;
|
||||
|
||||
if (range != null)
|
||||
{
|
||||
color = range.TextColor;
|
||||
|
||||
int dx = (int)(r.Width * range.TextHorizontalOffset);
|
||||
int dy = (int)(r.Height * range.TextVerticalOffset);
|
||||
|
||||
r.Offset(dx, dy);
|
||||
}
|
||||
else
|
||||
{
|
||||
int dx = (int)(r.Width * _TextHorizontalOffset);
|
||||
int dy = (int)(r.Height * _TextVerticalOffset);
|
||||
|
||||
r.Offset(dx, dy);
|
||||
}
|
||||
|
||||
using (Brush br = new SolidBrush(color))
|
||||
g.DrawString(text, AbsFont, br, r, sf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region SetStringAlignment
|
||||
|
||||
private void SetStringAlignment(StringFormat sf)
|
||||
{
|
||||
switch (_TextAlignment)
|
||||
{
|
||||
case TextAlignment.TopLeft:
|
||||
sf.LineAlignment = StringAlignment.Near;
|
||||
sf.Alignment = StringAlignment.Near;
|
||||
break;
|
||||
|
||||
case TextAlignment.TopCenter:
|
||||
sf.LineAlignment = StringAlignment.Near;
|
||||
sf.Alignment = StringAlignment.Center;
|
||||
break;
|
||||
|
||||
case TextAlignment.TopRight:
|
||||
sf.LineAlignment = StringAlignment.Near;
|
||||
sf.Alignment = StringAlignment.Far;
|
||||
break;
|
||||
|
||||
case TextAlignment.MiddleLeft:
|
||||
sf.LineAlignment = StringAlignment.Center;
|
||||
sf.Alignment = StringAlignment.Near;
|
||||
break;
|
||||
|
||||
case TextAlignment.MiddleCenter:
|
||||
sf.LineAlignment = StringAlignment.Center;
|
||||
sf.Alignment = StringAlignment.Center;
|
||||
break;
|
||||
|
||||
case TextAlignment.MiddleRight:
|
||||
sf.LineAlignment = StringAlignment.Center;
|
||||
sf.Alignment = StringAlignment.Far;
|
||||
break;
|
||||
|
||||
case TextAlignment.BottomLeft:
|
||||
sf.LineAlignment = StringAlignment.Far;
|
||||
sf.Alignment = StringAlignment.Near;
|
||||
break;
|
||||
|
||||
case TextAlignment.BottomCenter:
|
||||
sf.LineAlignment = StringAlignment.Far;
|
||||
sf.Alignment = StringAlignment.Center;
|
||||
break;
|
||||
|
||||
case TextAlignment.BottomRight:
|
||||
sf.LineAlignment = StringAlignment.Far;
|
||||
sf.Alignment = StringAlignment.Far;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Refresh
|
||||
|
||||
internal void Refresh()
|
||||
{
|
||||
if (NeedRecalcLayout == false)
|
||||
OnGaugeItemChanged(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Contains
|
||||
|
||||
internal override bool Contains(Point pt)
|
||||
{
|
||||
using (GraphicsPath path = GetStatePath(Bounds))
|
||||
{
|
||||
Matrix matrix = new Matrix();
|
||||
matrix.RotateAt(_Angle, Center);
|
||||
|
||||
path.Transform(matrix);
|
||||
|
||||
return (path.IsVisible(pt));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyToItem
|
||||
|
||||
public override void CopyToItem(GaugeItem copy)
|
||||
{
|
||||
StateIndicator c = copy as StateIndicator;
|
||||
|
||||
if (c != null)
|
||||
{
|
||||
base.CopyToItem(c);
|
||||
|
||||
c.Angle = _Angle;
|
||||
c.Image = _Image;
|
||||
|
||||
if (_Ranges != null)
|
||||
c.Ranges = (StateRangeCollection)_Ranges.Clone();
|
||||
|
||||
c.RoundRectangleArc = _RoundRectangleArc;
|
||||
c.Style = _Style;
|
||||
c.TextAlignment = _TextAlignment;
|
||||
c.TextColor = _TextColor;
|
||||
c.TextHorizontalOffset = _TextHorizontalOffset;
|
||||
c.TextVerticalOffset = _TextVerticalOffset;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#region Enums
|
||||
|
||||
public enum StateIndicatorStyle
|
||||
{
|
||||
Rectangular,
|
||||
RoundedRectangular,
|
||||
Circular
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
@@ -0,0 +1,251 @@
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using DevComponents.Instrumentation.Primitives;
|
||||
|
||||
namespace DevComponents.Instrumentation
|
||||
{
|
||||
public class StateRangeCollection : GenericCollection<StateRange>
|
||||
{
|
||||
#region GetValueRange
|
||||
|
||||
public StateRange GetValueRange(double value)
|
||||
{
|
||||
foreach (StateRange range in this)
|
||||
{
|
||||
if (value >= range.StartValue && value <= range.EndValue)
|
||||
return (range);
|
||||
}
|
||||
|
||||
return (null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
StateRangeCollection copy = new StateRangeCollection();
|
||||
|
||||
CopyToItem(copy);
|
||||
|
||||
return (copy);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyToItem
|
||||
|
||||
internal void CopyToItem(StateRangeCollection copy)
|
||||
{
|
||||
foreach (StateRange item in this)
|
||||
{
|
||||
StateRange ic = new StateRange();
|
||||
|
||||
item.CopyToItem(ic);
|
||||
|
||||
copy.Add(ic);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class StateRange : IndicatorRange
|
||||
{
|
||||
#region Private variables
|
||||
|
||||
private Image _Image;
|
||||
private StateIndicator _StateIndicator;
|
||||
|
||||
private string _Text;
|
||||
private Color _TextColor;
|
||||
private float _TextVerticalOffset;
|
||||
private float _TextHorizontalOffset;
|
||||
|
||||
#endregion
|
||||
|
||||
public StateRange()
|
||||
{
|
||||
TextColor = Color.Black;
|
||||
}
|
||||
|
||||
#region Public properties
|
||||
|
||||
#region Image
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Image to use
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Appearance"), DefaultValue(null)]
|
||||
[Description("Indicates the Image to use.")]
|
||||
public Image Image
|
||||
{
|
||||
get { return (_Image); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Image != value)
|
||||
{
|
||||
_Image = value;
|
||||
|
||||
OnIndicatorRangeChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region StateIndicator
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the StateIndicator
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public StateIndicator StateIndicator
|
||||
{
|
||||
get { return (_StateIndicator); }
|
||||
internal set { _StateIndicator = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Text
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the text to be displayed
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Behavior"), DefaultValue(null)]
|
||||
[Description("Indicates the text to be displayed.")]
|
||||
public string Text
|
||||
{
|
||||
get { return (_Text); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_Text != value)
|
||||
{
|
||||
_Text = value;
|
||||
|
||||
OnIndicatorRangeChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TextColor
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the text Color
|
||||
/// </summary>
|
||||
[Browsable(true), Category("Appearance"), DefaultValue(typeof(Color), "Black")]
|
||||
[Description("Indicates the text Color.")]
|
||||
public Color TextColor
|
||||
{
|
||||
get { return (_TextColor); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_TextColor != value)
|
||||
{
|
||||
_TextColor = value;
|
||||
|
||||
OnIndicatorRangeChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TextHorizontalOffset
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the horizontal distance to offset the Indicator Text, measured as a percentage
|
||||
/// </summary>
|
||||
[Browsable(true)]
|
||||
[Category("Layout"), DefaultValue(0f)]
|
||||
[Editor("DevComponents.Instrumentation.Design.OffsetRangeValueEditor, DevComponents.Instrumentation.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=76cb4c6eb576bca5", typeof(UITypeEditor))]
|
||||
[Description("Indicates the horizontal distance to offset the Indicator Text, measured as a percentage.")]
|
||||
public float TextHorizontalOffset
|
||||
{
|
||||
get { return (_TextHorizontalOffset); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_TextHorizontalOffset != value)
|
||||
{
|
||||
_TextHorizontalOffset = value;
|
||||
|
||||
OnIndicatorRangeChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region TextVerticalOffset
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the vertical distance to offset the Indicator Text, measured as a percentage
|
||||
/// </summary>
|
||||
[Browsable(true)]
|
||||
[Category("Layout"), DefaultValue(0f)]
|
||||
[Editor("DevComponents.Instrumentation.Design.OffsetRangeValueEditor, DevComponents.Instrumentation.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=76cb4c6eb576bca5", typeof(UITypeEditor))]
|
||||
[Description("Indicates the vertical distance to offset the Indicator Text, measured as a percentage.")]
|
||||
public float TextVerticalOffset
|
||||
{
|
||||
get { return (_TextVerticalOffset); }
|
||||
|
||||
set
|
||||
{
|
||||
if (_TextVerticalOffset != value)
|
||||
{
|
||||
_TextVerticalOffset = value;
|
||||
|
||||
OnIndicatorRangeChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region ICloneable Members
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
StateRange copy = new StateRange();
|
||||
|
||||
CopyToItem(copy);
|
||||
|
||||
return (copy);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CopyToItem
|
||||
|
||||
public override void CopyToItem(GaugeItem copy)
|
||||
{
|
||||
StateRange c = copy as StateRange;
|
||||
|
||||
if (c != null)
|
||||
{
|
||||
base.CopyToItem(c);
|
||||
|
||||
c.Image = _Image;
|
||||
c.Text = _Text;
|
||||
c.TextColor = _TextColor;
|
||||
c.TextHorizontalOffset = _TextHorizontalOffset;
|
||||
c.TextVerticalOffset = _TextVerticalOffset;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user