|
@@ -389,21 +389,65 @@ namespace UAS_DeviceMonitor
|
|
|
{
|
|
|
if (PageDeviceStatus.PageVisible)
|
|
|
{
|
|
|
- ShowDeviceStatus();
|
|
|
- TimerDeviceStatus.Start();
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql("select distinct de_code,dpc_status,dpc_id from device left join DEVICEPOLLINGCONFIG on dpc_decode=de_code order by de_code", "select");
|
|
|
+ //界面重新展示时如过数量不一致则重新绘制
|
|
|
+ if (PanelDeviceStatus.Controls.Count != dt.Rows.Count)
|
|
|
+ {
|
|
|
+ int CountPerRow = PanelDeviceStatus.Width / 110;
|
|
|
+ int RightPadding = PanelDeviceStatus.Width % 110;
|
|
|
+ int Count = dt.Rows.Count;
|
|
|
+ int RowCount = Count % CountPerRow == 0 ? Count / CountPerRow : Count / CountPerRow + 1;
|
|
|
+ int LastRowCount = 0;
|
|
|
+ for (int i = 0; i < PanelDeviceStatus.Controls.Count; i++)
|
|
|
+ {
|
|
|
+ PanelDeviceStatus.Controls[i].Dispose();
|
|
|
+ }
|
|
|
+ for (int j = 0; j < RowCount; j++)
|
|
|
+ {
|
|
|
+ //如果是最后一行则循环尾数
|
|
|
+ if (j == RowCount - 1)
|
|
|
+ {
|
|
|
+ LastRowCount = Count % CountPerRow;
|
|
|
+ }
|
|
|
+ for (int i = 0; i < (j == RowCount - 1 ? LastRowCount : CountPerRow); i++)
|
|
|
+ {
|
|
|
+ PictureEditWithText pic = new PictureEditWithText();
|
|
|
+ pic.Name = dt.Rows[j * CountPerRow + i]["de_code"].ToString() + i + j;
|
|
|
+ pic.Anchor = AnchorStyles.Left;
|
|
|
+ pic.Anchor = AnchorStyles.Top;
|
|
|
+ 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();
|
|
|
+ pic.Picedit.BorderStyle = BorderStyles.HotFlat;
|
|
|
+ pic.Location = new Point((10 + RightPadding) / 2 + 110 * i, 10 + j * 130);
|
|
|
+ PanelDeviceStatus.Controls.Add(pic);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ BaseUtil.CleanMemory();
|
|
|
+ TimerDeviceStatus.Start();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//重新展示设备图像界面
|
|
|
private void ShowDeviceStatus()
|
|
|
{
|
|
|
- DataTable dt = (DataTable)dh.ExecuteSql("select * from device left join DEVICEPOLLINGCONFIG on dpc_decode=de_code where rownum<4 order by de_code", "select");
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql("select distinct de_code,dpc_status,dpc_id from device left join DEVICEPOLLINGCONFIG on dpc_decode=de_code order by de_code", "select");
|
|
|
int CountPerRow = PanelDeviceStatus.Width / 110;
|
|
|
int RightPadding = PanelDeviceStatus.Width % 110;
|
|
|
int Count = dt.Rows.Count;
|
|
|
int RowCount = Count % CountPerRow == 0 ? Count / CountPerRow : Count / CountPerRow + 1;
|
|
|
- PanelDeviceStatus.Controls.Clear();
|
|
|
int LastRowCount = 0;
|
|
|
+ //只更换现有控件的图片,不必重新绘制控件
|
|
|
for (int j = 0; j < RowCount; j++)
|
|
|
{
|
|
|
//如果是最后一行则循环尾数
|
|
@@ -413,25 +457,14 @@ namespace UAS_DeviceMonitor
|
|
|
}
|
|
|
for (int i = 0; i < (j == RowCount - 1 ? LastRowCount : CountPerRow); i++)
|
|
|
{
|
|
|
- PictureEditWithText pic = new PictureEditWithText();
|
|
|
- pic.Name = dt.Rows[j * CountPerRow + i]["de_code"].ToString();
|
|
|
- pic.Anchor = AnchorStyles.Left;
|
|
|
- pic.Anchor = AnchorStyles.Top;
|
|
|
- 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;
|
|
|
+ (PanelDeviceStatus.Controls[dt.Rows[j * CountPerRow + i]["de_code"].ToString() + i + j] as PictureEditWithText).Picedit.Image = Properties.Resources.network_offline;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- CommonTipController.SetToolTip(pic.Picedit, "在线");
|
|
|
- pic.Picedit.Image = Properties.Resources.net_connected;
|
|
|
+ (PanelDeviceStatus.Controls[dt.Rows[j * CountPerRow + i]["de_code"].ToString() + i + j] as PictureEditWithText).Picedit.Image = Properties.Resources.net_connected;
|
|
|
}
|
|
|
- pic.Text = dt.Rows[j * CountPerRow + i]["de_code"].ToString();
|
|
|
- pic.Picedit.BorderStyle = BorderStyles.HotFlat;
|
|
|
- pic.Location = new Point((10 + RightPadding) / 2 + 110 * i, 10 + j * 130);
|
|
|
- PanelDeviceStatus.Controls.Add(pic);
|
|
|
}
|
|
|
}
|
|
|
}
|