diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/MainDetailControl/Entity/HslLanternAlarmEntity.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/MainDetailControl/Entity/HslLanternAlarmEntity.cs index ce8c5fd..6b37dc8 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/MainDetailControl/Entity/HslLanternAlarmEntity.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/MainDetailControl/Entity/HslLanternAlarmEntity.cs @@ -1,4 +1,6 @@ -using Mesnac.Controls.ChemicalWeighing; +using DevExpress.Utils.MVVM; + +using Mesnac.Controls.ChemicalWeighing; using System; using System.Collections.Generic; @@ -21,4 +23,20 @@ namespace Mesnac.Action.ChemicalWeighing.MainDetailControl.Entity } + + + public class HslLanternSimpleEntity + { + public HslLanternSimple HslLanternSimple1 { get; set; } + public HslLanternSimple HslLanternSimple2 { get; set; } + public HslLanternSimple HslLanternSimple3 { get; set; } + + public HslLanternSimple HslLanternSimple4 { get; set; } + public HslLanternSimple HslLanternSimple5 { get; set; } + public HslLanternSimple HslLanternSimple6 { get; set; } + public HslLanternSimple HslLanternSimple7 { get; set; } + + public HslLanternSimple HslLanternSimple8 { get; set; } + + } } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/MainDetailControl/MainDetailControlAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/MainDetailControl/MainDetailControlAction.cs index e34456f..5395170 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/MainDetailControl/MainDetailControlAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/MainDetailControl/MainDetailControlAction.cs @@ -22,6 +22,7 @@ using Mesnac.Action.ChemicalWeighing.MainDetailControl.Entity; using Mesnac.Action.ChemicalWeighing.RgvPlc; using System.Reflection; using DataBlockHelper; +using System.Drawing; namespace Mesnac.Action.ChemicalWeighing.MainDetailControl { @@ -60,7 +61,7 @@ namespace Mesnac.Action.ChemicalWeighing.MainDetailControl private MCLabel MCWatchDog; HslLanternAlarmEntity hslAlarmEntity; - + HslLanternSimpleEntity hslLanternSimpleEntity; #endregion @@ -81,6 +82,7 @@ namespace Mesnac.Action.ChemicalWeighing.MainDetailControl //更细自定义控件报警灯 FillControlHslLanternAlarm(); + FillHslLanternSimple(); MCWatchDog =Controls.FirstOrDefault(x => x.Name == "MCWatchDog") as MCLabel; @@ -210,7 +212,19 @@ namespace Mesnac.Action.ChemicalWeighing.MainDetailControl SetHslLanternAlarm(hslAlarmEntity.HslLanternAlarm7, list[6].Error); SetHslLanternAlarm(hslAlarmEntity.HslLanternAlarm8, list[7].Error); - + var sim = Db3000Helper.ReadDb(); + + + SetHslLanternSimple(hslLanternSimpleEntity.HslLanternSimple1, sim[0]); + SetHslLanternSimple(hslLanternSimpleEntity.HslLanternSimple2, sim[1]); + SetHslLanternSimple(hslLanternSimpleEntity.HslLanternSimple3, sim[2]); + SetHslLanternSimple(hslLanternSimpleEntity.HslLanternSimple4, sim[3]); + SetHslLanternSimple(hslLanternSimpleEntity.HslLanternSimple5, sim[4]); + SetHslLanternSimple(hslLanternSimpleEntity.HslLanternSimple6, sim[5]); + SetHslLanternSimple(hslLanternSimpleEntity.HslLanternSimple7, false); + SetHslLanternSimple(hslLanternSimpleEntity.HslLanternSimple8, false); + + ThreadPool.QueueUserWorkItem(new WaitCallback(NewThread)); @@ -2409,6 +2423,22 @@ namespace Mesnac.Action.ChemicalWeighing.MainDetailControl } + public void SetHslLanternSimple(HslLanternSimple lanternSimple, bool su) + { + + if (su == true) + { + lanternSimple.LanternBackground = Color.LimeGreen; + } + else + { + lanternSimple.LanternBackground = Color.Transparent; + } + + } + + //HslLanternSimpleEntity + private void FillControlHslLanternAlarm() { hslAlarmEntity = new HslLanternAlarmEntity(); @@ -2423,6 +2453,20 @@ namespace Mesnac.Action.ChemicalWeighing.MainDetailControl } + private void FillHslLanternSimple() + { + hslLanternSimpleEntity=new HslLanternSimpleEntity(); + + var sourceType = hslLanternSimpleEntity.GetType(); + PropertyInfo[] sourcePropertyInfoList = sourceType.GetProperties(); + foreach (PropertyInfo sourceProperty in sourcePropertyInfoList) + { + string name = sourceProperty.Name; + var pro = Controls.FirstOrDefault(x => x.Name == name) as HslLanternSimple; + sourceProperty.SetValue(hslLanternSimpleEntity, pro); + } + } + #endregion } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj index cdd8605..16eeb6d 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj @@ -176,6 +176,9 @@ False ..\..\..\PlugInPlatform\Mesnac.PlugIn.dll + + ..\..\Microsoft.Office.Interop.Excel.dll + diff --git a/Controls/Mesnac.Controls.ChemicalWeighing/HslLanternSimple.Designer.cs b/Controls/Mesnac.Controls.ChemicalWeighing/HslLanternSimple.Designer.cs new file mode 100644 index 0000000..3ed7ac2 --- /dev/null +++ b/Controls/Mesnac.Controls.ChemicalWeighing/HslLanternSimple.Designer.cs @@ -0,0 +1,37 @@ +namespace Mesnac.Controls.ChemicalWeighing +{ + partial class HslLanternSimple + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + } + + #endregion + } +} diff --git a/Controls/Mesnac.Controls.ChemicalWeighing/HslLanternSimple.cs b/Controls/Mesnac.Controls.ChemicalWeighing/HslLanternSimple.cs new file mode 100644 index 0000000..3313d84 --- /dev/null +++ b/Controls/Mesnac.Controls.ChemicalWeighing/HslLanternSimple.cs @@ -0,0 +1,273 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Drawing.Text; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace Mesnac.Controls.ChemicalWeighing +{ + [Description("一个圆形的信号灯,支持设置颜色,是否渐变")] + public partial class HslLanternSimple : UserControl + { + public HslLanternSimple() + { + InitializeComponent(); + base.AutoScaleMode = AutoScaleMode.None; + this.BackColor = Color.Transparent; + base.Name = "HslLanternSimple"; + base.Size = new Size(78, 94); + base.ResumeLayout(false); + + + 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); + + + LanternBackground = Color.Transparent; + } + + // Token: 0x040002C0 RID: 704 + private Color colorBackground = Color.LimeGreen; + + // Token: 0x040002C1 RID: 705 + private Brush brushBackground = new SolidBrush(Color.LimeGreen); + + // Token: 0x040002C2 RID: 706 + private StringFormat sf = null; + + // Token: 0x040002C3 RID: 707 + private Color centerColor = Color.White; + + // Token: 0x040002C4 RID: 708 + private bool isUseGradientColor = false; + + /// + /// 获取或设置控件的背景色 + /// + // Token: 0x170001B1 RID: 433 + // (get) Token: 0x0600057F RID: 1407 RVA: 0x000362BC File Offset: 0x000344BC + // (set) Token: 0x06000580 RID: 1408 RVA: 0x000362C4 File Offset: 0x000344C4 + [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: 0x170001B2 RID: 434 + // (get) Token: 0x06000581 RID: 1409 RVA: 0x000362D0 File Offset: 0x000344D0 + // (set) Token: 0x06000582 RID: 1410 RVA: 0x000362E8 File Offset: 0x000344E8 + [Browsable(true)] + [Description("获取或设置信号灯的背景色")] + [Category("HslControls")] + [DefaultValue(typeof(Color), "LimeGreen")] + public Color LanternBackground + { + get + { + return this.colorBackground; + } + set + { + this.colorBackground = value; + Brush brush = this.brushBackground; + if (brush != null) + { + brush.Dispose(); + } + this.brushBackground = new SolidBrush(this.colorBackground); + base.Invalidate(); + } + } + + /// + /// 获取或设置中心点的颜色,当且仅当UseGradientColor属性为True时生效 + /// + // Token: 0x170001B3 RID: 435 + // (get) Token: 0x06000583 RID: 1411 RVA: 0x0003631C File Offset: 0x0003451C + // (set) Token: 0x06000584 RID: 1412 RVA: 0x00036334 File Offset: 0x00034534 + [Browsable(true)] + [Description("获取或设置中心点的颜色,当且仅当UseGradientColor属性为True时生效")] + [Category("HslControls")] + [DefaultValue(typeof(Color), "White")] + public Color CenterBackground + { + get + { + return this.centerColor; + } + set + { + this.centerColor = value; + base.Invalidate(); + } + } + + /// + /// 获取或设置当前的灯信号是否启用渐变色的画刷 + /// + // Token: 0x170001B4 RID: 436 + // (get) Token: 0x06000585 RID: 1413 RVA: 0x00036348 File Offset: 0x00034548 + // (set) Token: 0x06000586 RID: 1414 RVA: 0x00036360 File Offset: 0x00034560 + [Browsable(true)] + [Description("获取或设置当前的灯信号是否启用渐变色的画刷")] + [Category("HslControls")] + [DefaultValue(false)] + public bool UseGradientColor + { + get + { + return this.isUseGradientColor; + } + set + { + this.isUseGradientColor = value; + base.Invalidate(); + } + } + + /// + /// 获取或设置当前控件的文本 + /// + // Token: 0x170001B5 RID: 437 + // (get) Token: 0x06000587 RID: 1415 RVA: 0x00036374 File Offset: 0x00034574 + // (set) Token: 0x06000588 RID: 1416 RVA: 0x0003638C File Offset: 0x0003458C + [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: 0x06000589 RID: 1417 RVA: 0x0003639E File Offset: 0x0003459E + public void PerformClick() + { + this.OnClick(new EventArgs()); + } + + + /// + // Token: 0x0600057D RID: 1405 RVA: 0x00035FA0 File Offset: 0x000341A0 + protected override void OnPaint(PaintEventArgs e) + { + e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; + e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; + e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; + e.Graphics.CompositingQuality = CompositingQuality.HighQuality; + this.PaintHslControls(e.Graphics, base.Width, base.Height); + base.OnPaint(e); + } + + /// + // Token: 0x0600057E RID: 1406 RVA: 0x00036004 File Offset: 0x00034204 + public void PaintHslControls(Graphics g, int width, int height) + { + bool flag = false; + if (!flag) + { + int num = Math.Min(width, height); + num--; + Point point = new Point(num / 2, num / 2); + g.TranslateTransform((float)point.X, (float)point.Y); + float num2 = (float)(point.X * 17) / 20f; + float num3 = (float)point.X / 20f; + bool flag2 = num2 < 2f; + if (!flag2) + { + RectangleF rect = new RectangleF(-num2 - 2f * num3, -num2 - 2f * num3, 2f * num2 + 4f * num3, 2f * num2 + 4f * num3); + RectangleF rect2 = new RectangleF(-num2, -num2, 2f * num2, 2f * num2); + using (Pen pen = new Pen(this.colorBackground, num3)) + { + g.DrawEllipse(pen, rect); + } + bool flag3 = !this.UseGradientColor; + if (flag3) + { + g.FillEllipse(this.brushBackground, rect2); + } + else + { + GraphicsPath graphicsPath = new GraphicsPath(); + graphicsPath.AddEllipse(-num2, -num2, 2f * num2, 2f * num2); + PathGradientBrush pathGradientBrush = new PathGradientBrush(graphicsPath); + pathGradientBrush.CenterPoint = new Point(0, 0); + pathGradientBrush.InterpolationColors = new ColorBlend + { + Positions = new float[] + { + 0f, + 1f + }, + Colors = new Color[] + { + this.colorBackground, + this.centerColor + } + }; + g.FillEllipse(pathGradientBrush, rect2); + using (Pen pen2 = new Pen(this.colorBackground)) + { + g.DrawEllipse(pen2, -num2, -num2, 2f * num2, 2f * num2); + } + pathGradientBrush.Dispose(); + graphicsPath.Dispose(); + } + g.TranslateTransform((float)(-(float)point.X), (float)(-(float)point.Y)); + bool flag4 = height - num > 0; + if (flag4) + { + bool flag5 = !string.IsNullOrEmpty(this.Text); + if (flag5) + { + using (Brush brush = new SolidBrush(this.ForeColor)) + { + g.DrawString(this.Text, this.Font, brush, new Rectangle(0, num, num, height - num), this.sf); + } + } + } + } + } + } + + } +} diff --git a/Controls/Mesnac.Controls.ChemicalWeighing/Mesnac.Controls.ChemicalWeighing.csproj b/Controls/Mesnac.Controls.ChemicalWeighing/Mesnac.Controls.ChemicalWeighing.csproj index aca2354..7b42ad0 100644 --- a/Controls/Mesnac.Controls.ChemicalWeighing/Mesnac.Controls.ChemicalWeighing.csproj +++ b/Controls/Mesnac.Controls.ChemicalWeighing/Mesnac.Controls.ChemicalWeighing.csproj @@ -138,6 +138,12 @@ HslLanternAlarm.cs + + UserControl + + + HslLanternSimple.cs + UserControl diff --git a/Main/MCEdit/Data/ComponentProperty.xml b/Main/MCEdit/Data/ComponentProperty.xml index 79b6737..e672f3f 100644 --- a/Main/MCEdit/Data/ComponentProperty.xml +++ b/Main/MCEdit/Data/ComponentProperty.xml @@ -1637,6 +1637,21 @@ + + + + + + + + + + + + + + + diff --git a/Main/MCEdit/Data/MCProject/nodeForm/MainDetail.xml b/Main/MCEdit/Data/MCProject/nodeForm/MainDetail.xml index 95e9afe..d4fc9d8 100644 --- a/Main/MCEdit/Data/MCProject/nodeForm/MainDetail.xml +++ b/Main/MCEdit/Data/MCProject/nodeForm/MainDetail.xml @@ -1,6 +1,46 @@ + + 1850, 470 + HslLanternSimple8 + 15, 17 + + + 1676, 470 + HslLanternSimple7 + 15, 17 + + + 1533, 470 + HslLanternSimple6 + 15, 17 + + + 1365, 470 + HslLanternSimple5 + 15, 17 + + + 1290, 470 + HslLanternSimple4 + 15, 17 + + + 1118, 470 + HslLanternSimple3 + 15, 17 + + + 990, 472 + HslLanternSimple2 + 15, 17 + + + 815, 472 + HslLanternSimple1 + 15, 17 + diff --git a/Main/MCEdit/Data/SharpDevelopControlLibrary.xml b/Main/MCEdit/Data/SharpDevelopControlLibrary.xml index 4207726..8d7e2b9 100644 --- a/Main/MCEdit/Data/SharpDevelopControlLibrary.xml +++ b/Main/MCEdit/Data/SharpDevelopControlLibrary.xml @@ -115,7 +115,7 @@ - +