Selaa lähdekoodia

修改正确清除,错误时全选保存

章政 7 vuotta sitten
vanhempi
commit
c7e19d2852

+ 4 - 5
UAS_DeviceMonitor/Main.Designer.cs

@@ -33,7 +33,6 @@ namespace UAS_DeviceMonitor
         /// </summary>
         private void InitializeComponent()
         {
-            this.components = new System.ComponentModel.Container();
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main));
             this.RibbonNav = new DevExpress.XtraBars.Ribbon.RibbonControl();
             this.ButtonDeviceList = new DevExpress.XtraBars.BarButtonItem();
@@ -137,8 +136,8 @@ namespace UAS_DeviceMonitor
             this.PageWorkCenterStatus = new DevExpress.XtraTab.XtraTabPage();
             this.GridWorkCenterStatus = new UAS_DeviceMonitor.CustomerControl.AutoDataGridControl.AutoDataGridControl();
             this.GridViewWorkCenterStatus = new UAS_DeviceMonitor.CustomerControl.GridViewWithSerialNum.GridViewWithSerialNum();
-            this.TimerDeviceStatus = new System.Windows.Forms.Timer(this.components);
-            this.CommonTipController = new System.Windows.Forms.ToolTip(this.components);
+            this.TimerDeviceStatus = new System.Windows.Forms.Timer();
+            this.CommonTipController = new DevExpress.Utils.ToolTipController();
             ((System.ComponentModel.ISupportInitialize)(this.RibbonNav)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.MainTabControl)).BeginInit();
             this.MainTabControl.SuspendLayout();
@@ -1247,7 +1246,7 @@ namespace UAS_DeviceMonitor
             // 
             // CommonTipController
             // 
-            this.CommonTipController.ShowAlways = true;
+            this.CommonTipController.AutoPopDelay = 10000;
             // 
             // Main
             // 
@@ -1405,6 +1404,6 @@ namespace UAS_DeviceMonitor
         private AutoDataGridControl GridWorkCenterStatus;
         private GridViewWithSerialNum GridViewWorkCenterStatus;
         private XtraScrollableControl PanelDeviceStatus;
-        private System.Windows.Forms.ToolTip CommonTipController;
+        private DevExpress.Utils.ToolTipController CommonTipController;
     }
 }

+ 27 - 5
UAS_DeviceMonitor/Main.cs

@@ -13,6 +13,7 @@ using System.Threading;
 using UAS_DeviceMonitor.CustomerControl.PictureEditWithText;
 using System.Windows.Forms;
 using DevExpress.XtraEditors.Controls;
+using DevExpress.XtraEditors;
 
 namespace UAS_DeviceMonitor
 {
@@ -328,7 +329,7 @@ namespace UAS_DeviceMonitor
                     //更新轮询日志状态
                     sql.Clear();
                     sql.Append("update DEVICEPOLLINGLOG set dpg_status='Running',dpg_senddatasize=nvl(dpg_senddatasize,0)+" + SendCommandByteSize);
-                    sql.Append(",dpg_receivedatasize=nvl(dpg_receivedatasize,0)+" + ReceiveCommandByteSize);
+                    sql.Append(",dpg_receivedatasize=nvl(dpg_receivedatasize,0)+" + ReceiveCommandByteSize + ",dpg_count=nvl(dpg_count,0)+1 ");
                     sql.Append(" where dpg_id=(select max(dpg_id) from DEVICEPOLLINGLOG where dpg_decode='" + Decode + "')");
                     SQL.Add(sql.ToString());
                     dh.ExecuteSQLTran(SQL.ToArray());
@@ -342,8 +343,9 @@ namespace UAS_DeviceMonitor
                     SQL.Add(sql.ToString());
                     //更新轮询日志状态
                     sql.Clear();
-                    sql.Append("update DEVICEPOLLINGLOG set dpg_status='Running',dpg_senddatasize=nvl(dpg_senddatasize,0)+" + SendCommandByteSize);
-                    sql.Append(" where dpg_id=(select max(dpg_id) from DEVICEPOLLINGLOG where dpg_decode='" + Decode + "')");
+                    sql.Append("update DEVICEPOLLINGLOG set dpg_status='Running',dpg_senddatasize=nvl(dpg_senddatasize,0)+");
+                    sql.Append(SendCommandByteSize + ",dpg_count=nvl(dpg_count,0)+1 ");
+                    sql.Append("where dpg_id=(select max(dpg_id) from DEVICEPOLLINGLOG where dpg_decode='" + Decode + "')");
                     SQL.Add(sql.ToString());
                     dh.ExecuteSQLTran(SQL.ToArray());
                 }
@@ -441,18 +443,19 @@ namespace UAS_DeviceMonitor
                         for (int i = 0; i < (j == RowCount - 1 ? LastRowCount : CountPerRow); i++)
                         {
                             PictureEditWithText pic = new PictureEditWithText();
+                            pic.Picedit.ToolTipController = CommonTipController;
                             pic.Name = dt.Rows[j * CountPerRow + i]["de_code"].ToString() + i + j;
                             pic.Anchor = AnchorStyles.Left;
                             pic.Anchor = AnchorStyles.Top;
+                            pic.Picedit.Name = dt.Rows[j * CountPerRow + i]["de_code"].ToString();
+                            pic.Picedit.MouseHover += Pic_MouseHover;
                             pic.Picedit.Properties.SizeMode = PictureSizeMode.Squeeze;
                             if (dt.Rows[j * CountPerRow + i]["dpc_status"].ToString() != "Running")
                             {
-                                CommonTipController.SetToolTip(pic.Picedit, "离线");
                                 pic.Picedit.Image = Properties.Resources.network_offline;
                             }
                             else
                             {
-                                CommonTipController.SetToolTip(pic.Picedit, "在线");
                                 pic.Picedit.Image = Properties.Resources.net_connected;
                             }
                             pic.Text = dt.Rows[j * CountPerRow + i]["de_code"].ToString();
@@ -467,6 +470,25 @@ namespace UAS_DeviceMonitor
             }
         }
 
+        private void Pic_MouseHover(object sender, EventArgs e)
+        {
+            PictureEdit pic = sender as PictureEdit;
+            DataTable dt = (DataTable)dh.ExecuteSql("select * from DEVICEPOLLINGLOG where dpg_id=(select max(dpg_id) from DEVICEPOLLINGLOG where dpg_decode='" + pic.Name + "')", "select");
+            if (dt.Rows.Count > 0)
+            {
+                sql.Clear();
+                sql.Append("开始时间" + dt.Rows[0]["dpg_starttime"].ToString() + "\n");
+                sql.Append("发送数据大小"+ dt.Rows[0]["dpg_senddatasize"].ToString() + "字节\n");
+                sql.Append("接收数据大小" + dt.Rows[0]["dpg_receivedatasize"].ToString() + "字节\n");
+                sql.Append("轮询次数"+dt.Rows[0]["dpg_count"].ToString()+"次\n");
+                CommonTipController.ShowHint(sql.ToString(), pic.Name);
+            }
+            else
+            {
+                CommonTipController.ShowHint("暂无信息", pic.Name);
+            }
+        }
+
         //重新展示设备图像界面
         private void ShowDeviceStatus()
         {

+ 1 - 1
UAS_DeviceMonitor/Main.resx

@@ -474,7 +474,7 @@
     <value>17, 17</value>
   </metadata>
   <metadata name="CommonTipController.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>178, 17</value>
+    <value>362, 17</value>
   </metadata>
   <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>

+ 34 - 0
UAS_DeviceMonitor/PublicMethod/BaseUtil.cs

@@ -6,11 +6,13 @@ using System.Runtime.InteropServices;
 using System.Text;
 using System.Windows.Forms;
 using UAS_DeviceMonitor.DataOperate;
+using DevExpress.Utils;
 
 namespace UAS_DeviceMonitor.PublicMethod
 {
     class BaseUtil
     {
+    
 
         [DllImport("kernel32.dll", EntryPoint = "SetProcessWorkingSetSize")]
         public static extern int SetProcessWorkingSetSize(IntPtr process, int minSize, int maxSize);
@@ -111,5 +113,37 @@ namespace UAS_DeviceMonitor.PublicMethod
                 SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
             }
         }
+
+        private static ToolTipControllerShowEventArgs args;
+
+        public static ToolTipController MyToolTipClt { get; private set; }
+
+        public static void NewToolTip(Control ctl, string title, string content, int showTime, ToolTipType toolTipType, ToolTipLocation tipLocation, bool isAutoHide, ToolTipIconType tipIconType, ImageList imgList, int imgIndex)
+        {
+            try
+            {
+                MyToolTipClt = new ToolTipController();
+                args = MyToolTipClt.CreateShowArgs();
+                content = (string.IsNullOrEmpty(content) ? "???" : content);
+                title = string.IsNullOrEmpty(title) ? "温馨提示" : title;
+                MyToolTipClt.ImageList = imgList;
+                MyToolTipClt.ImageIndex = (imgList == null ? 0 : imgIndex);
+                args.AutoHide = isAutoHide;
+                MyToolTipClt.ShowBeak = true;
+                MyToolTipClt.ShowShadow = true;
+                MyToolTipClt.Rounded = true;
+                MyToolTipClt.AutoPopDelay = (showTime == 0 ? 2000 : showTime);
+                MyToolTipClt.SetToolTip(ctl, content);
+                MyToolTipClt.SetTitle(ctl, title);
+                MyToolTipClt.SetToolTipIconType(ctl, tipIconType);
+                MyToolTipClt.Active = true;
+                MyToolTipClt.HideHint();
+                MyToolTipClt.ShowHint(content, title, ctl, tipLocation);
+            }
+            catch (Exception)
+            {
+              
+            }
+        }
     }
 }