章政 7 жил өмнө
parent
commit
baf3013b86

+ 5 - 0
UAS_DeviceMonitor/CustomerControl/AutoDataGridControl/AutoDataGridControl.cs

@@ -14,6 +14,10 @@ namespace UAS_DeviceMonitor.CustomerControl.AutoDataGridControl
         //记录初始化的SQL,防止条件重复拼接
         string firstsql;
 
+        public delegate void OnDataRefresh(object sender, EventArgs e);
+
+        public event OnDataRefresh DataRefresh;
+
         DataHelper dh = new DataHelper();
         //获取数据的SQL
         public string GetDataSQL
@@ -129,6 +133,7 @@ namespace UAS_DeviceMonitor.CustomerControl.AutoDataGridControl
                 DataSource = dt;
                 getDataSQL = firstsql;
             }
+            DataRefresh?.Invoke(new object(), new EventArgs());
         }
     }
 }

+ 2 - 33
UAS_DeviceMonitor/Main.Designer.cs

@@ -98,8 +98,6 @@ namespace UAS_DeviceMonitor
             this.dpc_status = new DevExpress.XtraGrid.Columns.GridColumn();
             this.dpc_remark = new DevExpress.XtraGrid.Columns.GridColumn();
             this.POLLSETTINGSTATUSCOLUMN = new DevExpress.XtraGrid.Columns.GridColumn();
-            this.PollSettingItemColorEdit = new DevExpress.XtraEditors.Repository.RepositoryItemColorEdit();
-            this.PollSettingItemColorPickEdit = new DevExpress.XtraEditors.Repository.RepositoryItemColorPickEdit();
             this.PagePolling = new DevExpress.XtraTab.XtraTabPage();
             this.ButtonAddPolling = new UAS_DeviceMonitor.CustomerControl.Button.ButtonAddRow();
             this.ButtonDeletePolling = new UAS_DeviceMonitor.CustomerControl.Button.ButtonDeleteRow();
@@ -128,8 +126,6 @@ namespace UAS_DeviceMonitor
             ((System.ComponentModel.ISupportInitialize)(this.GridViewPollSetting)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.dpc_enableCheckEdit)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.PollingSetItemLookUpEdit)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.PollSettingItemColorEdit)).BeginInit();
-            ((System.ComponentModel.ISupportInitialize)(this.PollSettingItemColorPickEdit)).BeginInit();
             this.PagePolling.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.GridPolling)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewPolling)).BeginInit();
@@ -643,9 +639,7 @@ namespace UAS_DeviceMonitor
             this.GridPollingSetting.Name = "GridPollingSetting";
             this.GridPollingSetting.RepositoryItems.AddRange(new DevExpress.XtraEditors.Repository.RepositoryItem[] {
             this.dpc_enableCheckEdit,
-            this.PollingSetItemLookUpEdit,
-            this.PollSettingItemColorEdit,
-            this.PollSettingItemColorPickEdit});
+            this.PollingSetItemLookUpEdit});
             this.GridPollingSetting.RowCount = 0;
             this.GridPollingSetting.Size = new System.Drawing.Size(1027, 544);
             this.GridPollingSetting.TabIndex = 0;
@@ -796,34 +790,13 @@ namespace UAS_DeviceMonitor
             // POLLSETTINGSTATUSCOLUMN
             // 
             this.POLLSETTINGSTATUSCOLUMN.Caption = "运行状态";
-            this.POLLSETTINGSTATUSCOLUMN.ColumnEdit = this.PollSettingItemColorEdit;
             this.POLLSETTINGSTATUSCOLUMN.FieldName = "POLLSETTINGSTATUSCOLUMN";
             this.POLLSETTINGSTATUSCOLUMN.Name = "POLLSETTINGSTATUSCOLUMN";
+            this.POLLSETTINGSTATUSCOLUMN.OptionsColumn.ReadOnly = true;
             this.POLLSETTINGSTATUSCOLUMN.Visible = true;
             this.POLLSETTINGSTATUSCOLUMN.VisibleIndex = 10;
             this.POLLSETTINGSTATUSCOLUMN.Width = 98;
             // 
-            // PollSettingItemColorEdit
-            // 
-            this.PollSettingItemColorEdit.Appearance.BackColor = System.Drawing.Color.White;
-            this.PollSettingItemColorEdit.Appearance.ForeColor = System.Drawing.Color.White;
-            this.PollSettingItemColorEdit.Appearance.Options.UseBackColor = true;
-            this.PollSettingItemColorEdit.Appearance.Options.UseForeColor = true;
-            this.PollSettingItemColorEdit.AutoHeight = false;
-            this.PollSettingItemColorEdit.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
-            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
-            this.PollSettingItemColorEdit.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Custom;
-            this.PollSettingItemColorEdit.Name = "PollSettingItemColorEdit";
-            this.PollSettingItemColorEdit.ReadOnly = true;
-            // 
-            // PollSettingItemColorPickEdit
-            // 
-            this.PollSettingItemColorPickEdit.AutoHeight = false;
-            this.PollSettingItemColorPickEdit.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
-            new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
-            this.PollSettingItemColorPickEdit.Name = "PollSettingItemColorPickEdit";
-            this.PollSettingItemColorPickEdit.ReadOnly = true;
-            // 
             // PagePolling
             // 
             this.PagePolling.Controls.Add(this.ButtonAddPolling);
@@ -977,8 +950,6 @@ namespace UAS_DeviceMonitor
             ((System.ComponentModel.ISupportInitialize)(this.GridViewPollSetting)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.dpc_enableCheckEdit)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.PollingSetItemLookUpEdit)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.PollSettingItemColorEdit)).EndInit();
-            ((System.ComponentModel.ISupportInitialize)(this.PollSettingItemColorPickEdit)).EndInit();
             this.PagePolling.ResumeLayout(false);
             ((System.ComponentModel.ISupportInitialize)(this.GridPolling)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewPolling)).EndInit();
@@ -1064,8 +1035,6 @@ namespace UAS_DeviceMonitor
         private CustomerControl.Button.ButtonSaveGrid ButtonSaveCommandSet;
         private DevExpress.XtraEditors.Repository.RepositoryItemLookUpEdit PollingSetItemLookUpEdit;
         private DevExpress.XtraGrid.Columns.GridColumn GRIDVIEWPOLLSETTINGCHOOSE;
-        private DevExpress.XtraEditors.Repository.RepositoryItemColorEdit PollSettingItemColorEdit;
-        private DevExpress.XtraEditors.Repository.RepositoryItemColorPickEdit PollSettingItemColorPickEdit;
         private DevExpress.XtraGrid.Columns.GridColumn POLLSETTINGSTATUSCOLUMN;
     }
 }

+ 30 - 7
UAS_DeviceMonitor/Main.cs

@@ -8,9 +8,7 @@ using UAS_DeviceMonitor.Device.Command;
 using UAS_DeviceMonitor.PublicMethod;
 using DevExpress.XtraGrid.Views.Grid;
 using System.Collections.Generic;
-using DevExpress.XtraEditors;
 using System.Drawing;
-using DevExpress.XtraEditors.Controls;
 
 namespace UAS_DeviceMonitor
 {
@@ -19,14 +17,18 @@ namespace UAS_DeviceMonitor
 
         StringBuilder sql = new StringBuilder();
 
+
         public Main()
         {
             SystemInf.dh = new DataHelper();
             InitializeComponent();
             dpc_enableCheckEdit.QueryCheckStateByValue += CheckedEdit_QueryCheckStateByValue;
             CheckEditCommandSet.QueryCheckStateByValue += CheckedEdit_QueryCheckStateByValue;
+            GridViewPollSetting.RowCellStyle += GridViewPollSetting_RowCellStyle;
         }
 
+  
+
         private void Main_Load(object sender, EventArgs e)
         {
             //设备列表
@@ -45,6 +47,7 @@ namespace UAS_DeviceMonitor
             GridPollingSetting.ID = "DPC_ID";
             GridPollingSetting.TableName = "DEVICEPOLLINGCONFIG";
             GridPollingSetting.InsertSQL = "insert into DEVICEPOLLINGCONFIG(DPC_ID,DPC_DECODE ,DPC_PLCODE ,DPC_PLNAME ,DPC_INTERVAL ,DPC_DCCODE ,DPC_FUNCTION , DPC_ENABLE,DPC_STATUS ,DPC_REMARK) values(DEVICEPOLLINGCONFIG_seq.nextval,:DPC_DECODE ,:DPC_PLCODE ,:DPC_PLNAME ,:DPC_INTERVAL ,:DPC_DCCODE ,:DPC_FUNCTION , :DPC_ENABLE,:DPC_STATUS ,:DPC_REMARK)";
+        
             ButtonSaveCommandSet.Grid = GridPollingSetting;
             ButtonNewCommandSet.Grid = GridPollingSetting;
             ButtonDeleteCommandSet.Grid = GridPollingSetting;
@@ -171,6 +174,11 @@ namespace UAS_DeviceMonitor
         #region PagePollingSetting业务代码
 
         PollingTask pt = new PollingTask();
+        /// <summary>
+        /// 绘制轮询配置状态栏
+        /// </summary>
+        List<int> PollSettingPaintRowIndex = new List<int>();
+
         private void ButtonStartPolling_Click(object sender, EventArgs e)
         {
             GridView grid = GridViewPollSetting;
@@ -185,11 +193,26 @@ namespace UAS_DeviceMonitor
                 if (pl.Enable)
                 {
                     pt.AddTask(RunTask, pl);
-                    GridViewPollSetting.SetRowCellValue(i, "POLLSETTINGSTATUSCOLUMN", "green");
+                    //添加到状态为运行的行
+                    PollSettingPaintRowIndex.Add(i);
+                    GridPollingSetting.Focus();
                 }
             }
         }
 
+        /// <summary>
+        /// 绘制轮询状态
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void GridViewPollSetting_RowCellStyle(object sender, RowCellStyleEventArgs e)
+        {
+            if (e.Column.Name.ToUpper() == "POLLSETTINGSTATUSCOLUMN" && PollSettingPaintRowIndex.Contains(e.RowHandle))
+            {
+                e.Appearance.BackColor = Color.Green;
+            }
+        }
+
         Dictionary<int, PollingTimer> Ptime;
 
         private void RunTask(object i)
@@ -236,8 +259,8 @@ namespace UAS_DeviceMonitor
             {
                 item.Value.Stop();
             }
-            for (int i = 0; i < GridPollingSetting.RowCount; i++)
-                GridViewPollSetting.SetRowCellValue(i, "POLLSETTINGSTATUSCOLUMN", "White");
+            PollSettingPaintRowIndex.Clear();
+            GridPollingSetting.Focus();
             Ptime.Clear();
         }
 
@@ -253,7 +276,7 @@ namespace UAS_DeviceMonitor
                     {
                         Ptime[id].Stop();
                         Ptime.Remove(id);
-                        GridViewPollSetting.SetRowCellValue(e.RowHandle, "POLLSETTINGSTATUSCOLUMN", "White");
+                        PollSettingPaintRowIndex.Remove(e.RowHandle);
                     }
                 }
                 else
@@ -266,7 +289,7 @@ namespace UAS_DeviceMonitor
                     pl.Code = GridViewPollSetting.GetRowCellValue(e.RowHandle, "DPC_PLCODE").ToString();
                     if (pl.Enable)
                         pt.AddTask(RunTask, pl);
-                    GridViewPollSetting.SetRowCellValue(e.RowHandle, "POLLSETTINGSTATUSCOLUMN", "Green");
+                    PollSettingPaintRowIndex.Add(e.RowHandle);
                 }
             }
         }