Sfoglia il codice sorgente

调用about,可移动界面

cxs 1 anno fa
parent
commit
6186a7bebd

+ 1 - 0
OTSIncAMeasureApp/10-OTSSplashScreen/OTSSplashScreen_Cleanness.Designer.cs

@@ -204,6 +204,7 @@ namespace OTSMeasureApp._10_OTSSplashScreen
             this.Text = "OTSSplashScreen";
             this.TopMost = true;
             this.Load += new System.EventHandler(this.OTSSplashScreen_Load);
+            this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OTSSplashScreen_Cleanness_MouseDown);
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
             this.ResumeLayout(false);

+ 18 - 15
OTSIncAMeasureApp/10-OTSSplashScreen/OTSSplashScreen_Cleanness.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Drawing;
+using System.Runtime.InteropServices;
 using System.Windows.Forms;
 using System.Xml;
 
@@ -7,7 +8,17 @@ namespace OTSMeasureApp._10_OTSSplashScreen
 {
     public partial class OTSSplashScreen_Cleanness : Form
     {
+        #region 使窗体可以移动的代码
+        [DllImport("user32.dll")]
+        public static extern bool ReleaseCapture();
+        [DllImport("user32.dll")]
+        public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int IParam);
+        public const int WM_SYSCOMMAND = 0x0112;
+        public const int SC_MOVE = 0xF010;
+        public const int HTCAPTION = 0x0002; 
 
+
+#endregion
         public OTSSplashScreen_Cleanness()
         {
             InitializeComponent();
@@ -36,22 +47,14 @@ namespace OTSMeasureApp._10_OTSSplashScreen
             this.Close();
         }
 
-        string ReadSysTypeByXml()
+        
+        private void OTSSplashScreen_Cleanness_MouseDown(object sender, MouseEventArgs e)
         {
-            string path = @".\Config\SysData\OTSProgMgrParam.pmf";
-            try
-            {
-                XmlDocument xmlDocument = new XmlDocument();
-                xmlDocument.Load(path);
-                XmlNode node = xmlDocument.SelectSingleNode("XMLData");
-
-                XmlElement xe = (XmlElement)node;
-                return xe.GetAttribute("SysType");
-            }
-            catch /*(Exception ex)*/
-            {
-                return null;
-            }
+            //拖动窗体
+            this.Cursor = System.Windows.Forms.Cursors.Hand;//改变鼠标样式
+            ReleaseCapture();
+            SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
+            this.Cursor = System.Windows.Forms.Cursors.Default;
         }
     }
 }

+ 3 - 2
OTSIncAMeasureApp/10-OTSSplashScreen/OTSSplashScreen_IncA.Designer.cs

@@ -158,7 +158,7 @@ namespace OTSMeasureApp._10_OTSSplashScreen
             this.label5.TabIndex = 10;
             this.label5.Text = "Opton Copyright © 2024";
             // 
-            // OTSSplashScreen
+            // OTSSplashScreen_IncA
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
@@ -180,13 +180,14 @@ namespace OTSMeasureApp._10_OTSSplashScreen
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
             this.MaximizeBox = false;
             this.MinimizeBox = false;
-            this.Name = "OTSSplashScreen";
+            this.Name = "OTSSplashScreen_IncA";
             this.ShowIcon = false;
             this.ShowInTaskbar = false;
             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
             this.Text = "OTSSplashScreen";
             this.TopMost = true;
             this.Load += new System.EventHandler(this.OTSSplashScreen_Load);
+            this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.OTSSplashScreen_IncA_MouseDown);
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
             this.ResumeLayout(false);

+ 18 - 24
OTSIncAMeasureApp/10-OTSSplashScreen/OTSSplashScreen_IncA.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Drawing;
+using System.Runtime.InteropServices;
 using System.Windows.Forms;
 using System.Xml;
 
@@ -7,6 +8,16 @@ namespace OTSMeasureApp._10_OTSSplashScreen
 {
     public partial class OTSSplashScreen_IncA : Form
     {
+        #region 使窗体可以移动的代码
+        [DllImport("user32.dll")]
+        public static extern bool ReleaseCapture();
+        [DllImport("user32.dll")]
+        public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int IParam);
+        public const int WM_SYSCOMMAND = 0x0112;
+        public const int SC_MOVE = 0xF010;
+        public const int HTCAPTION = 0x0002; 
+        
+        #endregion
 
         public OTSSplashScreen_IncA()
         {
@@ -17,15 +28,6 @@ namespace OTSMeasureApp._10_OTSSplashScreen
         {
 
 
-            string str = ReadSysTypeByXml();
-            if (str == "IncA")
-            {
-                this.BackgroundImage = Properties.Resources.OTSIncA;
-            }
-            else if (str == "CleannessA")
-            {
-                this.BackgroundImage = Properties.Resources.Cleanliness;
-            }
         }
 
         private void label2_Click(object sender, EventArgs e)
@@ -44,22 +46,14 @@ namespace OTSMeasureApp._10_OTSSplashScreen
             this.Close();
         }
 
-        string ReadSysTypeByXml()
+        
+        private void OTSSplashScreen_IncA_MouseDown(object sender, MouseEventArgs e)
         {
-            string path = @".\Config\SysData\OTSProgMgrParam.pmf";
-            try
-            {
-                XmlDocument xmlDocument = new XmlDocument();
-                xmlDocument.Load(path);
-                XmlNode node = xmlDocument.SelectSingleNode("XMLData");
-
-                XmlElement xe = (XmlElement)node;
-                return xe.GetAttribute("SysType");
-            }
-            catch /*(Exception ex)*/
-            {
-                return null;
-            }
+            //拖动窗体
+            this.Cursor = System.Windows.Forms.Cursors.Hand;//改变鼠标样式
+            ReleaseCapture();
+            SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
+            this.Cursor = System.Windows.Forms.Cursors.Default;
         }
     }
 }

+ 2 - 0
OTSIncAMeasureApp/OTSIncAMeasureAppForm.cs

@@ -1279,6 +1279,7 @@ namespace OTSMeasureApp
             {
                 OTSSplashScreen_IncA m_about = new OTSSplashScreen_IncA();
                 m_about.TopMost = false;
+                m_about.ShowInTaskbar = true;
                 m_about.Show();
             }
             else if (m_ProjParam.GetDefaultParam().SystemTypeId == OTS_SysType_ID.CleannessA)
@@ -1287,6 +1288,7 @@ namespace OTSMeasureApp
 
 
                 m_about.TopMost = false;
+                m_about.ShowInTaskbar = true;
                 m_about.Show();
             }