From 3a127d0e3be57f883b550dd015577adc7db316bc Mon Sep 17 00:00:00 2001 From: jasonchenwork Date: Tue, 8 Apr 2025 10:08:41 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=81=E5=AE=A2=E7=95=AB=E9=9D=A2(=E5=8B=95?= =?UTF-8?q?=E6=85=8B=E8=AA=BF=E6=95=B4=E4=BD=8D=E7=BD=AE/=E9=9A=B1?= =?UTF-8?q?=E8=97=8F=E6=8C=89=E9=88=95)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 +- PrimaryFormParts/PrimaryForm.cs | 74 +++++++++++++++++++-------------- 2 files changed, 43 insertions(+), 35 deletions(-) diff --git a/.gitignore b/.gitignore index 0d27799..7455977 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,4 @@ Superstar_log.ldf .vs build.bat *.exe -bin/logfile.txt -bin/secondary_graph.grf -bin/themes/superstar/_www/* \ No newline at end of file +bin/* diff --git a/PrimaryFormParts/PrimaryForm.cs b/PrimaryFormParts/PrimaryForm.cs index 34f159d..769641e 100644 --- a/PrimaryFormParts/PrimaryForm.cs +++ b/PrimaryFormParts/PrimaryForm.cs @@ -291,7 +291,6 @@ namespace DualScreenDemo private Dictionary initialControlPositions = new Dictionary(); private Panel sendOffPanel; - private PictureBox sendOffPictureBox; private static Bitmap normalStateImageHotSong; private static Bitmap mouseDownImageHotSong; @@ -3404,26 +3403,18 @@ public class MultiPagePanel : Panel sendOffPanel = new Panel { Dock = DockStyle.Fill, - BackColor = Color.Black, - Visible = false - }; - - sendOffPictureBox = new PictureBox - { - Dock = DockStyle.Fill, - SizeMode = PictureBoxSizeMode.StretchImage, - Image = LoadSendOffImage() + //BackColor = Color.Black, + BackgroundImage = LoadSendOffImage(), + BackgroundImageLayout = ImageLayout.Stretch }; // 初始化服務鈴圖標 serviceBellPictureBox = new PictureBox { Visible = true, - Size = new Size(410, 130), // 调整为更大的尺寸 BackColor = Color.Transparent, SizeMode = PictureBoxSizeMode.StretchImage, Image = LoadButtonImage("服務鈴.png"), Cursor = System.Windows.Forms.Cursors.Hand, - Location = new Point(757, 151) // 调整位置到顶部 }; // 添加服務鈴點擊事件 @@ -3437,47 +3428,39 @@ public class MultiPagePanel : Panel // 使用 PictureBox 並加載小圖片 buttonMiddle = new PictureBox { Visible = true, - Size = new Size(80, 80), // 稍微縮小一點 BackColor = Color.Transparent, SizeMode = PictureBoxSizeMode.StretchImage, - Image = LoadButtonImage("巨.png"), + Image = null,//LoadButtonImage("巨.png") Cursor = System.Windows.Forms.Cursors.Hand }; buttonTopRight = new PictureBox { Visible = true, - Size = new Size(80, 80), BackColor = Color.Transparent, SizeMode = PictureBoxSizeMode.StretchImage, - Image = LoadButtonImage("級.png"), + Image = null, //LoadButtonImage("級.png") Cursor = System.Windows.Forms.Cursors.Hand }; buttonTopLeft = new PictureBox { Visible = true, - Size = new Size(150, 150), - BackColor = Color.FromArgb(255, 150, 180), + BackColor = Color.Transparent, SizeMode = PictureBoxSizeMode.StretchImage, - Image = LoadButtonImage("超.png"), + Image = null, //LoadButtonImage("超.png") Cursor = System.Windows.Forms.Cursors.Hand }; buttonThanks = new PictureBox { Visible = true, - Size = new Size(150, 150), - BackColor = Color.FromArgb(255, 150, 180), + BackColor = Color.Transparent, SizeMode = PictureBoxSizeMode.StretchImage, - Image = LoadButtonImage("星.png"), + Image = null, //LoadButtonImage("星.png") Cursor = System.Windows.Forms.Cursors.Hand }; - - - buttonTopLeft.Location = new Point(1598,490 ); // 右下 - buttonTopRight.Location = new Point(Screen.PrimaryScreen.Bounds.Width - 80, 0); // 右上 - buttonMiddle.Location = new Point(0,0); //左上 - buttonThanks.Location = new Point(831,490); - + // 設定按鈕的初始位置和大小 + UpdateSendOffButtonPositions(); + // 添加點擊事件 buttonMiddle.Click += buttonMiddle_Click; buttonTopRight.Click += buttonTopRight_Click; @@ -3485,7 +3468,6 @@ public class MultiPagePanel : Panel buttonThanks.Click += buttonThanks_Click; // 添加控件到面板 - sendOffPanel.Controls.Add(sendOffPictureBox); sendOffPanel.Controls.Add(serviceBellPictureBox); // 添加服務鈴 sendOffPanel.Controls.Add(buttonMiddle); sendOffPanel.Controls.Add(buttonTopRight); @@ -3498,9 +3480,37 @@ public class MultiPagePanel : Panel buttonTopRight.BringToFront(); buttonTopLeft.BringToFront(); buttonThanks.BringToFront(); - + sendOffPanel.Resize += (s, e) => UpdateSendOffButtonPositions(); this.Controls.Add(sendOffPanel); } + /// + /// 動態按鈕座標位置設定(依據螢幕大小) + /// + private void UpdateSendOffButtonPositions() + { Size designSize = new Size(1920, 1080); + var panelWidth = sendOffPanel.Width; + var panelHeight = sendOffPanel.Height; + + // 計算寬高的縮放比例 + float scaleX = panelWidth / (float)designSize.Width; + float scaleY = panelHeight / (float)designSize.Height; + + // 幫你設定的按鈕位置(以原始座標為基礎) + buttonTopLeft.Location = new Point((int)(1598 * scaleX), (int)(490 * scaleY)); + buttonTopRight.Location = new Point(panelWidth - (int)(80 * scaleX), 0); + buttonMiddle.Location = new Point(0, 0); + buttonThanks.Location = new Point((int)(831 * scaleX), (int)(490 * scaleY)); + + // 設定按鈕縮放後的大小(原始尺寸 * 縮放比例) + buttonTopLeft.Size = new Size((int)(150 * scaleX), (int)(150 * scaleY)); + buttonTopRight.Size = new Size((int)(80 * scaleX), (int)(80 * scaleY)); + buttonMiddle.Size = new Size((int)(80 * scaleX), (int)(80 * scaleY)); + buttonThanks.Size = new Size((int)(150 * scaleX), (int)(150 * scaleY)); + + // ========== 服務鈴位置與大小 ========== + serviceBellPictureBox.Location = new Point((int)(757 * scaleX), (int)(151 * scaleY)); + serviceBellPictureBox.Size = new Size((int)(410 * scaleX), (int)(130 * scaleY)); + } // 添加載入按鈕圖片的方法 private Image LoadButtonImage(string imageName) @@ -3528,7 +3538,7 @@ public class MultiPagePanel : Panel { try { - string filePath = Path.Combine(Application.StartupPath, "VOD_送客畫面.jpg"); + string filePath = Path.Combine(Application.StartupPath, "themes\\superstar\\VOD_送客畫面.jpg"); if (File.Exists(filePath)) { return Image.FromFile(filePath);