Pārlūkot izejas kodu

添加滚动条,优化控件展示

章政 7 gadi atpakaļ
vecāks
revīzija
3b79bef3e6

+ 72 - 0
UAS_DeviceMonitor/CustomerControl/PictureEditWithText/PictureEditWithText.Designer.cs

@@ -0,0 +1,72 @@
+namespace UAS_DeviceMonitor.CustomerControl.PictureEditWithText
+{
+    partial class PictureEditWithText
+    {
+        /// <summary> 
+        /// 必需的设计器变量。
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary> 
+        /// 清理所有正在使用的资源。
+        /// </summary>
+        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region 组件设计器生成的代码
+
+        /// <summary> 
+        /// 设计器支持所需的方法 - 不要修改
+        /// 使用代码编辑器修改此方法的内容。
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.UserPictureEdit = new DevExpress.XtraEditors.PictureEdit();
+            this.UserLabelControl = new DevExpress.XtraEditors.LabelControl();
+            ((System.ComponentModel.ISupportInitialize)(this.UserPictureEdit.Properties)).BeginInit();
+            this.SuspendLayout();
+            // 
+            // UserPictureEdit
+            // 
+            this.UserPictureEdit.Location = new System.Drawing.Point(1, 1);
+            this.UserPictureEdit.Name = "UserPictureEdit";
+            this.UserPictureEdit.Properties.ShowCameraMenuItem = DevExpress.XtraEditors.Controls.CameraMenuItemVisibility.Auto;
+            this.UserPictureEdit.Size = new System.Drawing.Size(100, 96);
+            this.UserPictureEdit.TabIndex = 0;
+            // 
+            // UserLabelControl
+            // 
+            this.UserLabelControl.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.Vertical;
+            this.UserLabelControl.Location = new System.Drawing.Point(17, 103);
+            this.UserLabelControl.MaximumSize = new System.Drawing.Size(110, 0);
+            this.UserLabelControl.Name = "UserLabelControl";
+            this.UserLabelControl.Size = new System.Drawing.Size(70, 0);
+            this.UserLabelControl.TabIndex = 1;
+            // 
+            // PictureEditWithText
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.Controls.Add(this.UserLabelControl);
+            this.Controls.Add(this.UserPictureEdit);
+            this.Name = "PictureEditWithText";
+            this.Size = new System.Drawing.Size(102, 129);
+            this.Load += new System.EventHandler(this.PictureEditWithText_Load);
+            ((System.ComponentModel.ISupportInitialize)(this.UserPictureEdit.Properties)).EndInit();
+            this.ResumeLayout(false);
+
+        }
+
+        #endregion
+
+        private DevExpress.XtraEditors.PictureEdit UserPictureEdit;
+        private DevExpress.XtraEditors.LabelControl UserLabelControl;
+    }
+}

+ 52 - 0
UAS_DeviceMonitor/CustomerControl/PictureEditWithText/PictureEditWithText.cs

@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using DevExpress.XtraEditors;
+
+namespace UAS_DeviceMonitor.CustomerControl.PictureEditWithText
+{
+    public partial class PictureEditWithText : XtraUserControl
+    {
+
+        public PictureEdit Picedit
+        {
+            get
+            {
+                return UserPictureEdit;
+            }
+
+            set
+            {
+                UserPictureEdit = value;
+            }
+        }
+
+        public override string Text
+        {
+            get
+            {
+                return UserLabelControl.Text;
+            }
+
+            set
+            {
+                UserLabelControl.Text = value;
+            }
+        }
+
+        public PictureEditWithText()
+        {
+            InitializeComponent();
+        }
+
+        private void PictureEditWithText_Load(object sender, EventArgs e)
+        {
+            UserLabelControl.Location = new Point((Width - UserLabelControl.Width) / 2, UserLabelControl.Location.Y);
+        }
+    }
+}

+ 120 - 0
UAS_DeviceMonitor/CustomerControl/PictureEditWithText/PictureEditWithText.resx

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 12 - 40
UAS_DeviceMonitor/Main.Designer.cs

@@ -35,7 +35,6 @@ namespace UAS_DeviceMonitor
         {
             this.components = new System.ComponentModel.Container();
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main));
-            DevExpress.XtraBars.Ribbon.GalleryItemGroup galleryItemGroup1 = new DevExpress.XtraBars.Ribbon.GalleryItemGroup();
             this.RibbonNav = new DevExpress.XtraBars.Ribbon.RibbonControl();
             this.ButtonDeviceList = new DevExpress.XtraBars.BarButtonItem();
             this.ButtonDeviceNetSetting = new DevExpress.XtraBars.BarButtonItem();
@@ -134,12 +133,11 @@ namespace UAS_DeviceMonitor
             this.pl_dccode = new DevExpress.XtraGrid.Columns.GridColumn();
             this.pl_remark = new DevExpress.XtraGrid.Columns.GridColumn();
             this.PageDeviceStatus = new DevExpress.XtraTab.XtraTabPage();
-            this.GalleryDeviceStatus = new DevExpress.XtraBars.Ribbon.GalleryControl();
-            this.galleryControlClient1 = new DevExpress.XtraBars.Ribbon.GalleryControlClient();
             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.PanelDeviceStatus = new DevExpress.XtraEditors.XtraScrollableControl();
             ((System.ComponentModel.ISupportInitialize)(this.RibbonNav)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.MainTabControl)).BeginInit();
             this.MainTabControl.SuspendLayout();
@@ -166,8 +164,6 @@ namespace UAS_DeviceMonitor
             ((System.ComponentModel.ISupportInitialize)(this.GridPolling)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewPolling)).BeginInit();
             this.PageDeviceStatus.SuspendLayout();
-            ((System.ComponentModel.ISupportInitialize)(this.GalleryDeviceStatus)).BeginInit();
-            this.GalleryDeviceStatus.SuspendLayout();
             this.PageWorkCenterStatus.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.GridWorkCenterStatus)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewWorkCenterStatus)).BeginInit();
@@ -1191,43 +1187,13 @@ namespace UAS_DeviceMonitor
             // 
             // PageDeviceStatus
             // 
-            this.PageDeviceStatus.Controls.Add(this.GalleryDeviceStatus);
+            this.PageDeviceStatus.Controls.Add(this.PanelDeviceStatus);
             this.PageDeviceStatus.Name = "PageDeviceStatus";
             this.PageDeviceStatus.PageVisible = false;
             this.PageDeviceStatus.Size = new System.Drawing.Size(1027, 577);
             this.PageDeviceStatus.Text = "xtraTabPage1";
             this.PageDeviceStatus.VisibleChanged += new System.EventHandler(this.PageDeviceStatus_VisibleChanged);
             // 
-            // GalleryDeviceStatus
-            // 
-            this.GalleryDeviceStatus.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Style3D;
-            this.GalleryDeviceStatus.Controls.Add(this.galleryControlClient1);
-            this.GalleryDeviceStatus.DesignGalleryGroupIndex = 0;
-            this.GalleryDeviceStatus.DesignGalleryItemIndex = 0;
-            this.GalleryDeviceStatus.Dock = System.Windows.Forms.DockStyle.Fill;
-            // 
-            // 
-            // 
-            galleryItemGroup1.Caption = "Group9";
-            galleryItemGroup1.CaptionAlignment = DevExpress.XtraBars.Ribbon.GalleryItemGroupCaptionAlignment.Center;
-            galleryItemGroup1.CaptionControlSize = new System.Drawing.Size(200, 200);
-            galleryItemGroup1.Visible = true;
-            this.GalleryDeviceStatus.Gallery.Groups.AddRange(new DevExpress.XtraBars.Ribbon.GalleryItemGroup[] {
-            galleryItemGroup1});
-            this.GalleryDeviceStatus.Gallery.ImageSize = new System.Drawing.Size(100, 100);
-            this.GalleryDeviceStatus.Gallery.ShowItemText = true;
-            this.GalleryDeviceStatus.Location = new System.Drawing.Point(0, 0);
-            this.GalleryDeviceStatus.Name = "GalleryDeviceStatus";
-            this.GalleryDeviceStatus.Size = new System.Drawing.Size(1027, 577);
-            this.GalleryDeviceStatus.TabIndex = 0;
-            this.GalleryDeviceStatus.Text = "GalleryDeviceStatus";
-            // 
-            // galleryControlClient1
-            // 
-            this.galleryControlClient1.GalleryControl = this.GalleryDeviceStatus;
-            this.galleryControlClient1.Location = new System.Drawing.Point(3, 3);
-            this.galleryControlClient1.Size = new System.Drawing.Size(1004, 571);
-            // 
             // PageWorkCenterStatus
             // 
             this.PageWorkCenterStatus.Controls.Add(this.GridWorkCenterStatus);
@@ -1268,6 +1234,14 @@ namespace UAS_DeviceMonitor
             this.TimerDeviceStatus.Interval = 10000;
             this.TimerDeviceStatus.Tick += new System.EventHandler(this.TimerDeviceStatus_Tick);
             // 
+            // PanelDeviceStatus
+            // 
+            this.PanelDeviceStatus.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.PanelDeviceStatus.Location = new System.Drawing.Point(0, 0);
+            this.PanelDeviceStatus.Name = "PanelDeviceStatus";
+            this.PanelDeviceStatus.Size = new System.Drawing.Size(1027, 577);
+            this.PanelDeviceStatus.TabIndex = 0;
+            // 
             // Main
             // 
             this.AllowFormGlass = DevExpress.Utils.DefaultBoolean.False;
@@ -1282,6 +1256,7 @@ namespace UAS_DeviceMonitor
             this.Ribbon = this.RibbonNav;
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
             this.Text = "设备监控管理平台";
+            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
             this.Load += new System.EventHandler(this.Main_Load);
             ((System.ComponentModel.ISupportInitialize)(this.RibbonNav)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.MainTabControl)).EndInit();
@@ -1310,8 +1285,6 @@ namespace UAS_DeviceMonitor
             ((System.ComponentModel.ISupportInitialize)(this.GridPolling)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewPolling)).EndInit();
             this.PageDeviceStatus.ResumeLayout(false);
-            ((System.ComponentModel.ISupportInitialize)(this.GalleryDeviceStatus)).EndInit();
-            this.GalleryDeviceStatus.ResumeLayout(false);
             this.PageWorkCenterStatus.ResumeLayout(false);
             ((System.ComponentModel.ISupportInitialize)(this.GridWorkCenterStatus)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.GridViewWorkCenterStatus)).EndInit();
@@ -1421,10 +1394,9 @@ namespace UAS_DeviceMonitor
         private DevExpress.XtraGrid.Columns.GridColumn dc_sendcoding;
         private DevExpress.XtraGrid.Columns.GridColumn dc_receivecoding;
         private DevExpress.XtraEditors.Repository.RepositoryItemComboBox CommandSetRepositoryItemComboBox1;
-        private DevExpress.XtraBars.Ribbon.GalleryControl GalleryDeviceStatus;
-        private DevExpress.XtraBars.Ribbon.GalleryControlClient galleryControlClient1;
         private System.Windows.Forms.Timer TimerDeviceStatus;
         private AutoDataGridControl GridWorkCenterStatus;
         private GridViewWithSerialNum GridViewWorkCenterStatus;
+        private XtraScrollableControl PanelDeviceStatus;
     }
 }

+ 34 - 16
UAS_DeviceMonitor/Main.cs

@@ -10,6 +10,10 @@ using System.Collections.Generic;
 using System.Drawing;
 using DevExpress.XtraBars.Ribbon;
 using System.Threading;
+using UAS_DeviceMonitor.CustomerControl.PictureEditWithText;
+using System.Windows.Forms;
+using DevExpress.XtraEditors.Controls;
+using System.Threading.Tasks;
 
 namespace UAS_DeviceMonitor
 {
@@ -26,6 +30,8 @@ namespace UAS_DeviceMonitor
             dh = new DataHelper();
             SystemInf.dh = dh;
             InitializeComponent();
+            PanelDeviceStatus.VerticalScroll.Enabled = true;
+            PanelDeviceStatus.VerticalScroll.Visible = true;
             dpc_enableCheckEdit.QueryCheckStateByValue += CheckedEdit_QueryCheckStateByValue;
             CommandSetRepositoryItemComboBox1.ParseEditValue += CommandSetRepositoryItemComboBox1_ParseEditValue;
             CheckEditCommandSet.QueryCheckStateByValue += CheckedEdit_QueryCheckStateByValue;
@@ -404,25 +410,28 @@ namespace UAS_DeviceMonitor
         //重新展示设备图像界面
         private void ShowDeviceStatus()
         {
-            //清除之前添加的图像
-            for (int i = 0; i < GalleryDeviceStatus.Gallery.Groups.Count; i++)
+            DataTable dt = (DataTable)dh.ExecuteSql("select * 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.VerticalScroll.Enabled = true;
+            for (int i = 0; i < (CountPerRow < dt.Rows.Count ? CountPerRow : dt.Rows.Count); i++)
             {
-                GalleryDeviceStatus.Gallery.Groups[i].Items.Clear();
-            }
-            DataTable dt = (DataTable)dh.ExecuteSql("select * from device left join DEVICEPOLLINGCONFIG on dpc_decode=de_code ", "select");
-            for (int i = 0; i < dt.Rows.Count; i++)
-            {
-                GalleryItem gallery;
-                //判断运行状态,是否
-                if (dt.Rows[i]["dpc_status"].ToString() == "Running")
+                for (int j = 0; j < RowCount; j++)
                 {
-                    gallery = new GalleryItem(Properties.Resources.devicecontrol, dt.Rows[i]["de_name"].ToString(), dt.Rows[i]["de_code"].ToString());
+                    PictureEditWithText pic = new PictureEditWithText();
+                    pic.Anchor = AnchorStyles.Left;
+                    pic.Anchor = AnchorStyles.Top;
+                    if (dt.Rows[i * CountPerRow + j]["dpc_status"].ToString() != "Running")
+                        pic.Picedit.Image = Properties.Resources.close_24px_1069872_easyicon_net;
+                    else
+                        pic.Picedit.Image = Properties.Resources.devicecontrol;
+                    pic.Text = dt.Rows[i * CountPerRow + j]["de_code"].ToString();
+                    pic.Picedit.BorderStyle = BorderStyles.HotFlat;
+                    pic.Location = new Point((10 + RightPadding) / 2 + 110 * i, 10 + j * 130);
+                    PanelDeviceStatus.Controls.Add(pic);
                 }
-                else
-                {
-                    gallery = new GalleryItem(Properties.Resources.close_24px_1069872_easyicon_net, dt.Rows[i]["de_name"].ToString(), dt.Rows[i]["de_code"].ToString());
-                }
-                GalleryDeviceStatus.Gallery.Groups[0].Items.Add(gallery);
             }
         }
 
@@ -431,6 +440,15 @@ namespace UAS_DeviceMonitor
         {
             ShowDeviceStatus();
         }
+
+        private void PanelDeviceStatus_SizeChanged(object sender, EventArgs e)
+        {
+            if (PageDeviceStatus.PageVisible)
+            {
+                ShowDeviceStatus();
+                TimerDeviceStatus.Start();
+            }
+        }
         #endregion
     }
 }

+ 9 - 0
UAS_DeviceMonitor/UAS_DeviceMonitor.csproj

@@ -103,6 +103,12 @@
     <Compile Include="CustomerControl\PagingControl\PageControl.Designer.cs">
       <DependentUpon>PageControl.cs</DependentUpon>
     </Compile>
+    <Compile Include="CustomerControl\PictureEditWithText\PictureEditWithText.cs">
+      <SubType>UserControl</SubType>
+    </Compile>
+    <Compile Include="CustomerControl\PictureEditWithText\PictureEditWithText.Designer.cs">
+      <DependentUpon>PictureEditWithText.cs</DependentUpon>
+    </Compile>
     <Compile Include="DataOperate\ComboBoxData.cs" />
     <Compile Include="DataOperate\DataHelper.cs" />
     <Compile Include="Device\Command\FormNewCommand.cs">
@@ -146,6 +152,9 @@
     <EmbeddedResource Include="CustomerControl\PagingControl\PageControl.resx">
       <DependentUpon>PageControl.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="CustomerControl\PictureEditWithText\PictureEditWithText.resx">
+      <DependentUpon>PictureEditWithText.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="Device\Command\FormNewCommand.resx">
       <DependentUpon>FormNewCommand.cs</DependentUpon>
     </EmbeddedResource>