using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Drawing.Text; using IntelligentControlForsx.ChildForms; using IntelligentControlForsx.Code; namespace IntelligentControlForsx.MyControls { public partial class WebfontLable : UserControl { public WebfontLable() { InitializeComponent(); SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲   this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); this.UpdateStyles(); } public void Build() { switch (LableShowType) { case 0: { break; } case 1: { LableMessage.AddLabel(this); break; } case 2: { break; } case 3: { break; } default: { break; } } } [Browsable(true), Category("Appearance")] public string LableText { get { return this.label1.Text; } set { this.label1.Text = value; } } /// /// 0是场站,1是风机,2是升压站 /// 0,不变化 1-3实时刷新 /// [Browsable(true), Category("Appearance")] public int LableType { get; set; } /// /// 0是显示固定值,1根据ID显示实时数据,2根据统一编码显示数据,3根据赋值显示 /// 0,不变化 1-3实时刷新 /// [Browsable(true), Category("Appearance")] public int LableShowType { get; set; } /// /// 测点编码 /// [Browsable(true), Category("Appearance")] public string TestPointId { get; set; } /// /// 统一编码 /// [Browsable(true), Category("Appearance")] public string UniformCode { get; set; } /// /// 风机编码 /// [Browsable(true), Category("Appearance")] public string WindTurbineId { get; set; } /// /// 风场编码 /// [Browsable(true), Category("Appearance")] public string WindPowerId { get; set; } /// /// 字体大小 /// [Browsable(true), Category("Appearance")] public float MyEmSize { set { this.label1.Font = new System.Drawing.Font("DS-Digital", value, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0))); } get { return this.label1.Font.Size; } } /// /// 字体位置 /// [Browsable(true), Category("Appearance")] public DockStyle MyLabelDock { set { this.label1.Dock = value; } get { return this.label1.Dock; } } /// /// 字体位置 /// [Browsable(true), Category("Appearance")] public ContentAlignment MyLabelTextAlign { set { this.label1.TextAlign = value; } get { return this.label1.TextAlign; } } private void WebfontLable_Load(object sender, EventArgs e) { this.Name = Guid.NewGuid().ToString(); //this.label1.Font = new System.Drawing.Font("DS-Digital", 21.75F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0))); //this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); //string str1 = UserTools.Path + @"\fonts\webfont.ttf"; ////读取字体文件 //PrivateFontCollection pfc = new PrivateFontCollection(); //pfc.AddFontFile(str1); ////实例化字体 //Font f = new Font(pfc.Families[0], 21.75F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0))); ////设置字体 //this.label1.Font = f; } public event EventHandler MyClick; private void label1_Click(object sender, EventArgs e) { PointLineForm form = null; if (!string.IsNullOrEmpty(ThingType) && !string.IsNullOrEmpty(ThingId) && !string.IsNullOrEmpty(UniformCodeString)) form = new PointLineForm(ThingType, ThingId, UniformCodeString, PointName); else if (!string.IsNullOrEmpty(TagName)) form = new PointLineForm(TagName, PointName); if (form != null) { form.StartPosition = FormStartPosition.CenterParent; form.ShowDialog(); } if (MyClick != null) { MyClick(this, e); } } private void label1_MouseEnter(object sender, EventArgs e) { this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); } private void label1_MouseLeave(object sender, EventArgs e) { this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); } private string ThingType { set; get; } private string ThingId { set; get; } private string UniformCodeString { set; get; } private string TagName { set; get; } private string PointName { set; get; } /// /// 绑定数据 /// /// 测点值 /// 设备类型 /// 设备编号 /// 统一编码 /// 统一编码含义 public void BindData(string pointValue, string thingType, string thingId, string uniformcode, string nameString) { this.LableText = pointValue; ThingType = thingType; ThingId = thingId; UniformCodeString = uniformcode; PointName = nameString; } /// /// 绑定数据 /// /// 测点值 /// 点名 /// 测点名含义 public void BindData(string pointValue, string tagName, string nameString) { this.LableText = pointValue; TagName = tagName; PointName = nameString; } } }