From 7bf8791f4d1a829c6ee862e6d4718663d559ddc1 Mon Sep 17 00:00:00 2001 From: SoulStar Date: Tue, 10 Jun 2025 16:14:56 +0800 Subject: [PATCH] =?UTF-8?q?feat=20-=20=E6=9C=80=E7=BB=88=E7=89=88=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HighWayIot.Controls/Controls/ControlHelper.cs | 1619 +++++++++++++++++ .../Controls/HslDirectionStyle.cs | 16 + HighWayIot.Controls/Controls/HslHelper.cs | 639 +++++++ HighWayIot.Controls/Controls/HslMoveText.cs | 254 +++ HighWayIot.Controls/Controls/ReferenceAxis.cs | 145 ++ .../Controls/ReferenceAxisConverter.cs | 25 + .../HighWayIot.Controls.csproj | 57 + .../Properties/AssemblyInfo.cs | 33 + HighWayIot.Plc/PlcHelper/TransferSingal.cs | 6 +- .../domain/ExportTableEntity.cs | 12 + .../domain/MonitorDataSource.cs | 6 + .../domain/ZxDailyReportEntity.cs | 7 + .../service/SysErrorLogService.cs | 17 + .../service/SysLogService.cs | 16 + .../service/ZxDailyReportService.cs | 40 + .../Business/MonitorDataRefreshBusiness.cs | 13 +- .../Business/TimerExportBusiness.cs | 330 ++++ HighWayIot.Winform/Business/XmlUtil.cs | 69 +- HighWayIot.Winform/Configuration.xml | 3 +- HighWayIot.Winform/HighWayIot.Winform.csproj | 16 +- .../MainForm/BaseForm.Designer.cs | 31 +- HighWayIot.Winform/MainForm/BaseForm.cs | 54 +- .../LogPages/AlarmLogPage.Designer.cs | 133 +- .../UserControlPages/LogPages/AlarmLogPage.cs | 8 + .../LogPages/AlarmLogPage.resx | 21 + .../LogPages/DailyReportPage.Designer.cs | 57 +- .../LogPages/DailyReportPage.cs | 59 +- .../LogPages/DailyReportPage.resx | 8 +- .../LogPages/ExportPreviewForm.Designer.cs | 104 +- .../LogPages/ExportPreviewForm.cs | 60 +- .../LogPages/ExportPreviewForm.resx | 8 +- .../LogPages/OperateConfigPage.Designer.cs | 19 +- .../LogPages/OperateConfigPage.cs | 8 + .../LogPages/OperateConfigPage.resx | 12 + .../MonitorMainPage.Designer.cs | 819 +++++---- .../MonitorMainPages/MonitorMainPage.cs | 98 +- .../MonitorMainPages/MonitorMainPage.resx | 8 +- .../ScrollTextSetForm.Designer.cs | 71 + .../MonitorMainPages/ScrollTextSetForm.cs | 36 + .../MonitorMainPages/ScrollTextSetForm.resx | 120 ++ .../UserControlPages/TestPage.Designer.cs | 1 + .../UserControlPages/TestPage.cs | 289 +-- HighWayIot.sln | 6 + 43 files changed, 4434 insertions(+), 919 deletions(-) create mode 100644 HighWayIot.Controls/Controls/ControlHelper.cs create mode 100644 HighWayIot.Controls/Controls/HslDirectionStyle.cs create mode 100644 HighWayIot.Controls/Controls/HslHelper.cs create mode 100644 HighWayIot.Controls/Controls/HslMoveText.cs create mode 100644 HighWayIot.Controls/Controls/ReferenceAxis.cs create mode 100644 HighWayIot.Controls/Controls/ReferenceAxisConverter.cs create mode 100644 HighWayIot.Controls/HighWayIot.Controls.csproj create mode 100644 HighWayIot.Controls/Properties/AssemblyInfo.cs create mode 100644 HighWayIot.Winform/Business/TimerExportBusiness.cs create mode 100644 HighWayIot.Winform/UserControlPages/MonitorMainPages/ScrollTextSetForm.Designer.cs create mode 100644 HighWayIot.Winform/UserControlPages/MonitorMainPages/ScrollTextSetForm.cs create mode 100644 HighWayIot.Winform/UserControlPages/MonitorMainPages/ScrollTextSetForm.resx diff --git a/HighWayIot.Controls/Controls/ControlHelper.cs b/HighWayIot.Controls/Controls/ControlHelper.cs new file mode 100644 index 0000000..2e8878e --- /dev/null +++ b/HighWayIot.Controls/Controls/ControlHelper.cs @@ -0,0 +1,1619 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Diagnostics; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Linq; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading; +using System.Windows.Forms; + +namespace Mesnac.Controls.ChemicalWeighing +{ + public static class ControlHelper + { + #region 设置控件Enabled,切不改变控件颜色 + /// + /// 功能描述:设置控件Enabled,切不改变控件颜色 + /// 作  者:HZH + /// 创建日期:2019-03-04 13:43:32 + /// 任务编号:POS + /// + /// c + /// enabled + public static void SetControlEnabled(this Control c, bool enabled) + { + if (!c.IsDisposed) + { + if (enabled) + { + ControlHelper.SetWindowLong(c.Handle, -16, -134217729 & ControlHelper.GetWindowLong(c.Handle, -16)); + } + else + { + ControlHelper.SetWindowLong(c.Handle, -16, 134217728 + ControlHelper.GetWindowLong(c.Handle, -16)); + } + } + } + + /// + /// 功能描述:设置控件Enabled,切不改变控件颜色 + /// 作  者:HZH + /// 创建日期:2019-03-04 13:43:32 + /// 任务编号:POS + /// + /// cs + /// enabled + public static void SetControlEnableds(Control[] cs, bool enabled) + { + for (int i = 0; i < cs.Length; i++) + { + Control c = cs[i]; + SetControlEnabled(c, enabled); + } + } + #endregion + /// + /// Sets the window long. + /// + /// The h WND. + /// Index of the n. + /// The wndproc. + /// System.Int32. + [DllImport("user32.dll ")] + public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int wndproc); + + /// + /// Gets the window long. + /// + /// The h WND. + /// Index of the n. + /// System.Int32. + [DllImport("user32.dll ")] + public static extern int GetWindowLong(IntPtr hWnd, int nIndex); + + /// + /// Gets the foreground window. + /// + /// IntPtr. + [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] + public static extern IntPtr GetForegroundWindow(); + + /// + /// Threads the base call back. + /// + /// The parent. + /// The object. + private static void ThreadBaseCallBack(Control parent, object obj) + { + if (obj is Exception) + { + if (parent != null) + { + ThreadInvokerControl(parent, delegate + { + Exception ex = obj as Exception; + }); + } + } + } + /// + /// 委托调用主线程控件 + /// + /// 主线程控件 + /// 修改控件方法 + public static void ThreadInvokerControl(Control parent, System.Action action) + { + if (parent != null) + { + if (parent.InvokeRequired) + { + parent.BeginInvoke(action); + } + else + { + action(); + SetForegroundWindow(parent.Handle); + } + } + } + /// + /// 使用一个线程执行一个操作 + /// + /// 父控件 + /// 执行内容 + /// 执行后回调 + /// 执行期间禁用控件列表 + /// 执行期间是否显示等待提示 + /// 执行期间等待提示内容,默认为“正在处理,请稍候...” + /// 延迟显示等待提示时间 + //public static void ThreadRunExt( + // Control parent, + // System.Action func, + // Action callback, + // Control enableControl = null, + // bool blnShowSplashScreen = true, + // string strMsg = null, + // int intSplashScreenDelayTime = 200) + //{ + // ThreadRunExt(parent, func, callback, new Control[] { enableControl }, blnShowSplashScreen, strMsg, intSplashScreenDelayTime); + //} + /// + /// 使用一个线程执行一个操作 + /// + /// 父控件 + /// 执行内容 + /// 执行后回调 + /// 执行期间禁用控件列表 + /// 执行期间是否显示等待提示 + /// 执行期间等待提示内容,默认为“正在处理,请稍候...” + /// 延迟显示等待提示时间 + //public static void ThreadRunExt( + // Control parent, + // System.Action func, + // Action callback, + // Control[] enableControl = null, + // bool blnShowSplashScreen = true, + // string strMsg = null, + // int intSplashScreenDelayTime = 200) + //{ + // if (blnShowSplashScreen) + // { + // if (string.IsNullOrEmpty(strMsg)) + // { + // strMsg = "正在处理,请稍候..."; + // } + // if (parent != null) + // { + // ShowProcessPanel(parent, strMsg, intSplashScreenDelayTime); + // } + // } + // if (enableControl != null) + // { + // List lstCs = new List(); + // foreach (var c in enableControl) + // { + // if (c == null) + // continue; + // if (c is Form) + // { + // lstCs.AddRange(c.Controls.ToArray()); + // } + // else + // { + // lstCs.Add(c); + // } + // } + // SetControlEnableds(lstCs.ToArray(), false); + // } + // ThreadPool.QueueUserWorkItem(delegate(object a) + // { + // try + // { + // func(); + // if (callback != null) + // { + // callback(null); + // } + // } + // catch (Exception obj) + // { + // if (callback != null) + // { + // callback(obj); + // } + // else + // { + // ThreadBaseCallBack(parent, obj); + // } + // } + // finally + // { + // if (parent != null) + // { + // ThreadInvokerControl(parent, delegate + // { + // CloseProcessPanel(parent); + // SetForegroundWindow(parent.Handle); + // }); + // } + // if (enableControl != null) + // { + // if (parent != null) + // { + // ThreadInvokerControl(parent, delegate + // { + // List lstCs = new List(); + // foreach (var c in enableControl) + // { + // if (c == null) + // continue; + // if (c is Form) + // { + // lstCs.AddRange(c.Controls.ToArray()); + // } + // else + // { + // lstCs.Add(c); + // } + // } + // SetControlEnableds(lstCs.ToArray(), true); + // }); + // } + // } + // } + // }); + //} + + /// + /// Sets the foreground window. + /// + /// The h WND. + /// true if XXXX, false otherwise. + [DllImport("user32.dll")] + public static extern bool SetForegroundWindow(IntPtr hWnd); + /// + /// Shows the process panel. + /// + /// The parent. + /// The string message. + /// The int splash screen delay time. + //public static void ShowProcessPanel(Control parent, string strMessage, int intSplashScreenDelayTime = 0) + //{ + // if (parent.InvokeRequired) + // { + // parent.BeginInvoke(new MethodInvoker(delegate + // { + // ShowProcessPanel(parent, strMessage, intSplashScreenDelayTime); + // })); + // } + // else + // { + // parent.VisibleChanged -= new EventHandler(parent_VisibleChanged); + // parent.VisibleChanged += new EventHandler(parent_VisibleChanged); + // parent.FindForm().FormClosing -= ControlHelper_FormClosing; + // parent.FindForm().FormClosing += ControlHelper_FormClosing; + // Control control = null; + // lock (parent) + // { + // control = HaveProcessPanelControl(parent); + // if (control == null) + // { + // control = CreateProgressPanel(); + // parent.Controls.Add(control); + // } + // } + // System.Windows.Forms.FrmWaiting frmWaitingEx = control.Tag as Forms.FrmWaiting; + // frmWaitingEx.Msg = strMessage; + // frmWaitingEx.ShowForm(intSplashScreenDelayTime); + // } + //} + + /// + /// Handles the FormClosing event of the ControlHelper control. + /// + /// The source of the event. + /// The instance containing the event data. + //static void ControlHelper_FormClosing(object sender, FormClosingEventArgs e) + //{ + // Control control = sender as Control; + // control.FindForm().FormClosing -= ControlHelper_FormClosing; + // CloseWaiting(control); + //} + + ///// + ///// Handles the VisibleChanged event of the parent control. + ///// + ///// The source of the event. + ///// The instance containing the event data. + //private static void parent_VisibleChanged(object sender, EventArgs e) + //{ + // Control control = sender as Control; + // control.VisibleChanged -= new EventHandler(parent_VisibleChanged); + // if (!control.Visible) + // { + // CloseWaiting(control); + // } + //} + + /// + /// Closes the waiting. + /// + /// The control. + //private static void CloseWaiting(Control control) + //{ + // Control[] array = control.Controls.Find("myprogressPanelext", false); + // if (array.Length > 0) + // { + // Control control2 = array[0]; + // if (control2.Tag != null && control2.Tag is Forms.FrmWaiting) + // { + // Forms.FrmWaiting frmWaitingEx = control2.Tag as Forms.FrmWaiting; + // if (frmWaitingEx != null && !frmWaitingEx.IsDisposed && frmWaitingEx.Visible) + // { + // frmWaitingEx.Hide(); + // } + // } + // } + //} + + /// + /// Closes the process panel. + /// + /// The parent. + public static void CloseProcessPanel(Control parent) + { + if (parent.InvokeRequired) + { + parent.BeginInvoke(new MethodInvoker(delegate + { + CloseProcessPanel(parent); + })); + } + else if (parent != null) + { + Control control = HaveProcessPanelControl(parent); + if (control != null) + { + Form frm = control.Tag as Form; + if (frm != null && !frm.IsDisposed && frm.Visible) + { + if (frm.InvokeRequired) + { + frm.BeginInvoke(new MethodInvoker(delegate + { + frm.Hide(); + })); + } + else + { + frm.Hide(); + } + } + } + } + } + + /// + /// Haves the process panel control. + /// + /// The parent. + /// Control. + public static Control HaveProcessPanelControl(Control parent) + { + Control[] array = parent.Controls.Find("myprogressPanelext", false); + Control result; + if (array.Length > 0) + { + result = array[0]; + } + else + { + result = null; + } + return result; + } + + /// + /// Creates the progress panel. + /// + /// Control. + //public static Control CreateProgressPanel() + //{ + // return new Label + // { + // Name = "myprogressPanelext", + // Visible = false, + // Tag = new Forms.FrmWaiting + // { + // TopMost = true, + // Opacity = 0.0 + // } + // }; + //} + + /// + /// Converts to array. + /// + /// The controls. + /// Control[]. + public static Control[] ToArray(this System.Windows.Forms.Control.ControlCollection controls) + { + if (controls == null || controls.Count <= 0) + return new Control[0]; + List lst = new List(); + foreach (Control item in controls) + { + lst.Add(item); + } + return lst.ToArray(); + } + + + #region 根据控件宽度截取字符串 + /// + /// 功能描述:根据控件宽度截取字符串 + /// 作  者:HZH + /// 创建日期:2019-06-27 10:49:10 + /// 任务编号:POS + /// + /// 字符串 + /// 控件宽度 + /// Graphics + /// 字体 + /// 截取后的字符串 + public static string GetSubString( + string strSource, + float fltControlWidth, + System.Drawing.Graphics g, + System.Drawing.Font font) + { + try + { + fltControlWidth = fltControlWidth - 20; + strSource = strSource.Trim(); + while (true) + { + + System.Drawing.SizeF sizeF = g.MeasureString(strSource.Replace(" ", "A"), font); + if (sizeF.Width > fltControlWidth) + { + strSource = strSource.TrimEnd('…'); + if (strSource.Length <= 1) + return ""; + strSource = strSource.Substring(0, strSource.Length - 1).Trim() + "…"; + } + else + { + return strSource; + } + } + } + finally + { + g.Dispose(); + } + } + #endregion + + #region 获取字符串宽度 + /// + /// 功能描述:获取字符串宽度 + /// 作  者:HZH + /// 创建日期:2019-06-27 11:54:50 + /// 任务编号:POS + /// + /// strSource + /// g + /// font + /// 返回值 + public static int GetStringWidth( + string strSource, + System.Drawing.Graphics g, + System.Drawing.Font font) + { + string[] strs = strSource.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); + float fltWidth = 0; + foreach (var item in strs) + { + System.Drawing.SizeF sizeF = g.MeasureString(strSource.Replace(" ", "A"), font); + if (sizeF.Width > fltWidth) + fltWidth = sizeF.Width; + } + + return (int)fltWidth; + } + #endregion + + #region 动画特效 + /// + /// Animates the window. + /// + /// The WHND. + /// The dwtime. + /// The dwflag. + /// true if XXXX, false otherwise. + [DllImport("user32.dll")] + public static extern bool AnimateWindow(IntPtr whnd, int dwtime, int dwflag); + //dwflag的取值如下 + /// + /// The aw hor positive + /// + public const Int32 AW_HOR_POSITIVE = 0x00000001; + //从左到右显示 + /// + /// The aw hor negative + /// + public const Int32 AW_HOR_NEGATIVE = 0x00000002; + //从右到左显示 + /// + /// The aw ver positive + /// + public const Int32 AW_VER_POSITIVE = 0x00000004; + //从上到下显示 + /// + /// The aw ver negative + /// + public const Int32 AW_VER_NEGATIVE = 0x00000008; + //从下到上显示 + /// + /// The aw center + /// + public const Int32 AW_CENTER = 0x00000010; + //若使用了AW_HIDE标志,则使窗口向内重叠,即收缩窗口;否则使窗口向外扩展,即展开窗口 + /// + /// The aw hide + /// + public const Int32 AW_HIDE = 0x00010000; + //隐藏窗口,缺省则显示窗口 + /// + /// The aw activate + /// + public const Int32 AW_ACTIVATE = 0x00020000; + //激活窗口。在使用了AW_HIDE标志后不能使用这个标志 + /// + /// The aw slide + /// + public const Int32 AW_SLIDE = 0x00040000; + //使用滑动类型。缺省则为滚动动画类型。当使用AW_CENTER标志时,这个标志就被忽略 + /// + /// The aw blend + /// + public const Int32 AW_BLEND = 0x00080000; + //透明度从高到低 + #endregion + + #region 检查文本控件输入类型是否有效 + /// + /// 功能描述:检查文本控件输入类型是否有效 + /// 作  者:HZH + /// 创建日期:2019-02-28 10:23:34 + /// 任务编号:POS + /// + /// 值 + /// 控制类型 + /// 最大值 + /// 最小值 + /// 小数位长度 + /// 正则 + /// 返回值 + public static bool CheckInputType( + string strValue, + TextInputType inputType, + decimal decMaxValue = default(decimal), + decimal decMinValue = default(decimal), + int intLength = 2, + string strRegexPattern = null) + { + bool result; + switch (inputType) + { + case TextInputType.NotControl: + result = true; + return result; + case TextInputType.UnsignNumber: + if (string.IsNullOrEmpty(strValue)) + { + result = true; + return result; + } + else + { + if (strValue.IndexOf("-") >= 0) + { + result = false; + return result; + } + } + break; + case TextInputType.Number: + if (string.IsNullOrEmpty(strValue)) + { + result = true; + return result; + } + else + { + if (!Regex.IsMatch(strValue, "^-?\\d*(\\.?\\d*)?$")) + { + result = false; + return result; + } + } + break; + case TextInputType.Integer: + if (string.IsNullOrEmpty(strValue)) + { + result = true; + return result; + } + else + { + if (!Regex.IsMatch(strValue, "^-?\\d*$")) + { + result = false; + return result; + } + } + break; + case TextInputType.PositiveInteger: + if (string.IsNullOrEmpty(strValue)) + { + result = true; + return result; + } + else + { + if (!Regex.IsMatch(strValue, "^\\d+$")) + { + result = false; + return result; + } + } + break; + case TextInputType.Regex: + result = (string.IsNullOrEmpty(strRegexPattern) || Regex.IsMatch(strValue, strRegexPattern)); + return result; + } + if (strValue == "-") + { + return true; + } + decimal d; + if (!decimal.TryParse(strValue, out d)) + { + result = false; + } + else if (d < decMinValue || d > decMaxValue) + { + result = false; + } + else + { + if (inputType == TextInputType.Number || inputType == TextInputType.UnsignNumber || inputType == TextInputType.PositiveNumber) + { + if (strValue.IndexOf(".") >= 0) + { + string text = strValue.Substring(strValue.IndexOf(".")); + if (text.Length > intLength + 1) + { + result = false; + return result; + } + } + } + result = true; + } + return result; + } + #endregion + + #region 冻结控件 + /// + /// The m LST freeze control + /// + static Dictionary m_lstFreezeControl = new Dictionary(); + /// + /// 功能描述:停止更新控件 + /// 作  者:HZH + /// 创建日期:2019-07-13 11:11:32 + /// 任务编号:POS + /// + /// control + /// 是否停止更新 + //public static void FreezeControl(Control control, bool blnToFreeze) + //{ + // if (blnToFreeze && control.IsHandleCreated && control.Visible && !control.IsDisposed && (!m_lstFreezeControl.ContainsKey(control) || (m_lstFreezeControl.ContainsKey(control) && m_lstFreezeControl[control] == false))) + // { + // m_lstFreezeControl[control] = true; + // control.Disposed += control_Disposed; + // NativeMethods.SendMessage(control.Handle, 11, 0, 0); + // } + // else if (!blnToFreeze && !control.IsDisposed && m_lstFreezeControl.ContainsKey(control) && m_lstFreezeControl[control] == true) + // { + // m_lstFreezeControl.Remove(control); + // NativeMethods.SendMessage(control.Handle, 11, 1, 0); + // control.Invalidate(true); + // } + //} + + /// + /// Handles the Disposed event of the control control. + /// + /// The source of the event. + /// The instance containing the event data. + static void control_Disposed(object sender, EventArgs e) + { + try + { + if (m_lstFreezeControl.ContainsKey((Control)sender)) + m_lstFreezeControl.Remove((Control)sender); + } + catch { } + } + #endregion + + /// + /// 设置GDI高质量模式抗锯齿 + /// + /// The g. + public static void SetGDIHigh(this Graphics g) + { + g.SmoothingMode = SmoothingMode.AntiAlias; //使绘图质量最高,即消除锯齿 + g.InterpolationMode = InterpolationMode.HighQualityBicubic; + g.CompositingQuality = CompositingQuality.HighQuality; + } + + /// + /// 根据矩形和圆得到一个圆角矩形Path + /// + /// The rect. + /// The corner radius. + /// GraphicsPath. + public static GraphicsPath CreateRoundedRectanglePath(this Rectangle rect, int cornerRadius) + { + GraphicsPath roundedRect = new GraphicsPath(); + roundedRect.AddArc(rect.X, rect.Y, cornerRadius * 2, cornerRadius * 2, 180, 90); + roundedRect.AddLine(rect.X + cornerRadius, rect.Y, rect.Right - cornerRadius * 2, rect.Y); + roundedRect.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y, cornerRadius * 2, cornerRadius * 2, 270, 90); + roundedRect.AddLine(rect.Right, rect.Y + cornerRadius * 2, rect.Right, rect.Y + rect.Height - cornerRadius * 2); + roundedRect.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y + rect.Height - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 0, 90); + roundedRect.AddLine(rect.Right - cornerRadius * 2, rect.Bottom, rect.X + cornerRadius * 2, rect.Bottom); + roundedRect.AddArc(rect.X, rect.Bottom - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 90, 90); + roundedRect.AddLine(rect.X, rect.Bottom - cornerRadius * 2, rect.X, rect.Y + cornerRadius * 2); + roundedRect.CloseFigure(); + return roundedRect; + } + + /// + /// Creates the rounded rectangle path. + /// + /// The rect. + /// The corner radius. + /// GraphicsPath. + public static GraphicsPath CreateRoundedRectanglePath(this RectangleF rect, int cornerRadius) + { + GraphicsPath roundedRect = new GraphicsPath(); + roundedRect.AddArc(rect.X, rect.Y, cornerRadius * 2, cornerRadius * 2, 180, 90); + roundedRect.AddLine(rect.X + cornerRadius, rect.Y, rect.Right - cornerRadius * 2, rect.Y); + roundedRect.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y, cornerRadius * 2, cornerRadius * 2, 270, 90); + roundedRect.AddLine(rect.Right, rect.Y + cornerRadius * 2, rect.Right, rect.Y + rect.Height - cornerRadius * 2); + roundedRect.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y + rect.Height - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 0, 90); + roundedRect.AddLine(rect.Right - cornerRadius * 2, rect.Bottom, rect.X + cornerRadius * 2, rect.Bottom); + roundedRect.AddArc(rect.X, rect.Bottom - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 90, 90); + roundedRect.AddLine(rect.X, rect.Bottom - cornerRadius * 2, rect.X, rect.Y + cornerRadius * 2); + roundedRect.CloseFigure(); + return roundedRect; + } + /// + /// Gets the colors. + /// + /// The colors. + public static Color[] Colors { get; private set; } + + static ControlHelper() + { + List list = new List(); + list.Add(Color.FromArgb(55, 162, 218)); + list.Add(Color.FromArgb(50, 197, 233)); + list.Add(Color.FromArgb(103, 224, 227)); + list.Add(Color.FromArgb(159, 230, 184)); + list.Add(Color.FromArgb(255, 219, 92)); + list.Add(Color.FromArgb(255, 159, 127)); + list.Add(Color.FromArgb(251, 114, 147)); + list.Add(Color.FromArgb(224, 98, 174)); + list.Add(Color.FromArgb(230, 144, 209)); + list.Add(Color.FromArgb(231, 188, 243)); + list.Add(Color.FromArgb(157, 150, 245)); + list.Add(Color.FromArgb(131, 120, 234)); + list.Add(Color.FromArgb(150, 191, 255)); + + list.Add(Color.FromArgb(243, 67, 54)); + list.Add(Color.FromArgb(156, 39, 176)); + list.Add(Color.FromArgb(103, 58, 183)); + list.Add(Color.FromArgb(63, 81, 181)); + list.Add(Color.FromArgb(33, 150, 243)); + list.Add(Color.FromArgb(0, 188, 211)); + list.Add(Color.FromArgb(3, 169, 244)); + list.Add(Color.FromArgb(0, 150, 136)); + list.Add(Color.FromArgb(139, 195, 74)); + list.Add(Color.FromArgb(76, 175, 80)); + list.Add(Color.FromArgb(204, 219, 57)); + list.Add(Color.FromArgb(233, 30, 99)); + list.Add(Color.FromArgb(254, 234, 59)); + list.Add(Color.FromArgb(254, 192, 7)); + list.Add(Color.FromArgb(254, 152, 0)); + list.Add(Color.FromArgb(255, 87, 34)); + list.Add(Color.FromArgb(121, 85, 72)); + list.Add(Color.FromArgb(158, 158, 158)); + list.Add(Color.FromArgb(96, 125, 139)); + list.Add(Color.FromArgb(252, 117, 85)); + list.Add(Color.FromArgb(172, 113, 191)); + list.Add(Color.FromArgb(115, 131, 253)); + list.Add(Color.FromArgb(78, 206, 255)); + list.Add(Color.FromArgb(121, 195, 82)); + list.Add(Color.FromArgb(255, 163, 28)); + list.Add(Color.FromArgb(255, 185, 15)); + list.Add(Color.FromArgb(255, 181, 197)); + list.Add(Color.FromArgb(255, 110, 180)); + list.Add(Color.FromArgb(255, 69, 0)); + list.Add(Color.FromArgb(255, 48, 48)); + list.Add(Color.FromArgb(154, 205, 50)); + list.Add(Color.FromArgb(155, 205, 155)); + list.Add(Color.FromArgb(154, 50, 205)); + list.Add(Color.FromArgb(131, 111, 255)); + list.Add(Color.FromArgb(124, 205, 124)); + list.Add(Color.FromArgb(0, 206, 209)); + list.Add(Color.FromArgb(0, 178, 238)); + list.Add(Color.FromArgb(56, 142, 142)); + + Type typeFromHandle = typeof(Color); + PropertyInfo[] properties = typeFromHandle.GetProperties(); + PropertyInfo[] array = properties; + for (int i = 0; i < array.Length; i++) + { + PropertyInfo propertyInfo = array[i]; + if (propertyInfo.PropertyType == typeof(Color) && (propertyInfo.Name.StartsWith("Dark") || propertyInfo.Name.StartsWith("Medium"))) + { + object value = propertyInfo.GetValue(null, null); + list.Add((Color)value); + } + } + Colors = list.ToArray(); + } + /// + /// Draws the string. + /// + /// The g. + /// The s. + /// The font. + /// The brush. + /// The point. + /// The format. + /// The angle. + public static void DrawString(Graphics g, string s, Font font, Brush brush, PointF point, StringFormat format, float angle) + { + Matrix transform = g.Transform; + Matrix transform2 = g.Transform; + transform2.RotateAt(angle, point); + g.Transform = transform2; + g.DrawString(s, font, brush, point, format); + g.Transform = transform; + } + + /// + /// Gets the rhombus from rectangle. + /// + /// The rect. + /// Point[]. + public static Point[] GetRhombusFromRectangle(Rectangle rect) + { + return new Point[5] + { + new Point(rect.X, rect.Y + rect.Height / 2), + new Point(rect.X + rect.Width / 2, rect.Y + rect.Height - 1), + new Point(rect.X + rect.Width - 1, rect.Y + rect.Height / 2), + new Point(rect.X + rect.Width / 2, rect.Y), + new Point(rect.X, rect.Y + rect.Height / 2) + }; + } + + /// + /// Computes the paint location y. + /// + /// The maximum. + /// The minimum. + /// The height. + /// The value. + /// System.Single. + public static float ComputePaintLocationY(int max, int min, int height, int value) + { + if ((float)(max - min) == 0f) + { + return height; + } + return (float)height - (float)(value - min) * 1f / (float)(max - min) * (float)height; + } + + /// + /// Computes the paint location y. + /// + /// The maximum. + /// The minimum. + /// The height. + /// The value. + /// System.Single. + public static float ComputePaintLocationY(float max, float min, float height, float value) + { + if (max - min == 0f) + { + return height; + } + return height - (value - min) / (max - min) * height; + } + + + /// + /// Paints the coordinate divide. + /// + /// The g. + /// The pen line. + /// The pen dash. + /// The font. + /// The brush. + /// The sf. + /// The degree. + /// The maximum. + /// The minimum. + /// The width. + /// The height. + /// The left. + /// The right. + /// Up. + /// Down. + public static void PaintCoordinateDivide(Graphics g, System.Drawing.Pen penLine, System.Drawing.Pen penDash, Font font, System.Drawing.Brush brush, StringFormat sf, int degree, int max, int min, int width, int height, int left = 60, int right = 8, int up = 8, int down = 8) + { + for (int i = 0; i <= degree; i++) + { + int value = (max - min) * i / degree + min; + int num = (int)ComputePaintLocationY(max, min, height - up - down, value) + up + 1; + g.DrawLine(penLine, left - 1, num, left - 4, num); + if (i != 0) + { + g.DrawLine(penDash, left, num, width - right, num); + } + g.DrawString(value.ToString(), font, brush, new Rectangle(-5, num - font.Height / 2, left, font.Height), sf); + } + } + + /// + /// Paints the triangle. + /// + /// The g. + /// The brush. + /// The point. + /// The size. + /// The direction. + public static void PaintTriangle(Graphics g, System.Drawing.Brush brush, Point point, int size, GraphDirection direction) + { + Point[] array = new Point[4]; + switch (direction) + { + case GraphDirection.Leftward: + array[0] = new Point(point.X, point.Y - size); + array[1] = new Point(point.X, point.Y + size); + array[2] = new Point(point.X - 2 * size, point.Y); + break; + case GraphDirection.Rightward: + array[0] = new Point(point.X, point.Y - size); + array[1] = new Point(point.X, point.Y + size); + array[2] = new Point(point.X + 2 * size, point.Y); + break; + case GraphDirection.Upward: + array[0] = new Point(point.X - size, point.Y); + array[1] = new Point(point.X + size, point.Y); + array[2] = new Point(point.X, point.Y - 2 * size); + break; + default: + array[0] = new Point(point.X - size, point.Y); + array[1] = new Point(point.X + size, point.Y); + array[2] = new Point(point.X, point.Y + 2 * size); + break; + } + array[3] = array[0]; + g.FillPolygon(brush, array); + } + + /// + /// Paints the triangle. + /// + /// The g. + /// The brush. + /// The point. + /// The size. + /// The direction. + public static void PaintTriangle(Graphics g, System.Drawing.Brush brush, PointF point, int size, GraphDirection direction) + { + PointF[] array = new PointF[4]; + switch (direction) + { + case GraphDirection.Leftward: + array[0] = new PointF(point.X, point.Y - (float)size); + array[1] = new PointF(point.X, point.Y + (float)size); + array[2] = new PointF(point.X - (float)(2 * size), point.Y); + break; + case GraphDirection.Rightward: + array[0] = new PointF(point.X, point.Y - (float)size); + array[1] = new PointF(point.X, point.Y + (float)size); + array[2] = new PointF(point.X + (float)(2 * size), point.Y); + break; + case GraphDirection.Upward: + array[0] = new PointF(point.X - (float)size, point.Y); + array[1] = new PointF(point.X + (float)size, point.Y); + array[2] = new PointF(point.X, point.Y - (float)(2 * size)); + break; + default: + array[0] = new PointF(point.X - (float)size, point.Y); + array[1] = new PointF(point.X + (float)size, point.Y); + array[2] = new PointF(point.X, point.Y + (float)(2 * size)); + break; + } + array[3] = array[0]; + g.FillPolygon(brush, array); + } + + /// + /// Adds the array data. + /// + /// + /// The array. + /// The data. + /// The maximum. + public static void AddArrayData(ref T[] array, T[] data, int max) + { + if (data == null || data.Length == 0) + { + return; + } + if (array.Length == max) + { + Array.Copy(array, data.Length, array, 0, array.Length - data.Length); + Array.Copy(data, 0, array, array.Length - data.Length, data.Length); + } + else if (array.Length + data.Length > max) + { + T[] array2 = new T[max]; + for (int i = 0; i < max - data.Length; i++) + { + array2[i] = array[i + (array.Length - max + data.Length)]; + } + for (int j = 0; j < data.Length; j++) + { + array2[array2.Length - data.Length + j] = data[j]; + } + array = array2; + } + else + { + T[] array3 = new T[array.Length + data.Length]; + for (int k = 0; k < array.Length; k++) + { + array3[k] = array[k]; + } + for (int l = 0; l < data.Length; l++) + { + array3[array3.Length - data.Length + l] = data[l]; + } + array = array3; + } + } + + /// + /// Converts the size. + /// + /// The size. + /// The angle. + /// SizeF. + public static SizeF ConvertSize(SizeF size, float angle) + { + System.Drawing.Drawing2D.Matrix matrix = new System.Drawing.Drawing2D.Matrix(); + matrix.Rotate(angle); + PointF[] array = new PointF[4]; + array[0].X = (0f - size.Width) / 2f; + array[0].Y = (0f - size.Height) / 2f; + array[1].X = (0f - size.Width) / 2f; + array[1].Y = size.Height / 2f; + array[2].X = size.Width / 2f; + array[2].Y = size.Height / 2f; + array[3].X = size.Width / 2f; + array[3].Y = (0f - size.Height) / 2f; + matrix.TransformPoints(array); + float num = float.MaxValue; + float num2 = float.MinValue; + float num3 = float.MaxValue; + float num4 = float.MinValue; + PointF[] array2 = array; + for (int i = 0; i < array2.Length; i++) + { + PointF pointF = array2[i]; + if (pointF.X < num) + { + num = pointF.X; + } + if (pointF.X > num2) + { + num2 = pointF.X; + } + if (pointF.Y < num3) + { + num3 = pointF.Y; + } + if (pointF.Y > num4) + { + num4 = pointF.Y; + } + } + return new SizeF(num2 - num, num4 - num3); + } + + + + /// + /// Gets the pow. + /// + /// The digit. + /// System.Int32. + private static int GetPow(int digit) + { + int num = 1; + for (int i = 0; i < digit; i++) + { + num *= 10; + } + return num; + } + + /// + /// Calculates the maximum section from. + /// + /// The values. + /// System.Int32. + public static double CalculateMaxSectionFrom(double[] values) + { + double num = values.Max(); + return CalculateMaxSection(num); + } + + public static double CalculateMaxSectionFrom(double[][] values) + { + double num = values.Max(p => p.Max()); + return CalculateMaxSection(num); + } + + private static double CalculateMaxSection(double num) + { + if (num <= 5) + { + return 5; + } + if (num <= 10) + { + return 10; + } + int digit = num.ToString().Length - 2; + int num2 = int.Parse(num.ToString().Substring(0, 2)); + if (num2 < 12) + { + return 12 * GetPow(digit); + } + if (num2 < 14) + { + return 14 * GetPow(digit); + } + if (num2 < 16) + { + return 16 * GetPow(digit); + } + if (num2 < 18) + { + return 18 * GetPow(digit); + } + if (num2 < 20) + { + return 20 * GetPow(digit); + } + if (num2 < 22) + { + return 22 * GetPow(digit); + } + if (num2 < 24) + { + return 24 * GetPow(digit); + } + if (num2 < 26) + { + return 26 * GetPow(digit); + } + if (num2 < 28) + { + return 28 * GetPow(digit); + } + if (num2 < 30) + { + return 30 * GetPow(digit); + } + if (num2 < 40) + { + return 40 * GetPow(digit); + } + if (num2 < 50) + { + return 50 * GetPow(digit); + } + if (num2 < 60) + { + return 60 * GetPow(digit); + } + if (num2 < 80) + { + return 80 * GetPow(digit); + } + return 100 * GetPow(digit); + } + + /// + /// Gets the color light. + /// + /// The color. + /// System.Drawing.Color. + public static System.Drawing.Color GetColorLight(System.Drawing.Color color) + { + return System.Drawing.Color.FromArgb(color.R + (255 - color.R) * 40 / 100, color.G + (255 - color.G) * 40 / 100, color.B + (255 - color.B) * 40 / 100); + } + + /// + /// Gets the color light five. + /// + /// The color. + /// System.Drawing.Color. + public static System.Drawing.Color GetColorLightFive(System.Drawing.Color color) + { + return System.Drawing.Color.FromArgb(color.R + (255 - color.R) * 50 / 100, color.G + (255 - color.G) * 50 / 100, color.B + (255 - color.B) * 50 / 100); + } + + /// + /// Gets the points from. + /// + /// The points. + /// Width of the soure. + /// Height of the source. + /// The width. + /// The height. + /// The dx. + /// The dy. + /// PointF[]. + public static PointF[] GetPointsFrom(string points, float soureWidth, float sourceHeight, float width, float height, float dx = 0f, float dy = 0f) + { + string[] array = points.Split(new char[1] + { + ' ' + }, StringSplitOptions.RemoveEmptyEntries); + PointF[] array2 = new PointF[array.Length]; + for (int i = 0; i < array.Length; i++) + { + int num = array[i].IndexOf(','); + float num2 = Convert.ToSingle(array[i].Substring(0, num)); + float num3 = Convert.ToSingle(array[i].Substring(num + 1)); + array2[i] = new PointF(width * (num2 + dx) / soureWidth, height * (num3 + dy) / sourceHeight); + } + return array2; + } + + public static bool IsDesignMode() + { + bool returnFlag = false; + + if (LicenseManager.UsageMode == LicenseUsageMode.Designtime) + { + returnFlag = true; + } + else if (Process.GetCurrentProcess().ProcessName == "devenv") + { + returnFlag = true; + } + + return returnFlag; + } + + #region 滚动条 English:scroll bar + static uint SB_HORZ = 0x0; + static uint SB_VERT = 0x1; + //static uint SB_CTL = 0x2; + //static uint SB_BOTH = 0x3; + [DllImport("user32.dll", SetLastError = true, EntryPoint = "GetScrollInfo")] + private static extern int GetScrollInfo(IntPtr hWnd, uint fnBar, ref SCROLLINFO psbi); + [DllImport("user32.dll")]//[return: MarshalAs(UnmanagedType.Bool)] + private static extern int SetScrollInfo(IntPtr handle, uint fnBar, ref SCROLLINFO si, bool fRedraw); + + [DllImport("user32.dll", EntryPoint = "PostMessage")] + private static extern bool PostMessage(IntPtr handle, int msg, uint wParam, uint lParam); + [DllImport("User32.dll", EntryPoint = "SendMessage")] + private static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); + /// + /// ShowScrollBar + /// + /// hWnd + /// 0:horizontal,1:vertical,3:both + /// bShow + /// + [DllImport("user32.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + public static extern bool ShowScrollBar(IntPtr hWnd, int wBar, bool bShow); + /// + ///获取水平滚动条信息 + /// + /// The h WND. + /// Scrollbarinfo. + public static SCROLLINFO GetHScrollBarInfo(IntPtr hWnd) + { + SCROLLINFO info = new SCROLLINFO(); + info.cbSize = (int)Marshal.SizeOf(info); + info.fMask = (int)ScrollInfoMask.SIF_DISABLENOSCROLL | (int)ScrollInfoMask.SIF_ALL; + int intRef = GetScrollInfo(hWnd, SB_HORZ, ref info); + return info; + } + /// + /// 获取垂直滚动条信息 + /// + /// The h WND. + /// Scrollbarinfo. + public static SCROLLINFO GetVScrollBarInfo(IntPtr hWnd) + { + SCROLLINFO info = new SCROLLINFO(); + info.cbSize = (int)Marshal.SizeOf(info); + info.fMask = (int)ScrollInfoMask.SIF_DISABLENOSCROLL | (int)ScrollInfoMask.SIF_ALL; + int intRef = GetScrollInfo(hWnd, SB_VERT, ref info); + return info; + } + public struct SCROLLINFO + { + public int cbSize; + public int fMask; + public int nMin; + public int nMax; + public int nPage; + public int nPos; + public int nTrackPos; + public int ScrollMax { get { return nMax + 1 - nPage; } } + } + public enum ScrollInfoMask : uint + { + SIF_RANGE = 0x1, + SIF_PAGE = 0x2, + SIF_POS = 0x4, + SIF_DISABLENOSCROLL = 0x8, + SIF_TRACKPOS = 0x10, + SIF_ALL = (SIF_RANGE | SIF_PAGE | SIF_POS | SIF_TRACKPOS), + SB_THUMBTRACK = 5, + WM_HSCROLL = 0x0114, + WM_VSCROLL = 0x0115, + SB_LINEUP = 0, + SB_LINEDOWN = 1, + SB_LINELEFT = 0, + SB_LINERIGHT = 1, + } + + public static void SetVScrollValue(IntPtr handle, int value) + { + var info = GetVScrollBarInfo(handle); + info.nPos = value; + SetScrollInfo(handle, SB_VERT, ref info, true); + PostMessage(handle, (int)ScrollInfoMask.WM_VSCROLL, MakeLong((short)ScrollInfoMask.SB_THUMBTRACK, highPart: (short)info.nPos), 0); + } + public static void SetHScrollValue(IntPtr handle, int value) + { + var info = GetHScrollBarInfo(handle); + info.nPos = value; + SetScrollInfo(handle, SB_HORZ, ref info, true); + PostMessage(handle, (int)ScrollInfoMask.WM_HSCROLL, MakeLong((short)ScrollInfoMask.SB_THUMBTRACK, highPart: (short)info.nPos), 0); + } + private static uint MakeLong(short lowPart, short highPart) + { + return (ushort)lowPart | (uint)(highPart << 16); + } + /// + /// 控件向上滚动一个单位 + /// + /// 控件句柄 + public static void ScrollUp(IntPtr handle) + { + SendMessage(handle, (int)ScrollInfoMask.WM_VSCROLL, (int)ScrollInfoMask.SB_LINEUP, 0); + } + + /// + /// 控件向下滚动一个单位 + /// + /// 控件句柄 + public static void ScrollDown(IntPtr handle) + { + SendMessage(handle, (int)ScrollInfoMask.WM_VSCROLL, (int)ScrollInfoMask.SB_LINEDOWN, 0); + } + /// + /// 控件向左滚动一个单位 + /// + /// 控件句柄 + public static void ScrollLeft(IntPtr handle) + { + SendMessage(handle, (int)ScrollInfoMask.WM_HSCROLL, (int)ScrollInfoMask.SB_LINELEFT, 0); + } + + /// + /// 控件向右滚动一个单位 + /// + /// 控件句柄 + public static void ScrollRight(IntPtr handle) + { + SendMessage(handle, (int)ScrollInfoMask.WM_VSCROLL, (int)ScrollInfoMask.SB_LINERIGHT, 0); + } + #endregion + + + /// + /// 返回指定图片中的非透明区域; + /// + /// 位图 + /// + public static GraphicsPath CalculateControlGraphicsPath(Bitmap bitmap, Color? colorTransparent = null) + { + // Create GraphicsPath for our bitmap calculation + //创建 GraphicsPath + GraphicsPath graphicsPath = new GraphicsPath(); + // Use the top left pixel as our transparent color + //使用左上角的一点的颜色作为我们透明色 + + Color _colorTransparent = bitmap.GetPixel(0, 0); + if (colorTransparent != null && colorTransparent != Color.Transparent && colorTransparent != Color.Empty) + _colorTransparent = colorTransparent.Value; + // This is to store the column value where an opaque pixel is first found. + // This value will determine where we start scanning for trailing opaque pixels. + //第一个找到点的X + int colOpaquePixel = 0; + // Go through all rows (Y axis) + // 偏历所有行(Y方向) + for (int row = 0; row < bitmap.Height; row++) + { + // Reset value + //重设 + colOpaquePixel = 0; + // Go through all columns (X axis) + //偏历所有列(X方向) + for (int col = 0; col < bitmap.Width; col++) + { + // If this is an opaque pixel, mark it and search for anymore trailing behind + //如果是不需要透明处理的点则标记,然后继续偏历 + if (bitmap.GetPixel(col, row) != _colorTransparent) + { + // Opaque pixel found, mark current position + //记录当前 + colOpaquePixel = col; + // Create another variable to set the current pixel position + //建立新变量来记录当前点 + int colNext = col; + // Starting from current found opaque pixel, search for anymore opaque pixels + // trailing behind, until a transparent pixel is found or minimum width is reached + ///从找到的不透明点开始,继续寻找不透明点,一直到找到或则达到图片宽度 + for (colNext = colOpaquePixel; colNext < bitmap.Width; colNext++) + if (bitmap.GetPixel(colNext, row) == _colorTransparent) + break; + // Form a rectangle for line of opaque pixels found and add it to our graphics path + //将不透明点加到graphics path + graphicsPath.AddRectangle(new Rectangle(colOpaquePixel, row, colNext - colOpaquePixel, 1)); + // No need to scan the line of opaque pixels just found + col = colNext; + } + } + } + // Return calculated graphics path + return graphicsPath; + } + + /// + /// 颜色加深 + /// + /// + /// -1.0f <= correctionFactor <= 1.0f + /// + public static Color ChangeColor(this Color color, float correctionFactor) + { + float red = (float)color.R; + float green = (float)color.G; + float blue = (float)color.B; + + if (correctionFactor < 0) + { + correctionFactor = 1 + correctionFactor; + red *= correctionFactor; + green *= correctionFactor; + blue *= correctionFactor; + } + else + { + red = (255 - red) * correctionFactor + red; + green = (255 - green) * correctionFactor + green; + blue = (255 - blue) * correctionFactor + blue; + } + + if (red < 0) red = 0; + + if (red > 255) red = 255; + + if (green < 0) green = 0; + + if (green > 255) green = 255; + + if (blue < 0) blue = 0; + + if (blue > 255) blue = 255; + + + + return Color.FromArgb(color.A, (int)red, (int)green, (int)blue); + } + + + /// + /// 相对于屏幕显示的位置 + /// + /// 窗体需要显示的屏幕 + /// left + /// top + /// + public static Point GetScreenLocation(Screen screen, int left, int top) + { + return new Point(screen.Bounds.Left + left, screen.Bounds.Top + top); + } + } + + public enum GraphDirection + { + /// + /// The upward + /// + Upward = 1, + /// + /// The downward + /// + Downward, + /// + /// The leftward + /// + Leftward, + /// + /// The rightward + /// + Rightward + } + + public enum TextInputType + { + /// + /// 不控制输入 + /// + [Description("不控制输入")] + NotControl = 1, + /// + /// 任意数字 + /// + [Description("任意数字")] + Number = 2, + /// + /// 非负数 + /// + [Description("非负数")] + UnsignNumber = 4, + /// + /// 正数 + /// + [Description("正数")] + PositiveNumber = 8, + /// + /// 整数 + /// + [Description("整数")] + Integer = 16, + /// + /// 非负整数 + /// + [Description("非负整数")] + PositiveInteger = 32, + /// + /// 正则验证 + /// + [Description("正则验证")] + Regex = 64 + } +} diff --git a/HighWayIot.Controls/Controls/HslDirectionStyle.cs b/HighWayIot.Controls/Controls/HslDirectionStyle.cs new file mode 100644 index 0000000..894eba2 --- /dev/null +++ b/HighWayIot.Controls/Controls/HslDirectionStyle.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Mesnac.Controls.ChemicalWeighing +{ + public enum HslDirectionStyle + { + /// 控件是横向摆放的 + Horizontal = 1, + /// 控件是纵向摆放的 + Vertical = 2, + } +} diff --git a/HighWayIot.Controls/Controls/HslHelper.cs b/HighWayIot.Controls/Controls/HslHelper.cs new file mode 100644 index 0000000..20b11db --- /dev/null +++ b/HighWayIot.Controls/Controls/HslHelper.cs @@ -0,0 +1,639 @@ +using System; +using System.Collections.Generic; +using System.Drawing.Drawing2D; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +namespace Mesnac.Controls.ChemicalWeighing +{ + /// 整个组件的代码辅助工具,提供了一个基础的类库方法 + public class HslHelper + { + static HslHelper() + { + HslHelper.StringFormatDefault = new StringFormat(); + HslHelper.StringFormatCenter = new StringFormat(); + HslHelper.StringFormatCenter.Alignment = StringAlignment.Center; + HslHelper.StringFormatCenter.LineAlignment = StringAlignment.Center; + HslHelper.StringFormatLeft = new StringFormat(); + HslHelper.StringFormatLeft.LineAlignment = StringAlignment.Center; + HslHelper.StringFormatLeft.Alignment = StringAlignment.Near; + HslHelper.StringFormatRight = new StringFormat(); + HslHelper.StringFormatRight.LineAlignment = StringAlignment.Center; + HslHelper.StringFormatRight.Alignment = StringAlignment.Far; + HslHelper.StringFormatTopCenter = new StringFormat(); + HslHelper.StringFormatTopCenter.Alignment = StringAlignment.Center; + HslHelper.StringFormatTopCenter.LineAlignment = StringAlignment.Near; + } + + /// 返回中间范围值数据,如果大于最大值,则返回最大值,如果小于最小值,则返回最小值 + /// 最小值 + /// 实际值 + /// 最大值 + /// 中间值信息 + public static int Middle(int min, int value, int max) + { + if (value > max) + return max; + return value < min ? min : value; + } + + /// 从一个矩形的图形中获取菱形的坐标数组 + /// 矩形 + /// 数组结果 + public static Point[] GetRhombusFromRectangle(Rectangle rect) => new Point[5] + { + new Point(rect.X, rect.Y + rect.Height / 2), + new Point(rect.X + rect.Width / 2, rect.Y + rect.Height - 1), + new Point(rect.X + rect.Width - 1, rect.Y + rect.Height / 2), + new Point(rect.X + rect.Width / 2, rect.Y), + new Point(rect.X, rect.Y + rect.Height / 2) + }; + + /// 计算绘图时的相对偏移值 + /// 0-100分的最大值,就是指准备绘制的最大值 + /// 0-100分的最小值,就是指准备绘制的最小值 + /// 实际绘图区域的高度 + /// 需要绘制数据的当前值 + /// 相对于0的位置,还需要增加上面的偏值 + public static float ComputePaintLocationY(int max, int min, int height, int value) => (double)(max - min) == 0.0 ? (float)height : (float)height - (float)(value - min) * 1f / (float)(max - min) * (float)height; + + /// 计算绘图Y轴时的相对偏移值 + /// 0-100分的最大值,就是指准备绘制的最大值 + /// 0-100分的最小值,就是指准备绘制的最小值 + /// 实际绘图区域的高度 + /// 需要绘制数据的当前值 + /// 相对于0的位置,还需要增加上面的偏值 + public static float ComputePaintLocationY(float max, float min, float height, float value) + { + if ((double)max - (double)min == 0.0) + return height; + float num = max - min; + if ((double)num == 0.0) + num = 1f; + return height - (value - min) / num * height; + } + + /// 计算绘图X轴时的相对偏移值 + /// 0-100分的最大值,就是指准备绘制的最大值 + /// 0-100分的最小值,就是指准备绘制的最小值 + /// 实际绘图区域的宽度 + /// 需要绘制数据的当前值 + /// 相对于0的位置,还需要增加上面的偏值 + public static float ComputePaintLocationX(float max, float min, float width, float value) + { + if ((double)max - (double)min == 0.0) + return width; + float num = max - min; + if ((double)num == 0.0) + num = 1f; + return (value - min) / num * width; + } + + /// 根据绘制的值计算原始的值信息 + /// 0-100分的最大值,就是指准备绘制的最大值 + /// 0-100分的最小值,就是指准备绘制的最小值 + /// 实际绘图区域的高度 + /// 实际绘制的位置信息 + /// 实际的值信息 + public static float ComputeValueFromPaintLocationY( + float max, + float min, + float height, + float paint) + { + if ((double)max - (double)min == 0.0) + return max; + float num = max - min; + if ((double)num == 0.0) + num = 1f; + return (height - paint) * num / height + min; + } + + /// 计算绘图时的相对偏移值 + /// 坐标轴信息 + /// 实际绘图区域的高度 + /// 需要绘制数据的当前值 + /// 相对于0的位置,还需要增加上面的偏值 + public static float ComputePaintLocationY( + ReferenceAxis referenceAxis, + float height, + float value) + { + return HslHelper.ComputePaintLocationY(referenceAxis.Max, referenceAxis.Min, height, value); + } + + /// 绘制坐标系中的刻度线 + /// 绘图对象 + /// 画坐标轴的画笔 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static void PaintCoordinateDivide( + Graphics g, + System.Drawing.Pen penLine, + System.Drawing.Pen penDash, + Font font, + System.Drawing.Brush brush, + StringFormat sf, + int degree, + int max, + int min, + int width, + int height, + int left = 60, + int right = 8, + int up = 8, + int down = 8) + { + for (int index = 0; index <= degree; ++index) + { + int num1 = (max - min) * index / degree + min; + int num2 = (int)HslHelper.ComputePaintLocationY(max, min, height - up - down, num1) + up + 1; + g.DrawLine(penLine, left - 1, num2, left - 4, num2); + if (index != 0) + g.DrawLine(penDash, left, num2, width - right, num2); + g.DrawString(num1.ToString(), font, brush, (RectangleF)new Rectangle(-5, num2 - font.Height / 2, left, font.Height), sf); + } + } + + /// 根据指定的方向绘制一个箭头 + /// + /// + /// + /// + /// + public static void PaintTriangle( + Graphics g, + System.Drawing.Brush brush, + Point point, + int size, + GraphDirection direction) + { + Point[] points = new Point[4]; + switch (direction) + { + case GraphDirection.Upward: + points[0] = new Point(point.X - size, point.Y); + points[1] = new Point(point.X + size, point.Y); + points[2] = new Point(point.X, point.Y - 2 * size); + break; + case GraphDirection.Leftward: + points[0] = new Point(point.X, point.Y - size); + points[1] = new Point(point.X, point.Y + size); + points[2] = new Point(point.X - 2 * size, point.Y); + break; + case GraphDirection.Rightward: + points[0] = new Point(point.X, point.Y - size); + points[1] = new Point(point.X, point.Y + size); + points[2] = new Point(point.X + 2 * size, point.Y); + break; + default: + points[0] = new Point(point.X - size, point.Y); + points[1] = new Point(point.X + size, point.Y); + points[2] = new Point(point.X, point.Y + 2 * size); + break; + } + points[3] = points[0]; + g.FillPolygon(brush, points); + } + + /// 绘制向左或是向右的箭头,例如 << 或是 >> + /// 画刷资源 + /// 画笔资源 + /// 绘制的矩形 + /// 方向信息 + public static void DrawLeftRight( + Graphics g, + System.Drawing.Pen pen, + Rectangle rectangle, + GraphDirection direction) + { + if (direction == GraphDirection.Leftward) + { + g.DrawLines(pen, new Point[3] + { + new Point(rectangle.X + rectangle.Width / 2, rectangle.Y), + new Point(rectangle.X, rectangle.Y + rectangle.Height / 2), + new Point(rectangle.X + rectangle.Width / 2, rectangle.Y + rectangle.Height) + }); + g.DrawLines(pen, new Point[3] + { + new Point(rectangle.X + rectangle.Width, rectangle.Y), + new Point(rectangle.X + rectangle.Width / 2, rectangle.Y + rectangle.Height / 2), + new Point(rectangle.X + rectangle.Width, rectangle.Y + rectangle.Height) + }); + } + else + { + if (direction != GraphDirection.Rightward) + return; + g.DrawLines(pen, new Point[3] + { + new Point(rectangle.X, rectangle.Y), + new Point(rectangle.X + rectangle.Width / 2, rectangle.Y + rectangle.Height / 2), + new Point(rectangle.X, rectangle.Y + rectangle.Height) + }); + g.DrawLines(pen, new Point[3] + { + new Point(rectangle.X + rectangle.Width / 2, rectangle.Y), + new Point(rectangle.X + rectangle.Width, rectangle.Y + rectangle.Height / 2), + new Point(rectangle.X + rectangle.Width / 2, rectangle.Y + rectangle.Height) + }); + } + } + + /// 根据指定的方向绘制一个箭头 + /// + /// + /// + /// + /// + public static void PaintTriangle( + Graphics g, + System.Drawing.Brush brush, + PointF point, + int size, + GraphDirection direction) + { + PointF[] points = new PointF[4]; + switch (direction) + { + case GraphDirection.Upward: + points[0] = new PointF(point.X - (float)size, point.Y); + points[1] = new PointF(point.X + (float)size, point.Y); + points[2] = new PointF(point.X, point.Y - (float)(2 * size)); + break; + case GraphDirection.Leftward: + points[0] = new PointF(point.X, point.Y - (float)size); + points[1] = new PointF(point.X, point.Y + (float)size); + points[2] = new PointF(point.X - (float)(2 * size), point.Y); + break; + case GraphDirection.Rightward: + points[0] = new PointF(point.X, point.Y - (float)size); + points[1] = new PointF(point.X, point.Y + (float)size); + points[2] = new PointF(point.X + (float)(2 * size), point.Y); + break; + default: + points[0] = new PointF(point.X - (float)size, point.Y); + points[1] = new PointF(point.X + (float)size, point.Y); + points[2] = new PointF(point.X, point.Y + (float)(2 * size)); + break; + } + points[3] = points[0]; + g.FillPolygon(brush, points); + } + + /// + /// 一个通用的数组新增个数方法,会自动判断越界情况,越界的情况下,会自动的截断或是填充 -> + /// A common array of new methods, will automatically determine the cross-border situation, in the case of cross-border, will be automatically truncated or filled + /// + /// 数据类型 + /// 原数据 + /// 等待新增的数据 + /// 原数据的最大值 + public static void AddArrayData(ref T[] array, T[] data, int max) + { + if (data == null || data.Length == 0) + return; + if (array.Length == max) + { + Array.Copy((Array)array, data.Length, (Array)array, 0, array.Length - data.Length); + Array.Copy((Array)data, 0, (Array)array, array.Length - data.Length, data.Length); + } + else if (array.Length + data.Length > max) + { + T[] objArray = new T[max]; + for (int index = 0; index < max - data.Length; ++index) + objArray[index] = array[index + (array.Length - max + data.Length)]; + for (int index = 0; index < data.Length; ++index) + objArray[objArray.Length - data.Length + index] = data[index]; + array = objArray; + } + else + { + T[] objArray = new T[array.Length + data.Length]; + for (int index = 0; index < array.Length; ++index) + objArray[index] = array[index]; + for (int index = 0; index < data.Length; ++index) + objArray[objArray.Length - data.Length + index] = data[index]; + array = objArray; + } + } + + /// 尺寸转换,计算旋转后的尺寸。 + /// + /// + /// + public static SizeF ConvertSize(SizeF size, float angle) + { + System.Drawing.Drawing2D.Matrix matrix = new System.Drawing.Drawing2D.Matrix(); + matrix.Rotate(angle); + PointF[] pts = new PointF[4]; + pts[0].X = (float)(-(double)size.Width / 2.0); + pts[0].Y = (float)(-(double)size.Height / 2.0); + pts[1].X = (float)(-(double)size.Width / 2.0); + pts[1].Y = size.Height / 2f; + pts[2].X = size.Width / 2f; + pts[2].Y = size.Height / 2f; + pts[3].X = size.Width / 2f; + pts[3].Y = (float)(-(double)size.Height / 2.0); + matrix.TransformPoints(pts); + float num1 = float.MaxValue; + float num2 = float.MinValue; + float num3 = float.MaxValue; + float num4 = float.MinValue; + foreach (PointF pointF in pts) + { + if ((double)pointF.X < (double)num1) + num1 = pointF.X; + if ((double)pointF.X > (double)num2) + num2 = pointF.X; + if ((double)pointF.Y < (double)num3) + num3 = pointF.Y; + if ((double)pointF.Y > (double)num4) + num4 = pointF.Y; + } + return new SizeF(num2 - num1, num4 - num3); + } + + /// 绘制旋转文本 + /// + /// + /// + /// + /// + /// + /// + public static void DrawString( + Graphics g, + string s, + Font font, + System.Drawing.Brush brush, + PointF point, + StringFormat format, + float angle) + { + System.Drawing.Drawing2D.Matrix transform1 = g.Transform; + System.Drawing.Drawing2D.Matrix transform2 = g.Transform; + transform2.RotateAt(angle, point); + g.Transform = transform2; + g.DrawString(s, font, brush, point, format); + g.Transform = transform1; + } + + private static int GetPow(int digit) + { + int pow = 1; + for (int index = 0; index < digit; ++index) + pow *= 10; + return pow; + } + + /// 将int数组转换为double数组 + /// int数组值 + /// 结果值 + public static double[] TranlateArrayToDouble(int[] values) + { + if (values == null) + return (double[])null; + double[] numArray = new double[values.Length]; + for (int index = 0; index < values.Length; ++index) + numArray[index] = (double)values[index]; + return numArray; + } + + /// 将float数组转换为double数组值 + /// float数组值 + /// 结果值 + public static double[] TranlateArrayToDouble(float[] values) + { + double[] numArray = new double[values.Length]; + for (int index = 0; index < values.Length; ++index) + numArray[index] = (double)values[index]; + return numArray; + } + + /// 获得数据的上限值,这个上限值是自动计算的。 + /// 数据值 + /// 数据值 + public static int CalculateMaxSectionFrom(double[] values) + { + double a = ((IEnumerable)values).Max(); + if (a <= 5.0) + return 5; + if (a <= 9.0) + return 10; + int int32 = Convert.ToInt32(Math.Ceiling(a)); + int digit = int32.ToString().Length - 2; + int num = int.Parse(int32.ToString().Substring(0, 2)); + if (num < 11) + return 12 * HslHelper.GetPow(digit); + if (num < 13) + return 14 * HslHelper.GetPow(digit); + if (num < 15) + return 16 * HslHelper.GetPow(digit); + if (num < 17) + return 18 * HslHelper.GetPow(digit); + if (num < 19) + return 20 * HslHelper.GetPow(digit); + if (num < 21) + return 22 * HslHelper.GetPow(digit); + if (num < 23) + return 24 * HslHelper.GetPow(digit); + if (num < 25) + return 26 * HslHelper.GetPow(digit); + if (num < 27) + return 28 * HslHelper.GetPow(digit); + if (num < 29) + return 30 * HslHelper.GetPow(digit); + if (num < 33) + return 34 * HslHelper.GetPow(digit); + if (num < 40) + return 40 * HslHelper.GetPow(digit); + if (num < 50) + return 50 * HslHelper.GetPow(digit); + if (num < 60) + return 60 * HslHelper.GetPow(digit); + if (num < 80) + return 80 * HslHelper.GetPow(digit); + return num < 95 ? 100 * HslHelper.GetPow(digit) : 100 * HslHelper.GetPow(digit); + } + + /// + public static int CalculateMaxSectionFrom(Dictionary values) => HslHelper.CalculateMaxSectionFrom(values.Select, double>((Func, double>)(m => ((IEnumerable)m.Value).Max())).ToArray()); + + /// 获取当前颜色更淡的颜色信息 + /// 颜色信息 + /// 颜色 + public static System.Drawing.Color GetColorLight(System.Drawing.Color color) => HslHelper.GetColorLight(color, 40); + + /// 获取当前颜色更深的颜色信息 + /// 颜色信息 + /// 颜色 + public static System.Drawing.Color GetColorDeep(System.Drawing.Color color) => HslHelper.GetColorLight(color, -40); + + /// 获取当前颜色更淡的颜色信息,需要指定系数0-100,0时是原来的原色,100时是纯白色 + /// 颜色信息 + /// 获取颜色的系数信息 + /// 颜色 + public static System.Drawing.Color GetColorLight(System.Drawing.Color color, int scale) => scale > 0 ? System.Drawing.Color.FromArgb((int)color.R + ((int)byte.MaxValue - (int)color.R) * scale / 100, (int)color.G + ((int)byte.MaxValue - (int)color.G) * scale / 100, (int)color.B + ((int)byte.MaxValue - (int)color.B) * scale / 100) : System.Drawing.Color.FromArgb((int)color.R + (int)color.R * scale / 100, (int)color.G + (int)color.G * scale / 100, (int)color.B + (int)color.B * scale / 100); + + /// 获取颜色的偏移信息 + /// 颜色值 + /// 颜色偏移信息 + /// 颜色值 + public static System.Drawing.Color GetColorOffset(System.Drawing.Color color, int offset) + { + int red = (int)color.R + offset; + if (red < 0) + red = 0; + if (red > (int)byte.MaxValue) + red = (int)byte.MaxValue; + int green = (int)color.G + offset; + if (green < 0) + green = 0; + if (green > (int)byte.MaxValue) + green = (int)byte.MaxValue; + int blue = (int)color.B + offset; + if (blue < 0) + blue = 0; + if (blue > (int)byte.MaxValue) + blue = (int)byte.MaxValue; + return System.Drawing.Color.FromArgb(red, green, blue); + } + + ///// 获取当前颜色更淡的颜色信息 + ///// 颜色信息 + ///// 颜色 + //public static System.Drawing.Color GetColorLightFive(System.Drawing.Color color) => HslHelper.GetColorLight(color, 50); + + ///// 获取当前颜色更淡的颜色信息 + ///// 颜色信息 + ///// 颜色 + //public static System.Windows.Media.Color GetColorLight(System.Windows.Media.Color color) => System.Windows.Media.Color.FromRgb((byte)((uint)color.R + (uint)(((int)byte.MaxValue - (int)color.R) * 40 / 100)), (byte)((uint)color.G + (uint)(((int)byte.MaxValue - (int)color.G) * 40 / 100)), (byte)((uint)color.B + (uint)(((int)byte.MaxValue - (int)color.B) * 40 / 100))); + + ///// 获取当前颜色更淡的颜色信息 + ///// 颜色信息 + ///// 颜色 + //public static System.Windows.Media.Color GetColorLightFive(System.Windows.Media.Color color) => System.Windows.Media.Color.FromRgb((byte)((uint)color.R + (uint)(((int)byte.MaxValue - (int)color.R) * 50 / 100)), (byte)((uint)color.G + (uint)(((int)byte.MaxValue - (int)color.G) * 50 / 100)), (byte)((uint)color.B + (uint)(((int)byte.MaxValue - (int)color.B) * 50 / 100))); + + /// 从字符串表示的点位信息里解析出真正的点位信息 + /// 字符串的点位 + /// 原来的长度信息 + /// 原来的高度信息 + /// 实际的宽度信息 + /// 实际的高度信息 + /// x偏移量信息 + /// y偏移量信息 + /// + public static PointF[] GetPointsFrom( + string points, + float soureWidth, + float sourceHeight, + float width, + float height, + float dx = 0.0f, + float dy = 0.0f) + { + string[] strArray = points.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); + PointF[] pointsFrom = new PointF[strArray.Length]; + for (int index = 0; index < strArray.Length; ++index) + { + int length = strArray[index].IndexOf(','); + float single1 = Convert.ToSingle(strArray[index].Substring(0, length)); + float single2 = Convert.ToSingle(strArray[index].Substring(length + 1)); + pointsFrom[index] = new PointF(width * (single1 + dx) / soureWidth, height * (single2 + dy) / sourceHeight); + } + return pointsFrom; + } + + /// 根据矩形及其各个定点的配置信息,获取圆角的路径信息,可以指定每个定点的圆角情况 + /// + /// + /// + /// + /// + /// + /// + public static GraphicsPath GetRoundRectange( + Rectangle rectangle, + int radius, + bool topLeft, + bool topRight, + bool buttomRight, + bool buttomLeft) + { + GraphicsPath roundRectange = new GraphicsPath(); + Point pt1_1 = new Point(rectangle.X + (topLeft ? radius : 0), rectangle.Y); + Point pt2_1 = new Point(rectangle.X + rectangle.Width - 1 - (topRight ? radius : 0), rectangle.Y); + roundRectange.AddLine(pt1_1, pt2_1); + if (topRight && radius > 0) + roundRectange.AddArc(rectangle.X + rectangle.Width - radius * 2 - 1, rectangle.Y, radius * 2, radius * 2, 270f, 90f); + Point pt1_2 = new Point(rectangle.X + rectangle.Width - 1, rectangle.Y + (topRight ? radius : 0)); + Point pt2_2 = new Point(rectangle.X + rectangle.Width - 1, rectangle.Y + rectangle.Height - 1 - (buttomRight ? radius : 0)); + roundRectange.AddLine(pt1_2, pt2_2); + if (buttomRight && radius > 0) + roundRectange.AddArc(rectangle.X + rectangle.Width - radius * 2 - 1, rectangle.Y + rectangle.Height - radius * 2 - 1, radius * 2, radius * 2, 0.0f, 90f); + Point pt1_3 = new Point(rectangle.X + rectangle.Width - 1 - (buttomRight ? radius : 0), rectangle.Y + rectangle.Height - 1); + Point pt2_3 = new Point(rectangle.X + (buttomLeft ? radius : 0), rectangle.Y + rectangle.Height - 1); + roundRectange.AddLine(pt1_3, pt2_3); + if (buttomLeft && radius > 0) + roundRectange.AddArc(rectangle.X, rectangle.Y + rectangle.Height - radius * 2 - 1, radius * 2, radius * 2, 90f, 90f); + Point pt1_4 = new Point(rectangle.X, rectangle.Y + rectangle.Height - 1 - (buttomLeft ? radius : 0)); + Point pt2_4 = new Point(rectangle.X, rectangle.Y + (topLeft ? radius : 0)); + roundRectange.AddLine(pt1_4, pt2_4); + if (topLeft && radius > 0) + roundRectange.AddArc(rectangle.X, rectangle.Y, radius * 2, radius * 2, 180f, 90f); + return roundRectange; + } + + private static string FloatMatchEvaluator(Match m) => m.Value.Length == 5 ? m.Value.Substring(0, 3) : m.Value.Substring(0, 2); + + /// 获取浮点数值的格式化文本信息,如果发生了异常,则返回错误消息 + /// 格式化信息 + /// 值信息 + /// 是否保留0的信息 + /// 等待显示的文本 + public static string GetFormatString(string format, float value, bool remainZero = false) + { + try + { + string input = string.Format(format, (object)value); + return remainZero ? input : Regex.Replace(input, "[Ee][+-][0]+", new MatchEvaluator(HslHelper.FloatMatchEvaluator)); + } + catch + { + return "Wrong"; + } + } + + /// 矩形中间的字符串对齐机制 + public static StringFormat StringFormatCenter { get; set; } + + /// 矩形的左侧中间的对齐机制 + public static StringFormat StringFormatLeft { get; set; } + + /// 矩形的右侧的中间对齐机制 + public static StringFormat StringFormatRight { get; set; } + + /// 矩形的的默认的左上角对齐的机制 + public static StringFormat StringFormatDefault { get; set; } + + /// 矩形的下方中间的对齐的机制 + public static StringFormat StringFormatTopCenter { get; set; } + } +} diff --git a/HighWayIot.Controls/Controls/HslMoveText.cs b/HighWayIot.Controls/Controls/HslMoveText.cs new file mode 100644 index 0000000..a8e124f --- /dev/null +++ b/HighWayIot.Controls/Controls/HslMoveText.cs @@ -0,0 +1,254 @@ +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 = 30; + 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) + { + if (this.moveSpeed != 0f) + { + if (this.startLocationX < -this.fontWidth - 5f) + { + 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/HighWayIot.Controls/Controls/ReferenceAxis.cs b/HighWayIot.Controls/Controls/ReferenceAxis.cs new file mode 100644 index 0000000..f1d33cd --- /dev/null +++ b/HighWayIot.Controls/Controls/ReferenceAxis.cs @@ -0,0 +1,145 @@ +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 +{ + /// 参考坐标系的轴信息 + [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; + + /// 实例化一个默认的对象 + public ReferenceAxis() + { + this.Max = 100f; + this.Min = 0.0f; + this.Color = Color.LightGray; + this.Format = "{0}"; + } + + /// 实例化一个默认的对象 + public ReferenceAxis(UserControl userControl) + : this() + { + this._control = userControl; + } + + /// 实例化一个默认的对象 + /// 最大值 + /// 最小值 + public ReferenceAxis(float max, float min) + { + this.Max = max; + this.Min = min; + } + + /// 最大值 + [Category("HslControls")] + [Description("获取或设置当前的Y轴的最大值")] + [Browsable(true)] + [DefaultValue(100f)] + public float Max + { + get => this._max; + set + { + this._max = value; + this._control?.Invalidate(); + } + } + + /// 最小值 + [Category("HslControls")] + [Description("获取或设置当前的Y轴的最小值")] + [Browsable(true)] + [DefaultValue(0.0f)] + public float Min + { + get => this._min; + set + { + this._min = value; + this._control?.Invalidate(); + } + } + + /// 单位信息 + [Category("HslControls")] + [Description("获取或设置当前的Y轴的单位值")] + [Browsable(true)] + [DefaultValue("")] + public string Unit + { + get => this._unit; + set + { + this._unit = value; + this._control?.Invalidate(); + } + } + + /// 获取或设置当前的坐标系的颜色信息 + [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(); + } + } + + /// 获取或设置当前坐标轴数字的格式化信息,默认为 {0}, 直接转字符串 + [Category("HslControls")] + [Description("获取或设置当前坐标轴数字的格式化信息,默认为 {0}, 直接转字符串")] + [Browsable(true)] + [DefaultValue("{0}")] + public string Format + { + get => this._format; + set + { + this._format = value; + this._control?.Invalidate(); + } + } + + /// 获取画笔信息 + /// 画笔信息 + public Pen GetPen() + { + if (this._pen != null) + return this._pen; + this._pen = new Pen(this.Color, 1f); + return this._pen; + } + + /// 画刷资源 + [Browsable(false)] + public Brush Brush { get; set; } + } +} diff --git a/HighWayIot.Controls/Controls/ReferenceAxisConverter.cs b/HighWayIot.Controls/Controls/ReferenceAxisConverter.cs new file mode 100644 index 0000000..19d8895 --- /dev/null +++ b/HighWayIot.Controls/Controls/ReferenceAxisConverter.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Mesnac.Controls.ChemicalWeighing +{ + /// 参考坐标轴的转换器 + public class ReferenceAxisConverter : TypeConverter + { + /// + public override PropertyDescriptorCollection GetProperties( + ITypeDescriptorContext context, + object value, + Attribute[] attributes) + { + return TypeDescriptor.GetProperties(value, attributes); + } + + /// + public override bool GetPropertiesSupported(ITypeDescriptorContext context) => true; + } +} diff --git a/HighWayIot.Controls/HighWayIot.Controls.csproj b/HighWayIot.Controls/HighWayIot.Controls.csproj new file mode 100644 index 0000000..be419b4 --- /dev/null +++ b/HighWayIot.Controls/HighWayIot.Controls.csproj @@ -0,0 +1,57 @@ + + + + + Debug + AnyCPU + {DDEE27AA-0694-47A6-9335-E9308261F63A} + Library + HighWayIot.Controls + HighWayIot.Controls + v4.8 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + UserControl + + + + + + + + \ No newline at end of file diff --git a/HighWayIot.Controls/Properties/AssemblyInfo.cs b/HighWayIot.Controls/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..fbe3069 --- /dev/null +++ b/HighWayIot.Controls/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("HighWayIot.Controls")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("HighWayIot.Controls")] +[assembly: AssemblyCopyright("Copyright © 2025")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("ddee27aa-0694-47a6-9335-e9308261f63a")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/HighWayIot.Plc/PlcHelper/TransferSingal.cs b/HighWayIot.Plc/PlcHelper/TransferSingal.cs index 5f1e16c..715c70d 100644 --- a/HighWayIot.Plc/PlcHelper/TransferSingal.cs +++ b/HighWayIot.Plc/PlcHelper/TransferSingal.cs @@ -46,11 +46,11 @@ namespace HighWayIot.Plc.PlcHelper /// 复位报警点位信号 /// /// - public void WriteAlarmSignal(int No) + public void WriteAlarmSignal() { - if(!PlcConnect.PlcWrite2($"3030.{No:X}", false, DataTypeEnum.Bool).IsSuccess) + if(!PlcConnect.PlcWrite2($"D3030", 0, DataTypeEnum.UInt16).IsSuccess) { - LogHelper.Instance.Error($"小车报警复位失败 No.{No}"); + LogHelper.Instance.Error($"小车报警复位失败"); } } diff --git a/HighWayIot.Repository/domain/ExportTableEntity.cs b/HighWayIot.Repository/domain/ExportTableEntity.cs index 9c1f6ec..0b1fddd 100644 --- a/HighWayIot.Repository/domain/ExportTableEntity.cs +++ b/HighWayIot.Repository/domain/ExportTableEntity.cs @@ -138,6 +138,12 @@ namespace HighWayIot.Repository.domain [Description("生胎宽度")] public string RawTireWidth { get; set; } = string.Empty; + /// + /// 标准重量 + /// + [Description("标准重量")] + public string StandardWeight { get; set; } = string.Empty; + /// /// 生胎重量 /// @@ -149,5 +155,11 @@ namespace HighWayIot.Repository.domain /// [Description("复重重量")] public string RepeatWeight { get; set; } = string.Empty; + + /// + /// 状态 + /// + [Description("状态")] + public string IsDone { get; set; } = string.Empty; } } diff --git a/HighWayIot.Repository/domain/MonitorDataSource.cs b/HighWayIot.Repository/domain/MonitorDataSource.cs index 288870d..cc6689d 100644 --- a/HighWayIot.Repository/domain/MonitorDataSource.cs +++ b/HighWayIot.Repository/domain/MonitorDataSource.cs @@ -55,6 +55,12 @@ namespace HighWayIot.Repository.domain /// public int? RawTireWeight { get; set; } + /// + /// 备 注:标准重量 + /// 默认值: + /// + public int? StandardWeight { get; set; } + /// /// 基部胶耗时 /// diff --git a/HighWayIot.Repository/domain/ZxDailyReportEntity.cs b/HighWayIot.Repository/domain/ZxDailyReportEntity.cs index 98016bf..389514a 100644 --- a/HighWayIot.Repository/domain/ZxDailyReportEntity.cs +++ b/HighWayIot.Repository/domain/ZxDailyReportEntity.cs @@ -68,6 +68,13 @@ namespace HighWayIot.Repository.domain [SugarColumn(ColumnName = "raw_tire_weight")] public int? RawTireWeight { get; set; } + /// + /// 备 注:标准重量 + /// 默认值: + /// + [SugarColumn(ColumnName = "standard_weight")] + public int? StandardWeight { get; set; } + /// /// 备 注:基部胶开始 /// 默认值: diff --git a/HighWayIot.Repository/service/SysErrorLogService.cs b/HighWayIot.Repository/service/SysErrorLogService.cs index 6f5cad2..55a1a69 100644 --- a/HighWayIot.Repository/service/SysErrorLogService.cs +++ b/HighWayIot.Repository/service/SysErrorLogService.cs @@ -67,5 +67,22 @@ namespace HighWayIot.Repository.service return false; } } + + /// + /// 删除一个月之前的数据 + /// + /// + public bool DeleteMoreData() + { + try + { + return _repository.Delete(x => x.LogTime <= (DateTime.Now - TimeSpan.FromDays(30))); + } + catch (Exception ex) + { + log.Error("数据删除异常", ex); + return false; + } + } } } diff --git a/HighWayIot.Repository/service/SysLogService.cs b/HighWayIot.Repository/service/SysLogService.cs index b7e00d6..07710c6 100644 --- a/HighWayIot.Repository/service/SysLogService.cs +++ b/HighWayIot.Repository/service/SysLogService.cs @@ -68,5 +68,21 @@ namespace HighWayIot.Repository.service } } + /// + /// 删除一个月之前的数据 + /// + /// + public bool DeleteMoreData() + { + try + { + return _repository.Delete(x => x.LogTime <= (DateTime.Now - TimeSpan.FromDays(30))); + } + catch (Exception ex) + { + log.Error("数据删除异常", ex); + return false; + } + } } } diff --git a/HighWayIot.Repository/service/ZxDailyReportService.cs b/HighWayIot.Repository/service/ZxDailyReportService.cs index 627c012..38587f8 100644 --- a/HighWayIot.Repository/service/ZxDailyReportService.cs +++ b/HighWayIot.Repository/service/ZxDailyReportService.cs @@ -34,6 +34,29 @@ namespace HighWayIot.Repository.service /// /// public List GetDailyReportInfos() + { + try + { + DateTime day = DateTime.Now - TimeSpan.FromDays(2); + List entity = + _repository.AsQueryable() + .Where(x => x.StartTime >= day) + .OrderByDescending(x => x.StartTime) + .ToList(); + return entity; + } + catch (Exception ex) + { + log.Error("报表息获取异常", ex); + return null; + } + } + + /// + /// 查询报表信息 + /// + /// + public List GetOneDayDailyReportInfos() { try { @@ -127,5 +150,22 @@ namespace HighWayIot.Repository.service return false; } } + + /// + /// 删除一个月之前的数据 + /// + /// + public bool DeleteMoreData() + { + try + { + return _repository.Delete(x => x.StartTime <= (DateTime.Now - TimeSpan.FromDays(30))); + } + catch (Exception ex) + { + log.Error("数据删除异常", ex); + return false; + } + } } } diff --git a/HighWayIot.Winform/Business/MonitorDataRefreshBusiness.cs b/HighWayIot.Winform/Business/MonitorDataRefreshBusiness.cs index 7293775..c6a63df 100644 --- a/HighWayIot.Winform/Business/MonitorDataRefreshBusiness.cs +++ b/HighWayIot.Winform/Business/MonitorDataRefreshBusiness.cs @@ -54,6 +54,7 @@ namespace HighWayIot.Winform.Business float[] weights = new float[4]; //报警信号 bool[] alarm = new bool[10]; + //报警信号获取 alarm[0] = signals[58].GetBoolByIndex(0); alarm[1] = signals[58].GetBoolByIndex(1); @@ -66,6 +67,7 @@ namespace HighWayIot.Winform.Business alarm[8] = signals[59].GetBoolByIndex(0); alarm[9] = signals[59].GetBoolByIndex(1); + bool flag = false; //称重信号解析 for (int i = 0; i < 10; i++) { @@ -79,10 +81,14 @@ namespace HighWayIot.Winform.Business P1 = i + 1, })) { - transferSingal.WriteAlarmSignal(i + 1); + flag = true; } } } + if (flag) + { + transferSingal.WriteAlarmSignal(); + } //报表信号获取 for (int i = 0; i < 7; i++) @@ -208,7 +214,7 @@ namespace HighWayIot.Winform.Business /// RGV编号 public bool MonitorInsert(string recipeCode, string deviceNo, int rgvNo) { - DateTime judgeTime = DateTime.Now - TimeSpan.FromMinutes(30); + DateTime judgeTime = DateTime.Now - TimeSpan.FromMinutes(10); List judgeEntity = ZxDailyReportService.Instance .GetDailyReportInfos(x => x.DeviceNo == rgvNo && @@ -239,7 +245,8 @@ namespace HighWayIot.Winform.Business RecipeCode = recipeEntity.RecipeCode, SpecCode = recipeEntity.RecipeSpecCode, DeviceNo = rgvNo, - RawTireWeight = 0,//(int)ZxRecipeParaService.Instance.GetRecipeParaInfoByRecipeCode(recipeCode).FirstOrDefault()?.TireWeight, + RawTireWeight = 0, + StandardWeight = (int)ZxRecipeParaService.Instance.GetRecipeParaInfoByRecipeCode(recipeCode).FirstOrDefault()?.TireWeight, IsDone = 0 }; diff --git a/HighWayIot.Winform/Business/TimerExportBusiness.cs b/HighWayIot.Winform/Business/TimerExportBusiness.cs new file mode 100644 index 0000000..4bdb58a --- /dev/null +++ b/HighWayIot.Winform/Business/TimerExportBusiness.cs @@ -0,0 +1,330 @@ +using HighWayIot.Repository.domain; +using HighWayIot.Repository.service; +using Models; +using NPOI.HSSF.UserModel; +using NPOI.SS.UserModel; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Timer = System.Threading.Timer; + + +namespace HighWayIot.Winform.Business +{ + /// + /// 定时报表导出 + /// + public class TimerExportBusiness + { + private Timer RecordTimer; + + private string _savePath = string.Empty; + + /// + /// 处理前的报表数据 + /// + private List _zxDailyReportEntities; + + /// + /// 导出的报表 + /// + private List _exportTableEntities = new List(); + + private DataTable dataTable; + + public TimerExportBusiness() + { + RecordTimer = new Timer(ExportJudge, null, 0, 1000); + } + + /// + /// 判断是否该导出了 + /// + /// + private void ExportJudge(object o) + { + DateTime now = DateTime.Now; + var timeList = SysShiftTimeService.Instance.GetShiftInfos(); + var morningShift = timeList.Where(x => x.ShiftName == "早").FirstOrDefault(); + var startArray = morningShift.ShiftStartTime.Split(':'); + if(startArray.Length != 3) + { + return; + } + if (now.Hour == Convert.ToInt32(startArray[0]) + && now.Minute == Convert.ToInt32(startArray[1]) + && now.Second == Convert.ToInt32(startArray[3])) + { + AutoExport(); + ZxDailyReportService.Instance.DeleteMoreData(); + } + } + + private void AutoExport() + { + + _savePath = XmlUtil.Instance.ExportPathReader(); + + //获取前一天的报表 + _zxDailyReportEntities = ZxDailyReportService.Instance.GetOneDayDailyReportInfos(); + + //查询所有称重信息 + List _zxWeightEntities = ZxWeightService.Instance.GetWeightInfos(); + + //查询所有配方信息 + List _zxRecipeEntities = ZxRecipeService.Instance.GetRecipeInfos(); + + //开始关联 生成报表 + foreach (ZxDailyReportEntity rawEntity in _zxDailyReportEntities) + { + ExportTableEntity exportTableEntity = new ExportTableEntity(); + ZxRecipeEntity recipeEntity = _zxRecipeEntities.Where(x => x.RecipeCode == rawEntity.RecipeCode).FirstOrDefault(); + ZxWeightEntity baseWeight = _zxWeightEntities.Where(x => x.RecipeCode == rawEntity.RecipeCode && x.MaterialType == "基部胶").FirstOrDefault(); + ZxWeightEntity midWeight = _zxWeightEntities.Where(x => x.RecipeCode == rawEntity.RecipeCode && x.MaterialType == "中层胶").FirstOrDefault(); + ZxWeightEntity faceWeight = _zxWeightEntities.Where(x => x.RecipeCode == rawEntity.RecipeCode && x.MaterialType == "胎面胶").FirstOrDefault(); + if (recipeEntity == null) + { + continue; + } + exportTableEntity.RecipeCode = rawEntity.RecipeCode; + exportTableEntity.RecipeName = rawEntity.RecipeName; + exportTableEntity.SpecCode = rawEntity.SpecCode; + exportTableEntity.SpecName = recipeEntity.RecipeSpecName; + exportTableEntity.StartTime = rawEntity.StartTime.ToString("yyyy-MM-dd hh:mm:ss"); + + //基部胶 + if (baseWeight != null) + { + exportTableEntity.BaseRubName = baseWeight.MaterialName; + exportTableEntity.BaseRubThickness = baseWeight.SetThickness.ToString(); + //基部胶宽度和层数(可能有三层 + if (baseWeight.SetLayer2 == 0 || baseWeight.SetLayer2 == null) + { + exportTableEntity.BaseRubWidth = baseWeight.SetWidth.ToString(); + exportTableEntity.BaseRubLayer = baseWeight.SetLayer.ToString(); + } + else if (baseWeight.SetLayer3 == 0 || baseWeight.SetLayer3 == null) + { + exportTableEntity.BaseRubWidth = $"{baseWeight.SetWidth2}/{baseWeight.SetWidth}"; + exportTableEntity.BaseRubLayer = $"{baseWeight.SetLayer2}/{baseWeight.SetLayer}"; + } + else + { + exportTableEntity.BaseRubWidth = $"{baseWeight.SetWidth2}/{baseWeight.SetWidth3}/{baseWeight.SetWidth}"; + exportTableEntity.BaseRubLayer = $"{baseWeight.SetLayer2}/{baseWeight.SetLayer3}/{baseWeight.SetLayer}"; + } + exportTableEntity.BaseRubFinishTime = GeneralUtils.DateTimeToString(rawEntity.StartTime, rawEntity.BaseEndTime); + } + + //中层胶 + if (midWeight != null) + { + exportTableEntity.MidRubName = midWeight.MaterialName; + exportTableEntity.MidRubThickness = midWeight.SetThickness.ToString(); + //中层胶宽度和层数(可能有三层 + if (midWeight.SetLayer2 == 0 || midWeight.SetLayer2 == null) + { + exportTableEntity.MidRubWidth = midWeight.SetWidth.ToString(); + exportTableEntity.MidRubLayer = midWeight.SetLayer.ToString(); + } + else if (midWeight.SetLayer3 == 0 || midWeight.SetLayer3 == null) + { + exportTableEntity.MidRubWidth = $"{midWeight.SetWidth2}/{midWeight.SetWidth}"; + exportTableEntity.MidRubLayer = $"{midWeight.SetLayer2}/{midWeight.SetLayer}"; + } + else + { + exportTableEntity.MidRubWidth = $"{midWeight.SetWidth2}/{midWeight.SetWidth3}/{midWeight.SetWidth}"; + exportTableEntity.MidRubLayer = $"{midWeight.SetLayer2}/{midWeight.SetLayer3}/{midWeight.SetLayer}"; + } + exportTableEntity.MidRubFinishTime = GeneralUtils.DateTimeToString(rawEntity.StartTime, rawEntity.MidEndTime); + } + + //胎面胶 + if (faceWeight != null) + { + exportTableEntity.FaceRubName = faceWeight.MaterialName; + exportTableEntity.FaceRubThickness = faceWeight.SetThickness.ToString(); + //胎面胶宽度和层数(可能有三层 + if (faceWeight.SetLayer2 == 0 || faceWeight.SetLayer2 == null) + { + exportTableEntity.FaceRubWidth = faceWeight.SetWidth.ToString(); + exportTableEntity.FaceRubLayer = faceWeight.SetLayer.ToString(); + } + else if (faceWeight.SetLayer3 == 0 || faceWeight.SetLayer3 == null) + { + exportTableEntity.FaceRubWidth = $"{faceWeight.SetWidth2}/{faceWeight.SetWidth}"; + exportTableEntity.FaceRubLayer = $"{faceWeight.SetLayer2}/{faceWeight.SetLayer}"; + } + else + { + exportTableEntity.FaceRubWidth = $"{faceWeight.SetWidth2}/{faceWeight.SetWidth3}/{faceWeight.SetWidth}"; + exportTableEntity.FaceRubLayer = $"{faceWeight.SetLayer2}/{faceWeight.SetLayer3}/{faceWeight.SetLayer}"; + } + exportTableEntity.FaceRubFinishTime = GeneralUtils.DateTimeToString(rawEntity.StartTime, rawEntity.FaceEndTime); + } + + exportTableEntity.RawTireWidth = (faceWeight.SetThickness * 2 + faceWeight.SetWidth).ToString(); + exportTableEntity.StandardWeight = rawEntity.StandardWeight.ToString(); + exportTableEntity.RawTireWeight = (rawEntity.RawTireWeight ?? 0).ToString(); + exportTableEntity.RepeatWeight = (rawEntity.RepeatWeight ?? 0).ToString(); + exportTableEntity.IsDone = rawEntity.IsDone == 1 ? "已完成" : "未完成"; + + _exportTableEntities.Add(exportTableEntity); + } + + try + { + dataTable = ToDataTable(_exportTableEntities.ToArray()); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + + ExportExcel(dataTable, _savePath); + } + + /// + /// 导出Excel + /// + /// + public void ExportExcel(DataTable dt, string path) + { + try + { + //创建一个工作簿 + IWorkbook workbook = new HSSFWorkbook(); + + //创建一个 sheet 表 + ISheet sheet = workbook.CreateSheet(dt.TableName); + + //创建一行 + IRow rowH = sheet.CreateRow(0); + + //创建一个单元格 + ICell cell = null; + + //创建单元格样式 + ICellStyle cellStyle = workbook.CreateCellStyle(); + + //创建格式 + IDataFormat dataFormat = workbook.CreateDataFormat(); + + //设置为文本格式,也可以为 text,即 dataFormat.GetFormat("text"); + cellStyle.DataFormat = dataFormat.GetFormat("@"); + + //设置列名 + foreach (DataColumn col in dt.Columns) + { + //创建单元格并设置单元格内容 + rowH.CreateCell(col.Ordinal).SetCellValue(col.Caption); + + //设置单元格格式 + rowH.Cells[col.Ordinal].CellStyle = cellStyle; + } + + //写入数据 + for (int i = 0; i < dt.Rows.Count; i++) + { + //跳过第一行,第一行为列名 + IRow row = sheet.CreateRow(i + 1); + + for (int j = 0; j < dt.Columns.Count; j++) + { + cell = row.CreateCell(j); + cell.SetCellValue(dt.Rows[i][j].ToString()); + cell.CellStyle = cellStyle; + } + } + + //设置导出文件路径 + //string path = HttpContext.Current.Server.MapPath("Export/"); + + //设置新建文件路径及名称 + string savePath = $"{path}/自动导出-203报表{DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")}.xls"; + + //创建文件 + FileStream file = new FileStream(savePath, FileMode.CreateNew, FileAccess.Write); + + //创建一个 IO 流 + MemoryStream ms = new MemoryStream(); + + //写入到流 + workbook.Write(ms); + + //转换为字节数组 + byte[] bytes = ms.ToArray(); + + file.Write(bytes, 0, bytes.Length); + file.Flush(); + + //还可以调用下面的方法,把流输出到浏览器下载 + //OutputClient(bytes); + + //释放资源 + bytes = null; + + ms.Close(); + ms.Dispose(); + + file.Close(); + file.Dispose(); + + workbook.Close(); + sheet = null; + workbook = null; + MessageBox.Show("导出成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + + + + /// + /// 实体类转dt + /// + /// + /// + /// + public DataTable ToDataTable(T[] entities) + { + DataTable dataTable = new DataTable(typeof(T).Name); + + PropertyInfo[] properties = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance); + + foreach (PropertyInfo propInfo in properties) + { + // Get the Description attribute if it exists + var descriptionAttribute = propInfo.GetCustomAttribute(); + string columnName = descriptionAttribute != null ? descriptionAttribute.Description : propInfo.Name; + + dataTable.Columns.Add(columnName, propInfo.PropertyType); + } + + foreach (T entity in entities) + { + object[] values = new object[properties.Length]; + for (int i = 0; i < properties.Length; i++) + { + values[i] = properties[i].GetValue(entity); + } + + dataTable.Rows.Add(values); + } + + return dataTable; + } + + } +} diff --git a/HighWayIot.Winform/Business/XmlUtil.cs b/HighWayIot.Winform/Business/XmlUtil.cs index 6d10479..6e46230 100644 --- a/HighWayIot.Winform/Business/XmlUtil.cs +++ b/HighWayIot.Winform/Business/XmlUtil.cs @@ -1,6 +1,8 @@ -using HighWayIot.Repository.service; +using HighWayIot.Log4net; +using HighWayIot.Repository.service; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -58,8 +60,66 @@ namespace HighWayIot.Winform.Business return list; } + + /// + /// 读取导出路径配置 + /// + /// + public string ExportPathReader() + { + xmlDocument.Load($"{Path}\\Configuration.xml"); + XmlNode root = xmlDocument.DocumentElement; + XmlNode node = root.SelectSingleNode("ExportConfig"); + XmlAttribute path = (XmlAttribute)node.Attributes.GetNamedItem("Path"); + return path.Value; + } + + public void ExportPathWriter(string path) + { + //xmlDocument.Load($"{Path}\\Configuration.xml"); + //XmlNode root = xmlDocument.DocumentElement; + //XmlNode node = root.SelectSingleNode("ExportConfig"); + //node.Attributes["Path"].Value = path; + //xmlDocument.Save($"{Path}\\Configuration.xml"); + + // 参数验证 + if (string.IsNullOrWhiteSpace(path)) + { + throw new ArgumentNullException(nameof(path), "导出路径不能为空"); + } + + try + { + // 加载XML文档 + xmlDocument.Load($"{Path}\\Configuration.xml"); + + // 获取根节点 + XmlNode root = xmlDocument.DocumentElement ?? + throw new InvalidOperationException("XML文档没有根元素"); + + // 查找ExportConfig节点 + XmlNode node = root.SelectSingleNode("ExportConfig") ?? + throw new InvalidOperationException("找不到ExportConfig节点"); + + // 获取Path属性 + XmlAttribute pathAttribute = node.Attributes?["Path"] ?? + throw new InvalidOperationException("ExportConfig节点没有Path属性"); + + // 设置新值 + pathAttribute.Value = path; + + // 保存修改 + xmlDocument.Save($"{Path}\\Configuration.xml"); + } + catch (Exception ex) + { + // 记录日志或处理特定异常 + LogHelper.Instance.Error("保存导出路径配置失败", ex); + } + } } + public class RoleConfig { /// @@ -72,4 +132,11 @@ namespace HighWayIot.Winform.Business /// public int RoleIndex { get; set; } } + + public class ExportPathConfig + { + public string ExportConfig { get; set; } + + public string Config { get; set; } + } } diff --git a/HighWayIot.Winform/Configuration.xml b/HighWayIot.Winform/Configuration.xml index e846df0..4ffb70a 100644 --- a/HighWayIot.Winform/Configuration.xml +++ b/HighWayIot.Winform/Configuration.xml @@ -18,5 +18,6 @@ - + + diff --git a/HighWayIot.Winform/HighWayIot.Winform.csproj b/HighWayIot.Winform/HighWayIot.Winform.csproj index 91b386c..597cfbd 100644 --- a/HighWayIot.Winform/HighWayIot.Winform.csproj +++ b/HighWayIot.Winform/HighWayIot.Winform.csproj @@ -153,6 +153,7 @@ + @@ -175,6 +176,12 @@ ExportPreviewForm.cs + + Form + + + ScrollTextSetForm.cs + UserControl @@ -333,6 +340,9 @@ ExportPreviewForm.cs + + ScrollTextSetForm.cs + RFIDParamSettingPage.cs @@ -421,6 +431,10 @@ + + {DDEE27AA-0694-47A6-9335-E9308261F63A} + HighWayIot.Controls + {DEABC30C-EC6F-472E-BD67-D65702FDAF74} HighWayIot.Log4net @@ -467,7 +481,7 @@ - Always + PreserveNewest diff --git a/HighWayIot.Winform/MainForm/BaseForm.Designer.cs b/HighWayIot.Winform/MainForm/BaseForm.Designer.cs index 0c0eb67..526298e 100644 --- a/HighWayIot.Winform/MainForm/BaseForm.Designer.cs +++ b/HighWayIot.Winform/MainForm/BaseForm.Designer.cs @@ -64,9 +64,6 @@ namespace HighWayIot.Winform.MainForm this.SplitLabel2 = new System.Windows.Forms.ToolStripStatusLabel(); this.LogInformationToolStrip = new System.Windows.Forms.ToolStripStatusLabel(); this.SplitLabel3 = new System.Windows.Forms.ToolStripStatusLabel(); - this.Label2 = new System.Windows.Forms.ToolStripStatusLabel(); - this.MolderStateLabel = new System.Windows.Forms.ToolStripStatusLabel(); - this.SplitLabel4 = new System.Windows.Forms.ToolStripStatusLabel(); this.StripLabel2 = new System.Windows.Forms.ToolStripStatusLabel(); this.TimeStripLabel = new System.Windows.Forms.ToolStripStatusLabel(); this.TimeDisplayTimer = new System.Windows.Forms.Timer(this.components); @@ -270,7 +267,7 @@ namespace HighWayIot.Winform.MainForm this.UserControlTabs.SelectedIndex = 0; this.UserControlTabs.Size = new System.Drawing.Size(1905, 995); this.UserControlTabs.TabIndex = 3; - this.UserControlTabs.Selected += new TabControlEventHandler(this.TabControlChange); + this.UserControlTabs.Selected += new System.Windows.Forms.TabControlEventHandler(this.TabControlChange); // // ClosePageButton // @@ -297,9 +294,6 @@ namespace HighWayIot.Winform.MainForm this.SplitLabel2, this.LogInformationToolStrip, this.SplitLabel3, - this.Label2, - this.MolderStateLabel, - this.SplitLabel4, this.StripLabel2, this.TimeStripLabel}); this.statusStrip1.Location = new System.Drawing.Point(0, 1019); @@ -341,7 +335,7 @@ namespace HighWayIot.Winform.MainForm // LogInformationToolStrip // this.LogInformationToolStrip.Name = "LogInformationToolStrip"; - this.LogInformationToolStrip.Size = new System.Drawing.Size(1400, 17); + this.LogInformationToolStrip.Size = new System.Drawing.Size(1524, 17); this.LogInformationToolStrip.Spring = true; this.LogInformationToolStrip.Text = "message"; // @@ -351,24 +345,6 @@ namespace HighWayIot.Winform.MainForm this.SplitLabel3.Name = "SplitLabel3"; this.SplitLabel3.Size = new System.Drawing.Size(4, 17); // - // Label2 - // - this.Label2.Name = "Label2"; - this.Label2.Size = new System.Drawing.Size(89, 17); - this.Label2.Text = "成型PLC状态:"; - // - // MolderStateLabel - // - this.MolderStateLabel.Name = "MolderStateLabel"; - this.MolderStateLabel.Size = new System.Drawing.Size(31, 17); - this.MolderStateLabel.Text = "N/A"; - // - // SplitLabel4 - // - this.SplitLabel4.BorderSides = ((System.Windows.Forms.ToolStripStatusLabelBorderSides)((System.Windows.Forms.ToolStripStatusLabelBorderSides.Left | System.Windows.Forms.ToolStripStatusLabelBorderSides.Right))); - this.SplitLabel4.Name = "SplitLabel4"; - this.SplitLabel4.Size = new System.Drawing.Size(4, 17); - // // StripLabel2 // this.StripLabel2.Name = "StripLabel2"; @@ -479,9 +455,6 @@ namespace HighWayIot.Winform.MainForm private ToolStripMenuItem MaterialTypeConfigStripItem; private ToolStripStatusLabel SplitLabel2; private ToolStripStatusLabel SplitLabel3; - private ToolStripStatusLabel SplitLabel4; - private ToolStripStatusLabel Label2; - private ToolStripStatusLabel MolderStateLabel; private ToolStripMenuItem rToolStripMenuItem; private ToolStripMenuItem rFID参数配置ToolStripMenuItem; private ToolStripMenuItem 机台物料信息绑定ToolStripMenuItem1; diff --git a/HighWayIot.Winform/MainForm/BaseForm.cs b/HighWayIot.Winform/MainForm/BaseForm.cs index c24389b..363e9f6 100644 --- a/HighWayIot.Winform/MainForm/BaseForm.cs +++ b/HighWayIot.Winform/MainForm/BaseForm.cs @@ -52,6 +52,11 @@ namespace HighWayIot.Winform.MainForm /// MonitorDataRefreshBusiness monitorDataRefreshBusiness = new MonitorDataRefreshBusiness(); + /// + /// 定时报表导出 + /// + TimerExportBusiness timerExportBusiness = new TimerExportBusiness(); + /// /// 排程combobox刷新 /// @@ -82,11 +87,6 @@ namespace HighWayIot.Winform.MainForm /// public int LastMoldingMachineWatchDogNum = -1; - /// - /// 看门狗计时器 - /// - private System.Threading.Timer WatchDogTimer; - public BaseForm() { InitializeComponent(); @@ -104,7 +104,6 @@ namespace HighWayIot.Winform.MainForm UserPanelSwitch(typeof(MonitorMainPage), "监控主页面"); RoleControl(); SqlLogHelper.AddLog($"用户[{RoleBusiness.LoginUserName}]登录成功"); - WatchDogTimer = new System.Threading.Timer(WarchDogJudge, null, 0, 2000); // 每2秒执行一次 LogRefreshAction += (log) => { LogInformationToolStrip.Text = log; @@ -346,49 +345,6 @@ namespace HighWayIot.Winform.MainForm } } - /// - /// PLC看门狗状态判断 - /// - /// 看门狗点位 - /// - private void WarchDogJudge(object state) - { - //int openMixNow, moldingNow; - //if (PlcConnect.IsConnect1) - //{ - // openMixNow = PlcConnect.ReadInt161("D666"); - // if (openMixNow == LastOpenMixWatchDogNum) - // { - // OpenMixMachineWatchDog = 0; - // } - // else - // { - // OpenMixMachineWatchDog = 1; - // } - //} - //else - //{ - // OpenMixMachineWatchDog = 2; - //} - - //if (PlcConnect.IsConnect2) - //{ - // moldingNow = PlcConnect.ReadInt162("D666"); - // if (moldingNow == LastMoldingMachineWatchDogNum) - // { - // MoldingMachineWatchDog = 0; - // } - // else - // { - // MoldingMachineWatchDog = 1; - // } - //} - //else - //{ - // MoldingMachineWatchDog = 2; - //} - } - /// /// 配方下传方式转换 /// diff --git a/HighWayIot.Winform/UserControlPages/LogPages/AlarmLogPage.Designer.cs b/HighWayIot.Winform/UserControlPages/LogPages/AlarmLogPage.Designer.cs index 92f30a3..281f313 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/AlarmLogPage.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/LogPages/AlarmLogPage.Designer.cs @@ -32,6 +32,13 @@ namespace HighWayIot.Winform.UserControlPages private void InitializeComponent() { this.LogDataGridView = new System.Windows.Forms.DataGridView(); + this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Text = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.LogTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Operator = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.P1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.P2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.P3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.SelectErrorLog = new System.Windows.Forms.Button(); this.ButtonPanel = new System.Windows.Forms.Panel(); this.P3TextBox = new System.Windows.Forms.TextBox(); @@ -49,13 +56,7 @@ namespace HighWayIot.Winform.UserControlPages this.label2 = new System.Windows.Forms.Label(); this.LogTextTextBox = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); - this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Text = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.LogTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Operator = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.P1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.P2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.P3 = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.DeleteUselessData = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.LogDataGridView)).BeginInit(); this.ButtonPanel.SuspendLayout(); this.SuspendLayout(); @@ -85,6 +86,58 @@ namespace HighWayIot.Winform.UserControlPages this.LogDataGridView.Size = new System.Drawing.Size(1170, 816); this.LogDataGridView.TabIndex = 0; // + // Id + // + this.Id.DataPropertyName = "Id"; + this.Id.HeaderText = "ID"; + this.Id.Name = "Id"; + this.Id.ReadOnly = true; + this.Id.Width = 50; + // + // Text + // + this.Text.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.Text.DataPropertyName = "Text"; + this.Text.HeaderText = "日志内容"; + this.Text.Name = "Text"; + this.Text.ReadOnly = true; + // + // LogTime + // + this.LogTime.DataPropertyName = "LogTime"; + this.LogTime.HeaderText = "日志时间"; + this.LogTime.Name = "LogTime"; + this.LogTime.ReadOnly = true; + this.LogTime.Width = 150; + // + // Operator + // + this.Operator.DataPropertyName = "Operator"; + this.Operator.HeaderText = "操作者用户名"; + this.Operator.Name = "Operator"; + this.Operator.ReadOnly = true; + // + // P1 + // + this.P1.DataPropertyName = "P1"; + this.P1.HeaderText = "字段1"; + this.P1.Name = "P1"; + this.P1.ReadOnly = true; + // + // P2 + // + this.P2.DataPropertyName = "P2"; + this.P2.HeaderText = "字段2"; + this.P2.Name = "P2"; + this.P2.ReadOnly = true; + // + // P3 + // + this.P3.DataPropertyName = "P3"; + this.P3.HeaderText = "字段3"; + this.P3.Name = "P3"; + this.P3.ReadOnly = true; + // // SelectErrorLog // this.SelectErrorLog.Location = new System.Drawing.Point(11, 11); @@ -100,6 +153,7 @@ namespace HighWayIot.Winform.UserControlPages // this.ButtonPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.ButtonPanel.Controls.Add(this.DeleteUselessData); this.ButtonPanel.Controls.Add(this.P3TextBox); this.ButtonPanel.Controls.Add(this.label7); this.ButtonPanel.Controls.Add(this.P2TextBox); @@ -214,9 +268,9 @@ namespace HighWayIot.Winform.UserControlPages this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(295, 16); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(65, 12); + this.label3.Size = new System.Drawing.Size(41, 12); this.label3.TabIndex = 31; - this.label3.Text = "登陆时间:"; + this.label3.Text = "时间:"; // // OperatorNameTextBox // @@ -250,57 +304,17 @@ namespace HighWayIot.Winform.UserControlPages this.label1.TabIndex = 27; this.label1.Text = "日志内容"; // - // Id + // DeleteUselessData // - this.Id.DataPropertyName = "Id"; - this.Id.HeaderText = "ID"; - this.Id.Name = "Id"; - this.Id.ReadOnly = true; - this.Id.Width = 50; - // - // Text - // - this.Text.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.Text.DataPropertyName = "Text"; - this.Text.HeaderText = "日志内容"; - this.Text.Name = "Text"; - this.Text.ReadOnly = true; - // - // LogTime - // - this.LogTime.DataPropertyName = "LogTime"; - this.LogTime.HeaderText = "日志时间"; - this.LogTime.Name = "LogTime"; - this.LogTime.ReadOnly = true; - this.LogTime.Width = 150; - // - // Operator - // - this.Operator.DataPropertyName = "Operator"; - this.Operator.HeaderText = "操作者用户名"; - this.Operator.Name = "Operator"; - this.Operator.ReadOnly = true; - // - // P1 - // - this.P1.DataPropertyName = "P1"; - this.P1.HeaderText = "字段1"; - this.P1.Name = "P1"; - this.P1.ReadOnly = true; - // - // P2 - // - this.P2.DataPropertyName = "P2"; - this.P2.HeaderText = "字段2"; - this.P2.Name = "P2"; - this.P2.ReadOnly = true; - // - // P3 - // - this.P3.DataPropertyName = "P3"; - this.P3.HeaderText = "字段3"; - this.P3.Name = "P3"; - this.P3.ReadOnly = true; + this.DeleteUselessData.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.DeleteUselessData.Location = new System.Drawing.Point(1072, 13); + this.DeleteUselessData.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.DeleteUselessData.Name = "DeleteUselessData"; + this.DeleteUselessData.Size = new System.Drawing.Size(82, 39); + this.DeleteUselessData.TabIndex = 42; + this.DeleteUselessData.Text = "删除一个月之前的数据"; + this.DeleteUselessData.UseVisualStyleBackColor = true; + this.DeleteUselessData.Click += new System.EventHandler(this.DeleteUselessData_Click); // // AlarmConfigPage // @@ -347,5 +361,6 @@ namespace HighWayIot.Winform.UserControlPages private DataGridViewTextBoxColumn P1; private DataGridViewTextBoxColumn P2; private DataGridViewTextBoxColumn P3; + private Button DeleteUselessData; } } diff --git a/HighWayIot.Winform/UserControlPages/LogPages/AlarmLogPage.cs b/HighWayIot.Winform/UserControlPages/LogPages/AlarmLogPage.cs index c0c7f28..0815fc8 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/AlarmLogPage.cs +++ b/HighWayIot.Winform/UserControlPages/LogPages/AlarmLogPage.cs @@ -61,5 +61,13 @@ namespace HighWayIot.Winform.UserControlPages LogDataGridView.DataSource = null; LogDataGridView.DataSource = Lists; } + + private void DeleteUselessData_Click(object sender, EventArgs e) + { + if (sysErrorLogService.DeleteMoreData()) + { + MessageBox.Show("删除成功"); + } + } } } diff --git a/HighWayIot.Winform/UserControlPages/LogPages/AlarmLogPage.resx b/HighWayIot.Winform/UserControlPages/LogPages/AlarmLogPage.resx index e86d420..dbbe9df 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/AlarmLogPage.resx +++ b/HighWayIot.Winform/UserControlPages/LogPages/AlarmLogPage.resx @@ -138,4 +138,25 @@ True + + True + + + True + + + True + + + True + + + True + + + True + + + True + \ No newline at end of file diff --git a/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.Designer.cs b/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.Designer.cs index 4ae5582..0773d20 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.Designer.cs @@ -40,11 +40,13 @@ namespace HighWayIot.Winform.UserControlPages this.RecipeName = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.SpecCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.DeviceNo = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.RawTireWeight = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.StandardWeight = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.BaseRubTimeSpan = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.MidRubTimeSpan = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.FaceRubTimeSpan = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.RawTireWeight = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.RepeatWeight = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.IsDone = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ButtonPanel = new System.Windows.Forms.Panel(); this.DataCountLabel = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); @@ -60,6 +62,7 @@ namespace HighWayIot.Winform.UserControlPages this.label3 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.SelectReport = new System.Windows.Forms.Button(); + this.DeleteUselessData = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.ReportDataGridView)).BeginInit(); this.ButtonPanel.SuspendLayout(); this.SuspendLayout(); @@ -88,11 +91,13 @@ namespace HighWayIot.Winform.UserControlPages this.RecipeName, this.SpecCode, this.DeviceNo, - this.RawTireWeight, + this.StandardWeight, this.BaseRubTimeSpan, this.MidRubTimeSpan, this.FaceRubTimeSpan, - this.RepeatWeight}); + this.RawTireWeight, + this.RepeatWeight, + this.IsDone}); this.ReportDataGridView.Location = new System.Drawing.Point(-3, 65); this.ReportDataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.ReportDataGridView.Name = "ReportDataGridView"; @@ -161,13 +166,12 @@ namespace HighWayIot.Winform.UserControlPages this.DeviceNo.ReadOnly = true; this.DeviceNo.Width = 80; // - // RawTireWeight + // StandardWeight // - this.RawTireWeight.DataPropertyName = "RawTireWeight"; - this.RawTireWeight.HeaderText = "生胎重量"; - this.RawTireWeight.Name = "RawTireWeight"; - this.RawTireWeight.ReadOnly = true; - this.RawTireWeight.Width = 80; + this.StandardWeight.DataPropertyName = "StandardWeight"; + this.StandardWeight.HeaderText = "标准重量"; + this.StandardWeight.Name = "StandardWeight"; + this.StandardWeight.ReadOnly = true; // // BaseRubTimeSpan // @@ -193,6 +197,14 @@ namespace HighWayIot.Winform.UserControlPages this.FaceRubTimeSpan.ReadOnly = true; this.FaceRubTimeSpan.Width = 140; // + // RawTireWeight + // + this.RawTireWeight.DataPropertyName = "RawTireWeight"; + this.RawTireWeight.HeaderText = "生胎重量"; + this.RawTireWeight.Name = "RawTireWeight"; + this.RawTireWeight.ReadOnly = true; + this.RawTireWeight.Width = 80; + // // RepeatWeight // this.RepeatWeight.DataPropertyName = "RepeatWeight"; @@ -201,10 +213,19 @@ namespace HighWayIot.Winform.UserControlPages this.RepeatWeight.ReadOnly = true; this.RepeatWeight.Width = 80; // + // IsDone + // + this.IsDone.DataPropertyName = "IsDone"; + this.IsDone.HeaderText = "状态"; + this.IsDone.Name = "IsDone"; + this.IsDone.ReadOnly = true; + this.IsDone.Width = 50; + // // ButtonPanel // this.ButtonPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.ButtonPanel.Controls.Add(this.DeleteUselessData); this.ButtonPanel.Controls.Add(this.DataCountLabel); this.ButtonPanel.Controls.Add(this.label5); this.ButtonPanel.Controls.Add(this.ExportTableButton); @@ -224,7 +245,6 @@ namespace HighWayIot.Winform.UserControlPages this.ButtonPanel.Name = "ButtonPanel"; this.ButtonPanel.Size = new System.Drawing.Size(1636, 61); this.ButtonPanel.TabIndex = 6; - this.ButtonPanel.Paint += new System.Windows.Forms.PaintEventHandler(this.ButtonPanel_Paint); // // DataCountLabel // @@ -355,6 +375,18 @@ namespace HighWayIot.Winform.UserControlPages this.SelectReport.UseVisualStyleBackColor = true; this.SelectReport.Click += new System.EventHandler(this.SelectReport_Click); // + // DeleteUselessData + // + this.DeleteUselessData.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.DeleteUselessData.Location = new System.Drawing.Point(1537, 13); + this.DeleteUselessData.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.DeleteUselessData.Name = "DeleteUselessData"; + this.DeleteUselessData.Size = new System.Drawing.Size(82, 39); + this.DeleteUselessData.TabIndex = 30; + this.DeleteUselessData.Text = "删除一个月之前的数据"; + this.DeleteUselessData.UseVisualStyleBackColor = true; + this.DeleteUselessData.Click += new System.EventHandler(this.DeleteUselessData_Click); + // // DailyReportPage // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -397,10 +429,13 @@ namespace HighWayIot.Winform.UserControlPages private DataGridViewTextBoxColumn RecipeName; private DataGridViewTextBoxColumn SpecCode; private DataGridViewTextBoxColumn DeviceNo; - private DataGridViewTextBoxColumn RawTireWeight; + private DataGridViewTextBoxColumn StandardWeight; private DataGridViewTextBoxColumn BaseRubTimeSpan; private DataGridViewTextBoxColumn MidRubTimeSpan; private DataGridViewTextBoxColumn FaceRubTimeSpan; + private DataGridViewTextBoxColumn RawTireWeight; private DataGridViewTextBoxColumn RepeatWeight; + private DataGridViewTextBoxColumn IsDone; + private Button DeleteUselessData; } } diff --git a/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.cs b/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.cs index 13b8703..3b218fa 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.cs +++ b/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.cs @@ -44,28 +44,6 @@ namespace HighWayIot.Winform.UserControlPages { ReportDataGridView.AutoGenerateColumns = false; - List recipeCodes = new List() - { - "" - }; - recipeCodes.AddRange(ZxRecipeService.Instance.GetRecipeInfos().Select(x => x.RecipeCode).ToList()); - - List workStationNos = new List() - { - "" - }; - workStationNos.AddRange(ZxReaderSettingService.Instance.GetReaderInfos().Select(x => x.WorkstationNo).ToList()); - - List deviceNos = new List() - { - "" - }; - deviceNos.AddRange(ZxTagSettingService.Instance.GetTagInfos().Select(x => x.DeviceNo).ToList()); - - RecipeCodeCombobox.DataSource = recipeCodes; - VulcanizationNoCombobox.DataSource = workStationNos; - DeviceNoCombobox.DataSource = deviceNos; - SelectStartTime.Value = DateTime.Now.AddDays(-1); SelectEndTime.Value = DateTime.Now; @@ -88,8 +66,9 @@ namespace HighWayIot.Winform.UserControlPages && x.StartTime <= SelectEndTime.Value && (string.IsNullOrEmpty(RecipeCodeCombobox.Text) || x.RecipeCode == RecipeCodeCombobox.Text) && (string.IsNullOrEmpty(VulcanizationNoCombobox.Text) || x.VulcanizationNo == VulcanizationNoCombobox.Text) - && (string.IsNullOrEmpty(DeviceNoCombobox.Text) || x.DeviceNo.ToString() == DeviceNoCombobox.Text) - && x.IsDone == 1); + && (string.IsNullOrEmpty(DeviceNoCombobox.Text) || x.DeviceNo.ToString() == DeviceNoCombobox.Text)) + .OrderByDescending(x => x.StartTime) + .ToList(); _monitorDataSources.Clear(); @@ -104,25 +83,39 @@ namespace HighWayIot.Winform.UserControlPages RecipeCode = dailyEntities[i].RecipeCode, SpecCode = dailyEntities[i].SpecCode, DeviceNo = dailyEntities[i].DeviceNo.ToString(), + StandardWeight = dailyEntities[i].StandardWeight ?? 0, RawTireWeight = dailyEntities[i].RawTireWeight ?? 0, BaseRubTimeSpan = GeneralUtils.DateTimeToString(dailyEntities[i].StartTime, dailyEntities[i].BaseEndTime), MidRubTimeSpan = GeneralUtils.DateTimeToString(dailyEntities[i].StartTime, dailyEntities[i].MidEndTime), FaceRubTimeSpan = GeneralUtils.DateTimeToString(dailyEntities[i].StartTime, dailyEntities[i].FaceEndTime), + IsDone = dailyEntities[i].IsDone == 1 ? "已完成" : "未完成" }); } List ds1 = new List() { "" }; - ds1.AddRange(_monitorDataSources.Select(x => x.VulcanizationNo).ToList()); + ds1.AddRange(_monitorDataSources + .Select(x => x.VulcanizationNo) + .Distinct() + .OrderBy(x => x) + .ToList()); VulcanizationNoCombobox.DataSource = ds1; VulcanizationNoCombobox.SelectedIndex = 0; List ds2 = new List() { "" }; - ds2.AddRange(_monitorDataSources.Select(x => x.DeviceNo).ToList()); + ds2.AddRange(_monitorDataSources + .Select(x => x.DeviceNo) + .Distinct() + .OrderBy(x => x) + .ToList()); DeviceNoCombobox.DataSource = ds2; DeviceNoCombobox.SelectedIndex = 0; List ds3 = new List() { "" }; - ds3.AddRange(_monitorDataSources.Select(x => x.RecipeCode).ToList()); + ds3.AddRange(_monitorDataSources + .Select(x => x.RecipeCode) + .Distinct() + .OrderBy(x => x) + .ToList()); RecipeCodeCombobox.DataSource = ds3; RecipeCodeCombobox.SelectedIndex = 0; @@ -143,9 +136,17 @@ namespace HighWayIot.Winform.UserControlPages } } - private void ButtonPanel_Paint(object sender, PaintEventArgs e) + /// + /// 删除多余数据 + /// + /// + /// + private void DeleteUselessData_Click(object sender, EventArgs e) { - + if (_zxDailyReportService.DeleteMoreData()) + { + MessageBox.Show("删除成功"); + } } } } diff --git a/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.resx b/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.resx index a8f53f4..d4e125c 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.resx +++ b/HighWayIot.Winform/UserControlPages/LogPages/DailyReportPage.resx @@ -138,7 +138,7 @@ True - + True @@ -150,7 +150,13 @@ True + + True + True + + True + \ No newline at end of file diff --git a/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.Designer.cs b/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.Designer.cs index f2cdf79..e3f8994 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.Designer.cs @@ -30,6 +30,10 @@ { System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); + this.ExportButton = new System.Windows.Forms.Button(); + this.PathTextBox = new System.Windows.Forms.TextBox(); + this.PathSelectButton = new System.Windows.Forms.Button(); + this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); this.RecipeCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.RecipeName = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.SpecCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); @@ -50,13 +54,11 @@ this.FaceRubWidth = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.FaceRubLayer = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.RawTireWidth = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.RawTireFinishTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.FaceRubFinishTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.StandardWeight = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.RawTireWeight = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.RepeatWeight = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.ExportButton = new System.Windows.Forms.Button(); - this.PathTextBox = new System.Windows.Forms.TextBox(); - this.PathSelectButton = new System.Windows.Forms.Button(); - this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); + this.IsDone = new System.Windows.Forms.DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.SuspendLayout(); // @@ -96,9 +98,11 @@ this.FaceRubWidth, this.FaceRubLayer, this.RawTireWidth, - this.RawTireFinishTime, + this.FaceRubFinishTime, + this.StandardWeight, this.RawTireWeight, - this.RepeatWeight}); + this.RepeatWeight, + this.IsDone}); this.dataGridView1.Cursor = System.Windows.Forms.Cursors.IBeam; this.dataGridView1.EnableHeadersVisualStyles = false; this.dataGridView1.Location = new System.Drawing.Point(0, 50); @@ -108,6 +112,34 @@ this.dataGridView1.Size = new System.Drawing.Size(1904, 991); this.dataGridView1.TabIndex = 0; // + // ExportButton + // + this.ExportButton.Location = new System.Drawing.Point(9, 9); + this.ExportButton.Margin = new System.Windows.Forms.Padding(0); + this.ExportButton.Name = "ExportButton"; + this.ExportButton.Size = new System.Drawing.Size(90, 38); + this.ExportButton.TabIndex = 1; + this.ExportButton.Text = "导出为EXCEL"; + this.ExportButton.UseVisualStyleBackColor = true; + this.ExportButton.Click += new System.EventHandler(this.ExportButton_Click); + // + // PathTextBox + // + this.PathTextBox.Location = new System.Drawing.Point(102, 19); + this.PathTextBox.Name = "PathTextBox"; + this.PathTextBox.Size = new System.Drawing.Size(364, 21); + this.PathTextBox.TabIndex = 2; + // + // PathSelectButton + // + this.PathSelectButton.Location = new System.Drawing.Point(472, 18); + this.PathSelectButton.Name = "PathSelectButton"; + this.PathSelectButton.Size = new System.Drawing.Size(86, 23); + this.PathSelectButton.TabIndex = 3; + this.PathSelectButton.Text = "路径选择"; + this.PathSelectButton.UseVisualStyleBackColor = true; + this.PathSelectButton.Click += new System.EventHandler(this.PathSelectButton_Click); + // // RecipeCode // this.RecipeCode.DataPropertyName = "RecipeCode"; @@ -270,7 +302,7 @@ // FaceRubLayer // this.FaceRubLayer.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; - this.FaceRubLayer.DataPropertyName = "(无)FaceRubLayer"; + this.FaceRubLayer.DataPropertyName = "FaceRubLayer"; this.FaceRubLayer.FillWeight = 88.53656F; this.FaceRubLayer.HeaderText = "胎面胶层数"; this.FaceRubLayer.Name = "FaceRubLayer"; @@ -285,14 +317,21 @@ this.RawTireWidth.Name = "RawTireWidth"; this.RawTireWidth.Width = 59; // - // RawTireFinishTime + // FaceRubFinishTime // - this.RawTireFinishTime.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; - this.RawTireFinishTime.DataPropertyName = "RawTireFinishTime"; - this.RawTireFinishTime.FillWeight = 88.53656F; - this.RawTireFinishTime.HeaderText = "生胎完成时间"; - this.RawTireFinishTime.Name = "RawTireFinishTime"; - this.RawTireFinishTime.Width = 83; + this.FaceRubFinishTime.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None; + this.FaceRubFinishTime.DataPropertyName = "FaceRubFinishTime"; + this.FaceRubFinishTime.FillWeight = 88.53656F; + this.FaceRubFinishTime.HeaderText = "生胎完成时间"; + this.FaceRubFinishTime.Name = "FaceRubFinishTime"; + this.FaceRubFinishTime.Width = 83; + // + // StandardWeight + // + this.StandardWeight.DataPropertyName = "StandardWeight"; + this.StandardWeight.HeaderText = "标准重量"; + this.StandardWeight.Name = "StandardWeight"; + this.StandardWeight.Width = 59; // // RawTireWeight // @@ -312,33 +351,12 @@ this.RepeatWeight.Name = "RepeatWeight"; this.RepeatWeight.Width = 59; // - // ExportButton + // IsDone // - this.ExportButton.Location = new System.Drawing.Point(9, 9); - this.ExportButton.Margin = new System.Windows.Forms.Padding(0); - this.ExportButton.Name = "ExportButton"; - this.ExportButton.Size = new System.Drawing.Size(90, 38); - this.ExportButton.TabIndex = 1; - this.ExportButton.Text = "导出为EXCEL"; - this.ExportButton.UseVisualStyleBackColor = true; - this.ExportButton.Click += new System.EventHandler(this.ExportButton_Click); - // - // PathTextBox - // - this.PathTextBox.Location = new System.Drawing.Point(102, 19); - this.PathTextBox.Name = "PathTextBox"; - this.PathTextBox.Size = new System.Drawing.Size(364, 21); - this.PathTextBox.TabIndex = 2; - // - // PathSelectButton - // - this.PathSelectButton.Location = new System.Drawing.Point(472, 18); - this.PathSelectButton.Name = "PathSelectButton"; - this.PathSelectButton.Size = new System.Drawing.Size(86, 23); - this.PathSelectButton.TabIndex = 3; - this.PathSelectButton.Text = "路径选择"; - this.PathSelectButton.UseVisualStyleBackColor = true; - this.PathSelectButton.Click += new System.EventHandler(this.PathSelectButton_Click); + this.IsDone.DataPropertyName = "IsDone"; + this.IsDone.HeaderText = "状态"; + this.IsDone.Name = "IsDone"; + this.IsDone.Width = 50; // // ExportPreviewForm // @@ -386,8 +404,10 @@ private System.Windows.Forms.DataGridViewTextBoxColumn FaceRubWidth; private System.Windows.Forms.DataGridViewTextBoxColumn FaceRubLayer; private System.Windows.Forms.DataGridViewTextBoxColumn RawTireWidth; - private System.Windows.Forms.DataGridViewTextBoxColumn RawTireFinishTime; + private System.Windows.Forms.DataGridViewTextBoxColumn FaceRubFinishTime; + private System.Windows.Forms.DataGridViewTextBoxColumn StandardWeight; private System.Windows.Forms.DataGridViewTextBoxColumn RawTireWeight; private System.Windows.Forms.DataGridViewTextBoxColumn RepeatWeight; + private System.Windows.Forms.DataGridViewTextBoxColumn IsDone; } } \ No newline at end of file diff --git a/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.cs b/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.cs index 85c7c06..71cd6a6 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.cs +++ b/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.cs @@ -50,6 +50,7 @@ namespace HighWayIot.Winform.UserControlPages.LogPages private void Init() { dataGridView1.AutoGenerateColumns = false; + PathTextBox.Text = XmlUtil.Instance.ExportPathReader(); //查询所有称重信息 _zxWeightEntities = _zxWeightService.GetWeightInfos(); @@ -58,7 +59,7 @@ namespace HighWayIot.Winform.UserControlPages.LogPages _zxRecipeEntities = _zxRecipeService.GetRecipeInfos(); //开始关联 生成报表 - foreach(ZxDailyReportEntity rawEntity in _zxDailyReportEntities) + foreach (ZxDailyReportEntity rawEntity in _zxDailyReportEntities) { ExportTableEntity exportTableEntity = new ExportTableEntity(); ZxRecipeEntity recipeEntity = _zxRecipeEntities.Where(x => x.RecipeCode == rawEntity.RecipeCode).FirstOrDefault(); @@ -86,10 +87,15 @@ namespace HighWayIot.Winform.UserControlPages.LogPages exportTableEntity.BaseRubWidth = baseWeight.SetWidth.ToString(); exportTableEntity.BaseRubLayer = baseWeight.SetLayer.ToString(); } + else if(baseWeight.SetLayer3 == 0 || baseWeight.SetLayer3 == null) + { + exportTableEntity.BaseRubWidth = $"{baseWeight.SetWidth2}/{baseWeight.SetWidth}"; + exportTableEntity.BaseRubLayer = $"{baseWeight.SetLayer2}/{baseWeight.SetLayer}"; + } else { - exportTableEntity.BaseRubWidth = $"{baseWeight.SetWidth}/{baseWeight.SetWidth2}"; - exportTableEntity.BaseRubLayer = $"{baseWeight.SetLayer}/{baseWeight.SetLayer2}"; + exportTableEntity.BaseRubWidth = $"{baseWeight.SetWidth2}/{baseWeight.SetWidth3}/{baseWeight.SetWidth}"; + exportTableEntity.BaseRubLayer = $"{baseWeight.SetLayer2}/{baseWeight.SetLayer3}/{baseWeight.SetLayer}"; } exportTableEntity.BaseRubFinishTime = GeneralUtils.DateTimeToString(rawEntity.StartTime, rawEntity.BaseEndTime); } @@ -99,8 +105,22 @@ namespace HighWayIot.Winform.UserControlPages.LogPages { exportTableEntity.MidRubName = midWeight.MaterialName; exportTableEntity.MidRubThickness = midWeight.SetThickness.ToString(); - exportTableEntity.MidRubWidth = midWeight.SetWidth.ToString(); - exportTableEntity.MidRubLayer = midWeight.SetLayer.ToString(); + //中层胶宽度和层数(可能有三层 + if (midWeight.SetLayer2 == 0 || midWeight.SetLayer2 == null) + { + exportTableEntity.MidRubWidth = midWeight.SetWidth.ToString(); + exportTableEntity.MidRubLayer = midWeight.SetLayer.ToString(); + } + else if (midWeight.SetLayer3 == 0 || midWeight.SetLayer3 == null) + { + exportTableEntity.MidRubWidth = $"{midWeight.SetWidth2}/{midWeight.SetWidth}"; + exportTableEntity.MidRubLayer = $"{midWeight.SetLayer2}/{midWeight.SetLayer}"; + } + else + { + exportTableEntity.MidRubWidth = $"{midWeight.SetWidth2}/{midWeight.SetWidth3}/{midWeight.SetWidth}"; + exportTableEntity.MidRubLayer = $"{midWeight.SetLayer2}/{midWeight.SetLayer3}/{midWeight.SetLayer}"; + } exportTableEntity.MidRubFinishTime = GeneralUtils.DateTimeToString(rawEntity.StartTime, rawEntity.MidEndTime); } @@ -109,31 +129,34 @@ namespace HighWayIot.Winform.UserControlPages.LogPages { exportTableEntity.FaceRubName = faceWeight.MaterialName; exportTableEntity.FaceRubThickness = faceWeight.SetThickness.ToString(); - //胎面胶宽度和层数(可能有两层 + //胎面胶宽度和层数(可能有三层 if (faceWeight.SetLayer2 == 0 || faceWeight.SetLayer2 == null) { exportTableEntity.FaceRubWidth = faceWeight.SetWidth.ToString(); exportTableEntity.FaceRubLayer = faceWeight.SetLayer.ToString(); } + else if (faceWeight.SetLayer3 == 0 || faceWeight.SetLayer3 == null) + { + exportTableEntity.FaceRubWidth = $"{faceWeight.SetWidth2}/{faceWeight.SetWidth}"; + exportTableEntity.FaceRubLayer = $"{faceWeight.SetLayer2}/{faceWeight.SetLayer}"; + } else { - exportTableEntity.FaceRubWidth = $"{faceWeight.SetWidth}/{faceWeight.SetWidth2}"; - exportTableEntity.FaceRubLayer = $"{faceWeight.SetLayer}/{faceWeight.SetLayer2}"; + exportTableEntity.FaceRubWidth = $"{faceWeight.SetWidth2}/{faceWeight.SetWidth3}/{faceWeight.SetWidth}"; + exportTableEntity.FaceRubLayer = $"{faceWeight.SetLayer2}/{faceWeight.SetLayer3}/{faceWeight.SetLayer}"; } exportTableEntity.FaceRubFinishTime = GeneralUtils.DateTimeToString(rawEntity.StartTime, rawEntity.FaceEndTime); } exportTableEntity.RawTireWidth = (faceWeight.SetThickness * 2 + faceWeight.SetWidth).ToString(); - exportTableEntity.RawTireWeight = rawEntity.RawTireWeight.ToString(); - exportTableEntity.RepeatWeight = rawEntity.RepeatWeight.ToString(); - + exportTableEntity.StandardWeight = rawEntity.StandardWeight.ToString(); + exportTableEntity.RawTireWeight = (rawEntity.RawTireWeight ?? 0).ToString(); + exportTableEntity.RepeatWeight = (rawEntity.RepeatWeight ?? 0).ToString(); + exportTableEntity.IsDone = rawEntity.IsDone == 1 ? "已完成" : "未完成"; _exportTableEntities.Add(exportTableEntity); } - dataGridView1.DataSource = null; - dataGridView1.DataSource = _exportTableEntities; - try { dataTable = ToDataTable(_exportTableEntities.ToArray()); @@ -142,6 +165,9 @@ namespace HighWayIot.Winform.UserControlPages.LogPages { MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Information); } + + dataGridView1.DataSource = null; + dataGridView1.DataSource = _exportTableEntities; } /// @@ -156,7 +182,8 @@ namespace HighWayIot.Winform.UserControlPages.LogPages if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { _savePath = folderBrowserDialog1.SelectedPath; - PathTextBox.Text = _savePath; + PathTextBox.Text = _savePath; + XmlUtil.Instance.ExportPathWriter(_savePath); } } @@ -168,6 +195,7 @@ namespace HighWayIot.Winform.UserControlPages.LogPages return; } ExportExcel(dataTable, _savePath); + ZxDailyReportService.Instance.DeleteMoreData(); this.Close(); } @@ -313,5 +341,5 @@ namespace HighWayIot.Winform.UserControlPages.LogPages { } - } + } } diff --git a/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.resx b/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.resx index 43fdad8..b89b8ec 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.resx +++ b/HighWayIot.Winform/UserControlPages/LogPages/ExportPreviewForm.resx @@ -177,7 +177,10 @@ True - + + True + + True @@ -186,6 +189,9 @@ True + + True + 17, 17 diff --git a/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.Designer.cs b/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.Designer.cs index 900f34a..4cfd366 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.Designer.cs @@ -47,6 +47,7 @@ namespace HighWayIot.Winform.UserControlPages this.Text = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.LogTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Operator = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.DeleteUselessData = new System.Windows.Forms.Button(); this.ButtonPanel.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.LogDataGridView)).BeginInit(); this.SuspendLayout(); @@ -66,6 +67,7 @@ namespace HighWayIot.Winform.UserControlPages // this.ButtonPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + this.ButtonPanel.Controls.Add(this.DeleteUselessData); this.ButtonPanel.Controls.Add(this.label4); this.ButtonPanel.Controls.Add(this.SelectLogEndTime); this.ButtonPanel.Controls.Add(this.SelectLogBeginTime); @@ -125,9 +127,9 @@ namespace HighWayIot.Winform.UserControlPages this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(295, 16); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(65, 12); + this.label3.Size = new System.Drawing.Size(41, 12); this.label3.TabIndex = 14; - this.label3.Text = "登陆时间:"; + this.label3.Text = "时间:"; // // OperatorNameTextBox // @@ -214,6 +216,18 @@ namespace HighWayIot.Winform.UserControlPages this.Operator.Name = "Operator"; this.Operator.ReadOnly = true; // + // DeleteUselessData + // + this.DeleteUselessData.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.DeleteUselessData.Location = new System.Drawing.Point(1061, 11); + this.DeleteUselessData.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.DeleteUselessData.Name = "DeleteUselessData"; + this.DeleteUselessData.Size = new System.Drawing.Size(82, 39); + this.DeleteUselessData.TabIndex = 31; + this.DeleteUselessData.Text = "删除一个月之前的数据"; + this.DeleteUselessData.UseVisualStyleBackColor = true; + this.DeleteUselessData.Click += new System.EventHandler(this.DeleteUselessData_Click); + // // OperateConfigPage // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -248,5 +262,6 @@ namespace HighWayIot.Winform.UserControlPages private DataGridViewTextBoxColumn Text; private DataGridViewTextBoxColumn LogTime; private DataGridViewTextBoxColumn Operator; + private Button DeleteUselessData; } } diff --git a/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.cs b/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.cs index f3cb14f..960db78 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.cs +++ b/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.cs @@ -53,5 +53,13 @@ namespace HighWayIot.Winform.UserControlPages LogDataGridView.DataSource = null; LogDataGridView.DataSource = Lists; } + + private void DeleteUselessData_Click(object sender, EventArgs e) + { + if (sysLogService.DeleteMoreData()) + { + MessageBox.Show("删除成功"); + } + } } } diff --git a/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.resx b/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.resx index 0aace97..219dbe0 100644 --- a/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.resx +++ b/HighWayIot.Winform/UserControlPages/LogPages/OperateConfigPage.resx @@ -129,4 +129,16 @@ True + + True + + + True + + + True + + + True + \ No newline at end of file diff --git a/HighWayIot.Winform/UserControlPages/MonitorMainPages/MonitorMainPage.Designer.cs b/HighWayIot.Winform/UserControlPages/MonitorMainPages/MonitorMainPage.Designer.cs index 5c31af5..fd2c1dd 100644 --- a/HighWayIot.Winform/UserControlPages/MonitorMainPages/MonitorMainPage.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/MonitorMainPages/MonitorMainPage.Designer.cs @@ -46,35 +46,13 @@ namespace HighWayIot.Winform.UserControlPages System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle13 = new System.Windows.Forms.DataGridViewCellStyle(); System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle14 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle15 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.RgvNoLabel = new System.Windows.Forms.Label(); - this.label10 = new System.Windows.Forms.Label(); - this.RawTireWeightLabel = new System.Windows.Forms.Label(); - this.label7 = new System.Windows.Forms.Label(); - this.panel2 = new System.Windows.Forms.Panel(); - this.SpecCodeLabel = new System.Windows.Forms.Label(); - this.RecipeNameLabel = new System.Windows.Forms.Label(); - this.RecipeCodeLabel = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.MonitorDataGridView = new System.Windows.Forms.DataGridView(); - this.No = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.VulcanizationNo = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.StartTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.RecipeCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.RecipeName = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.SpecCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.DeviceNo = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.TireWeight = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.BaseRubFinishTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.MidRubFinishTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.RowTireFinishTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.RepeatWeight = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.IsDone = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.DataRefresh = new System.Windows.Forms.Timer(this.components); this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel(); + this.panel5 = new System.Windows.Forms.Panel(); + this.NowDateProductNumTextBox = new System.Windows.Forms.TextBox(); + this.NowDateProductNumLabel = new System.Windows.Forms.Label(); this.panel4 = new System.Windows.Forms.Panel(); this.NightProductNumTextBox = new System.Windows.Forms.TextBox(); this.DayProductNumTextBox = new System.Windows.Forms.TextBox(); @@ -82,19 +60,46 @@ namespace HighWayIot.Winform.UserControlPages this.label13 = new System.Windows.Forms.Label(); this.DayTimeLabel = new System.Windows.Forms.Label(); this.label12 = new System.Windows.Forms.Label(); - this.panel5 = new System.Windows.Forms.Panel(); - this.NowDateProductNumTextBox = new System.Windows.Forms.TextBox(); - this.NowDateProductNumLabel = new System.Windows.Forms.Label(); + this.panel2 = new System.Windows.Forms.Panel(); + this.RgvNoLabel = new System.Windows.Forms.Label(); + this.SpecCodeLabel = new System.Windows.Forms.Label(); + this.label10 = new System.Windows.Forms.Label(); + this.RecipeNameLabel = new System.Windows.Forms.Label(); + this.RawTireWeightLabel = new System.Windows.Forms.Label(); + this.RecipeCodeLabel = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.MonitorDataGridView = new System.Windows.Forms.DataGridView(); + this.DataRefresh = new System.Windows.Forms.Timer(this.components); this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); + this.panel6 = new System.Windows.Forms.Panel(); this.panel3 = new System.Windows.Forms.Panel(); + this.No = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.VulcanizationNo = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.StartTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.RecipeCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.RecipeName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.SpecCode = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.DeviceNo = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.StandardWeight = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.BaseRubFinishTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.MidRubFinishTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.RowTireFinishTime = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.TireWeight = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.RepeatWeight = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.IsDone = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.MoveText = new Mesnac.Controls.ChemicalWeighing.HslMoveText(); this.panel1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); + this.tableLayoutPanel3.SuspendLayout(); + this.panel5.SuspendLayout(); + this.panel4.SuspendLayout(); this.panel2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.MonitorDataGridView)).BeginInit(); - this.tableLayoutPanel3.SuspendLayout(); - this.panel4.SuspendLayout(); - this.panel5.SuspendLayout(); this.tableLayoutPanel2.SuspendLayout(); + this.panel6.SuspendLayout(); this.panel3.SuspendLayout(); this.SuspendLayout(); // @@ -120,316 +125,10 @@ namespace HighWayIot.Winform.UserControlPages this.tableLayoutPanel1.Name = "tableLayoutPanel1"; this.tableLayoutPanel1.RowCount = 1; this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 231F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 114F)); this.tableLayoutPanel1.Size = new System.Drawing.Size(2169, 114); this.tableLayoutPanel1.TabIndex = 0; // - // RgvNoLabel - // - this.RgvNoLabel.AutoSize = true; - this.RgvNoLabel.Font = new System.Drawing.Font("微软雅黑", 18F); - this.RgvNoLabel.ForeColor = System.Drawing.Color.Khaki; - this.RgvNoLabel.Location = new System.Drawing.Point(110, 14); - this.RgvNoLabel.Name = "RgvNoLabel"; - this.RgvNoLabel.Size = new System.Drawing.Size(61, 31); - this.RgvNoLabel.TabIndex = 11; - this.RgvNoLabel.Text = "N/A"; - // - // label10 - // - this.label10.AutoSize = true; - this.label10.Font = new System.Drawing.Font("微软雅黑", 18F); - this.label10.ForeColor = System.Drawing.Color.Khaki; - this.label10.Location = new System.Drawing.Point(16, 14); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(110, 31); - this.label10.TabIndex = 10; - this.label10.Text = "小车号:"; - // - // RawTireWeightLabel - // - this.RawTireWeightLabel.AutoSize = true; - this.RawTireWeightLabel.Font = new System.Drawing.Font("微软雅黑", 18F); - this.RawTireWeightLabel.ForeColor = System.Drawing.Color.Khaki; - this.RawTireWeightLabel.Location = new System.Drawing.Point(741, 49); - this.RawTireWeightLabel.Name = "RawTireWeightLabel"; - this.RawTireWeightLabel.Size = new System.Drawing.Size(61, 31); - this.RawTireWeightLabel.TabIndex = 9; - this.RawTireWeightLabel.Text = "N/A"; - // - // label7 - // - this.label7.AutoSize = true; - this.label7.Font = new System.Drawing.Font("微软雅黑", 18F); - this.label7.ForeColor = System.Drawing.Color.Khaki; - this.label7.Location = new System.Drawing.Point(590, 49); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(165, 31); - this.label7.TabIndex = 7; - this.label7.Text = "生胎重量(g):"; - // - // panel2 - // - this.panel2.BackColor = System.Drawing.Color.Gray; - this.panel2.Controls.Add(this.RgvNoLabel); - this.panel2.Controls.Add(this.SpecCodeLabel); - this.panel2.Controls.Add(this.label10); - this.panel2.Controls.Add(this.RecipeNameLabel); - this.panel2.Controls.Add(this.RawTireWeightLabel); - this.panel2.Controls.Add(this.RecipeCodeLabel); - this.panel2.Controls.Add(this.label4); - this.panel2.Controls.Add(this.label7); - this.panel2.Controls.Add(this.label3); - this.panel2.Controls.Add(this.label2); - this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel2.Location = new System.Drawing.Point(0, 0); - this.panel2.Margin = new System.Windows.Forms.Padding(0); - this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(1084, 114); - this.panel2.TabIndex = 2; - // - // SpecCodeLabel - // - this.SpecCodeLabel.AutoSize = true; - this.SpecCodeLabel.Font = new System.Drawing.Font("微软雅黑", 18F); - this.SpecCodeLabel.ForeColor = System.Drawing.Color.LightGoldenrodYellow; - this.SpecCodeLabel.Location = new System.Drawing.Point(454, 50); - this.SpecCodeLabel.Name = "SpecCodeLabel"; - this.SpecCodeLabel.Size = new System.Drawing.Size(112, 31); - this.SpecCodeLabel.TabIndex = 6; - this.SpecCodeLabel.Text = "T123456"; - // - // RecipeNameLabel - // - this.RecipeNameLabel.AutoSize = true; - this.RecipeNameLabel.Font = new System.Drawing.Font("微软雅黑", 18F); - this.RecipeNameLabel.ForeColor = System.Drawing.Color.LightGoldenrodYellow; - this.RecipeNameLabel.Location = new System.Drawing.Point(297, 14); - this.RecipeNameLabel.Name = "RecipeNameLabel"; - this.RecipeNameLabel.Size = new System.Drawing.Size(494, 31); - this.RecipeNameLabel.TabIndex = 5; - this.RecipeNameLabel.Text = "8.15-15/28×9-15 C8900 THS NM 正新轮胎"; - // - // RecipeCodeLabel - // - this.RecipeCodeLabel.AutoSize = true; - this.RecipeCodeLabel.Font = new System.Drawing.Font("微软雅黑", 18F); - this.RecipeCodeLabel.ForeColor = System.Drawing.Color.LightGoldenrodYellow; - this.RecipeCodeLabel.Location = new System.Drawing.Point(156, 49); - this.RecipeCodeLabel.Name = "RecipeCodeLabel"; - this.RecipeCodeLabel.Size = new System.Drawing.Size(147, 31); - this.RecipeCodeLabel.TabIndex = 4; - this.RecipeCodeLabel.Text = "TI12345567"; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Font = new System.Drawing.Font("微软雅黑", 18F); - this.label4.ForeColor = System.Drawing.Color.LightGoldenrodYellow; - this.label4.Location = new System.Drawing.Point(329, 49); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(144, 31); - this.label4.TabIndex = 3; - this.label4.Text = "SPEC编号:"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Font = new System.Drawing.Font("微软雅黑", 18F); - this.label3.ForeColor = System.Drawing.Color.LightGoldenrodYellow; - this.label3.Location = new System.Drawing.Point(177, 14); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(134, 31); - this.label3.TabIndex = 2; - this.label3.Text = "标称尺度:"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Font = new System.Drawing.Font("微软雅黑", 18F); - this.label2.ForeColor = System.Drawing.Color.LightGoldenrodYellow; - this.label2.Location = new System.Drawing.Point(16, 49); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(134, 31); - this.label2.TabIndex = 1; - this.label2.Text = "成品代号:"; - // - // MonitorDataGridView - // - this.MonitorDataGridView.AllowUserToAddRows = false; - this.MonitorDataGridView.AllowUserToDeleteRows = false; - this.MonitorDataGridView.AllowUserToResizeColumns = false; - this.MonitorDataGridView.AllowUserToResizeRows = false; - this.MonitorDataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.MonitorDataGridView.BorderStyle = System.Windows.Forms.BorderStyle.None; - dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.TopCenter; - dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.MonitorDataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; - this.MonitorDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.MonitorDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { - this.No, - this.VulcanizationNo, - this.StartTime, - this.RecipeCode, - this.RecipeName, - this.SpecCode, - this.DeviceNo, - this.TireWeight, - this.BaseRubFinishTime, - this.MidRubFinishTime, - this.RowTireFinishTime, - this.RepeatWeight, - this.IsDone}); - this.MonitorDataGridView.Location = new System.Drawing.Point(0, 228); - this.MonitorDataGridView.Margin = new System.Windows.Forms.Padding(0); - this.MonitorDataGridView.MultiSelect = false; - this.MonitorDataGridView.Name = "MonitorDataGridView"; - this.MonitorDataGridView.ReadOnly = true; - this.MonitorDataGridView.RowHeadersVisible = false; - this.MonitorDataGridView.RowTemplate.Height = 32; - this.MonitorDataGridView.Size = new System.Drawing.Size(2169, 767); - this.MonitorDataGridView.TabIndex = 1; - // - // No - // - this.No.DataPropertyName = "No"; - dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.No.DefaultCellStyle = dataGridViewCellStyle2; - this.No.HeaderText = "序号"; - this.No.Name = "No"; - this.No.ReadOnly = true; - this.No.Width = 60; - // - // VulcanizationNo - // - this.VulcanizationNo.DataPropertyName = "VulcanizationNo"; - dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.VulcanizationNo.DefaultCellStyle = dataGridViewCellStyle3; - this.VulcanizationNo.HeaderText = "机位"; - this.VulcanizationNo.Name = "VulcanizationNo"; - this.VulcanizationNo.ReadOnly = true; - // - // StartTime - // - this.StartTime.DataPropertyName = "StartTime"; - dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.StartTime.DefaultCellStyle = dataGridViewCellStyle4; - this.StartTime.HeaderText = "开始时间"; - this.StartTime.Name = "StartTime"; - this.StartTime.ReadOnly = true; - this.StartTime.Width = 200; - // - // RecipeCode - // - this.RecipeCode.DataPropertyName = "RecipeCode"; - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold); - this.RecipeCode.DefaultCellStyle = dataGridViewCellStyle5; - this.RecipeCode.HeaderText = "成品代号"; - this.RecipeCode.Name = "RecipeCode"; - this.RecipeCode.ReadOnly = true; - this.RecipeCode.Width = 180; - // - // RecipeName - // - this.RecipeName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.RecipeName.DataPropertyName = "RecipeName"; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold); - this.RecipeName.DefaultCellStyle = dataGridViewCellStyle6; - this.RecipeName.HeaderText = "标称尺度"; - this.RecipeName.Name = "RecipeName"; - this.RecipeName.ReadOnly = true; - // - // SpecCode - // - this.SpecCode.DataPropertyName = "SpecCode"; - dataGridViewCellStyle7.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold); - this.SpecCode.DefaultCellStyle = dataGridViewCellStyle7; - this.SpecCode.HeaderText = "SPEC编号"; - this.SpecCode.Name = "SpecCode"; - this.SpecCode.ReadOnly = true; - this.SpecCode.Width = 140; - // - // DeviceNo - // - this.DeviceNo.DataPropertyName = "DeviceNo"; - dataGridViewCellStyle8.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold); - this.DeviceNo.DefaultCellStyle = dataGridViewCellStyle8; - this.DeviceNo.HeaderText = "小车号"; - this.DeviceNo.Name = "DeviceNo"; - this.DeviceNo.ReadOnly = true; - this.DeviceNo.Width = 80; - // - // TireWeight - // - this.TireWeight.DataPropertyName = "RawTireWeight"; - dataGridViewCellStyle9.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold); - this.TireWeight.DefaultCellStyle = dataGridViewCellStyle9; - this.TireWeight.HeaderText = "生胎重量"; - this.TireWeight.Name = "TireWeight"; - this.TireWeight.ReadOnly = true; - // - // BaseRubFinishTime - // - this.BaseRubFinishTime.DataPropertyName = "BaseRubTimeSpan"; - dataGridViewCellStyle10.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold); - this.BaseRubFinishTime.DefaultCellStyle = dataGridViewCellStyle10; - this.BaseRubFinishTime.HeaderText = "基部胶完成时间"; - this.BaseRubFinishTime.Name = "BaseRubFinishTime"; - this.BaseRubFinishTime.ReadOnly = true; - this.BaseRubFinishTime.Width = 162; - // - // MidRubFinishTime - // - this.MidRubFinishTime.DataPropertyName = "MidRubTimeSpan"; - dataGridViewCellStyle11.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold); - this.MidRubFinishTime.DefaultCellStyle = dataGridViewCellStyle11; - this.MidRubFinishTime.HeaderText = "中层胶完成时间"; - this.MidRubFinishTime.Name = "MidRubFinishTime"; - this.MidRubFinishTime.ReadOnly = true; - this.MidRubFinishTime.Width = 162; - // - // RowTireFinishTime - // - this.RowTireFinishTime.DataPropertyName = "FaceRubTimeSpan"; - dataGridViewCellStyle12.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold); - this.RowTireFinishTime.DefaultCellStyle = dataGridViewCellStyle12; - this.RowTireFinishTime.HeaderText = "生胎完成时间"; - this.RowTireFinishTime.Name = "RowTireFinishTime"; - this.RowTireFinishTime.ReadOnly = true; - this.RowTireFinishTime.Width = 141; - // - // RepeatWeight - // - this.RepeatWeight.DataPropertyName = "RepeatWeight"; - dataGridViewCellStyle13.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold); - this.RepeatWeight.DefaultCellStyle = dataGridViewCellStyle13; - this.RepeatWeight.HeaderText = "复重重量"; - this.RepeatWeight.Name = "RepeatWeight"; - this.RepeatWeight.ReadOnly = true; - // - // IsDone - // - this.IsDone.DataPropertyName = "IsDone"; - dataGridViewCellStyle14.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold); - this.IsDone.DefaultCellStyle = dataGridViewCellStyle14; - this.IsDone.HeaderText = "状态"; - this.IsDone.Name = "IsDone"; - this.IsDone.ReadOnly = true; - this.IsDone.Width = 80; - // - // DataRefresh - // - this.DataRefresh.Enabled = true; - this.DataRefresh.Interval = 1000; - this.DataRefresh.Tick += new System.EventHandler(this.DataRefresh_Tick); - // // tableLayoutPanel3 // this.tableLayoutPanel3.ColumnCount = 2; @@ -446,6 +145,42 @@ namespace HighWayIot.Winform.UserControlPages this.tableLayoutPanel3.Size = new System.Drawing.Size(1085, 114); this.tableLayoutPanel3.TabIndex = 3; // + // panel5 + // + this.panel5.BackColor = System.Drawing.SystemColors.ControlLight; + this.panel5.Controls.Add(this.NowDateProductNumTextBox); + this.panel5.Controls.Add(this.NowDateProductNumLabel); + this.panel5.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel5.Location = new System.Drawing.Point(824, 0); + this.panel5.Margin = new System.Windows.Forms.Padding(0); + this.panel5.Name = "panel5"; + this.panel5.Size = new System.Drawing.Size(261, 114); + this.panel5.TabIndex = 18; + // + // NowDateProductNumTextBox + // + this.NowDateProductNumTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.NowDateProductNumTextBox.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.NowDateProductNumTextBox.Location = new System.Drawing.Point(67, 58); + this.NowDateProductNumTextBox.Name = "NowDateProductNumTextBox"; + this.NowDateProductNumTextBox.ReadOnly = true; + this.NowDateProductNumTextBox.Size = new System.Drawing.Size(122, 30); + this.NowDateProductNumTextBox.TabIndex = 18; + this.NowDateProductNumTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + // + // NowDateProductNumLabel + // + this.NowDateProductNumLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); + this.NowDateProductNumLabel.AutoSize = true; + this.NowDateProductNumLabel.Font = new System.Drawing.Font("微软雅黑", 15F); + this.NowDateProductNumLabel.ForeColor = System.Drawing.Color.Sienna; + this.NowDateProductNumLabel.Location = new System.Drawing.Point(48, 23); + this.NowDateProductNumLabel.Name = "NowDateProductNumLabel"; + this.NowDateProductNumLabel.Size = new System.Drawing.Size(164, 27); + this.NowDateProductNumLabel.TabIndex = 13; + this.NowDateProductNumLabel.Text = "99 月 99 日 产量"; + this.NowDateProductNumLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // // panel4 // this.panel4.BackColor = System.Drawing.SystemColors.ScrollBar; @@ -526,47 +261,192 @@ namespace HighWayIot.Winform.UserControlPages this.label12.TabIndex = 12; this.label12.Text = "白班:"; // - // panel5 + // panel2 // - this.panel5.BackColor = System.Drawing.SystemColors.ControlLight; - this.panel5.Controls.Add(this.NowDateProductNumTextBox); - this.panel5.Controls.Add(this.NowDateProductNumLabel); - this.panel5.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel5.Location = new System.Drawing.Point(824, 0); - this.panel5.Margin = new System.Windows.Forms.Padding(0); - this.panel5.Name = "panel5"; - this.panel5.Size = new System.Drawing.Size(261, 114); - this.panel5.TabIndex = 18; + this.panel2.BackColor = System.Drawing.Color.Gray; + this.panel2.Controls.Add(this.RgvNoLabel); + this.panel2.Controls.Add(this.SpecCodeLabel); + this.panel2.Controls.Add(this.label10); + this.panel2.Controls.Add(this.RecipeNameLabel); + this.panel2.Controls.Add(this.RawTireWeightLabel); + this.panel2.Controls.Add(this.RecipeCodeLabel); + this.panel2.Controls.Add(this.label4); + this.panel2.Controls.Add(this.label7); + this.panel2.Controls.Add(this.label3); + this.panel2.Controls.Add(this.label2); + this.panel2.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel2.Location = new System.Drawing.Point(0, 0); + this.panel2.Margin = new System.Windows.Forms.Padding(0); + this.panel2.Name = "panel2"; + this.panel2.Size = new System.Drawing.Size(1084, 114); + this.panel2.TabIndex = 2; // - // NowDateProductNumTextBox + // RgvNoLabel // - this.NowDateProductNumTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); - this.NowDateProductNumTextBox.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.NowDateProductNumTextBox.Location = new System.Drawing.Point(67, 58); - this.NowDateProductNumTextBox.Name = "NowDateProductNumTextBox"; - this.NowDateProductNumTextBox.ReadOnly = true; - this.NowDateProductNumTextBox.Size = new System.Drawing.Size(122, 30); - this.NowDateProductNumTextBox.TabIndex = 18; - this.NowDateProductNumTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.RgvNoLabel.AutoSize = true; + this.RgvNoLabel.Font = new System.Drawing.Font("微软雅黑", 18F); + this.RgvNoLabel.ForeColor = System.Drawing.Color.Khaki; + this.RgvNoLabel.Location = new System.Drawing.Point(122, 23); + this.RgvNoLabel.Name = "RgvNoLabel"; + this.RgvNoLabel.Size = new System.Drawing.Size(61, 31); + this.RgvNoLabel.TabIndex = 11; + this.RgvNoLabel.Text = "N/A"; // - // NowDateProductNumLabel + // SpecCodeLabel // - this.NowDateProductNumLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); - this.NowDateProductNumLabel.AutoSize = true; - this.NowDateProductNumLabel.Font = new System.Drawing.Font("微软雅黑", 15F); - this.NowDateProductNumLabel.ForeColor = System.Drawing.Color.Sienna; - this.NowDateProductNumLabel.Location = new System.Drawing.Point(48, 23); - this.NowDateProductNumLabel.Name = "NowDateProductNumLabel"; - this.NowDateProductNumLabel.Size = new System.Drawing.Size(164, 27); - this.NowDateProductNumLabel.TabIndex = 13; - this.NowDateProductNumLabel.Text = "99 月 99 日 产量"; - this.NowDateProductNumLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.SpecCodeLabel.AutoSize = true; + this.SpecCodeLabel.Font = new System.Drawing.Font("微软雅黑", 18F); + this.SpecCodeLabel.ForeColor = System.Drawing.Color.LightGoldenrodYellow; + this.SpecCodeLabel.Location = new System.Drawing.Point(466, 59); + this.SpecCodeLabel.Name = "SpecCodeLabel"; + this.SpecCodeLabel.Size = new System.Drawing.Size(112, 31); + this.SpecCodeLabel.TabIndex = 6; + this.SpecCodeLabel.Text = "T123456"; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Font = new System.Drawing.Font("微软雅黑", 18F); + this.label10.ForeColor = System.Drawing.Color.Khaki; + this.label10.Location = new System.Drawing.Point(28, 23); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(110, 31); + this.label10.TabIndex = 10; + this.label10.Text = "小车号:"; + // + // RecipeNameLabel + // + this.RecipeNameLabel.AutoSize = true; + this.RecipeNameLabel.Font = new System.Drawing.Font("微软雅黑", 18F); + this.RecipeNameLabel.ForeColor = System.Drawing.Color.LightGoldenrodYellow; + this.RecipeNameLabel.Location = new System.Drawing.Point(309, 23); + this.RecipeNameLabel.Name = "RecipeNameLabel"; + this.RecipeNameLabel.Size = new System.Drawing.Size(494, 31); + this.RecipeNameLabel.TabIndex = 5; + this.RecipeNameLabel.Text = "8.15-15/28×9-15 C8900 THS NM 正新轮胎"; + // + // RawTireWeightLabel + // + this.RawTireWeightLabel.AutoSize = true; + this.RawTireWeightLabel.Font = new System.Drawing.Font("微软雅黑", 18F); + this.RawTireWeightLabel.ForeColor = System.Drawing.Color.Khaki; + this.RawTireWeightLabel.Location = new System.Drawing.Point(753, 58); + this.RawTireWeightLabel.Name = "RawTireWeightLabel"; + this.RawTireWeightLabel.Size = new System.Drawing.Size(61, 31); + this.RawTireWeightLabel.TabIndex = 9; + this.RawTireWeightLabel.Text = "N/A"; + // + // RecipeCodeLabel + // + this.RecipeCodeLabel.AutoSize = true; + this.RecipeCodeLabel.Font = new System.Drawing.Font("微软雅黑", 18F); + this.RecipeCodeLabel.ForeColor = System.Drawing.Color.LightGoldenrodYellow; + this.RecipeCodeLabel.Location = new System.Drawing.Point(150, 58); + this.RecipeCodeLabel.Name = "RecipeCodeLabel"; + this.RecipeCodeLabel.Size = new System.Drawing.Size(147, 31); + this.RecipeCodeLabel.TabIndex = 4; + this.RecipeCodeLabel.Text = "TI12345567"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Font = new System.Drawing.Font("微软雅黑", 18F); + this.label4.ForeColor = System.Drawing.Color.LightGoldenrodYellow; + this.label4.Location = new System.Drawing.Point(341, 58); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(144, 31); + this.label4.TabIndex = 3; + this.label4.Text = "SPEC编号:"; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Font = new System.Drawing.Font("微软雅黑", 18F); + this.label7.ForeColor = System.Drawing.Color.Khaki; + this.label7.Location = new System.Drawing.Point(602, 58); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(165, 31); + this.label7.TabIndex = 7; + this.label7.Text = "生胎重量(g):"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Font = new System.Drawing.Font("微软雅黑", 18F); + this.label3.ForeColor = System.Drawing.Color.LightGoldenrodYellow; + this.label3.Location = new System.Drawing.Point(189, 23); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(134, 31); + this.label3.TabIndex = 2; + this.label3.Text = "标称尺度:"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Font = new System.Drawing.Font("微软雅黑", 18F); + this.label2.ForeColor = System.Drawing.Color.LightGoldenrodYellow; + this.label2.Location = new System.Drawing.Point(28, 58); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(134, 31); + this.label2.TabIndex = 1; + this.label2.Text = "成品代号:"; + // + // MonitorDataGridView + // + this.MonitorDataGridView.AllowUserToAddRows = false; + this.MonitorDataGridView.AllowUserToDeleteRows = false; + this.MonitorDataGridView.AllowUserToResizeColumns = false; + this.MonitorDataGridView.AllowUserToResizeRows = false; + this.MonitorDataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.MonitorDataGridView.BorderStyle = System.Windows.Forms.BorderStyle.None; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.TopCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.MonitorDataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; + this.MonitorDataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.MonitorDataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.No, + this.VulcanizationNo, + this.StartTime, + this.RecipeCode, + this.RecipeName, + this.SpecCode, + this.DeviceNo, + this.StandardWeight, + this.BaseRubFinishTime, + this.MidRubFinishTime, + this.RowTireFinishTime, + this.TireWeight, + this.RepeatWeight, + this.IsDone}); + this.MonitorDataGridView.Location = new System.Drawing.Point(0, 228); + this.MonitorDataGridView.Margin = new System.Windows.Forms.Padding(0); + this.MonitorDataGridView.MultiSelect = false; + this.MonitorDataGridView.Name = "MonitorDataGridView"; + this.MonitorDataGridView.ReadOnly = true; + this.MonitorDataGridView.RowHeadersVisible = false; + this.MonitorDataGridView.RowTemplate.Height = 32; + this.MonitorDataGridView.Size = new System.Drawing.Size(2169, 799); + this.MonitorDataGridView.TabIndex = 1; + // + // DataRefresh + // + this.DataRefresh.Enabled = true; + this.DataRefresh.Interval = 1000; + this.DataRefresh.Tick += new System.EventHandler(this.DataRefresh_Tick); // // tableLayoutPanel2 // this.tableLayoutPanel2.ColumnCount = 1; this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tableLayoutPanel2.Controls.Add(this.panel1, 0, 1); + this.tableLayoutPanel2.Controls.Add(this.panel6, 0, 0); this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill; this.tableLayoutPanel2.Location = new System.Drawing.Point(0, 0); this.tableLayoutPanel2.Name = "tableLayoutPanel2"; @@ -576,6 +456,15 @@ namespace HighWayIot.Winform.UserControlPages this.tableLayoutPanel2.Size = new System.Drawing.Size(2169, 228); this.tableLayoutPanel2.TabIndex = 2; // + // panel6 + // + this.panel6.Controls.Add(this.MoveText); + this.panel6.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel6.Location = new System.Drawing.Point(3, 3); + this.panel6.Name = "panel6"; + this.panel6.Size = new System.Drawing.Size(2163, 108); + this.panel6.TabIndex = 1; + // // panel3 // this.panel3.Controls.Add(this.tableLayoutPanel2); @@ -585,6 +474,156 @@ namespace HighWayIot.Winform.UserControlPages this.panel3.Size = new System.Drawing.Size(2169, 228); this.panel3.TabIndex = 3; // + // No + // + this.No.DataPropertyName = "No"; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.No.DefaultCellStyle = dataGridViewCellStyle2; + this.No.HeaderText = "序号"; + this.No.Name = "No"; + this.No.ReadOnly = true; + this.No.Width = 60; + // + // VulcanizationNo + // + this.VulcanizationNo.DataPropertyName = "VulcanizationNo"; + dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.VulcanizationNo.DefaultCellStyle = dataGridViewCellStyle3; + this.VulcanizationNo.HeaderText = "机位"; + this.VulcanizationNo.Name = "VulcanizationNo"; + this.VulcanizationNo.ReadOnly = true; + this.VulcanizationNo.Width = 75; + // + // StartTime + // + this.StartTime.DataPropertyName = "StartTime"; + dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.StartTime.DefaultCellStyle = dataGridViewCellStyle4; + this.StartTime.HeaderText = "开始时间"; + this.StartTime.Name = "StartTime"; + this.StartTime.ReadOnly = true; + this.StartTime.Width = 110; + // + // RecipeCode + // + this.RecipeCode.DataPropertyName = "RecipeCode"; + dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold); + this.RecipeCode.DefaultCellStyle = dataGridViewCellStyle5; + this.RecipeCode.HeaderText = "成品代号"; + this.RecipeCode.Name = "RecipeCode"; + this.RecipeCode.ReadOnly = true; + this.RecipeCode.Width = 140; + // + // RecipeName + // + this.RecipeName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.RecipeName.DataPropertyName = "RecipeName"; + dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold); + this.RecipeName.DefaultCellStyle = dataGridViewCellStyle6; + this.RecipeName.HeaderText = "标称尺度"; + this.RecipeName.Name = "RecipeName"; + this.RecipeName.ReadOnly = true; + // + // SpecCode + // + this.SpecCode.DataPropertyName = "SpecCode"; + dataGridViewCellStyle7.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold); + this.SpecCode.DefaultCellStyle = dataGridViewCellStyle7; + this.SpecCode.HeaderText = "SPEC编号"; + this.SpecCode.Name = "SpecCode"; + this.SpecCode.ReadOnly = true; + this.SpecCode.Width = 110; + // + // DeviceNo + // + this.DeviceNo.DataPropertyName = "DeviceNo"; + dataGridViewCellStyle8.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold); + this.DeviceNo.DefaultCellStyle = dataGridViewCellStyle8; + this.DeviceNo.HeaderText = "小车号"; + this.DeviceNo.Name = "DeviceNo"; + this.DeviceNo.ReadOnly = true; + this.DeviceNo.Width = 80; + // + // StandardWeight + // + this.StandardWeight.DataPropertyName = "StandardWeight"; + dataGridViewCellStyle9.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold); + this.StandardWeight.DefaultCellStyle = dataGridViewCellStyle9; + this.StandardWeight.HeaderText = "标准重量"; + this.StandardWeight.Name = "StandardWeight"; + this.StandardWeight.ReadOnly = true; + // + // BaseRubFinishTime + // + this.BaseRubFinishTime.DataPropertyName = "BaseRubTimeSpan"; + dataGridViewCellStyle10.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold); + this.BaseRubFinishTime.DefaultCellStyle = dataGridViewCellStyle10; + this.BaseRubFinishTime.HeaderText = "基部胶完成时间"; + this.BaseRubFinishTime.Name = "BaseRubFinishTime"; + this.BaseRubFinishTime.ReadOnly = true; + this.BaseRubFinishTime.Width = 162; + // + // MidRubFinishTime + // + this.MidRubFinishTime.DataPropertyName = "MidRubTimeSpan"; + dataGridViewCellStyle11.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold); + this.MidRubFinishTime.DefaultCellStyle = dataGridViewCellStyle11; + this.MidRubFinishTime.HeaderText = "中层胶完成时间"; + this.MidRubFinishTime.Name = "MidRubFinishTime"; + this.MidRubFinishTime.ReadOnly = true; + this.MidRubFinishTime.Width = 162; + // + // RowTireFinishTime + // + this.RowTireFinishTime.DataPropertyName = "FaceRubTimeSpan"; + dataGridViewCellStyle12.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold); + this.RowTireFinishTime.DefaultCellStyle = dataGridViewCellStyle12; + this.RowTireFinishTime.HeaderText = "生胎完成时间"; + this.RowTireFinishTime.Name = "RowTireFinishTime"; + this.RowTireFinishTime.ReadOnly = true; + this.RowTireFinishTime.Width = 141; + // + // TireWeight + // + this.TireWeight.DataPropertyName = "RawTireWeight"; + dataGridViewCellStyle13.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold); + this.TireWeight.DefaultCellStyle = dataGridViewCellStyle13; + this.TireWeight.HeaderText = "生胎重量"; + this.TireWeight.Name = "TireWeight"; + this.TireWeight.ReadOnly = true; + // + // RepeatWeight + // + this.RepeatWeight.DataPropertyName = "RepeatWeight"; + dataGridViewCellStyle14.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold); + this.RepeatWeight.DefaultCellStyle = dataGridViewCellStyle14; + this.RepeatWeight.HeaderText = "复重重量"; + this.RepeatWeight.Name = "RepeatWeight"; + this.RepeatWeight.ReadOnly = true; + // + // IsDone + // + this.IsDone.DataPropertyName = "IsDone"; + dataGridViewCellStyle15.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Bold); + this.IsDone.DefaultCellStyle = dataGridViewCellStyle15; + this.IsDone.HeaderText = "状态"; + this.IsDone.Name = "IsDone"; + this.IsDone.ReadOnly = true; + this.IsDone.Width = 80; + // + // MoveText + // + this.MoveText.BackColor = System.Drawing.Color.Gold; + this.MoveText.Dock = System.Windows.Forms.DockStyle.Fill; + this.MoveText.Font = new System.Drawing.Font("宋体", 48F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.MoveText.Location = new System.Drawing.Point(0, 0); + this.MoveText.MoveSpeed = 5F; + this.MoveText.Name = "MoveText"; + this.MoveText.Size = new System.Drawing.Size(2163, 108); + this.MoveText.TabIndex = 1; + this.MoveText.Text = "欢迎各位领导莅临参观"; + this.MoveText.DoubleClick += new System.EventHandler(this.MoveText_DoubleClick); + // // MonitorMainPage // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); @@ -596,18 +635,19 @@ namespace HighWayIot.Winform.UserControlPages this.Controls.Add(this.MonitorDataGridView); this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Name = "MonitorMainPage"; - this.Size = new System.Drawing.Size(2169, 1019); + this.Size = new System.Drawing.Size(2169, 1027); this.panel1.ResumeLayout(false); this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel3.ResumeLayout(false); + this.panel5.ResumeLayout(false); + this.panel5.PerformLayout(); + this.panel4.ResumeLayout(false); + this.panel4.PerformLayout(); this.panel2.ResumeLayout(false); this.panel2.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.MonitorDataGridView)).EndInit(); - this.tableLayoutPanel3.ResumeLayout(false); - this.panel4.ResumeLayout(false); - this.panel4.PerformLayout(); - this.panel5.ResumeLayout(false); - this.panel5.PerformLayout(); this.tableLayoutPanel2.ResumeLayout(false); + this.panel6.ResumeLayout(false); this.panel3.ResumeLayout(false); this.ResumeLayout(false); @@ -630,19 +670,6 @@ namespace HighWayIot.Winform.UserControlPages private Label RgvNoLabel; private Label label10; private Timer DataRefresh; - private DataGridViewTextBoxColumn No; - private DataGridViewTextBoxColumn VulcanizationNo; - private DataGridViewTextBoxColumn StartTime; - private DataGridViewTextBoxColumn RecipeCode; - private DataGridViewTextBoxColumn RecipeName; - private DataGridViewTextBoxColumn SpecCode; - private DataGridViewTextBoxColumn DeviceNo; - private DataGridViewTextBoxColumn TireWeight; - private DataGridViewTextBoxColumn BaseRubFinishTime; - private DataGridViewTextBoxColumn MidRubFinishTime; - private DataGridViewTextBoxColumn RowTireFinishTime; - private DataGridViewTextBoxColumn RepeatWeight; - private DataGridViewTextBoxColumn IsDone; private TableLayoutPanel tableLayoutPanel3; private Panel panel4; private TextBox NightProductNumTextBox; @@ -656,5 +683,21 @@ namespace HighWayIot.Winform.UserControlPages private Label NowDateProductNumLabel; private TableLayoutPanel tableLayoutPanel2; private Panel panel3; + private Panel panel6; + private Mesnac.Controls.ChemicalWeighing.HslMoveText MoveText; + private DataGridViewTextBoxColumn No; + private DataGridViewTextBoxColumn VulcanizationNo; + private DataGridViewTextBoxColumn StartTime; + private DataGridViewTextBoxColumn RecipeCode; + private DataGridViewTextBoxColumn RecipeName; + private DataGridViewTextBoxColumn SpecCode; + private DataGridViewTextBoxColumn DeviceNo; + private DataGridViewTextBoxColumn StandardWeight; + private DataGridViewTextBoxColumn BaseRubFinishTime; + private DataGridViewTextBoxColumn MidRubFinishTime; + private DataGridViewTextBoxColumn RowTireFinishTime; + private DataGridViewTextBoxColumn TireWeight; + private DataGridViewTextBoxColumn RepeatWeight; + private DataGridViewTextBoxColumn IsDone; } } diff --git a/HighWayIot.Winform/UserControlPages/MonitorMainPages/MonitorMainPage.cs b/HighWayIot.Winform/UserControlPages/MonitorMainPages/MonitorMainPage.cs index e0c640f..b8d5243 100644 --- a/HighWayIot.Winform/UserControlPages/MonitorMainPages/MonitorMainPage.cs +++ b/HighWayIot.Winform/UserControlPages/MonitorMainPages/MonitorMainPage.cs @@ -2,6 +2,7 @@ using HighWayIot.Repository.domain; using HighWayIot.Repository.service; using HighWayIot.Winform.Business; +using HighWayIot.Winform.UserControlPages.MonitorMainPages; using Models; using System; using System.Collections.Generic; @@ -38,14 +39,36 @@ namespace HighWayIot.Winform.UserControlPages private List _monitorDataSources = new List(); + /// + /// 白班开始时间 + /// private DateTime DayStartTime; + /// + /// 白班结束时间 + /// private DateTime DayEndTine; + /// + /// 夜班开始时间 + /// private DateTime NightStartTime; + /// + /// 夜班结束时间 + /// private DateTime NightEndTime; + /// + /// 上次白班开始时间 + /// + private DateTime LastDayStartTime; + + /// + /// 上次夜班结束时间 + /// + private DateTime LastNightEndTime; + public static Action MonitorRefreshAction; /// @@ -109,15 +132,26 @@ namespace HighWayIot.Winform.UserControlPages DayEndTine = DateTime.Now.Date + EndTime; NightStartTime = DateTime.Now.Date - TimeSpan.FromDays(1) + EndTime; NightEndTime = DateTime.Now.Date + StartTime; + + LastDayStartTime = DateTime.Today - TimeSpan.FromDays(1) + StartTime; + LastNightEndTime = DateTime.Today + StartTime; + DayProductNumTextBox.BackColor = Color.LightGreen; + NightProductNumTextBox.BackColor = Color.LightGray; } else {//夜班 + + DayProductNumTextBox.BackColor = Color.LightGray; + NightProductNumTextBox.BackColor = Color.LightGreen; if (DateTime.Now.TimeOfDay < StartTime) //前半夜 { DayStartTime = DateTime.Now.Date + StartTime; DayEndTine = DateTime.Now.Date + EndTime; NightStartTime = DateTime.Now.Date + EndTime; NightEndTime = DateTime.Now + TimeSpan.FromDays(1) + StartTime; + + LastDayStartTime = DateTime.Today - TimeSpan.FromDays(1) + StartTime; + LastNightEndTime = DateTime.Today + StartTime; } else if (DateTime.Now.TimeOfDay > EndTime) //后半夜 { @@ -125,6 +159,9 @@ namespace HighWayIot.Winform.UserControlPages DayEndTine = DateTime.Now.Date - TimeSpan.FromDays(1) + EndTime; NightStartTime = DateTime.Now.Date - TimeSpan.FromDays(1) + EndTime; NightEndTime = DateTime.Now + StartTime; + + LastDayStartTime = DateTime.Today - TimeSpan.FromDays(2) + StartTime; + LastNightEndTime = DateTime.Today - TimeSpan.FromDays(1) + StartTime; } } @@ -133,7 +170,7 @@ namespace HighWayIot.Winform.UserControlPages DayTimeLabel.Text = dayString; NightTimeLabel.Text = nightString; - NowDateProductNumLabel.Text = DateTime.Now.ToString("MM 月 dd 日 产量"); + NowDateProductNumLabel.Text = (DateTime.Now - TimeSpan.FromDays(1)).ToString("MM 月 dd 日 产量"); } /// @@ -150,17 +187,29 @@ namespace HighWayIot.Winform.UserControlPages { return; } - for (int i = 0; i < dailyEntity.Count; i++) + + int showCount = 0; + if (dailyEntity.Count >= 50) + { + showCount = 50; + } + else + { + showCount = dailyEntity.Count; + } + + for (int i = 0; i < showCount; i++) { _monitorDataSources.Add(new MonitorDataSource() { No = i + 1, VulcanizationNo = dailyEntity[i].VulcanizationNo, - StartTime = dailyEntity[i].StartTime.ToString("MM月dd日 HH:mm:ss"), + StartTime = dailyEntity[i].StartTime.ToString("HH:mm:ss"), RecipeName = dailyEntity[i].RecipeName, RecipeCode = dailyEntity[i].RecipeCode, SpecCode = dailyEntity[i].SpecCode, DeviceNo = dailyEntity[i].DeviceNo.ToString(), + StandardWeight = dailyEntity[i].StandardWeight ?? 0, RawTireWeight = dailyEntity[i].RawTireWeight ?? 0, BaseRubTimeSpan = GeneralUtils.DateTimeToString(dailyEntity[i].StartTime, dailyEntity[i].BaseEndTime), MidRubTimeSpan = GeneralUtils.DateTimeToString(dailyEntity[i].StartTime, dailyEntity[i].MidEndTime), @@ -168,16 +217,18 @@ namespace HighWayIot.Winform.UserControlPages RepeatWeight = dailyEntity[i].RepeatWeight ?? 0, IsDone = dailyEntity[i].IsDone == 1 ? "已完成" : "未完成" }); + } MonitorDataGridView.DataSource = null; MonitorDataGridView.DataSource = _monitorDataSources; + MonitorDataGridView.CellFormatting += MonitorDataGridView_CellFormatting; int daycount = dailyEntity.Count(x => x.StartTime >= DayStartTime && x.StartTime <= DayEndTine && x.IsDone == 1); DayProductNumTextBox.Text = daycount.ToString(); int nightcount = dailyEntity.Count(x => x.StartTime >= NightStartTime && x.StartTime <= NightEndTime && x.IsDone == 1); NightProductNumTextBox.Text = nightcount.ToString(); - NowDateProductNumTextBox.Text = dailyEntity.Count(x => x.StartTime >= DateTime.Today).ToString(); + NowDateProductNumTextBox.Text = dailyEntity.Count(x => x.StartTime >= LastDayStartTime && x.StartTime <= LastNightEndTime).ToString(); ZxDailyReportEntity first = dailyEntity.FirstOrDefault(); if (first == null) @@ -198,10 +249,45 @@ namespace HighWayIot.Winform.UserControlPages } } RgvNoLabel.Text = first.DeviceNo.ToString(); - } - } + /// + /// 单元格格式回调方法 + /// + /// + /// + private void MonitorDataGridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) + { + // 确保是针对 "IsDone" 列的操作 + if (MonitorDataGridView.Columns[e.ColumnIndex].Name == "IsDone" && e.RowIndex >= 0) + { + var cell = MonitorDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex]; + string status = cell.Value?.ToString(); + + if (status == "已完成") + { + cell.Style.BackColor = Color.LightGreen; // 绿色 + } + else if (status == "未完成") + { + cell.Style.BackColor = Color.Yellow; // 黄色 + } + } + } + + /// + /// 滚动文本框双击事件 + /// + /// + /// + private void MoveText_DoubleClick(object sender, EventArgs e) + { + ScrollTextSetForm form = new ScrollTextSetForm(); + if (form.ShowDialog() == DialogResult.OK) + { + MoveText.Text = form.OutValue; + } + } } } diff --git a/HighWayIot.Winform/UserControlPages/MonitorMainPages/MonitorMainPage.resx b/HighWayIot.Winform/UserControlPages/MonitorMainPages/MonitorMainPage.resx index 9af3200..1bd8809 100644 --- a/HighWayIot.Winform/UserControlPages/MonitorMainPages/MonitorMainPage.resx +++ b/HighWayIot.Winform/UserControlPages/MonitorMainPages/MonitorMainPage.resx @@ -138,7 +138,7 @@ True - + True @@ -150,6 +150,9 @@ True + + True + True @@ -159,6 +162,9 @@ 17, 17 + + True + 44 diff --git a/HighWayIot.Winform/UserControlPages/MonitorMainPages/ScrollTextSetForm.Designer.cs b/HighWayIot.Winform/UserControlPages/MonitorMainPages/ScrollTextSetForm.Designer.cs new file mode 100644 index 0000000..927e18d --- /dev/null +++ b/HighWayIot.Winform/UserControlPages/MonitorMainPages/ScrollTextSetForm.Designer.cs @@ -0,0 +1,71 @@ +namespace HighWayIot.Winform.UserControlPages.MonitorMainPages +{ + partial class ScrollTextSetForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.textBox1 = new System.Windows.Forms.TextBox(); + this.button1 = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(26, 22); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(427, 21); + this.textBox1.TabIndex = 0; + // + // button1 + // + this.button1.Location = new System.Drawing.Point(163, 59); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(155, 37); + this.button1.TabIndex = 1; + this.button1.Text = "确认设置"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // ScrollTextSetForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(478, 118); + this.Controls.Add(this.button1); + this.Controls.Add(this.textBox1); + this.Name = "ScrollTextSetForm"; + this.Text = "滚动文本设置"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.Button button1; + } +} \ No newline at end of file diff --git a/HighWayIot.Winform/UserControlPages/MonitorMainPages/ScrollTextSetForm.cs b/HighWayIot.Winform/UserControlPages/MonitorMainPages/ScrollTextSetForm.cs new file mode 100644 index 0000000..fd3e1a1 --- /dev/null +++ b/HighWayIot.Winform/UserControlPages/MonitorMainPages/ScrollTextSetForm.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace HighWayIot.Winform.UserControlPages.MonitorMainPages +{ + public partial class ScrollTextSetForm : Form + { + public ScrollTextSetForm() + { + InitializeComponent(); + } + + public string OutValue { get; set; } + + /// + /// 滚动文本设置 + /// + /// + /// + private void button1_Click(object sender, EventArgs e) + { + this.OutValue = this.textBox1.Text.Trim(); + this.DialogResult = DialogResult.OK; + + this.Close(); + this.Dispose(); + } + } +} diff --git a/HighWayIot.Winform/UserControlPages/MonitorMainPages/ScrollTextSetForm.resx b/HighWayIot.Winform/UserControlPages/MonitorMainPages/ScrollTextSetForm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/HighWayIot.Winform/UserControlPages/MonitorMainPages/ScrollTextSetForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/HighWayIot.Winform/UserControlPages/TestPage.Designer.cs b/HighWayIot.Winform/UserControlPages/TestPage.Designer.cs index 797cff2..72be99b 100644 --- a/HighWayIot.Winform/UserControlPages/TestPage.Designer.cs +++ b/HighWayIot.Winform/UserControlPages/TestPage.Designer.cs @@ -64,6 +64,7 @@ this.TestButton2.TabIndex = 2; this.TestButton2.Text = "读"; this.TestButton2.UseVisualStyleBackColor = true; + this.TestButton2.Click += new System.EventHandler(this.TestButton2_Click); // // TestButton1 // diff --git a/HighWayIot.Winform/UserControlPages/TestPage.cs b/HighWayIot.Winform/UserControlPages/TestPage.cs index 767e709..91d7b66 100644 --- a/HighWayIot.Winform/UserControlPages/TestPage.cs +++ b/HighWayIot.Winform/UserControlPages/TestPage.cs @@ -9,11 +9,17 @@ using HighWayIot.Winform.Business; using HighWayIot.Winform.Properties; using HslCommunication; using Models; +using NPOI.HSSF.UserModel; +using NPOI.SS.UserModel; using System; using System.Collections; using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.IO; using System.Linq; using System.Net; +using System.Reflection; using System.Runtime.InteropServices; using System.Threading.Tasks; using System.Windows.Forms; @@ -119,284 +125,15 @@ namespace HighWayIot.Winform.UserControlPages } } - /// - /// 配方同步方法 - /// - public void SyncRecipe(ZxMesPlanTransferEntity newRecipe) - { - if(newRecipe == null) - { - return; - } - //同步到配方(配方和称量,如果是新的加字段) - List RecipeLists = ZxRecipeService.Instance.GetRecipeInfos(); - var nowEneity = RecipeLists.Where(x => x.RecipeCode == newRecipe.RecipeCode && x.IsDeleted == false).FirstOrDefault(); - if (nowEneity != null) //有就更新 只更新配方和称量信息 - { - //同步配方 - nowEneity.RecipeSpecCode = newRecipe.SpecCode; - nowEneity.RecipeSpecName = newRecipe.SpecName; - nowEneity.SizeKind = newRecipe.RimInch; - nowEneity.FixedWidth = newRecipe.FixRubWidth; - if (!ZxRecipeService.Instance.UpdateRecipeInfo(nowEneity)) - { - return; - } - - //同步称量信息 - List zxWeightEntities = ZxWeightService.Instance.GetWeightInfos(nowEneity.RecipeCode); - for (int i = 1; i <= 3; i++) - { - string typeName = string.Empty; - switch (i) - { - case 1: - typeName = "基部胶"; - break; - case 2: - typeName = "中层胶"; - break; - case 3: - typeName = "胎面胶"; - break; - default: - break; - } - string MaterialName = Convert.ToString(newRecipe.GetType().GetProperty($"MaterialName{i}").GetValue(newRecipe)); - if (!string.IsNullOrEmpty(MaterialName)) - { - ZxWeightEntity weight = zxWeightEntities.FirstOrDefault(x => x.MaterialCode == MaterialName); - if (weight != null) //原来就有 - { - weight.SetThickness = Convert.ToDecimal(newRecipe.GetType().GetProperty($"MaterialThickness{i}").GetValue(newRecipe)); //(decimal)newRecipe.MaterialThickness1; - weight.SetWidth = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}").GetValue(newRecipe)); //newRecipe.MaterialWidth1; - weight.SetWidth2 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}2").GetValue(newRecipe)); //newRecipe.MaterialWidth12; - weight.SetWidth3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}3").GetValue(newRecipe)); //newRecipe.MaterialWidth13; - weight.SetLayer = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}").GetValue(newRecipe)); //newRecipe.MaterialLayers1; - weight.SetLayer2 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}2").GetValue(newRecipe)); //newRecipe.MaterialLayers12; - weight.SetLayer3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}3").GetValue(newRecipe)); //newRecipe.MaterialLayers13; - ZxWeightService.Instance.UpdateWeightInfo(weight); - } - else //原来没有就添加 - { - ZxWeightService.Instance.InsertWeightInfo(new ZxWeightEntity() - { - RecipeCode = newRecipe.RecipeCode, - MaterialCode = MaterialName, - MaterialName = MaterialName + typeName, - MaterialType = typeName, - SetThickness = Convert.ToDecimal(newRecipe.GetType().GetProperty($"MaterialThickness{i}").GetValue(newRecipe)), - SetWidth = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}").GetValue(newRecipe)), - SetWidth2 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}2").GetValue(newRecipe)), - SetWidth3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}3").GetValue(newRecipe)), - SetLayer = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}").GetValue(newRecipe)), - SetLayer2 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}2").GetValue(newRecipe)), - SetLayer3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}3").GetValue(newRecipe)), - SetError = 1, - IsUse = true, - IsDeleted = false, - }); - } - } - } - } - else //没有就插入 全部同步 - { - //同步配方 - ZxRecipeEntity entity = new ZxRecipeEntity() - { - RecipeName = newRecipe.RecipeName, - RecipeCode = newRecipe.RecipeCode, - RecipeSpecCode = newRecipe.SpecCode, - RecipeSpecName = newRecipe.SpecName, - SizeKind = newRecipe.RimInch, - FixedWidth = newRecipe.FixRubWidth, - IsUse = true, - IsDeleted = false, - }; - ZxRecipeService.Instance.InsertRecipeInfo(entity); - - //同步称量信息 - List zxWeightEntities = ZxWeightService.Instance.GetWeightInfos(nowEneity.RecipeCode); - for (int i = 1; i <= 3; i++) - { - string typeName = string.Empty; - switch (i) - { - case 1: - typeName = "基部胶"; - break; - case 2: - typeName = "中层胶"; - break; - case 3: - typeName = "胎面胶"; - break; - default: - break; - } - string MaterialName = Convert.ToString(newRecipe.GetType().GetProperty($"MaterialName{i}").GetValue(newRecipe)); - if (!string.IsNullOrEmpty(MaterialName)) - { - ZxWeightEntity weight = zxWeightEntities.FirstOrDefault(x => x.MaterialCode == MaterialName); - if (weight != null) //原来就有 - { - weight.SetThickness = Convert.ToDecimal(newRecipe.GetType().GetProperty($"MaterialThickness{i}").GetValue(newRecipe)); //(decimal)newRecipe.MaterialThickness1; - weight.SetWidth = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}").GetValue(newRecipe)); //newRecipe.MaterialWidth1; - weight.SetWidth2 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}2").GetValue(newRecipe)); //newRecipe.MaterialWidth12; - weight.SetWidth3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}3").GetValue(newRecipe)); //newRecipe.MaterialWidth13; - weight.SetLayer = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}").GetValue(newRecipe)); //newRecipe.MaterialLayers1; - weight.SetLayer2 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}2").GetValue(newRecipe)); //newRecipe.MaterialLayers12; - weight.SetLayer3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}3").GetValue(newRecipe)); //newRecipe.MaterialLayers13; - ZxWeightService.Instance.UpdateWeightInfo(weight); - } - else //原来没有就添加 - { - ZxWeightService.Instance.InsertWeightInfo(new ZxWeightEntity() - { - RecipeCode = newRecipe.RecipeCode, - MaterialCode = MaterialName, - MaterialName = MaterialName + typeName, - MaterialType = typeName, - SetThickness = Convert.ToDecimal(newRecipe.GetType().GetProperty($"MaterialThickness{i}").GetValue(newRecipe)), - SetWidth = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}").GetValue(newRecipe)), - SetWidth2 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}2").GetValue(newRecipe)), - SetWidth3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}3").GetValue(newRecipe)), - SetLayer = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}").GetValue(newRecipe)), - SetLayer2 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}2").GetValue(newRecipe)), - SetLayer3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}3").GetValue(newRecipe)), - SetError = 1, - IsUse = true, - IsDeleted = false, - }); - } - } - } - - //同步公共参数 - ZxRecipeParaEntity recipeParaEntity = new ZxRecipeParaEntity(); - recipeParaEntity.RimInch = newRecipe.RimInch; - recipeParaEntity.LightWidth = newRecipe.FixRubWidth; - recipeParaEntity.SlowDistance = 0; - recipeParaEntity.StopDistance = 0; - recipeParaEntity.TireWeight = newRecipe.TireWeight; - recipeParaEntity.SpecCode = newRecipe.SpecCode; - recipeParaEntity.SpecName = newRecipe.SpecName; - recipeParaEntity.RecipeCode = newRecipe.RecipeCode; - - //自动工位选择 - zxWeightEntities.Clear(); - zxWeightEntities = ZxWeightService.Instance.GetWeightInfos(nowEneity.RecipeCode); - List openMixConfig = ZxOpenMixMaterialService.Instance.GetInfos(); - foreach (ZxWeightEntity weightEntity in zxWeightEntities) - { - var config = openMixConfig.Where(x => x.MaterialName == weightEntity.MaterialName).FirstOrDefault(); - if (config == null) - { - continue; - } - var prop = recipeParaEntity.GetType().GetProperty($"S{config.StationNo + 1}"); - if (prop != null) - { - prop.SetValue(recipeParaEntity, true); - } - //自动包边选择 - if (!(weightEntity.SetLayer2 == 0 - || weightEntity.SetLayer2 == null - || weightEntity.SetWidth2 == null - || weightEntity.SetWidth2 == 0)) - { - var propp = recipeParaEntity.GetType().GetProperty($"B{config.StationNo - 1}"); - if (propp != null) - { - propp.SetValue(recipeParaEntity, true); - } - } - if (!(weightEntity.SetLayer3 == 0 - || weightEntity.SetLayer3 == null - || weightEntity.SetWidth3 == null - || weightEntity.SetWidth3 == 0)) - { - var propp = recipeParaEntity.GetType().GetProperty($"B{config.StationNo + 4}"); - if (propp != null) - { - propp.SetValue(recipeParaEntity, true); - } - } - //设置胎体重量 - if (weightEntity.MaterialType == "胎面胶") - { - recipeParaEntity.TireWeight = Convert.ToSingle(weightEntity.SetWeight); - switch (config.StationNo) - { - case 3: - recipeParaEntity.S7 = true; - break; - case 4: - recipeParaEntity.S8 = true; - break; - case 5: - recipeParaEntity.S9 = true; - break; - default: - break; - } - } - } - ZxRecipeParaEntity nowRecipeParaEntity = ZxRecipeParaService.Instance.GetRecipeParaInfoByRecipeCode(nowEneity.RecipeCode).FirstOrDefault(); - - if (nowRecipeParaEntity != null) //如果存在就更改 - { - recipeParaEntity.Id = nowRecipeParaEntity.Id; - ZxRecipeParaService.Instance.UpdateRecipeParaInfo(recipeParaEntity); - } - else - { - ZxRecipeParaService.Instance.InsertRecipeParaInfo(recipeParaEntity); - } - - //同步工位参数 - ZxRecipePositionParaService.Instance.DeleteRecipePositionParaInfoByRecipeCode(newRecipe.RecipeCode); //删除可能存在的脏数据 - for (int i = 1; i <= 3; i++) - { - string MaterialName = Convert.ToString(newRecipe.GetType().GetProperty($"MaterialName{i}").GetValue(newRecipe)); - if (string.IsNullOrEmpty(MaterialName)) - { - continue; - } - - var config = openMixConfig.Where(x => x.MaterialName.Contains(MaterialName)).FirstOrDefault(); - if (config == null) - { - continue; - } - ZxRecipePositionParaEntity positionEntity = new ZxRecipePositionParaEntity() - { - RecipeCode = newRecipe.RecipeCode, - Position = config.StationNo, - E1 = 15, - E2 = 52, - E5 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}").GetValue(newRecipe)) * 10, - E9 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}").GetValue(newRecipe)), - E6 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}2").GetValue(newRecipe)) * 10, - E7 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}2").GetValue(newRecipe)), - E3 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialLayers{i}3").GetValue(newRecipe)) * 10, - E4 = Convert.ToInt32(newRecipe.GetType().GetProperty($"MaterialWidth{i}3").GetValue(newRecipe)), - E10 = 800, - E8 = 300 - }; - - ZxRecipePositionParaService.Instance.InsertRecipePositionParaInfo(positionEntity); - } - - } - - } - private void TestButton1_Click(object sender, EventArgs e) { - var a = ZxMesPlanTransferService.Instance.GetRecipeInfos(x => x.RequestFlag == false).FirstOrDefault(); - SyncRecipe(a); + } + + private void TestButton2_Click(object sender, EventArgs e) + { + + } + } } diff --git a/HighWayIot.sln b/HighWayIot.sln index 96e8d53..856c76c 100644 --- a/HighWayIot.sln +++ b/HighWayIot.sln @@ -24,6 +24,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HighWayIot.Plc", "HighWayIot.Plc\HighWayIot.Plc.csproj", "{FE3EA2BE-71C5-4F56-8125-E8E5AAA8FB84}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HighWayIot.Controls", "HighWayIot.Controls\HighWayIot.Controls.csproj", "{DDEE27AA-0694-47A6-9335-E9308261F63A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -62,6 +64,10 @@ Global {FE3EA2BE-71C5-4F56-8125-E8E5AAA8FB84}.Debug|Any CPU.Build.0 = Debug|Any CPU {FE3EA2BE-71C5-4F56-8125-E8E5AAA8FB84}.Release|Any CPU.ActiveCfg = Release|Any CPU {FE3EA2BE-71C5-4F56-8125-E8E5AAA8FB84}.Release|Any CPU.Build.0 = Release|Any CPU + {DDEE27AA-0694-47A6-9335-E9308261F63A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DDEE27AA-0694-47A6-9335-E9308261F63A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DDEE27AA-0694-47A6-9335-E9308261F63A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DDEE27AA-0694-47A6-9335-E9308261F63A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE