using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.ComponentModel; using System.Drawing; using System.Windows.Forms; namespace Mesnac.Controls.ChemicalWeighing { /// 参考坐标系的轴信息 [TypeConverter(typeof(ReferenceAxisConverter))] public class ReferenceAxis { private float _max; private float _min; private string _unit; private string _format; private Color _color; private UserControl _control; private Pen _pen; /// 实例化一个默认的对象 public ReferenceAxis() { this.Max = 100f; this.Min = 0.0f; this.Color = Color.LightGray; this.Format = "{0}"; } /// 实例化一个默认的对象 public ReferenceAxis(UserControl userControl) : this() { this._control = userControl; } /// 实例化一个默认的对象 /// 最大值 /// 最小值 public ReferenceAxis(float max, float min) { this.Max = max; this.Min = min; } /// 最大值 [Category("HslControls")] [Description("获取或设置当前的Y轴的最大值")] [Browsable(true)] [DefaultValue(100f)] public float Max { get => this._max; set { this._max = value; this._control?.Invalidate(); } } /// 最小值 [Category("HslControls")] [Description("获取或设置当前的Y轴的最小值")] [Browsable(true)] [DefaultValue(0.0f)] public float Min { get => this._min; set { this._min = value; this._control?.Invalidate(); } } /// 单位信息 [Category("HslControls")] [Description("获取或设置当前的Y轴的单位值")] [Browsable(true)] [DefaultValue("")] public string Unit { get => this._unit; set { this._unit = value; this._control?.Invalidate(); } } /// 获取或设置当前的坐标系的颜色信息 [Category("HslControls")] [Description("获取或设置当前的坐标系的颜色信息")] [Browsable(true)] [DefaultValue(typeof(Color), "LightGray")] public Color Color { get => this._color; set { this._color = value; this.Brush?.Dispose(); this.Brush = (Brush)new SolidBrush(this._color); this._pen?.Dispose(); this._pen = new Pen(this._color, 1f); this._control?.Invalidate(); } } /// 获取或设置当前坐标轴数字的格式化信息,默认为 {0}, 直接转字符串 [Category("HslControls")] [Description("获取或设置当前坐标轴数字的格式化信息,默认为 {0}, 直接转字符串")] [Browsable(true)] [DefaultValue("{0}")] public string Format { get => this._format; set { this._format = value; this._control?.Invalidate(); } } /// 获取画笔信息 /// 画笔信息 public Pen GetPen() { if (this._pen != null) return this._pen; this._pen = new Pen(this.Color, 1f); return this._pen; } /// 画刷资源 [Browsable(false)] public Brush Brush { get; set; } } }