DotNet 4.8.1 build of DotNetBar

This commit is contained in:
2025-02-07 10:35:23 -05:00
parent 33439b63a0
commit 6b0a5d60f4
2609 changed files with 989814 additions and 7 deletions

View File

@@ -0,0 +1,327 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Globalization;
using System.Windows.Forms;
namespace DevComponents.Instrumentation
{
[TypeConverter(typeof(GaugeTickMarkConvertor))]
public class GaugeTickMark : GaugeTickMarkBase
{
#region Private variables
private double _Interval;
private double _IntervalOffset;
private double _DefaultInterval;
private TickPoint[] _TickPoints;
#endregion
public GaugeTickMark(GaugeScale scale, GaugeTickMarkRank rank,
GaugeMarkerStyle style, float width, float length, double interval)
: base(scale, rank, style, width, length)
{
_Interval = interval;
_DefaultInterval = interval;
}
#region Public properties
#region Interval
/// <summary>
/// Gets or sets the TickMark Interval spacing
/// </summary>
[Browsable(true)]
[Category("Layout")]
[Description("Indicates the TickMark Interval spacing.")]
public double Interval
{
get { return (_Interval); }
set
{
if (value < 0)
throw new ArgumentException("Value can not be less than zero.");
if (_Interval != value)
{
_Interval = value;
OnGaugeItemChanged(true);
}
}
}
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public bool ShouldSerializeInterval()
{
return (_Interval != _DefaultInterval);
}
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public void ResetInterval()
{
Interval = _DefaultInterval;
}
#endregion
#region IntervalOffset
/// <summary>
/// Gets or sets the initial TickMark Interval Offset
/// </summary>
[Browsable(true)]
[Category("Layout"), DefaultValue(0d)]
[Description("Indicates the initial TickMark Interval Offset.")]
public double IntervalOffset
{
get { return (_IntervalOffset); }
set
{
if (value < 0)
throw new ArgumentException("Value can not be less than zero.");
if (_IntervalOffset != value)
{
_IntervalOffset = value;
OnGaugeItemChanged(true);
}
}
}
#endregion
#endregion
#region Internal properties
#region TickPoints
internal TickPoint[] TickPoints
{
get { return (_TickPoints); }
set { _TickPoints = value; }
}
#endregion
#endregion
#region RecalcLayout
public override void RecalcLayout()
{
if (NeedRecalcLayout == true)
{
base.RecalcLayout();
CalcTickPoints();
Scale.NeedLabelRecalcLayout = true;
}
}
#region CalcTickPoints
private void CalcTickPoints()
{
_TickPoints = null;
if (_Interval > 0)
{
double ticks = Scale.MaxValue - Scale.MinValue;
if (ticks > 0)
{
int n = (int) ((ticks - _IntervalOffset)/_Interval) + 1;
if (n > 0)
{
if (Scale is GaugeCircularScale)
CalcCircularTickPoints(Scale as GaugeCircularScale, ticks, n);
else if (Scale is GaugeLinearScale)
CalcLinearTickPoints(Scale as GaugeLinearScale, ticks, n);
}
}
}
}
#region CalcCircularTickPoints
private void CalcCircularTickPoints(
GaugeCircularScale scale, double ticks, int n)
{
double dpt = scale.SweepAngle / ticks;
double theta = _Interval * dpt;
double startAngle = scale.StartAngle;
if (scale.Reversed == true)
startAngle += scale.SweepAngle;
int dir = scale.Reversed ? -1 : 1;
startAngle += (dpt * _IntervalOffset * dir);
_TickPoints = new TickPoint[n];
double interval = _IntervalOffset;
for (int i = 0; i < n; i++)
{
_TickPoints[i] = new TickPoint(this);
_TickPoints[i].Angle = (float)(startAngle + (i * theta * dir));
_TickPoints[i].Point = scale.GetPoint(Radius, _TickPoints[i].Angle);
_TickPoints[i].Interval = interval;
interval += _Interval;
}
}
#endregion
#region CalcLinearTickPoints
private void CalcLinearTickPoints(
GaugeLinearScale scale, double ticks, int n)
{
double dpt = scale.AbsScaleLength/ticks;
if (scale.Orientation == Orientation.Horizontal)
CalcHorizontalTickPoints(n, dpt);
else
CalcVerticalTickPoints(n, dpt);
}
#region CalcHorizontalTickPoints
private void CalcHorizontalTickPoints(int n, double dpt)
{
_TickPoints = new TickPoint[n];
double interval = _IntervalOffset;
for (int i = 0; i < n; i++)
{
_TickPoints[i] = new TickPoint(this);
int x = (Scale.Reversed == true)
? Bounds.Right - (int)(dpt * interval)
: Bounds.X + (int)(dpt * interval);
_TickPoints[i].Point = new Point(x, Bounds.Y);
_TickPoints[i].Interval = interval;
interval += _Interval;
}
}
#endregion
#region CalcVerticalTickPoints
private void CalcVerticalTickPoints(int n, double dpt)
{
_TickPoints = new TickPoint[n];
double interval = _IntervalOffset;
for (int i = 0; i < n; i++)
{
_TickPoints[i] = new TickPoint(this);
int y = (Scale.Reversed == true)
? Bounds.Top + (int)(dpt * interval)
: Bounds.Bottom - (int)(dpt * interval);
_TickPoints[i].Point = new Point(Bounds.X, y);
_TickPoints[i].Interval = interval;
interval += _Interval;
}
}
#endregion
#endregion
#endregion
#endregion
#region ICloneable Members
public override object Clone()
{
GaugeTickMark copy = new
GaugeTickMark(Scale, Rank, Layout.Style, Width, Length, Interval);
CopyToItem(copy);
return (copy);
}
#endregion
#region CopyToItem
public override void CopyToItem(GaugeItem copy)
{
GaugeTickMark c = copy as GaugeTickMark;
if (c != null)
{
base.CopyToItem(c);
c.Interval = _Interval;
c.IntervalOffset = _IntervalOffset;
c._DefaultInterval = _DefaultInterval;
}
}
#endregion
}
#region GaugeTickMarkConvertor
public class GaugeTickMarkConvertor : ExpandableObjectConverter
{
public override object ConvertTo(
ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof(string))
{
GaugeTickMark tickMark = value as GaugeTickMark;
if (tickMark != null)
{
//ColorConverter cvt = new ColorConverter();
//if (lct.Start != Color.Empty)
// return (cvt.ConvertToString(lct.Start));
//if (lct.End != Color.Empty)
// return (cvt.ConvertToString(lct.End));
//if (lct.GradientAngle != 90)
// return (lct.GradientAngle.ToString());
return (String.Empty);
}
}
return (base.ConvertTo(context, culture, value, destinationType));
}
}
#endregion
}

View File

@@ -0,0 +1,596 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Globalization;
using System.Windows.Forms;
namespace DevComponents.Instrumentation
{
[TypeConverter(typeof(GaugeTickMarkBaseConvertor))]
public class GaugeTickMarkBase : GaugeItem
{
#region Private variables
private int _Radius;
private int _Width;
private int _Length;
private int _Offset;
private Rectangle _Bounds;
private TickMarkLayout _Layout;
private GaugeTickMarkRank _Rank;
private GaugeMarker _GaugeMarker;
private GaugeScale _Scale;
#endregion
public GaugeTickMarkBase(GaugeScale scale,
GaugeTickMarkRank rank, GaugeMarkerStyle style, float width, float length)
: this(scale, rank, new TickMarkLayout(style, width, length))
{
}
public GaugeTickMarkBase(GaugeScale scale, GaugeTickMarkRank rank, TickMarkLayout layout)
{
_Scale = scale;
_Rank = rank;
_Layout = layout;
_GaugeMarker = new GaugeMarker();
HookEvents(true);
}
#region Hidden properties
#region Name
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public new string Name
{
get { return (base.Name); }
set { base.Name = value; }
}
#endregion
#region Tooltip
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public new string Tooltip
{
get { return (base.Tooltip); }
set { base.Tooltip = value; }
}
#endregion
#endregion
#region Public properties
#region Scale
/// <summary>
/// Gets the associated Scale
/// </summary>
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public GaugeScale Scale
{
get { return (_Scale); }
internal set { _Scale = value; }
}
#endregion
#region Layout
/// <summary>
/// Gets the Tickmark leyout
/// </summary>
[Browsable(true), Category("Layout")]
[Description("Specifies the TickMark layout properties.")]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public TickMarkLayout Layout
{
get { return (_Layout); }
}
#endregion
#region Visible
public override bool Visible
{
get { return (base.Visible); }
set
{
if (base.Visible != value)
{
base.Visible = value;
if (_Scale != null)
_Scale.Labels.NeedRecalcLayout = true;
}
}
}
#endregion
#endregion
#region Internal properties
#region Bounds
internal Rectangle Bounds
{
get { return (_Bounds); }
set { _Bounds = value; }
}
#endregion
#region Length
internal int Length
{
get { return (_Length); }
set { _Length = value; }
}
#endregion
#region Offset
internal int Offset
{
get { return (_Offset); }
set { _Offset = value; }
}
#endregion
#region Radius
internal int Radius
{
get { return (_Radius); }
}
#endregion
#region Rank
internal GaugeTickMarkRank Rank
{
get { return (_Rank); }
}
#endregion
#region Width
internal int Width
{
get { return (_Width); }
set { _Width = value; }
}
#endregion
#endregion
#region HookEvents
private void HookEvents(bool hook)
{
if (hook == true)
{
_Layout.TickMarkLayoutChanged += TickMarkLayout_TickMarkLayoutChanged;
}
else
{
_Layout.TickMarkLayoutChanged -= TickMarkLayout_TickMarkLayoutChanged;
}
}
#endregion
#region Event processing
void TickMarkLayout_TickMarkLayoutChanged(object sender, EventArgs e)
{
OnGaugeItemChanged(true);
}
#endregion
#region RecalcLayout
public override void RecalcLayout()
{
if (NeedRecalcLayout == true)
{
base.RecalcLayout();
CalcTickMarkMetrics();
_GaugeMarker.Clear();
}
}
#region CalcTickMarkMetrics
private void CalcTickMarkMetrics()
{
if (Scale is GaugeCircularScale)
CalcCircularMetrics(Scale as GaugeCircularScale);
else if (Scale is GaugeLinearScale)
CalcLinearMetrics(Scale as GaugeLinearScale);
}
#region CalcCircularMetrics
private void CalcCircularMetrics(GaugeCircularScale scale)
{
_Radius = scale.AbsRadius;
_Length = (int)(_Radius * _Layout.Length);
_Width = (int)(_Radius * _Layout.Width);
int m = scale.AbsScaleWidth;
int offset = (int)(scale.AbsRadius * _Layout.ScaleOffset);
switch (_Layout.Placement)
{
case DisplayPlacement.Near:
_Radius -= ((_Length + m / 2) + offset);
break;
case DisplayPlacement.Center:
_Radius += ((_Length / 2) + offset + 1);
break;
case DisplayPlacement.Far:
_Radius += ((_Length + m / 2) + offset);
break;
}
}
#endregion
#region CalcLinearMetrics
private void CalcLinearMetrics(GaugeLinearScale scale)
{
if (scale.Orientation == Orientation.Horizontal)
CalcHorizontalLayout(scale);
else
CalcVerticalLayout(scale);
}
#region CalcHorizontalLayout
private void CalcHorizontalLayout(GaugeLinearScale scale)
{
int n = scale.AbsWidth;
_Length = (int)(n * _Layout.Length);
_Width = (int)(n * _Layout.Width);
if (_Layout.Length > 0 && _Length < 2)
_Length = 2;
if (_Layout.Width > 0 && _Width < 2)
_Width = 2;
int offset = (int) (n * _Layout.ScaleOffset);
_Bounds = scale.ScaleBounds;
_Bounds.Height = _Length;
switch (_Layout.Placement)
{
case DisplayPlacement.Near:
_Bounds.Y = scale.ScaleBounds.Top - _Length - offset;
break;
case DisplayPlacement.Center:
_Bounds.Y = scale.Center.Y - _Length / 2 - offset;
break;
case DisplayPlacement.Far:
_Bounds.Y = scale.ScaleBounds.Bottom + offset;
break;
}
_Offset = _Bounds.Y - scale.ScaleBounds.Y;
}
#endregion
#region CalcVerticalLayout
private void CalcVerticalLayout(GaugeLinearScale scale)
{
int n = scale.AbsWidth;
_Length = (int)(n * _Layout.Length);
_Width = (int)(n * _Layout.Width);
if (_Layout.Length > 0 && _Length < 2)
_Length = 2;
if (_Layout.Width > 0 && _Width < 2)
_Width = 2;
int offset = (int)(n * _Layout.ScaleOffset);
_Bounds = scale.ScaleBounds;
_Bounds.Width = _Length;
switch (_Layout.Placement)
{
case DisplayPlacement.Near:
_Bounds.X = scale.ScaleBounds.Left - _Length - offset;
break;
case DisplayPlacement.Center:
_Bounds.X = scale.Center.X - _Length / 2 - offset;
break;
case DisplayPlacement.Far:
_Bounds.X = scale.ScaleBounds.Right + offset;
break;
}
_Offset = _Bounds.X - scale.ScaleBounds.X;
}
#endregion
#endregion
#endregion
#endregion
#region Paint support
#region PaintTickPoint
#region PaintTickPoint
internal void PaintTickPoint(Graphics g, TickPoint tp)
{
Image image = _Layout.Image ?? GetTickMarkBitmap(g, tp);
if (image != null)
{
if (Scale is GaugeCircularScale)
PaintCircularTickPoint(g, tp, image);
else if (Scale is GaugeLinearScale)
PaintLinearTickPoint(g, tp, image, Scale as GaugeLinearScale);
}
}
#endregion
#region PaintCircularTickPoint
private void PaintCircularTickPoint(Graphics g, TickPoint tp, Image image)
{
Rectangle r = new Rectangle(0, 0, _Width, _Length);
float angle = tp.Angle + 90;
if (_Layout.Placement == DisplayPlacement.Near)
angle += 180;
g.TranslateTransform(tp.Point.X, tp.Point.Y);
g.RotateTransform(angle % 360);
r.X -= _Width / 2;
g.DrawImage(image, r);
g.ResetTransform();
}
#endregion
#region PaintLinearTickPoint
private void PaintLinearTickPoint(Graphics g,
TickPoint tp, Image image, GaugeLinearScale scale)
{
if (scale.Orientation == Orientation.Horizontal)
PaintHorizontalTickPoint(g, tp, image);
else
PaintVerticalTickPoint(g, tp, image);
}
#region PaintHorizontalTickPoint
private void PaintHorizontalTickPoint(Graphics g, TickPoint tp, Image image)
{
if (_Layout.Placement != DisplayPlacement.Far)
{
Rectangle r = new Rectangle(tp.Point.X, tp.Point.Y, _Width, _Length);
r.X -= _Width / 2;
g.DrawImage(image, r);
}
else
{
Rectangle r = new Rectangle(0, 0, _Width, _Length);
g.TranslateTransform(tp.Point.X, tp.Point.Y + _Length - (_Length % 2));
g.RotateTransform(180);
r.X -= _Width / 2;
g.DrawImage(image, r);
g.ResetTransform();
}
}
#endregion
#region PaintVerticalTickPoint
private void PaintVerticalTickPoint(Graphics g, TickPoint tp, Image image)
{
Rectangle r = new Rectangle(0, 0, _Width, _Length);
if (_Layout.Placement == DisplayPlacement.Far)
{
g.TranslateTransform(tp.Point.X + _Length - (_Length % 2), tp.Point.Y);
g.RotateTransform(90);
}
else
{
g.TranslateTransform(tp.Point.X, tp.Point.Y);
g.RotateTransform(-90);
}
r.X -= (_Width / 2);
g.DrawImage(image, r);
g.ResetTransform();
}
#endregion
#endregion
#endregion
#region GetTickMarkBitmap
internal Bitmap GetTickMarkBitmap(Graphics g, TickPoint tp)
{
if (_Layout.Style != GaugeMarkerStyle.None)
{
if (_Width > 0 && _Length > 0)
{
return (_GaugeMarker.GetMarkerBitmap(g, _Layout.Style,
GetTickMarkFillColor(tp), _Width, _Length));
}
}
return (null);
}
#endregion
#region GetTickMarkFillColor
private GradientFillColor GetTickMarkFillColor(TickPoint tp)
{
if (_Rank == GaugeTickMarkRank.Custom)
return (Layout.FillColor);
ColorSourceFillEntry entry = (_Rank == GaugeTickMarkRank.Major)
? ColorSourceFillEntry.MajorTickMark : ColorSourceFillEntry.MinorTickMark;
GradientFillColor fillColor = (Scale.GetRangeFillColor(tp.Interval, entry) ??
Scale.GetSectionFillColor(tp.Interval, entry)) ?? Layout.FillColor;
return (fillColor);
}
#endregion
#endregion
#region OnDispose
protected override void OnDispose()
{
HookEvents(false);
_GaugeMarker.Dispose();
base.OnDispose();
}
#endregion
#region ICloneable Members
public override object Clone()
{
GaugeTickMarkBase copy = new GaugeTickMarkBase(
_Scale, _Rank, _Layout.Style, _Layout.Width, _Layout.Length);
CopyToItem(copy);
return (copy);
}
#endregion
#region CopyToItem
public override void CopyToItem(GaugeItem copy)
{
GaugeTickMarkBase c = copy as GaugeTickMarkBase;
if (c != null)
{
base.CopyToItem(c);
_Layout.CopyToItem(c.Layout);
}
}
#endregion
}
#region GaugeTickMarkBaseConvertor
public class GaugeTickMarkBaseConvertor : ExpandableObjectConverter
{
public override object ConvertTo(
ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof(string))
{
GaugeTickMarkBase tickMark = value as GaugeTickMarkBase;
if (tickMark != null)
{
return (String.Empty);
}
}
return (base.ConvertTo(context, culture, value, destinationType));
}
}
#endregion
#region Enums
public enum GaugeTickMarkRank
{
Major,
Minor,
Custom
}
public enum GaugeTickMarkOverlap
{
ReplaceNone,
ReplaceLast,
ReplaceAll
}
#endregion
}

View File

@@ -0,0 +1,171 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Globalization;
using System.Windows.Forms;
namespace DevComponents.Instrumentation
{
[TypeConverter(typeof(GaugeTickMarkLabelConvertor))]
public class GaugeTickMarkLabel : GaugeTickMarkBase
{
#region Private properties
private TickPoint _TickPoint;
private double _Interval;
#endregion
public GaugeTickMarkLabel(GaugeScale scale, GaugeTickMarkRank rank,
GaugeMarkerStyle style, float width, float length, double interval)
: base(scale, rank, style, width, length)
{
_Interval = interval;
}
#region Internal properties
internal double Interval
{
get { return (_Interval); }
set { _Interval = value; }
}
internal TickPoint TickPoint
{
get { return (_TickPoint); }
set { _TickPoint = value; }
}
#endregion
#region RecalcLayout
public override void RecalcLayout()
{
if (NeedRecalcLayout == true)
{
base.RecalcLayout();
CalcTickPoint();
}
}
#region CalcTickPoint
private void CalcTickPoint()
{
_TickPoint = null;
if (Scale is GaugeCircularScale)
CalcCircularTickPoint(Scale as GaugeCircularScale);
else if (Scale is GaugeLinearScale)
CalcLinearTickPoint(Scale as GaugeLinearScale);
}
#region CalcCircularTickPoint
private void CalcCircularTickPoint(GaugeCircularScale scale)
{
double spread = Scale.MaxValue - Scale.MinValue;
double dpt = scale.SweepAngle / spread;
if (_Interval >= 0 && _Interval <= spread)
{
_TickPoint = new TickPoint(this);
if (scale.Reversed == true)
_TickPoint.Angle = (float)(scale.StartAngle + scale.SweepAngle - (_Interval * dpt));
else
_TickPoint.Angle = (float)(scale.StartAngle + _Interval * dpt);
_TickPoint.Point = scale.GetPoint(Radius, _TickPoint.Angle);
_TickPoint.Interval = _Interval;
}
}
#endregion
#region CalcLinearTickPoint
private void CalcLinearTickPoint(GaugeLinearScale scale)
{
double spread = Math.Abs(scale.MaxValue - scale.MinValue);
double dpt = scale.AbsScaleLength / spread;
if (_Interval >= 0 && _Interval <= spread)
{
if (scale.Orientation == Orientation.Horizontal)
CalcHorizontalTickPoint(scale, dpt);
else
CalcVerticalTickPoint(scale, dpt);
}
}
#region CalcHorizontalTickPoint
private void CalcHorizontalTickPoint(GaugeLinearScale scale, double dpt)
{
_TickPoint = new TickPoint(this);
int x = (scale.Reversed == true)
? Scale.Bounds.Right - (int)(dpt * _Interval)
: Scale.Bounds.X + (int)(dpt * _Interval);
int y = scale.ScaleBounds.Y + Offset;
_TickPoint.Point = new Point(x, y);
_TickPoint.Interval = _Interval;
}
#endregion
#region CalcVerticalTickPoint
private void CalcVerticalTickPoint(GaugeLinearScale scale, double dpt)
{
_TickPoint = new TickPoint(this);
int x = scale.ScaleBounds.X + Offset;
int y = (scale.Reversed == true)
? Scale.Bounds.Top + (int)(dpt * _Interval)
: Scale.Bounds.Bottom - (int)(dpt * _Interval);
_TickPoint.Point = new Point(x, y);
_TickPoint.Interval = _Interval;
}
#endregion
#endregion
#endregion
#endregion
}
#region GaugeLabelTickMarkConvertor
public class GaugeTickMarkLabelConvertor : ExpandableObjectConverter
{
public override object ConvertTo(
ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof(string))
{
GaugeTickMarkLabel tickMark = value as GaugeTickMarkLabel;
if (tickMark != null)
{
return (String.Empty);
}
}
return (base.ConvertTo(context, culture, value, destinationType));
}
}
#endregion
}

View File

@@ -0,0 +1,456 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Globalization;
namespace DevComponents.Instrumentation
{
[TypeConverter(typeof(TickMarkLayoutConvertor))]
public class TickMarkLayout : IDisposable, ICloneable
{
#region Events
public event EventHandler<EventArgs> TickMarkLayoutChanged;
#endregion
#region Private variables
private GaugeMarkerStyle _Style;
private DisplayPlacement _Placement;
private float _ScaleOffset;
private float _Width;
private float _Length;
private GradientFillColor _FillColor;
private GaugeTickMarkOverlap _Overlap;
private Image _Image;
private Bitmap _Bitmap;
private float _DefaultWidth;
private float _DefaultLength;
private GaugeMarkerStyle _DefaultStyle;
#endregion
public TickMarkLayout()
: this(GaugeMarkerStyle.Rectangle, .045f, .09f)
{
}
public TickMarkLayout(GaugeMarkerStyle style, float width, float length)
{
_Style = style;
_Width = width;
_Length = length;
_DefaultStyle = style;
_DefaultWidth = width;
_DefaultLength = length;
_Placement = DisplayPlacement.Center;
FillColor = new GradientFillColor(Color.DarkGray, Color.White);
FillColor.BorderColor = Color.DimGray;
FillColor.BorderWidth = 1;
_Overlap = GaugeTickMarkOverlap.ReplaceAll;
}
#region Public properties
#region FillColor
/// <summary>
/// Gets or sets the TickMark Fill Color
/// </summary>
[Browsable(true), Category("Appearance")]
[Description("Indicates the TickMark Fill Color.")]
public GradientFillColor FillColor
{
get
{
if (_FillColor == null)
{
_FillColor = new GradientFillColor();
_FillColor.ColorTableChanged += FillColor_ColorTableChanged;
}
return (_FillColor);
}
set
{
if (_FillColor != null)
_FillColor.ColorTableChanged -= FillColor_ColorTableChanged;
_FillColor = value;
if (_FillColor != null)
_FillColor.ColorTableChanged += FillColor_ColorTableChanged;
OnTickMarkLayoutChanged();
}
}
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
internal bool ShouldSerializeFillColor()
{
return (_FillColor.IsEqualTo(Color.DarkGray,
Color.White, 90, GradientFillType.Auto, Color.DimGray, 1) == false);
}
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
internal void ResetFillColor()
{
FillColor = new GradientFillColor(Color.DarkGray, Color.White);
FillColor.BorderColor = Color.DimGray;
FillColor.BorderWidth = 1;
}
#endregion
#region Image
/// <summary>
/// Gets or sets the Image to use for the TickMark
/// </summary>
[Browsable(true), Category("Appearance"), DefaultValue(null)]
[Description("Indicates the Image to use for the TickMark.")]
public Image Image
{
get { return (_Image); }
set
{
if (_Image != value)
{
_Image = value;
OnTickMarkLayoutChanged();
}
}
}
#endregion
#region Length
/// <summary>
/// Gets or sets the Length of the TickMark, specified as a percentage
/// </summary>
[Browsable(true), Category("Layout")]
[Editor("DevComponents.Instrumentation.Design.RangeValueEditor, DevComponents.Instrumentation.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=76cb4c6eb576bca5", typeof(UITypeEditor))]
[Description("Indicates the Length of the TickMark, specified as a percentage.")]
public float Length
{
get { return (_Length); }
set
{
if (value < 0)
throw new ArgumentException("Value can not be less than zero.");
if (_Length != value)
{
_Length = value;
OnTickMarkLayoutChanged();
}
}
}
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public bool ShouldSerializeLength()
{
return (_Length != _DefaultLength);
}
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public void ResetLength()
{
Length = _DefaultLength;
}
#endregion
#region Placement
/// <summary>
/// Gets or sets the Placement of the TickMarks with respect to the Scale
/// </summary>
[Browsable(true)]
[Category("Layout"), DefaultValue(DisplayPlacement.Center)]
[Description("Indicates the Placement of the TickMarks with respect to the Scale.")]
public DisplayPlacement Placement
{
get { return (_Placement); }
set
{
if (_Placement != value)
{
_Placement = value;
OnTickMarkLayoutChanged();
}
}
}
#endregion
#region ScaleOffset
/// <summary>
/// Gets or sets the distance from the TickMark to the Scale, 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 distance from the TickMark to the Scale, measured as a percentage.")]
public float ScaleOffset
{
get { return (_ScaleOffset); }
set
{
if (_ScaleOffset != value)
{
_ScaleOffset = value;
OnTickMarkLayoutChanged();
}
}
}
#endregion
#region Style
/// <summary>
/// Gets or sets the TickMark Style
/// </summary>
[Browsable(true), Category("Appearance")]
[Description("Indicates the TickMark Style.")]
public GaugeMarkerStyle Style
{
get { return (_Style); }
set
{
if (_Style != value)
{
_Style = value;
OnTickMarkLayoutChanged();
}
}
}
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public bool ShouldSerializeStyle()
{
return (_Style != _DefaultStyle);
}
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public void ResetStyle()
{
Style = _DefaultStyle;
}
#endregion
#region Overlap
/// <summary>
/// Gets or sets how the TickMark overlaps previous TickMarks
/// </summary>
[Browsable(true)]
[Category("Behavior"), DefaultValue(GaugeTickMarkOverlap.ReplaceAll)]
[Description("Indicates how the TickMark overlaps previous TickMarks.")]
public GaugeTickMarkOverlap Overlap
{
get { return (_Overlap); }
set
{
if (_Overlap != value)
{
_Overlap = value;
OnTickMarkLayoutChanged();
}
}
}
#endregion
#region Width
/// <summary>
/// Gets or sets the Width of the TickMark, specified as a percentage
/// </summary>
[Browsable(true)]
[Category("Layout")]
[Editor("DevComponents.Instrumentation.Design.WidthRangeValueEditor, DevComponents.Instrumentation.Design, Version=14.1.0.37, Culture=neutral, PublicKeyToken=76cb4c6eb576bca5", typeof(UITypeEditor))]
[Description("Indicates the Width of the TickMark, specified as a percentage.")]
public float Width
{
get { return (_Width); }
set
{
if (value < 0)
throw new ArgumentException("Value can not be less than zero.");
if (_Width != value)
{
_Width = value;
OnTickMarkLayoutChanged();
}
}
}
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public bool ShouldSerializeWidth()
{
return (_Width != _DefaultWidth);
}
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
public void ResetWidth()
{
Width = _DefaultWidth;
}
#endregion
#endregion
#region Internal properties
#region Bitmap
internal Bitmap Bitmap
{
get { return (_Bitmap); }
set
{
if (_Bitmap != null)
_Bitmap.Dispose();
_Bitmap = value;
}
}
#endregion
#endregion
#region HookEvents
private void HookEvents(bool hook)
{
if (hook == true)
{
}
else
{
if (_FillColor != null)
_FillColor.ColorTableChanged -= FillColor_ColorTableChanged;
}
}
#endregion
#region Event processing
void FillColor_ColorTableChanged(object sender, EventArgs e)
{
OnTickMarkLayoutChanged();
}
#endregion
#region OnTickMarkLayoutChanged
protected virtual void OnTickMarkLayoutChanged()
{
if (TickMarkLayoutChanged != null)
TickMarkLayoutChanged(this, EventArgs.Empty);
}
#endregion
#region IDisposable Members
public void Dispose()
{
HookEvents(false);
}
#endregion
#region ICloneable Members
public virtual object Clone()
{
TickMarkLayout copy = new
TickMarkLayout(_Style, _Width, _Length);
CopyToItem(copy);
return (copy);
}
#endregion
#region CopyToItem
internal virtual void CopyToItem(TickMarkLayout copy)
{
if (_FillColor != null)
copy.FillColor = (GradientFillColor) _FillColor.Clone();
copy.Image = _Image;
copy.Length = _Length;
copy.Placement = _Placement;
copy.ScaleOffset = _ScaleOffset;
copy.Style = _Style;
copy.Overlap = _Overlap;
copy.Width = _Width;
}
#endregion
}
#region TickMarkLayoutConvertor
public class TickMarkLayoutConvertor : ExpandableObjectConverter
{
public override object ConvertTo(
ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof(string))
{
TickMarkLayout layout = value as TickMarkLayout;
if (layout != null)
{
return (String.Empty);
}
}
return (base.ConvertTo(context, culture, value, destinationType));
}
}
#endregion
}

View File

@@ -0,0 +1,95 @@
using System;
using System.Drawing;
namespace DevComponents.Instrumentation
{
internal class TickPoint : ICloneable
{
#region Private variables
private Point _Point;
private float _Angle;
private double _Interval;
private GaugeTickMarkBase _TickMark;
private bool _Visible = true;
#endregion
public TickPoint(GaugeTickMarkBase tickMark)
{
_TickMark = tickMark;
}
#region Public properties
#region Angle
public float Angle
{
get { return (_Angle); }
set { _Angle = value; }
}
#endregion
#region Point
public Point Point
{
get { return (_Point); }
set { _Point = value; }
}
#endregion
#region Interval
public double Interval
{
get { return (_Interval); }
set { _Interval = value; }
}
#endregion
#region TickMark
public GaugeTickMarkBase TickMark
{
get { return (_TickMark); }
set { _TickMark = value; }
}
#endregion
#region Visible
public bool Visible
{
get { return (_Visible); }
set { _Visible = value; }
}
#endregion
#endregion
#region ICloneable Members
public object Clone()
{
TickPoint tp = new TickPoint(_TickMark);
tp.Point = _Point;
tp.Angle = _Angle;
tp.Interval = _Interval;
tp.Visible = _Visible;
return (tp);
}
#endregion
}
}