From 6a639b59129a9f09c92f08c50dc60a7485a7c9ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Thu, 7 Dec 2023 08:29:52 +0800 Subject: [PATCH] HslMoveText --- .../Test/TestAction.cs | 19 +- .../HslMoveText.cs | 256 ++++++++++++++++++ .../Mesnac.Controls.ChemicalWeighing.csproj | 3 + Main/MCEdit/Data/ComponentProperty.xml | 16 ++ Main/MCEdit/Data/MCProject/nodeForm/Form1.xml | 5 + .../Data/SharpDevelopControlLibrary.xml | 2 +- 6 files changed, 299 insertions(+), 2 deletions(-) create mode 100644 Controls/Mesnac.Controls.ChemicalWeighing/HslMoveText.cs diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestAction.cs index bd854db..9db28d8 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestAction.cs @@ -36,7 +36,9 @@ namespace Mesnac.Action.ChemicalWeighing.Test MCButton mCButton; - // LoggingService _log; + // LoggingService _log; + + HslMoveText hslMove; public void theout(object source, EventArgs e) @@ -52,6 +54,21 @@ namespace Mesnac.Action.ChemicalWeighing.Test var allDb=GetAllControls(); mCButton = allDb.FirstOrDefault(x => x.Name == "MCButton1") as MCButton; + hslMove= allDb.FirstOrDefault(x => x.Name == "HslMoveText1") as HslMoveText; + + this.hslMove.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right); + this.hslMove.BackColor = Color.FromArgb(128, 128, 255); + this.hslMove.Font = new Font("楷体", 15f, FontStyle.Regular, GraphicsUnit.Point, 134); + this.hslMove.ForeColor = Color.Yellow; + + this.hslMove.Margin = new Padding(5, 6, 5, 6); + this.hslMove.MoveSpeed = 20f; + + this.hslMove.Size = new Size(726, 49); + this.hslMove.TabIndex = 8; + this.hslMove.Text = "公告:这是一条测试的公告信息。"; + + mCButton.Click += MCButton_Click; System.Timers.Timer t = new System.Timers.Timer(5000);//实例化Timer类,设置间隔时间为10000毫秒; diff --git a/Controls/Mesnac.Controls.ChemicalWeighing/HslMoveText.cs b/Controls/Mesnac.Controls.ChemicalWeighing/HslMoveText.cs new file mode 100644 index 0000000..55a10c6 --- /dev/null +++ b/Controls/Mesnac.Controls.ChemicalWeighing/HslMoveText.cs @@ -0,0 +1,256 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing.Drawing2D; +using System.Drawing.Text; +using System.Drawing; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Mesnac.Controls.ChemicalWeighing +{ + /// + /// 移动的文本控件 + /// + // Token: 0x02000045 RID: 69 + [Description("移动文本控件,支持文件正向反向移动,支持设置移动速度")] + public class HslMoveText : UserControl + { + /// + /// 实例化一个默认的对象 + /// + // Token: 0x060005CE RID: 1486 RVA: 0x00039D44 File Offset: 0x00037F44 + public HslMoveText() + { + this.InitializeComponent(); + this.sf = new StringFormat(); + this.sf.Alignment = StringAlignment.Center; + this.sf.LineAlignment = StringAlignment.Center; + base.SetStyle(ControlStyles.UserPaint | ControlStyles.SupportsTransparentBackColor, true); + base.SetStyle(ControlStyles.ResizeRedraw, true); + base.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); + base.SetStyle(ControlStyles.AllPaintingInWmPaint, true); + this.timer = new Timer(); + this.timer.Interval = 50; + this.timer.Tick += this.Timer_Tick; + this.timer.Start(); + } + + /// + /// 获取或设置控件的背景色 + /// + // Token: 0x170001CB RID: 459 + // (get) Token: 0x060005CF RID: 1487 RVA: 0x00039E30 File Offset: 0x00038030 + // (set) Token: 0x060005D0 RID: 1488 RVA: 0x00039E38 File Offset: 0x00038038 + [Browsable(true)] + [Description("获取或设置控件的背景色")] + [Category("HslControls")] + [DefaultValue(typeof(Color), "Transparent")] + [EditorBrowsable(EditorBrowsableState.Always)] + public override Color BackColor + { + get + { + return base.BackColor; + } + set + { + base.BackColor = value; + } + } + + /// + /// 获取或设置当前控件的文本 + /// + // Token: 0x170001CC RID: 460 + // (get) Token: 0x060005D1 RID: 1489 RVA: 0x00039E44 File Offset: 0x00038044 + // (set) Token: 0x060005D2 RID: 1490 RVA: 0x00039E5C File Offset: 0x0003805C + [Browsable(true)] + [Description("获取或设置当前控件的文本")] + [Category("HslControls")] + [EditorBrowsable(EditorBrowsableState.Always)] + [Bindable(true)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] + public override string Text + { + get + { + return base.Text; + } + set + { + base.Text = value; + base.Invalidate(); + } + } + + /// + /// 获取或设置泵控件是否是横向的还是纵向的 + /// + // Token: 0x170001CD RID: 461 + // (get) Token: 0x060005D3 RID: 1491 RVA: 0x00039E70 File Offset: 0x00038070 + // (set) Token: 0x060005D4 RID: 1492 RVA: 0x00039E88 File Offset: 0x00038088 + [Browsable(true)] + [Description("获取或设置泵控件是否是横向的还是纵向的")] + [Category("HslControls")] + [DefaultValue(typeof(HslDirectionStyle), "Vertical")] + public HslDirectionStyle PumpStyle + { + get + { + return this.hslValvesStyle; + } + set + { + this.hslValvesStyle = value; + base.Invalidate(); + } + } + + /// + /// 获取或设置泵的动画速度,0为静止,正数为正向流动,负数为反向流动 + /// + // Token: 0x170001CE RID: 462 + // (get) Token: 0x060005D5 RID: 1493 RVA: 0x00039E9C File Offset: 0x0003809C + // (set) Token: 0x060005D6 RID: 1494 RVA: 0x00039EB4 File Offset: 0x000380B4 + [Browsable(true)] + [Description("获取或设置传送带流动的速度,0为静止,正数为正向流动,负数为反向流动")] + [Category("HslControls")] + [DefaultValue(1f)] + public float MoveSpeed + { + get + { + return this.moveSpeed; + } + set + { + this.moveSpeed = value; + base.Invalidate(); + } + } + + /// + /// 重绘控件的 + /// + /// 重绘事件 + // Token: 0x060005D7 RID: 1495 RVA: 0x00039EC8 File Offset: 0x000380C8 + protected override void OnPaint(PaintEventArgs e) + { + Graphics graphics = e.Graphics; + graphics.SmoothingMode = SmoothingMode.HighQuality; + graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; + this.PaintHslControls(graphics, base.Width, base.Height); + base.OnPaint(e); + } + + /// + // Token: 0x060005D8 RID: 1496 RVA: 0x00039F18 File Offset: 0x00038118 + public void PaintHslControls(Graphics g, int width, int height) + { + bool flag2 = this.hslValvesStyle == HslDirectionStyle.Vertical; + if (flag2) + { + this.PaintMain(g, (float)width, (float)height); + } + else + { + g.TranslateTransform((float)width, 0f); + g.RotateTransform(90f); + this.PaintMain(g, (float)height, (float)width); + g.ResetTransform(); + } + } + + // Token: 0x060005D9 RID: 1497 RVA: 0x00039F80 File Offset: 0x00038180 + private void PaintMain(Graphics g, float width, float height) + { + this.fontWidth = g.MeasureString(this.Text, this.Font).Width + 3f; + Brush brush = new SolidBrush(this.ForeColor); + RectangleF layoutRectangle = new RectangleF(this.startLocationX, 0f, this.fontWidth, height); + g.DrawString(this.Text, this.Font, brush, layoutRectangle, this.sf); + } + + // Token: 0x060005DA RID: 1498 RVA: 0x00039FF4 File Offset: 0x000381F4 + private PointF[] GetPointsFrom(string points, float width, float height, float dx = 0f, float dy = 0f) + { + return HslHelper.GetPointsFrom(points, 80.7f, 112.5f, width, height, dx, dy); + } + + // Token: 0x060005DB RID: 1499 RVA: 0x0003A01C File Offset: 0x0003821C + private void Timer_Tick(object sender, EventArgs e) + { + bool flag = this.moveSpeed != 0f; + if (flag) + { + bool flag2 = this.startLocationX < -this.fontWidth - 5f; + if (flag2) + { + this.startLocationX = (float)(base.Width + 1); + } + else + { + this.startLocationX -= this.moveSpeed; + } + base.Invalidate(); + } + } + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + // Token: 0x060005DC RID: 1500 RVA: 0x0003A088 File Offset: 0x00038288 + protected override void Dispose(bool disposing) + { + bool flag = disposing && this.components != null; + if (flag) + { + this.components.Dispose(); + } + base.Dispose(disposing); + } + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + // Token: 0x060005DD RID: 1501 RVA: 0x0003A0C0 File Offset: 0x000382C0 + private void InitializeComponent() + { + base.SuspendLayout(); + base.AutoScaleMode = AutoScaleMode.None; + this.BackColor = Color.Transparent; + base.Name = "HslMoveText"; + base.Size = new Size(720, 41); + base.ResumeLayout(false); + } + + // Token: 0x040002DD RID: 733 + private float fontWidth = 100f; + + // Token: 0x040002DE RID: 734 + private StringFormat sf = null; + + // Token: 0x040002DF RID: 735 + private HslDirectionStyle hslValvesStyle = HslDirectionStyle.Vertical; + + // Token: 0x040002E0 RID: 736 + private float moveSpeed = 1f; + + // Token: 0x040002E1 RID: 737 + private Timer timer = null; + + // Token: 0x040002E2 RID: 738 + private float startLocationX = -100000f; + + /// + /// 必需的设计器变量。 + /// + // Token: 0x040002E3 RID: 739 + private IContainer components = null; + } +} diff --git a/Controls/Mesnac.Controls.ChemicalWeighing/Mesnac.Controls.ChemicalWeighing.csproj b/Controls/Mesnac.Controls.ChemicalWeighing/Mesnac.Controls.ChemicalWeighing.csproj index 0f0f0cf..74264b7 100644 --- a/Controls/Mesnac.Controls.ChemicalWeighing/Mesnac.Controls.ChemicalWeighing.csproj +++ b/Controls/Mesnac.Controls.ChemicalWeighing/Mesnac.Controls.ChemicalWeighing.csproj @@ -150,6 +150,9 @@ HslLedDisplay.cs + + UserControl + UserControl diff --git a/Main/MCEdit/Data/ComponentProperty.xml b/Main/MCEdit/Data/ComponentProperty.xml index 2681135..5c4b4c4 100644 --- a/Main/MCEdit/Data/ComponentProperty.xml +++ b/Main/MCEdit/Data/ComponentProperty.xml @@ -1650,6 +1650,22 @@ + + + + + + + + + + + + + + + + diff --git a/Main/MCEdit/Data/MCProject/nodeForm/Form1.xml b/Main/MCEdit/Data/MCProject/nodeForm/Form1.xml index 8bf25ec..77ade3a 100644 --- a/Main/MCEdit/Data/MCProject/nodeForm/Form1.xml +++ b/Main/MCEdit/Data/MCProject/nodeForm/Form1.xml @@ -1,6 +1,11 @@ + + 652, 182 + HslMoveText1 + 477, 41 + AAEAAAD/////AQAAAAAAAAAMAgAAAEtNZXNuYWMuQ29udHJvbHMuQmFzZSwgVmVyc2lvbj0xLjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPW51bGwEAQAAAJMBU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuTGlzdGAxW1tNZXNuYWMuQ29udHJvbHMuQmFzZS5EZXNpZ25BY3Rpb24sIE1lc25hYy5Db250cm9scy5CYXNlLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbF1dAwAAAAZfaXRlbXMFX3NpemUIX3ZlcnNpb24EAAAjTWVzbmFjLkNvbnRyb2xzLkJhc2UuRGVzaWduQWN0aW9uW10CAAAACAgJAwAAAAAAAAALAAAABwMAAAAAAQAAAAQAAAAEIU1lc25hYy5Db250cm9scy5CYXNlLkRlc2lnbkFjdGlvbgIAAAANBAs= diff --git a/Main/MCEdit/Data/SharpDevelopControlLibrary.xml b/Main/MCEdit/Data/SharpDevelopControlLibrary.xml index 286a345..d71b294 100644 --- a/Main/MCEdit/Data/SharpDevelopControlLibrary.xml +++ b/Main/MCEdit/Data/SharpDevelopControlLibrary.xml @@ -117,8 +117,8 @@ - +