소스 검색

优化界面按钮

callm 2 주 전
부모
커밋
1ac732f017
4개의 변경된 파일과 65개의 추가작업 그리고 38개의 파일을 삭제
  1. 6 0
      FileWatcher/.workbuddy/memory/2026-10-20.md
  2. 26 13
      FileWatcher/AutoSMTRXY.cs
  3. 25 25
      FileWatcher/AutoSMTRXYSetting.Designer.cs
  4. 8 0
      FileWatcher/AutoSMTRXYSetting.cs

+ 6 - 0
FileWatcher/.workbuddy/memory/2026-10-20.md

@@ -0,0 +1,6 @@
+# 2026-10-20
+
+## AutoSMTRXYSetting 小屏适配
+- 问题:工业小屏(约 768/800 高)上「参数设置」窗口底部被裁,计数方式和确定/关闭按钮不可见。
+- 处理:① 布局再压缩——200% 设计空间下行距 70→60(行 y=20/80/140/.../500),按钮 y=570 高 56,ClientSize 716×650(窗体总高约 730);② AutoSMTRXYSetting_Load 增加 Screen.GetWorkingArea 检测,窗口超出工作区时按比例整体 Scale 缩小,保证任何分辨率下按钮可见。
+- 注意:勿用 VS 设计器拖该窗体,高 DPI 下会再次×2 序列化坐标。

+ 26 - 13
FileWatcher/AutoSMTRXY.cs

@@ -144,16 +144,22 @@ namespace FileWatcher
                     int ma_qty = int.Parse(dt.Rows[0]["ma_qty"].ToString());
                     if (MHC_QTY >= ma_qty)
                     {
-                        OperateResult write = plc.Write(Stop, 1);
-                        if (write.IsSuccess)
+                        if (Stop != "")
                         {
-                            OperateResult.AppendText("通过,发送指令" + Stop + "写入1\n");
-                            OperateResult.ScrollToCaret();
+                            OperateResult write = plc.Write(Stop, 1);
+                            if (write.IsSuccess)
+                            {
+                                OperateResult.AppendText("通过,发送指令" + Stop + "写入1\n");
+                                OperateResult.ScrollToCaret();
+                            }
+                            else
+                            {
+                                OperateResult.AppendText("写入失败\n");
+                                OperateResult.ScrollToCaret();
+                            }
                         }
-                        else
-                        {
-                            OperateResult.AppendText("写入失败\n");
-                            OperateResult.ScrollToCaret();
+                        else {
+                            OperateResult.AppendText("写入失败,未维护参数\n");
                         }
                     }
                 }
@@ -236,7 +242,7 @@ namespace FileWatcher
                 }
                 if (dt.Rows.Count > 0)
                 {
-                    if (plc != null)
+                    if (plc != null && Stop != "")
                     {
                         OperateResult write = plc.Write(Stop, 1);
                         if (write.IsSuccess)
@@ -660,14 +666,21 @@ namespace FileWatcher
 
         private void Start_Click(object sender, EventArgs e)
         {
-            OperateResult write = plc.Write(Stop, 0);
-            if (write.IsSuccess)
+            if (Stop != "")
             {
-                OperateResult.AppendText("通过,发送指令" + Stop + "写入0\n");
+                OperateResult write = plc.Write(Stop, 0);
+                if (write.IsSuccess)
+                {
+                    OperateResult.AppendText("通过,发送指令" + Stop + "写入0\n");
+                }
+                else
+                {
+                    OperateResult.AppendText("写入失败\n");
+                }
             }
             else
             {
-                OperateResult.AppendText("写入失败\n");
+                OperateResult.AppendText("写入失败,未维护参数\n");
             }
         }
     }

+ 25 - 25
FileWatcher/AutoSMTRXYSetting.Designer.cs

@@ -53,7 +53,7 @@
             // label3
             // 
             this.label3.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label3.Location = new System.Drawing.Point(60, 40);
+            this.label3.Location = new System.Drawing.Point(60, 20);
             this.label3.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.label3.Name = "label3";
             this.label3.Size = new System.Drawing.Size(280, 46);
@@ -64,7 +64,7 @@
             // Password
             // 
             this.Password.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Password.Location = new System.Drawing.Point(356, 40);
+            this.Password.Location = new System.Drawing.Point(356, 20);
             this.Password.Margin = new System.Windows.Forms.Padding(8, 6, 8, 6);
             this.Password.Name = "Password";
             this.Password.PasswordChar = '*';
@@ -74,10 +74,10 @@
             // ComPort_label
             // 
             this.ComPort_label.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ComPort_label.Location = new System.Drawing.Point(60, 110);
+            this.ComPort_label.Location = new System.Drawing.Point(60, 80);
             this.ComPort_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.ComPort_label.Name = "ComPort_label";
-            this.ComPort_label.Size = new System.Drawing.Size(280, 70);
+            this.ComPort_label.Size = new System.Drawing.Size(280, 50);
             this.ComPort_label.TabIndex = 2;
             this.ComPort_label.Text = "串口";
             this.ComPort_label.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
@@ -85,16 +85,16 @@
             // ComPort
             // 
             this.ComPort.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ComPort.Location = new System.Drawing.Point(356, 110);
+            this.ComPort.Location = new System.Drawing.Point(356, 80);
             this.ComPort.Margin = new System.Windows.Forms.Padding(8, 10, 8, 10);
             this.ComPort.Name = "ComPort";
-            this.ComPort.Size = new System.Drawing.Size(300, 70);
+            this.ComPort.Size = new System.Drawing.Size(300, 50);
             this.ComPort.TabIndex = 3;
             // 
             // BaudRate_label
             // 
             this.BaudRate_label.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.BaudRate_label.Location = new System.Drawing.Point(60, 200);
+            this.BaudRate_label.Location = new System.Drawing.Point(60, 140);
             this.BaudRate_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.BaudRate_label.Name = "BaudRate_label";
             this.BaudRate_label.Size = new System.Drawing.Size(280, 46);
@@ -105,7 +105,7 @@
             // BaudRate
             // 
             this.BaudRate.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.BaudRate.Location = new System.Drawing.Point(356, 200);
+            this.BaudRate.Location = new System.Drawing.Point(356, 140);
             this.BaudRate.Margin = new System.Windows.Forms.Padding(8, 6, 8, 6);
             this.BaudRate.Name = "BaudRate";
             this.BaudRate.Size = new System.Drawing.Size(300, 46);
@@ -115,7 +115,7 @@
             // Read_label
             // 
             this.Read_label.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Read_label.Location = new System.Drawing.Point(60, 270);
+            this.Read_label.Location = new System.Drawing.Point(60, 200);
             this.Read_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.Read_label.Name = "Read_label";
             this.Read_label.Size = new System.Drawing.Size(280, 46);
@@ -126,7 +126,7 @@
             // Read
             // 
             this.Read.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Read.Location = new System.Drawing.Point(356, 270);
+            this.Read.Location = new System.Drawing.Point(356, 200);
             this.Read.Margin = new System.Windows.Forms.Padding(8, 6, 8, 6);
             this.Read.Name = "Read";
             this.Read.Size = new System.Drawing.Size(300, 46);
@@ -135,7 +135,7 @@
             // ToZero_label
             // 
             this.ToZero_label.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ToZero_label.Location = new System.Drawing.Point(60, 340);
+            this.ToZero_label.Location = new System.Drawing.Point(60, 260);
             this.ToZero_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.ToZero_label.Name = "ToZero_label";
             this.ToZero_label.Size = new System.Drawing.Size(280, 46);
@@ -146,7 +146,7 @@
             // ToZero
             // 
             this.ToZero.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ToZero.Location = new System.Drawing.Point(356, 340);
+            this.ToZero.Location = new System.Drawing.Point(356, 260);
             this.ToZero.Margin = new System.Windows.Forms.Padding(8, 6, 8, 6);
             this.ToZero.Name = "ToZero";
             this.ToZero.Size = new System.Drawing.Size(300, 46);
@@ -155,7 +155,7 @@
             // label6
             // 
             this.label6.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label6.Location = new System.Drawing.Point(60, 410);
+            this.label6.Location = new System.Drawing.Point(60, 320);
             this.label6.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.label6.Name = "label6";
             this.label6.Size = new System.Drawing.Size(280, 46);
@@ -166,7 +166,7 @@
             // Stop
             // 
             this.Stop.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Stop.Location = new System.Drawing.Point(356, 410);
+            this.Stop.Location = new System.Drawing.Point(356, 320);
             this.Stop.Margin = new System.Windows.Forms.Padding(8, 6, 8, 6);
             this.Stop.Name = "Stop";
             this.Stop.Size = new System.Drawing.Size(300, 46);
@@ -175,7 +175,7 @@
             // UseScan_label
             // 
             this.UseScan_label.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.UseScan_label.Location = new System.Drawing.Point(60, 480);
+            this.UseScan_label.Location = new System.Drawing.Point(60, 380);
             this.UseScan_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.UseScan_label.Name = "UseScan_label";
             this.UseScan_label.Size = new System.Drawing.Size(280, 46);
@@ -186,7 +186,7 @@
             // UseScan
             // 
             this.UseScan.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.UseScan.Location = new System.Drawing.Point(356, 480);
+            this.UseScan.Location = new System.Drawing.Point(356, 380);
             this.UseScan.Margin = new System.Windows.Forms.Padding(8, 6, 8, 6);
             this.UseScan.Name = "UseScan";
             this.UseScan.Size = new System.Drawing.Size(300, 46);
@@ -195,7 +195,7 @@
             // Write_label
             // 
             this.Write_label.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Write_label.Location = new System.Drawing.Point(60, 550);
+            this.Write_label.Location = new System.Drawing.Point(60, 440);
             this.Write_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.Write_label.Name = "Write_label";
             this.Write_label.Size = new System.Drawing.Size(280, 46);
@@ -206,7 +206,7 @@
             // Write
             // 
             this.Write.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Write.Location = new System.Drawing.Point(356, 550);
+            this.Write.Location = new System.Drawing.Point(356, 440);
             this.Write.Margin = new System.Windows.Forms.Padding(8, 6, 8, 6);
             this.Write.Name = "Write";
             this.Write.Size = new System.Drawing.Size(300, 46);
@@ -215,7 +215,7 @@
             // CountType_label
             // 
             this.CountType_label.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.CountType_label.Location = new System.Drawing.Point(60, 620);
+            this.CountType_label.Location = new System.Drawing.Point(60, 500);
             this.CountType_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.CountType_label.Name = "CountType_label";
             this.CountType_label.Size = new System.Drawing.Size(280, 46);
@@ -231,7 +231,7 @@
             this.CountType.Items.AddRange(new object[] {
             "PLC",
             "计数器"});
-            this.CountType.Location = new System.Drawing.Point(356, 620);
+            this.CountType.Location = new System.Drawing.Point(356, 500);
             this.CountType.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
             this.CountType.Name = "CountType";
             this.CountType.Size = new System.Drawing.Size(300, 46);
@@ -240,10 +240,10 @@
             // Confirm
             // 
             this.Confirm.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Confirm.Location = new System.Drawing.Point(118, 700);
+            this.Confirm.Location = new System.Drawing.Point(118, 570);
             this.Confirm.Margin = new System.Windows.Forms.Padding(8, 6, 8, 6);
             this.Confirm.Name = "Confirm";
-            this.Confirm.Size = new System.Drawing.Size(224, 70);
+            this.Confirm.Size = new System.Drawing.Size(224, 56);
             this.Confirm.TabIndex = 18;
             this.Confirm.Text = "确定";
             this.Confirm.UseVisualStyleBackColor = true;
@@ -252,10 +252,10 @@
             // Cancel
             // 
             this.Cancel.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Cancel.Location = new System.Drawing.Point(374, 700);
+            this.Cancel.Location = new System.Drawing.Point(374, 570);
             this.Cancel.Margin = new System.Windows.Forms.Padding(8, 6, 8, 6);
             this.Cancel.Name = "Cancel";
-            this.Cancel.Size = new System.Drawing.Size(224, 70);
+            this.Cancel.Size = new System.Drawing.Size(224, 56);
             this.Cancel.TabIndex = 19;
             this.Cancel.Text = "关闭";
             this.Cancel.UseVisualStyleBackColor = true;
@@ -265,7 +265,7 @@
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(716, 808);
+            this.ClientSize = new System.Drawing.Size(716, 650);
             this.Controls.Add(this.label3);
             this.Controls.Add(this.Password);
             this.Controls.Add(this.ComPort_label);

+ 8 - 0
FileWatcher/AutoSMTRXYSetting.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Drawing;
 using System.Windows.Forms;
 
 namespace FileWatcher
@@ -23,6 +24,13 @@ namespace FileWatcher
 
         private void AutoSMTRXYSetting_Load(object sender, EventArgs e)
         {
+            //低分辨率屏幕下若窗口超出可视区域,则整体等比缩小,保证按钮完整可见
+            Rectangle workArea = Screen.GetWorkingArea(this);
+            if (this.Height > workArea.Height || this.Width > workArea.Width)
+            {
+                float scale = Math.Min((float)workArea.Width / this.Width, (float)workArea.Height / this.Height);
+                this.Scale(new SizeF(scale, scale));
+            }
             ComPort.Text = GetCacheString("ComPort");
             BaudRate.Text = GetCacheString("BaudRate");
             Read.Text = GetCacheString("Read");