送客畫面修改

This commit is contained in:
jasonchenwork 2025-04-08 11:34:46 +08:00
parent 9b7907c837
commit 39a30dc4fa

View File

@ -3406,26 +3406,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) // 调整位置到顶部
};
// 添加服務鈴點擊事件
@ -3439,47 +3431,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;
@ -3487,23 +3471,84 @@ public class MultiPagePanel : Panel
buttonThanks.Click += buttonThanks_Click;
// 添加控件到面板
sendOffPanel.Controls.Add(sendOffPictureBox);
sendOffPanel.Controls.Add(serviceBellPictureBox); // 添加服務鈴
sendOffPanel.Controls.Add(buttonMiddle);
sendOffPanel.Controls.Add(buttonTopRight);
sendOffPanel.Controls.Add(buttonTopLeft);
sendOffPanel.Controls.Add(buttonThanks);
// 包廂名稱顯示
sendOffPanel.Paint+=SendOffPanel_Paint;
// 確保圖片在最上層
serviceBellPictureBox.BringToFront(); // 確保服務鈴在最上層
buttonMiddle.BringToFront();
buttonTopRight.BringToFront();
buttonTopLeft.BringToFront();
buttonThanks.BringToFront();
// 重新計算按鈕位置
sendOffPanel.Resize += (s, e) => {
UpdateSendOffButtonPositions();
sendOffPanel.Invalidate(); // 重新繪製面板以更新顯示
};
this.Controls.Add(sendOffPanel);
}
/// <summary>
/// 動態按鈕座標位置設定(依據螢幕大小)
/// </summary>
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));
}
/// <summary>
/// 送客畫面包廂名稱顯示
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SendOffPanel_Paint(object sender, PaintEventArgs e)
{
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;
float scaledFontSize = 84f * scaleY;
string hostName = System.Net.Dns.GetHostName();
string displayName = "包廂" + hostName.Substring(Math.Max(0, hostName.Length - 20));
using (Font font = new Font("微軟正黑體", scaledFontSize, FontStyle.Bold))
using (Brush brush = new SolidBrush(Color.Red))
{
PointF point_PCName = new PointF(820 * scaleX, 325 * scaleY);
e.Graphics.DrawString(displayName, font, brush, point_PCName);
}
}
// 添加載入按鈕圖片的方法
private Image LoadButtonImage(string imageName)
{