123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263 |
- 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; }
- }
- /// <summary>
- /// 0是场站,1是风机,2是升压站
- /// 0,不变化 1-3实时刷新
- /// </summary>
- [Browsable(true), Category("Appearance")]
- public int LableType
- {
- get;
- set;
- }
- /// <summary>
- /// 0是显示固定值,1根据ID显示实时数据,2根据统一编码显示数据,3根据赋值显示
- /// 0,不变化 1-3实时刷新
- /// </summary>
- [Browsable(true), Category("Appearance")]
- public int LableShowType
- {
- get;
- set;
- }
- /// <summary>
- /// 测点编码
- /// </summary>
- [Browsable(true), Category("Appearance")]
- public string TestPointId
- {
- get;
- set;
- }
- /// <summary>
- /// 统一编码
- /// </summary>
- [Browsable(true), Category("Appearance")]
- public string UniformCode
- {
- get;
- set;
- }
- /// <summary>
- /// 风机编码
- /// </summary>
- [Browsable(true), Category("Appearance")]
- public string WindTurbineId
- {
- get;
- set;
- }
- /// <summary>
- /// 风场编码
- /// </summary>
- [Browsable(true), Category("Appearance")]
- public string WindPowerId
- {
- get;
- set;
- }
- /// <summary>
- /// 字体大小
- /// </summary>
- [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;
- }
- }
- /// <summary>
- /// 字体位置
- /// </summary>
- [Browsable(true), Category("Appearance")]
- public DockStyle MyLabelDock
- {
- set
- {
- this.label1.Dock = value;
- }
- get
- {
- return this.label1.Dock;
- }
- }
- /// <summary>
- /// 字体位置
- /// </summary>
- [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; }
- /// <summary>
- /// 绑定数据
- /// </summary>
- /// <param name="pointValue">测点值</param>
- /// <param name="thingType">设备类型</param>
- /// <param name="thingId">设备编号</param>
- /// <param name="uniformcode">统一编码</param>
- /// <param name="nameString">统一编码含义</param>
- public void BindData(string pointValue, string thingType, string thingId, string uniformcode, string nameString)
- {
- this.LableText = pointValue;
- ThingType = thingType;
- ThingId = thingId;
- UniformCodeString = uniformcode;
- PointName = nameString;
- }
- /// <summary>
- /// 绑定数据
- /// </summary>
- /// <param name="pointValue">测点值</param>
- /// <param name="tagName">点名</param>
- /// <param name="nameString">测点名含义</param>
- public void BindData(string pointValue, string tagName, string nameString)
- {
- this.LableText = pointValue;
- TagName = tagName;
- PointName = nameString;
- }
- }
- }
|