From 0f8f046d23efc73146a5245d3edc55285c3219b1 Mon Sep 17 00:00:00 2001
From: lg <123456>
Date: 星期三, 24 十二月 2025 11:00:20 +0800
Subject: [PATCH] 条码交易加上汇总

---
 DevApp/Gs.DevApp/UserControl/Toast.cs |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/DevApp/Gs.DevApp/UserControl/Toast.cs b/DevApp/Gs.DevApp/UserControl/Toast.cs
index 7513510..15d856e 100644
--- a/DevApp/Gs.DevApp/UserControl/Toast.cs
+++ b/DevApp/Gs.DevApp/UserControl/Toast.cs
@@ -19,10 +19,24 @@
         public Toast(int it, string messageText, int vanishingSeconds = 5)
         {
             InitializeComponent();
-            messageText=messageText.Replace("@n", "\r\n");
+            this.StartPosition = FormStartPosition.CenterScreen; // 璁剧疆绐椾綋灞呬腑鏄剧ず
+            this.AutoScaleMode = AutoScaleMode.Font; // 鏍规嵁绯荤粺瀛椾綋澶у皬
+            int clientWidth=0;
+            int clientHeight = 0;
             this.lbMsg.BackColor = System.Drawing.Color.Firebrick;
             this.lbMsg.Font = new System.Drawing.Font("Tahoma", 38F);
             this.lbMsg.ForeColor = System.Drawing.Color.White;
+            messageText = messageText.Replace("@n", "\r\n");
+            using (Graphics graphics = this.CreateGraphics())
+            {
+                Size textSize = TextRenderer.MeasureText(messageText, lbMsg.Font);
+                clientWidth = (int)textSize.Width + 10;
+                clientHeight= (int)textSize.Height+10;
+            }
+            this.ClientSize = new System.Drawing.Size(clientWidth, clientHeight);
+            this.StartPosition = FormStartPosition.CenterScreen; // 璁剧疆绐椾綋灞呬腑鏄剧ず
+            this.AutoScaleMode = AutoScaleMode.Font; // 鏍规嵁绯荤粺瀛椾綋澶у皬
+            this.CenterToScreen();
             try
             {
                 string _vanishingSeconds = ConfigurationManager.AppSettings["ToastSeconds"];
@@ -70,6 +84,6 @@
             tmr2.Interval = (int)TimeSpan.FromMilliseconds(50).TotalMilliseconds;
             tmr2.Start();
         }
- 
+
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3