You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lj_plc/Controls/Mesnac.Controls.ChemicalWei.../ReferenceAxis.cs

146 lines
4.1 KiB
C#

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
{
/// <summary>参考坐标系的轴信息</summary>
[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;
/// <summary>实例化一个默认的对象</summary>
public ReferenceAxis()
{
this.Max = 100f;
this.Min = 0.0f;
this.Color = Color.LightGray;
this.Format = "{0}";
}
/// <summary>实例化一个默认的对象</summary>
public ReferenceAxis(UserControl userControl)
: this()
{
this._control = userControl;
}
/// <summary>实例化一个默认的对象</summary>
/// <param name="max">最大值</param>
/// <param name="min">最小值</param>
public ReferenceAxis(float max, float min)
{
this.Max = max;
this.Min = min;
}
/// <summary>最大值</summary>
[Category("HslControls")]
[Description("获取或设置当前的Y轴的最大值")]
[Browsable(true)]
[DefaultValue(100f)]
public float Max
{
get => this._max;
set
{
this._max = value;
this._control?.Invalidate();
}
}
/// <summary>最小值</summary>
[Category("HslControls")]
[Description("获取或设置当前的Y轴的最小值")]
[Browsable(true)]
[DefaultValue(0.0f)]
public float Min
{
get => this._min;
set
{
this._min = value;
this._control?.Invalidate();
}
}
/// <summary>单位信息</summary>
[Category("HslControls")]
[Description("获取或设置当前的Y轴的单位值")]
[Browsable(true)]
[DefaultValue("")]
public string Unit
{
get => this._unit;
set
{
this._unit = value;
this._control?.Invalidate();
}
}
/// <summary>获取或设置当前的坐标系的颜色信息</summary>
[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();
}
}
/// <summary>获取或设置当前坐标轴数字的格式化信息,默认为 {0}, 直接转字符串</summary>
[Category("HslControls")]
[Description("获取或设置当前坐标轴数字的格式化信息,默认为 {0}, 直接转字符串")]
[Browsable(true)]
[DefaultValue("{0}")]
public string Format
{
get => this._format;
set
{
this._format = value;
this._control?.Invalidate();
}
}
/// <summary>获取画笔信息</summary>
/// <returns>画笔信息</returns>
public Pen GetPen()
{
if (this._pen != null)
return this._pen;
this._pen = new Pen(this.Color, 1f);
return this._pen;
}
/// <summary>画刷资源</summary>
[Browsable(false)]
public Brush Brush { get; set; }
}
}