2364 lines
96 KiB
C#
Raw Normal View History

2025-04-07 16:54:10 +08:00
using System.IO;
using System.Runtime.InteropServices;
using NAudio.Wave;
using Microsoft.Ink;
using System.Text.RegularExpressions;
2025-04-07 16:54:10 +08:00
using DBObj;
using OverlayFormObj;
using Timer = System.Windows.Forms.Timer;
2025-08-06 17:21:45 +08:00
using IniParser.Model;
using IniParser;
using System.Text;
2025-04-07 16:54:10 +08:00
2025-08-07 18:32:08 +08:00
2025-04-07 16:54:10 +08:00
namespace DualScreenDemo
{
public partial class PrimaryForm : Form
{
#region
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000;
return cp;
}
}
#endregion
public static PrimaryForm Instance { get; private set; }
public bool isOnOrderedSongsPage = false;
private ProgressBar progressBar;
private PictureBox pictureBox1;
private PictureBox pictureBox2;
private PictureBox pictureBox3;
private PictureBox pictureBox4;
private PictureBox pictureBox5;
private PictureBox pictureBox6;
private PictureBox pictureBoxArtistSearch;
private Button singerSearchButton;
private Bitmap singerSearchNormalBackground;
private Bitmap singerSearchActiveBackground;
private Button songSearchButton;
private Bitmap songSearchNormalBackground;
private Bitmap songSearchActiveBackground;
private Button serviceBellButton;
private Button deliciousFoodButton;
private Bitmap deliciousFoodNormalBackground;
private Bitmap deliciousFoodActiveBackground;
private Button mobileSongRequestButton;
private Button qieGeButton;
private Button musicUpButton;
private Button musicDownButton;
private Button micUpButton;
private Button micDownButton;
private Button originalSongButton;
private Button replayButton;
public Button pauseButton;
public Button playButton;
private Button muteButton;
private Button maleKeyButton;
private Button femaleKeyButton;
private Button standardKeyButton;
private Button soundEffectButton;
private Button pitchUpButton;
private Button pitchDownButton;
private Button syncScreenButton;
private Button toggleLightButton;
private PictureBox promotionsPictureBox;
private List<Image> promotions;
private List<Image> menu;
private PictureBox VodScreenPictureBox;
private Panel overlayPanel;
private Button btnPreviousPage;
private Button btnReturn;
private Button btnNextPage;
private Button btnApplause;
private Button btnSimplifiedChinese;
private Button btnTraditionalChinese;
private Button exitButton;
//private static Bitmap normalStateImage;
//private static Bitmap mouseOverImage;
//private static Bitmap mouseDownImage;
//private static Bitmap resizedNormalStateImage;
//private static Bitmap resizedMouseOverImage;
//private static Bitmap resizedMouseDownImage;
//private static Bitmap normalStateImageNewSongAlert;
//private static Bitmap mouseOverImageNewSongAlert;
//private static Bitmap mouseDownImageNewSongAlert;
//private static Bitmap resizedNormalStateImageForNewSongAlert;
//private static Bitmap resizedMouseOverImageForNewSongAlert;
//private static Bitmap resizedMouseDownImageForNewSongAlert;
//private static Bitmap normalStateImageArtistQuery;
//private static Bitmap mouseOverImageArtistQuery;
//private static Bitmap mouseDownImageArtistQuery;
//private static Bitmap resizedNormalStateImageForArtistQuery;
//private static Bitmap resizedMouseOverImageForArtistQuery;
//private static Bitmap resizedMouseDownImageForArtistQuery;
//private static Bitmap normalStateImageSongQuery;
//private static Bitmap mouseOverImageSongQuery;
//private static Bitmap mouseDownImageSongQuery;
//private static Bitmap resizedNormalStateImageForSongQuery;
//private static Bitmap resizedMouseOverImageForSongQuery;
//private static Bitmap resizedMouseDownImageForSongQuery;
//private static Bitmap normalStateImageLanguageQuery;
//private static Bitmap mouseOverImageLanguageQuery;
//private static Bitmap mouseDownImageLanguageQuery;
//private static Bitmap resizedNormalStateImageForLanguageQuery;
//private static Bitmap resizedMouseOverImageForLanguageQuery;
//private static Bitmap resizedMouseDownImageForLanguageQuery;
//private static Bitmap normalStateImageCategoryQuery;
//private static Bitmap mouseOverImageCategoryQuery;
//private static Bitmap mouseDownImageCategoryQuery;
//private static Bitmap resizedNormalStateImageForCategoryQuery;
//private static Bitmap resizedMouseOverImageForCategoryQuery;
//private static Bitmap resizedMouseDownImageForCategoryQuery;
//private static Bitmap normalStateImageForPromotionsAndMenu;
//private static Bitmap resizedNormalStateImageForPromotionsAndMenu;
//private static Bitmap normalStateImageForSyncScreen;
//private static Bitmap resizedNormalStateImageForSyncScreen;
//private static Bitmap normalStateImageForSceneSoundEffects;
//private static Bitmap resizedNormalStateImageForSceneSoundEffects;
//private static Bitmap normalStateImageForLightControl;
//private static Bitmap resizedNormalStateImageForLightControl;
2025-04-07 16:54:10 +08:00
public VideoPlayerForm videoPlayerForm;
public List<Artist> currentArtistList;
public MultiPagePanel multiPagePanel;
private List<Label> songLabels = new List<Label>();
private int _currentPage { get; set; } = 0;
2025-04-07 16:54:10 +08:00
private int _totalPages { get; set; }
2025-08-07 13:09:10 +08:00
string serverPath = Utils.Env.GetPath("", "");
public int currentPage
{
2025-04-07 16:54:10 +08:00
get { return _currentPage; }
set { _currentPage = value; }
}
public int totalPages
{
get { return _totalPages; }
set { _totalPages = value; }
}
private void HandlePageChanged()
{
this.Invalidate(); // 重新繪製界面
}
public const int itemsPerPage = 18;
private WaveInEvent waveIn;
private WaveFileWriter waveWriter;
2025-04-07 16:54:10 +08:00
private const int PanelStartLeft = 25; // 修改為實際需要的左邊距
private const int PanelStartTop = 227; // 修改為實際需要的上邊距
private const int PanelEndLeft = 1175; // 修改為實際需要的右邊界
private const int PanelEndTop = 739; // 修改為實際需要的下邊界
private Timer lightControlTimer;
2025-04-07 16:54:10 +08:00
private SequenceManager sequenceManager = new SequenceManager();
private PictureBox buttonMiddle;
private PictureBox buttonTopRight;
private PictureBox buttonTopLeft;
private PictureBox buttonThanks;
private Dictionary<Control, (Point Location, bool Visible)> initialControlStates = new Dictionary<Control, (Point Location, bool Visible)>();
private Panel sendOffPanel;
2025-04-07 16:54:10 +08:00
//private static Bitmap normalStateImageHotSong;
//private static Bitmap mouseDownImageHotSong;
//private static Bitmap resizedNormalStateImageForHotSong;
//private static Bitmap resizedMouseDownImageForHotSong;
2025-04-07 16:54:10 +08:00
private PictureBox serviceBellPictureBox; // 添加为类成员变量
private Timer autoRefreshTimer;
2025-08-08 17:33:19 +08:00
private Timer timerCountdown;
string Rtime;
2025-04-07 16:54:10 +08:00
//private Label pageNumberLabel; // 添加頁碼標籤
public PrimaryForm()
{
Instance = this;
2025-06-03 16:52:44 +08:00
2025-04-07 16:54:10 +08:00
// 添加 DPI 感知支持
if (Environment.OSVersion.Version.Major >= 6)
{
SetProcessDPIAware();
}
2025-06-03 16:52:44 +08:00
2025-04-07 16:54:10 +08:00
this.DoubleBuffered = true;
2025-06-03 16:52:44 +08:00
2025-04-07 16:54:10 +08:00
InitializeProgressBar();
// 初始化自动刷新Timer
autoRefreshTimer = new Timer();
autoRefreshTimer.Interval = 1000; // 1秒
autoRefreshTimer.Tick += AutoRefreshTimer_Tick;
2025-06-03 16:52:44 +08:00
2025-04-07 16:54:10 +08:00
// 設置窗體屬性
this.WindowState = FormWindowState.Maximized;
this.FormBorderStyle = FormBorderStyle.None;
2025-06-03 16:52:44 +08:00
2025-04-07 16:54:10 +08:00
lightControlTimer = new Timer();
2025-06-03 16:52:44 +08:00
lightControlTimer.Interval = 5;
2025-04-07 16:54:10 +08:00
lightControlTimer.Tick += LightControlTimer_Tick;
2025-08-06 10:47:43 +08:00
2025-04-07 16:54:10 +08:00
InitializeRecording();
InitializeMediaPlayer();
//LoadImages();
2025-06-03 16:52:44 +08:00
InitializeFormAndControls();
2025-04-07 16:54:10 +08:00
InitializeMultiPagePanel();
OverlayQRCodeOnImage(HttpServer.randomFolderPath);
InitializeHandWritingForSingers();
InitializeHandWritingForSongs();
InitializeSendOffPanel();
2025-06-03 16:52:44 +08:00
2025-04-07 16:54:10 +08:00
InitializePromotionsAndMenuPanel();
SaveInitialControlStates(this);
// 包廂 + port 名稱
this.Paint += PrimaryForm_Paint;
2025-05-22 13:33:48 +08:00
this.Paint += User_Paint;
2025-04-07 16:54:10 +08:00
// 註冊多頁面面板的頁碼改變事件處理
2025-06-03 16:52:44 +08:00
multiPagePanel.PageIndexChanged += HandlePageChanged;
2025-04-07 16:54:10 +08:00
// 添加 Load 事件處理
this.Load += PrimaryForm_Load;
2025-08-08 17:33:19 +08:00
timerCountdown = new Timer();
timerCountdown.Interval = 1000; // 1 second
timerCountdown.Tick += TimerCountdown_Tick;
timerCountdown.Start();
2025-04-07 16:54:10 +08:00
}
// 添加 DPI 感知支持
[DllImport("user32.dll")]
private static extern bool SetProcessDPIAware();
private void SaveInitialControlStates(Control parent)
{
foreach (Control control in parent.Controls)
{
initialControlStates[control] = (control.Location, control.Visible);
if (control.HasChildren)
{
SaveInitialControlStates(control);
}
}
}
2025-08-08 17:33:19 +08:00
private async void TimerCountdown_Tick(object sender, EventArgs e)
{
TimeSpan remainingTime = Program.room.getTimeSpan();
2025-08-08 17:33:19 +08:00
if (remainingTime.TotalSeconds > 0)
{
remainingTime = remainingTime.Subtract(TimeSpan.FromSeconds(1));
Rtime = remainingTime.ToString(@"hh\:mm\:ss");
this.Invalidate();
}
else
{
timerCountdown.Stop();
await Task.Delay(10000);
2025-08-11 10:55:53 +08:00
//Program.room.setDB("closed");
//Program.room.set("");
2025-08-08 17:33:19 +08:00
}
}
2025-04-07 16:54:10 +08:00
private void PrimaryForm_Paint(object sender, PaintEventArgs e)
{
// 取得本機電腦的主機名稱 (hostname)
string hostName = System.Net.Dns.GetHostName();
2025-08-06 10:47:43 +08:00
string version = Program.verSion;
2025-04-07 16:54:10 +08:00
// 顯示包廂名稱
// 取主機名稱的最後 20 個字元 (如果長度不足 20則取全部)
2025-08-08 17:33:19 +08:00
string displayName = "包廂" + hostName.Substring(Math.Max(0, hostName.Length - 3)) + " " + Rtime;
2025-04-15 10:59:03 +08:00
string totalPages = multiPagePanel.totalPages.ToString() == "0" ? "1" : multiPagePanel.totalPages.ToString();
string pageNumber = (multiPagePanel.currentPageIndex + 1).ToString() + "/" + totalPages;
// 基準解析度(你目前的設計基準)
float baseWidth = 1920f;
float baseHeight = 1080f;
// 實際螢幕解析度
float actualWidth = Screen.PrimaryScreen.Bounds.Width;
float actualHeight = Screen.PrimaryScreen.Bounds.Height;
// 計算縮放比例
float scaleX = actualWidth / baseWidth;
float scaleY = actualHeight / baseHeight;
2025-04-07 16:54:10 +08:00
// 設定字型:
// "微軟正黑體",大小 24粗體 (Bold)
float fontSize = 24 * scaleY;
Font font = new Font("微軟正黑體", fontSize, FontStyle.Bold);
2025-04-07 16:54:10 +08:00
// 設定畫刷 (Brush)
// 使用紅色 (Red) 來繪製文字
Brush brush = new SolidBrush(Color.Red);
// 設定繪製文字的位置 (X=500, Y=30)
2025-08-06 10:47:43 +08:00
PointF point_PCName = new PointF(450 * scaleX, 30 * scaleY);
PointF point_PageNumber = new PointF(1390 * scaleX, 30 * scaleY);
PointF point_verSion = new PointF(1800 * scaleX, 30 * scaleY);
2025-04-07 16:54:10 +08:00
// 繪製文字:
// `DrawString(要繪製的文字, 字型, 畫刷, 位置)`
e.Graphics.DrawString(displayName, font, brush, point_PCName);
2025-08-06 10:47:43 +08:00
e.Graphics.DrawString(pageNumber, font, brush, point_PageNumber);
e.Graphics.DrawString(version.Substring(version.IndexOf("V"), 4), font, brush, point_verSion);
2025-04-07 16:54:10 +08:00
}
2025-05-22 13:33:48 +08:00
private void User_Paint(object sender, PaintEventArgs e)
{
if (!string.IsNullOrWhiteSpace(userPhone) && isLoggedIn)
{
string displayName = "歡迎貴賓 :" + userPhone;
float baseWidth = 1920f;
float baseHeight = 1080f;
// 實際螢幕解析度
float actualWidth = Screen.PrimaryScreen.Bounds.Width;
float actualHeight = Screen.PrimaryScreen.Bounds.Height;
// 計算縮放比例
float scaleX = actualWidth / baseWidth;
float scaleY = actualHeight / baseHeight;
2025-04-07 16:54:10 +08:00
2025-05-22 13:33:48 +08:00
// 設定字型:
// "微軟正黑體",大小 20粗體 (Bold)
float fontSize = 18 * scaleY;
Font font = new Font("微軟正黑體", fontSize, FontStyle.Bold);
// 設定畫刷 (Brush)
// 使用紅色 (Red) 來繪製文字
Brush brush = new SolidBrush(Color.Red);
// 設定繪製文字的位置 (X=800, Y=30)
PointF point_user = new PointF(800 * scaleX, 30 * scaleY);
e.Graphics.DrawString(displayName, font, brush, point_user);
}
}
2025-04-07 16:54:10 +08:00
private void buttonMiddle_Click(object sender, EventArgs e)
{
Console.WriteLine("巨");
2025-04-07 16:54:10 +08:00
sequenceManager.ProcessClick("巨");
}
private void buttonTopRight_Click(object sender, EventArgs e)
{
Console.WriteLine("級");
2025-04-07 16:54:10 +08:00
sequenceManager.ProcessClick("級");
}
private void buttonTopLeft_Click(object sender, EventArgs e)
{
Console.WriteLine("超");
2025-04-07 16:54:10 +08:00
sequenceManager.ProcessClick("超");
}
private void buttonThanks_Click(object sender, EventArgs e)
{
Console.WriteLine("星");
2025-04-07 16:54:10 +08:00
sequenceManager.ProcessClick("星");
}
public void ShowSendOffScreen()
{
sendOffPanel.BringToFront();
sendOffPanel.Visible = true;
2025-04-07 16:54:10 +08:00
// 確保按鈕可見並在最上層
buttonMiddle.Visible = true;
buttonTopRight.Visible = true;
buttonTopLeft.Visible = true;
buttonThanks.Visible = true;
buttonMiddle.BringToFront();
buttonTopRight.BringToFront();
buttonTopLeft.BringToFront();
buttonThanks.BringToFront();
}
// 修正螢幕初始化關鍵
2025-04-07 16:54:10 +08:00
public void HideSendOffScreen()
{
sendOffPanel.Visible = false;
foreach (Control ctrl in this.Controls)
{
ctrl.Enabled = true;
}
2025-04-07 16:54:10 +08:00
}
private void HideControlsRecursively(Control parent)
{
foreach (Control control in parent.Controls)
{
if (control is Button)
2025-04-07 16:54:10 +08:00
{
control.Visible = false;
2025-04-07 16:54:10 +08:00
}
else if (control.HasChildren)
2025-04-07 16:54:10 +08:00
{
HideControlsRecursively(control);
2025-04-07 16:54:10 +08:00
}
}
}
private void InitializeProgressBar()
{
2025-04-07 16:54:10 +08:00
progressBar = new ProgressBar();
progressBar.Location = new System.Drawing.Point(10, 10);
progressBar.Size = new System.Drawing.Size(300, 30);
2025-04-07 16:54:10 +08:00
progressBar.Minimum = 0;
progressBar.Maximum = 100;
progressBar.Value = 0;
2025-04-07 16:54:10 +08:00
this.Controls.Add(progressBar);
}
private void EnableDoubleBuffering(Control control)
{
if (control != null)
{
var doubleBufferedProperty = control.GetType().GetProperty("DoubleBuffered", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
if (doubleBufferedProperty != null)
{
doubleBufferedProperty.SetValue(control, true, null);
}
}
}
private void InitializeRecording()
{
2025-04-07 16:54:10 +08:00
for (int n = 0; n < WaveIn.DeviceCount; n++)
{
var caps = WaveIn.GetCapabilities(n);
Console.WriteLine(String.Format("{0}: {1}", n, caps.ProductName));
}
waveIn = new WaveInEvent();
waveIn.DataAvailable += OnDataAvailable;
waveIn.RecordingStopped += OnRecordingStopped;
waveIn.WaveFormat = new WaveFormat(44100, 1);
2025-04-07 16:54:10 +08:00
}
private void OnDataAvailable(object sender, WaveInEventArgs e)
{
if (waveWriter != null)
{
waveWriter.Write(e.Buffer, 0, e.BytesRecorded);
waveWriter.Flush();
}
}
private void OnRecordingStopped(object sender, StoppedEventArgs e)
{
if (waveIn != null)
{
waveIn.Dispose();
waveIn = null;
}
if (waveWriter != null)
{
waveWriter.Dispose();
waveWriter = null;
}
}
private void InitializeFormAndControls()
{
this.SuspendLayout();
2025-04-07 16:54:10 +08:00
// 獲取螢幕尺寸
Screen screen = Screen.PrimaryScreen;
int screenWidth = screen.Bounds.Width;
int screenHeight = screen.Bounds.Height;
2025-04-07 16:54:10 +08:00
// 設置窗體大小
this.Size = new Size(screenWidth, screenHeight);
this.Location = new Point(0, 0);
2025-04-07 16:54:10 +08:00
// 調整背景圖片
string selectedTheme = ReadSelectedThemePath();
if (!string.IsNullOrEmpty(selectedTheme))
{
var data = LoadBtnConfigData();
2025-08-06 17:21:45 +08:00
string backgroundImagePath = Path.Combine(serverPath, data["PrimaryFormBtn"]["MainFrameWSubBtn"]);
2025-04-07 16:54:10 +08:00
try
{
using (Image originalImage = Image.FromFile(backgroundImagePath))
{
this.BackgroundImage = new Bitmap(originalImage);
this.BackgroundImageLayout = ImageLayout.Stretch;
}
}
catch (Exception ex)
{
Console.WriteLine($"加載背景圖片時發生錯誤: {ex.Message}");
}
}
InitializePictureBox();
InitializeButtonsForHotSong();
InitializeButtonsForNewSong();
2025-04-07 16:54:10 +08:00
InitializeButtonsForSingerSearch();
InitializeButtonsForSongSearch();
InitializeLangSearchButtons();
2025-04-07 16:54:10 +08:00
InitializeButtonsForGroupPictureBox();
InitializeCategorySearchButtons();
InitializeButtonsForZhuYinSingers();
InitializeButtonsForZhuYinSongs();
InitializeButtonsForEnglishSingers();
InitializeButtonsForEnglishSongs();
InitializeButtonsForWordCountSongs();
InitializeButtonsForWordCountSingers();
InitializeButtonsForPinYinSingers();
InitializeButtonsForPinYinSongs();
InitializeButtonsForSongIDSearch();
InitializeButtonsForFavoritePictureBox();
InitializePromotionsButton();
InitializeButtonsForPictureBoxToggleLight();
InitializeButtonsForVodScreenPictureBox();
2025-04-07 16:54:10 +08:00
InitializeSoundEffectButtons();
InitializeSyncScreen();
InitializeButtonsForSongIDSearch();
InitializeOtherControls();
2025-04-07 16:54:10 +08:00
pictureBox1.BringToFront();
pictureBox2.BringToFront();
pictureBox3.BringToFront();
pictureBox4.BringToFront();
pictureBoxQRCode.BringToFront();
pictureBoxZhuYinSingers.BringToFront();
pictureBoxZhuYinSongs.BringToFront();
pictureBoxEnglishSingers.BringToFront();
pictureBoxEnglishSongs.BringToFront();
pictureBoxWordCountSongs.BringToFront();
FavoritePictureBox.BringToFront();
promotionsPictureBox.BringToFront();
pictureBoxToggleLight.BringToFront();
overlayPanel.BringToFront();
VodScreenPictureBox.BringToFront();
newSongAlertButton.BringToFront();
hotPlayButton.BringToFront();
singerSearchButton.BringToFront();
songSearchButton.BringToFront();
languageSearchButton.BringToFront();
groupSearchButton.BringToFront();
categorySearchButton.BringToFront();
serviceBellButton.BringToFront();
orderedSongsButton.BringToFront();
myFavoritesButton.BringToFront();
deliciousFoodButton.BringToFront();
promotionsButton.BringToFront();
mobileSongRequestButton.BringToFront();
qieGeButton.BringToFront();
musicUpButton.BringToFront();
musicDownButton.BringToFront();
micUpButton.BringToFront();
micDownButton.BringToFront();
originalSongButton.BringToFront();
replayButton.BringToFront();
pauseButton.BringToFront();
playButton.BringToFront();
muteButton.BringToFront();
maleKeyButton.BringToFront();
femaleKeyButton.BringToFront();
standardKeyButton.BringToFront();
soundEffectButton.BringToFront();
pitchUpButton.BringToFront();
pitchDownButton.BringToFront();
syncScreenButton.BringToFront();
toggleLightButton.BringToFront();
btnPreviousPage.BringToFront();
btnReturn.BringToFront();
btnNextPage.BringToFront();
btnApplause.BringToFront();
btnSimplifiedChinese.BringToFront();
btnTraditionalChinese.BringToFront();
exitButton.BringToFront();
this.ResumeLayout(false);
this.PerformLayout();
}
private string ReadSelectedThemePath()
{
2025-04-09 11:46:18 +08:00
string configFilePath = Path.Combine(Application.StartupPath, "txt", "theme_description.txt");
2025-04-07 16:54:10 +08:00
try
{
2025-04-07 16:54:10 +08:00
string[] lines = File.ReadAllLines(configFilePath);
2025-04-07 16:54:10 +08:00
foreach (string line in lines)
{
if (line.StartsWith("Selected Theme: "))
{
2025-04-07 16:54:10 +08:00
string themePath = line.Substring("Selected Theme: ".Length).Trim();
return themePath;
}
}
}
catch (Exception ex)
{
Console.WriteLine(String.Format("讀取文件時發生錯誤: {0}", ex.Message));
}
return string.Empty;
2025-04-07 16:54:10 +08:00
}
private void InitializePictureBox()
{
pictureBox1 = new PictureBox
{
Dock = DockStyle.Fill,
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage
};
2025-04-07 16:54:10 +08:00
pictureBox2 = new PictureBox
{
Dock = DockStyle.Fill,
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage,
Visible = false
2025-04-07 16:54:10 +08:00
};
2025-04-07 16:54:10 +08:00
pictureBox3 = new PictureBox
{
Dock = DockStyle.Fill,
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage,
Visible = false
2025-04-07 16:54:10 +08:00
};
2025-04-07 16:54:10 +08:00
pictureBox4 = new PictureBox
{
Dock = DockStyle.Fill,
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage,
Visible = false
2025-04-07 16:54:10 +08:00
};
2025-04-07 16:54:10 +08:00
pictureBox5 = new PictureBox
{
Dock = DockStyle.Fill,
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage,
Visible = false
2025-04-07 16:54:10 +08:00
};
2025-04-07 16:54:10 +08:00
pictureBox6 = new PictureBox
{
Dock = DockStyle.Fill,
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage,
Visible = false
2025-04-07 16:54:10 +08:00
};
2025-04-07 16:54:10 +08:00
pictureBoxZhuYinSingers = new PictureBox
{
Name = "pictureBoxZhuYinSingers",
2025-04-07 16:54:10 +08:00
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage,
Visible = false
2025-04-07 16:54:10 +08:00
};
pictureBoxZhuYinSongs = new PictureBox
{
Name = "pictureBoxZhuYinSongs",
2025-04-07 16:54:10 +08:00
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage,
Visible = false
2025-04-07 16:54:10 +08:00
};
pictureBoxEnglishSingers = new PictureBox
{
Name = "pictureBoxEnglishSingers",
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage,
Visible = false
2025-04-07 16:54:10 +08:00
};
pictureBoxEnglishSongs = new PictureBox
{
Name = "pictureBoxEnglishSongs",
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage,
Visible = false
2025-04-07 16:54:10 +08:00
};
pictureBoxArtistSearch = new PictureBox
{
Name = "pictureBoxArtistSearch",
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage,
Visible = false
2025-04-07 16:54:10 +08:00
};
pictureBoxWordCountSongs = new PictureBox
{
Name = "pictureBoxWordCountSongs",
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage,
Visible = false
2025-04-07 16:54:10 +08:00
};
pictureBoxWordCountSingers = new PictureBox
{
Name = "pictureBoxWordCountSingers",
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage,
Visible = false
2025-04-07 16:54:10 +08:00
};
pictureBoxPinYinSingers = new PictureBox
{
Name = "pictureBoxPinYinSingers",
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage,
Visible = false
2025-04-07 16:54:10 +08:00
};
pictureBoxPinYinSongs = new PictureBox
{
Name = "pictureBoxPinYinSongs",
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage,
Visible = false
2025-04-07 16:54:10 +08:00
};
pictureBoxSongIDSearch = new PictureBox
{
Name = "pictureBoxSongIDSearch",
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage,
Visible = false
2025-04-07 16:54:10 +08:00
};
pictureBoxHandWritingSingers = new PictureBox
{
Name = "pictureBoxHandWritingSingers",
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage,
Visible = false
2025-04-07 16:54:10 +08:00
};
pictureBoxHandWritingSongs = new PictureBox
{
Name = "pictureBoxHandWritingSongs",
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage,
Visible = false
2025-04-07 16:54:10 +08:00
};
FavoritePictureBox = new PictureBox
{
Name = "FavoritePictureBox",
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage,
Visible = false
};
FavoritePictureBox.Paint += new PaintEventHandler(FavoritePictureBox_Paint);
promotionsPictureBox = new PictureBox
{
Name = "promotionsPictureBox",
Dock = DockStyle.Fill,
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage,
Visible = false
2025-04-07 16:54:10 +08:00
};
pictureBoxToggleLight = new PictureBox
{
Name = "pictureBoxToggleLight",
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage,
Visible = false
2025-04-07 16:54:10 +08:00
};
VodScreenPictureBox = new PictureBox
{
Name = "VodScreenPictureBox",
BackColor = Color.FromArgb(128, 0, 0, 0),
SizeMode = PictureBoxSizeMode.StretchImage,
Visible = false
};
overlayPanel = new Panel
{
Name = "overlayPanel",
Dock = DockStyle.Fill,
BackColor = Color.FromArgb(128, 0, 0, 0),
2025-04-07 16:54:10 +08:00
Visible = false
};
pictureBoxQRCode = new PictureBox
{
Name = "pictureBoxQRCode",
2025-04-07 16:54:10 +08:00
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage,
Visible = false
2025-04-07 16:54:10 +08:00
};
pictureBoxSceneSoundEffects = new PictureBox
{
Name = "pictureBoxSceneSoundEffects",
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage,
Visible = false
2025-04-07 16:54:10 +08:00
};
this.Controls.Add(pictureBox1);
this.Controls.Add(pictureBox2);
this.Controls.Add(pictureBox3);
this.Controls.Add(pictureBox4);
this.Controls.Add(pictureBox5);
this.Controls.Add(pictureBox6);
this.Controls.Add(pictureBoxQRCode);
2025-04-07 16:54:10 +08:00
this.Controls.Add(pictureBoxZhuYinSingers);
this.Controls.Add(pictureBoxWordCountSongs);
this.Controls.Add(pictureBoxZhuYinSongs);
this.Controls.Add(pictureBoxEnglishSingers);
this.Controls.Add(pictureBoxEnglishSongs);
this.Controls.Add(pictureBoxArtistSearch);
this.Controls.Add(pictureBoxWordCountSingers);
this.Controls.Add(pictureBoxPinYinSingers);
this.Controls.Add(pictureBoxPinYinSongs);
this.Controls.Add(pictureBoxHandWritingSingers);
this.Controls.Add(pictureBoxHandWritingSongs);
this.Controls.Add(pictureBoxSongIDSearch);
this.Controls.Add(FavoritePictureBox);
this.Controls.Add(promotionsPictureBox);
this.Controls.Add(pictureBoxToggleLight);
this.Controls.Add(VodScreenPictureBox);
this.Controls.Add(overlayPanel);
this.Controls.Add(pictureBoxSceneSoundEffects);
2025-04-07 16:54:10 +08:00
}
private void PhoneticButton_Click(object sender, EventArgs e)
{
var button = sender as Button;
if (button != null && button.Tag != null)
{
2025-04-07 16:54:10 +08:00
if (inputBoxZhuYinSingers.Visible)
{
inputBoxZhuYinSingers.Text += button.Tag.ToString();
}
else if (inputBoxZhuYinSongs.Visible)
{
inputBoxZhuYinSongs.Text += button.Tag.ToString();
}
}
}
2025-04-07 16:54:10 +08:00
private void LightControlTimer_Tick(object sender, EventArgs e)
{
if (lightControlTimer.Tag != null)
2025-04-07 16:54:10 +08:00
{
SendCommandThroughSerialPort(lightControlTimer.Tag.ToString());
}
}
public static void SendCommandThroughSerialPort(string command)
{
if (SerialPortManager.mySerialPort != null && SerialPortManager.mySerialPort.IsOpen)
{
try
{
byte[] commandBytes = HexStringToByteArray(command);
SerialPortManager.mySerialPort.Write(commandBytes, 0, commandBytes.Length);
}
catch (Exception ex)
{
2025-06-20 13:12:10 +08:00
Console.WriteLine("Failed to send command: " + ex.Message);
2025-04-07 16:54:10 +08:00
}
}
else
{
2025-06-20 13:12:10 +08:00
Console.WriteLine("Serial port is not open.");
2025-04-07 16:54:10 +08:00
}
}
2025-04-07 16:54:10 +08:00
public static byte[] HexStringToByteArray(string hex)
{
hex = hex.Replace(" ", "");
2025-04-07 16:54:10 +08:00
byte[] bytes = new byte[hex.Length / 2];
for (int i = 0; i < hex.Length; i += 2)
{
bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
}
return bytes;
}
private void RecognizeInk(InkOverlay inkOverlay, ListBox candidateListBox)
{
if (inkOverlay.Ink.Strokes.Count > 0)
{
using (RecognizerContext context = new RecognizerContext())
{
context.Strokes = inkOverlay.Ink.Strokes;
RecognitionStatus status;
RecognitionResult result = context.Recognize(out status);
if (status == RecognitionStatus.NoError)
{
List<string> candidates = new List<string>();
foreach (RecognitionAlternate alternate in result.GetAlternatesFromSelection())
{
candidates.Add(alternate.ToString());
}
ShowCandidates(candidates, candidateListBox);
}
else
{
candidateListBox.Visible = false;
2025-04-07 16:54:10 +08:00
}
}
}
else
{
candidateListBox.Visible = false;
2025-04-07 16:54:10 +08:00
}
}
private void ShowCandidates(List<string> candidates, ListBox candidateListBox)
{
candidateListBox.Items.Clear();
foreach (var candidate in candidates)
{
candidateListBox.Items.Add(candidate);
}
candidateListBox.Visible = true;
}
2025-08-07 18:32:08 +08:00
//按鈕設定,游標移開後恢復預設圖案
private void ConfigureButton(Button button, int posX, int posY, int width, int height,
Bitmap normalStateImage, Bitmap mouseOverImage, Bitmap mouseDownImage,
2025-04-07 16:54:10 +08:00
EventHandler clickEventHandler)
{
2025-04-07 16:54:10 +08:00
ResizeAndPositionButton(button, posX, posY, width, height);
2025-08-06 10:47:43 +08:00
2025-04-07 16:54:10 +08:00
Rectangle cropArea = new Rectangle(button.Location.X, button.Location.Y, button.Size.Width, button.Size.Height);
2025-08-06 10:47:43 +08:00
//button.BackgroundImage = normalStateImage.Clone(cropArea, normalStateImage.PixelFormat);
button.BackgroundImage = normalStateImage;
2025-04-07 16:54:10 +08:00
button.BackgroundImageLayout = ImageLayout.Stretch;
button.FlatStyle = FlatStyle.Flat;
button.FlatAppearance.BorderSize = 0;
button.FlatAppearance.MouseDownBackColor = Color.Transparent;
2025-08-06 10:47:43 +08:00
button.FlatAppearance.MouseOverBackColor = Color.Transparent;
2025-04-07 16:54:10 +08:00
2025-08-06 10:47:43 +08:00
//button.MouseEnter += (sender, e) => button.BackgroundImage = mouseOverImage.Clone(cropArea, mouseOverImage.PixelFormat);
//button.MouseLeave += (sender, e) => button.BackgroundImage = normalStateImage.Clone(cropArea, normalStateImage.PixelFormat);
//button.MouseDown += (sender, e) => button.BackgroundImage = mouseDownImage.Clone(cropArea, mouseDownImage.PixelFormat);
//button.MouseUp += (sender, e) => button.BackgroundImage = normalStateImage.Clone(cropArea, normalStateImage.PixelFormat);
button.MouseEnter += (sender, e) => button.BackgroundImage = mouseOverImage;
button.MouseLeave += (sender, e) => button.BackgroundImage = normalStateImage;
button.MouseDown += (sender, e) => button.BackgroundImage = mouseDownImage;
button.MouseUp += (sender, e) => button.BackgroundImage = normalStateImage;
2025-04-07 16:54:10 +08:00
if (clickEventHandler != null)
{
button.Click += clickEventHandler;
}
2025-08-06 10:47:43 +08:00
button.AutoSize = true;
this.Controls.Add(button);
}
2025-08-07 18:32:08 +08:00
//設定透明按鈕
2025-08-06 10:47:43 +08:00
private void ConfigureTransButton(Button button, int posX, int posY, int width, int height,
EventHandler clickEventHandler)
{
ResizeAndPositionButton(button, posX, posY, width, height);
button.FlatStyle = FlatStyle.Flat;
button.FlatAppearance.BorderSize = 0;
button.FlatAppearance.MouseOverBackColor = Color.Transparent;
button.FlatAppearance.MouseDownBackColor = Color.Transparent;
button.BackColor = Color.Transparent;
if (clickEventHandler != null)
{
button.Click += clickEventHandler;
}
2025-04-07 16:54:10 +08:00
this.Controls.Add(button);
}
#region
2025-04-07 16:54:10 +08:00
private void InitializeOtherControls()
{
2025-08-07 18:32:08 +08:00
var data = LoadBtnConfigData();
2025-08-06 17:21:45 +08:00
2025-08-08 17:33:19 +08:00
InitializeButton(ref newSongAlertButton, ref newSongAlertNormalBackground, ref newSongAlertActiveBackground, "newSongAlertButton", 20, 98, 105, 120, data["PrimaryFormBtn"]["AlertNormal"], data["PrimaryFormBtn"]["AlertActive"], NewSongAlertButton_Click);
2025-04-07 16:54:10 +08:00
2025-08-07 18:32:08 +08:00
InitializeButton(ref hotPlayButton, ref hotPlayNormalBackground, ref hotPlayActiveBackground, "hotPlayButton", 137, 98, 106, 120, data["PrimaryFormBtn"]["HotNormal"], data["PrimaryFormBtn"]["HotActive"], HotPlayButton_Click);
2025-04-07 16:54:10 +08:00
2025-08-07 18:32:08 +08:00
InitializeButton(ref singerSearchButton, ref singerSearchNormalBackground, ref singerSearchActiveBackground, "singerSearchButton", 255, 98, 106, 120, data["PrimaryFormBtn"]["SingerNormal"], data["PrimaryFormBtn"]["SingerActive"], SingerSearchButton_Click);
2025-04-07 16:54:10 +08:00
2025-08-07 18:32:08 +08:00
InitializeButton(ref songSearchButton, ref songSearchNormalBackground, ref songSearchActiveBackground, "songSearchButton", 373, 98, 106, 120, data["PrimaryFormBtn"]["SongNormal"], data["PrimaryFormBtn"]["SongActive"], SongSearchButton_Click);
2025-04-07 16:54:10 +08:00
2025-08-07 18:32:08 +08:00
InitializeButton(ref languageSearchButton, ref languageSearchNormalBackground, ref languageSearchActiveBackground, "languageSearchButton", 491, 98, 106, 120, data["PrimaryFormBtn"]["LangNormal"], data["PrimaryFormBtn"]["LangActive"], LanguageSongSelectionButton_Click);
2025-08-07 18:32:08 +08:00
InitializeButton(ref groupSearchButton, ref groupSearchNormalBackground, ref groupSearchActiveBackground, "groupSearchButton", 608, 98, 106, 120, data["PrimaryFormBtn"]["GroupNormal"], data["PrimaryFormBtn"]["GroupActive"], GroupSongSelectionButton_Click);
2025-04-07 16:54:10 +08:00
2025-08-07 18:32:08 +08:00
InitializeButton(ref categorySearchButton, ref categorySearchNormalBackground, ref categorySearchActiveBackground, "categorySearchButton", 726, 98, 106, 120, data["PrimaryFormBtn"]["CategNormal"], data["PrimaryFormBtn"]["CategActive"], CategorySearchButton_Click);
2025-04-07 16:54:10 +08:00
serviceBellButton = new Button { Text = "" };
ConfigureButton(serviceBellButton, 843, 98, 107, 120,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormBtn"]["BellNormal"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormBtn"]["BellActive"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormBtn"]["BellActive"])),
(sender, e) => OnServiceBellButtonClick(sender, e));
2025-04-07 16:54:10 +08:00
2025-08-07 18:32:08 +08:00
InitializeButton(ref orderedSongsButton, ref orderedSongsNormalBackground, ref orderedSongsActiveBackground, "orderedSongsButton", 961, 98, 107, 120, data["PrimaryFormBtn"]["OrderSongNormal"], data["PrimaryFormBtn"]["OrderSongActive"], OrderedSongsButton_Click);
2025-04-07 16:54:10 +08:00
2025-08-07 18:32:08 +08:00
InitializeButton(ref myFavoritesButton, ref myFavoritesNormalBackground, ref myFavoritesActiveBackground, "myFavoritesButton", 1079, 98, 107, 120, data["PrimaryFormBtn"]["FavoriteNormal"], data["PrimaryFormBtn"]["FavoriteActive"], MyFavoritesButton_Click);
2025-04-07 16:54:10 +08:00
2025-08-07 18:32:08 +08:00
InitializeButton(ref promotionsButton, ref promotionsNormalBackground, ref promotionsActiveBackground, "promotionsButton", 1197, 98, 107, 120, data["PrimaryFormBtn"]["PromotNormal"], data["PrimaryFormBtn"]["PromotActive"], promotionsButton_Click);
2025-04-07 16:54:10 +08:00
2025-08-07 18:32:08 +08:00
InitializeButton(ref deliciousFoodButton, ref deliciousFoodNormalBackground, ref deliciousFoodActiveBackground, "deliciousFoodButton", 1315, 98, 107, 120, data["PrimaryFormBtn"]["FoodNormal"], data["PrimaryFormBtn"]["FoodActive"], DeliciousFoodButton_Click);
2025-04-07 16:54:10 +08:00
2025-08-06 10:47:43 +08:00
mobileSongRequestButton = new Button { Text = "" };
mobileSongRequestButton.Name = "mobileSongRequestButton";
ConfigureButton(mobileSongRequestButton, 1198, 629, 223, 88,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["MobileOrder"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["MobileOrder"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["MobileOrder"])),
MobileSongRequestButton_Click);
2025-08-06 10:47:43 +08:00
qieGeButton = new Button { Text = "" };
qieGeButton.Name = "qieGeButton";
ConfigureButton(qieGeButton, 20, 738, 92, 147,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["QieGe"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["QieGe"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["QieGe"])),
(sender, e) => videoPlayerForm.PlayNextSong());
musicUpButton = new Button { Text = "" };
2025-04-07 16:54:10 +08:00
musicUpButton.Name = "musicUpButton";
ConfigureButton(musicUpButton, 128, 738, 93, 62,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["MusicGainNormal"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["MusicGainNormal"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["MusicGainActive"])),
(sender, e) => { OverlayForm.MainForm.ShowTopRightLabel("音量 ↑", "a2 b3 a4"); });
musicDownButton = new Button { Text = "" };
2025-04-07 16:54:10 +08:00
musicDownButton.Name = "musicDownButton";
ConfigureButton(musicDownButton, 128, 823, 93, 62,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["MusicLowNormal"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["MusicLowNormal"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["MusicLowActive"])),
(sender, e) => { OverlayForm.MainForm.ShowTopRightLabel("音量 ↓", "a2 b4 a4"); });
micUpButton = new Button { Text = "" };
2025-04-07 16:54:10 +08:00
micUpButton.Name = "micUpButton";
ConfigureButton(micUpButton, 238, 738, 93, 62,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["MiPhoneGainNormal"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["MiPhoneGainNormal"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["MiPhoneGainActive"])),
(sender, e) => { OverlayForm.MainForm.ShowTopRightLabel("麥克風 ↑", "a2 b5 a4"); });
micDownButton = new Button { Text = "" };
2025-04-07 16:54:10 +08:00
micDownButton.Name = "micDownButton";
ConfigureButton(micDownButton, 238, 823, 93, 62,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["MiPhoneLowNormal"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["MiPhoneLowNormal"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["MiPhoneLowActive"])),
(sender, e) => { OverlayForm.MainForm.ShowTopRightLabel("麥克風 ↓", "a2 b6 a4"); });
2025-04-07 16:54:10 +08:00
originalSongButton = new Button { Text = "" };
originalSongButton.Name = "originalSongButton";
ConfigureButton(originalSongButton, 347, 738, 93, 62,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["OriginalSound"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["OriginalSound"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["OriginalSound"])),
OriginalSongButton_Click);
replayButton = new Button { Text = "" };
2025-04-07 16:54:10 +08:00
replayButton.Name = "replayButton";
ConfigureButton(replayButton, 347, 823, 93, 62,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["Replay"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["Replay"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["Replay"])),
ReplayButton_Click);
2025-08-08 17:33:19 +08:00
pauseButton = new Button
{
2025-04-07 16:54:10 +08:00
Text = "",
2025-08-08 17:33:19 +08:00
Name = "pauseButton"
};
ConfigureButton(pauseButton, 456, 738, 93, 62,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["Pause"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["Pause"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["Pause"])),
PauseButton_Click);
playButton = new Button
{
2025-04-07 16:54:10 +08:00
Text = "",
Name = "playButton",
Visible = false
2025-04-07 16:54:10 +08:00
};
ConfigureButton(playButton, 456, 738, 93, 62,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["Play"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["Play"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["Play"])),
PlayButton_Click);
muteButton = new Button { Text = "" };
2025-04-07 16:54:10 +08:00
muteButton.Name = "muteButton";
ConfigureButton(muteButton, 456, 823, 93, 62,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["Mute"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["Mute"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["Mute"])),
MuteUnmuteButton_Click);
maleKeyButton = new Button { Text = "" };
2025-04-07 16:54:10 +08:00
maleKeyButton.Name = "maleKeyButton";
ConfigureButton(maleKeyButton, 564, 738, 93, 62,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["MaleTone"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["MaleTone"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["MaleTone"])),
MaleKeyButton_Click);
femaleKeyButton = new Button { Text = "" };
2025-04-07 16:54:10 +08:00
femaleKeyButton.Name = "femaleKeyButton";
ConfigureButton(femaleKeyButton, 565, 823, 93, 62,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["FemaleTone"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["FemaleTone"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["FemaleTone"])),
FemaleKeyButton_Click);
2025-04-07 16:54:10 +08:00
standardKeyButton = new Button { Text = "" };
standardKeyButton.Name = "standardKeyButton";
ConfigureButton(standardKeyButton, 674, 738, 93, 62,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["StandardTone"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["StandardTone"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["StandardTone"])),
StandardKeyButton_Click);
2025-04-07 16:54:10 +08:00
soundEffectButton = new Button { Text = "" };
soundEffectButton.Name = "soundEffectButton";
ConfigureButton(soundEffectButton, 674, 823, 93, 62,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["SoundEffect"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["SoundEffect"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["SoundEffect"])),
SoundEffectButton_Click);
pitchUpButton = new Button { Text = "" };
2025-04-07 16:54:10 +08:00
pitchUpButton.Name = "pitchUpButton";
ConfigureButton(pitchUpButton, 784, 738, 93, 62,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["HigherTone"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["HigherTone"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["HigherTone"])),
PitchUpButton_Click);
pitchDownButton = new Button { Text = "" };
2025-04-07 16:54:10 +08:00
pitchDownButton.Name = "pitchDownButton";
ConfigureButton(pitchDownButton, 784, 823, 93, 62,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["LowerTone"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["LowerTone"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["LowerTone"])),
PitchDownButton_Click);
2025-04-07 16:54:10 +08:00
syncScreenButton = new Button { Text = "" };
syncScreenButton.Name = "syncScreenButton";
ConfigureButton(syncScreenButton, 893, 736, 92, 149,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["ScreenSync"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["ScreenSync"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["ScreenSync"])),
SyncScreenButton_Click);
2025-04-07 16:54:10 +08:00
2025-08-06 10:47:43 +08:00
toggleLightButton = new Button { Text = "" };
toggleLightButton.Name = "toggleLightButton";
ConfigureButton(toggleLightButton, 1002, 736, 92, 149,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["LightControl"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["LightControl"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["LightControl"])),
ToggleLightButton_Click);
2025-04-07 16:54:10 +08:00
2025-08-06 10:47:43 +08:00
btnPreviousPage = new Button { Text = "" };
btnPreviousPage.Name = "btnPreviousPageButton";
ConfigureButton(btnPreviousPage, 1110, 738, 93, 62,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["PrePage"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["PrePage"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["PrePage"])),
PreviousPageButton_Click);
2025-04-07 16:54:10 +08:00
2025-08-06 10:47:43 +08:00
btnReturn = new Button { Text = "" };
btnReturn.Name = "btnReturn";
ConfigureButton(btnReturn, 1220, 738, 93, 62,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["Exit"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["Exit"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["Exit"])),
ShouYeButton_Click);
btnNextPage = new Button { Text = "" };
btnNextPage.Name = "btnNextPage";
ConfigureButton(btnNextPage, 1330, 738, 93, 62,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["NextPage"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["NextPage"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["NextPage"])),
NextPageButton_Click);
btnApplause = new Button { Text = "" };
btnApplause.Name = "btnApplause";
ConfigureButton(btnApplause, 1110, 823, 93, 62,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["Appaulse"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["Appaulse"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["Appaulse"])),
ApplauseButton_Click);
btnSimplifiedChinese = new Button { Text = "" };
btnSimplifiedChinese.Name = "btnSimplifiedChinese";
ConfigureButton(btnSimplifiedChinese, 1330, 823, 93, 62,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["Simplified"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["Simplified"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["Simplified"])),
SimplifiedChineseButton_Click);
btnTraditionalChinese = new Button { Text = "" };
btnTraditionalChinese.Name = "btnTraditionalChinese";
ConfigureButton(btnTraditionalChinese, 1220, 823, 93, 62,
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["Traditional"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["Traditional"])),
new Bitmap(Path.Combine(serverPath, data["PrimaryFormSubBtn"]["Traditional"])),
TraditionalChineseButton_Click);
2025-04-07 16:54:10 +08:00
/* 關閉應用程式按鈕*/
exitButton = new Button { };
/*exitButton.Name = "exitButton";
2025-04-07 16:54:10 +08:00
ConfigureButton(exitButton, 1394, 2, 1428 - 1394, 37 - 2,
resizedNormalStateImage, resizedMouseOverImage, resizedMouseDownImage,
(sender, e) => Application.Exit());*/
2025-04-07 16:54:10 +08:00
}
#endregion
2025-04-07 16:54:10 +08:00
2025-08-07 18:32:08 +08:00
private void InitializeButton(ref Button button, ref Bitmap normalBackground, ref Bitmap activeBackground, string buttonName, int x, int y, int width, int height, string imagePath, string imagePathb, EventHandler clickEventHandler)
2025-04-07 16:54:10 +08:00
{
2025-08-06 17:21:45 +08:00
var data = LoadConfigData();
2025-04-07 16:54:10 +08:00
button = new Button { Text = "", Name = buttonName };
ResizeAndPositionButton(button, x, y, width, height);
2025-08-07 13:09:10 +08:00
normalBackground = new Bitmap(Path.Combine(serverPath, imagePath));
2025-08-07 18:32:08 +08:00
activeBackground = new Bitmap(Path.Combine(serverPath, imagePathb));
2025-04-07 16:54:10 +08:00
button.BackgroundImage = normalBackground;
button.BackgroundImageLayout = ImageLayout.Stretch;
button.FlatStyle = FlatStyle.Flat;
button.FlatAppearance.BorderSize = 0;
if (clickEventHandler != null)
{
button.Click += clickEventHandler;
}
this.Controls.Add(button);
}
2025-08-06 17:21:45 +08:00
2025-04-07 16:54:10 +08:00
private void InitializeMultiPagePanel()
{
// 獲取螢幕尺寸
Screen screen = Screen.PrimaryScreen;
int screenWidth = screen.Bounds.Width;
int screenHeight = screen.Bounds.Height;
2025-04-07 16:54:10 +08:00
// 計算縮放比例
float widthRatio = screenWidth / 1440f;
float heightRatio = screenHeight / 900f;
2025-04-07 16:54:10 +08:00
multiPagePanel = new MultiPagePanel();
2025-04-07 16:54:10 +08:00
// 計算面板位置和大小
int panelX = (int)(PanelStartLeft * widthRatio);
int panelY = (int)(PanelStartTop * heightRatio);
int panelWidth = (int)((PanelEndLeft - PanelStartLeft) * widthRatio);
int panelHeight = (int)((PanelEndTop - PanelStartTop) * heightRatio);
2025-04-07 16:54:10 +08:00
multiPagePanel.Location = new Point(panelX, panelY);
multiPagePanel.Size = new Size(panelWidth, panelHeight);
2025-04-07 16:54:10 +08:00
this.Controls.Add(multiPagePanel);
multiPagePanel.BringToFront();
}
private SongData currentSelectedSong;
public void Label_Click(object sender, EventArgs e)
{
2025-08-08 17:33:19 +08:00
var data = LoadBtnConfigData();
2025-04-07 16:54:10 +08:00
var label = sender as Label;
if (label != null && label.Tag is SongData)
{
2025-04-07 16:54:10 +08:00
currentSelectedSong = label.Tag as SongData;
this.DoubleBuffered = true;
this.SuspendLayout();
DrawTextOnVodScreenPictureBox(Path.Combine(serverPath, data["SongOrderPanel"]["UIBase"]), currentSelectedSong);
2025-04-07 16:54:10 +08:00
SetVodScreenPictureBoxAndButtonsVisibility(true);
this.ResumeLayout(true);
}
if (isOnOrderedSongsPage)
{
vodButton.BackgroundImage = new Bitmap(Path.Combine(serverPath, data["SongOrderPanel"]["DelBtn"]));
vodButton.MouseEnter += (sender, e) => vodButton.BackgroundImage = new Bitmap(Path.Combine(serverPath, data["SongOrderPanel"]["DelBtn"])); ;
vodButton.MouseLeave += (sender, e) => vodButton.BackgroundImage = new Bitmap(Path.Combine(serverPath, data["SongOrderPanel"]["DelBtn"])); ;
vodButton.MouseDown += (sender, e) => vodButton.BackgroundImage = new Bitmap(Path.Combine(serverPath, data["SongOrderPanel"]["DelBtn"])); ;
vodButton.MouseUp += (sender, e) => vodButton.BackgroundImage = new Bitmap(Path.Combine(serverPath, data["SongOrderPanel"]["DelBtn"])); ;
}
2025-04-07 16:54:10 +08:00
}
public static void WriteLog(string message)
{
2025-04-09 11:46:18 +08:00
string logFilePath = Path.Combine(Application.StartupPath, "txt", "logfile.txt");
using (StreamWriter sw = new StreamWriter(logFilePath, true))
2025-04-07 16:54:10 +08:00
{
2025-04-07 16:54:10 +08:00
sw.WriteLine(String.Format("{0}: {1}", DateTime.Now, message));
}
}
private void NextPageButton_Click(object sender, EventArgs e)
{
multiPagePanel.LoadNextPage();
}
private void SimplifiedChineseButton_Click(object sender, EventArgs e)
{
Console.WriteLine("切換到簡體顯示"); // 添加日誌
if (multiPagePanel != null)
{
multiPagePanel.IsSimplified = true;
btnSimplifiedChinese.Enabled = false;
btnTraditionalChinese.Enabled = true;
}
}
private void TraditionalChineseButton_Click(object sender, EventArgs e)
{
Console.WriteLine("切換到繁體顯示"); // 添加日誌
if (multiPagePanel != null)
{
multiPagePanel.IsSimplified = false;
btnSimplifiedChinese.Enabled = true;
btnTraditionalChinese.Enabled = false;
}
}
private void PreviousPageButton_Click(object sender, EventArgs e)
{
multiPagePanel.LoadPreviousPage();
}
private Bitmap ResizeImage(Image image, int width, int height)
{
var destRect = new Rectangle(0, 0, width, height);
var destImage = new Bitmap(width, height);
destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution);
using (var graphics = Graphics.FromImage(destImage))
{
graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
using (var wrapMode = new System.Drawing.Imaging.ImageAttributes())
{
wrapMode.SetWrapMode(System.Drawing.Drawing2D.WrapMode.TileFlipXY);
graphics.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, wrapMode);
}
}
return destImage;
}
#region LoadImages
//private void LoadImages()
//{
// var data = LoadBtnConfigData();
// string selectedThemePath = ReadSelectedThemePath();
// string basePath = Path.Combine(serverPath, selectedThemePath);
// int targetWidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
// int targetHeight = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
2025-04-07 16:54:10 +08:00
// normalStateImage = new Bitmap(Path.Combine(serverPath, data["PrimaryFormBtn"]["MainFrameWSubBtn"]));
// resizedNormalStateImage = ResizeImage(normalStateImage, targetWidth, targetHeight);
2025-04-07 16:54:10 +08:00
// mouseOverImage = new Bitmap(Path.Combine(serverPath, data["PrimaryFormBtn"]["MainFrameBtnPressed"]));
// resizedMouseOverImage = ResizeImage(mouseOverImage, targetWidth, targetHeight);
2025-04-07 16:54:10 +08:00
// mouseDownImage = new Bitmap(Path.Combine(serverPath, data["PrimaryFormBtn"]["MainFrameBtnPressed"]));
// resizedMouseDownImage = ResizeImage(mouseDownImage, targetWidth, targetHeight);
2025-04-07 16:54:10 +08:00
// normalStateImageNewSongAlert = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\1.新歌快報_未按.jpg"));
// resizedNormalStateImageForNewSongAlert = ResizeImage(normalStateImageNewSongAlert, targetWidth, targetHeight);
2025-04-07 16:54:10 +08:00
// mouseOverImageNewSongAlert = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\1.新歌快報_已按.jpg"));
// resizedMouseOverImageForNewSongAlert = ResizeImage(mouseOverImageNewSongAlert, targetWidth, targetHeight);
2025-04-07 16:54:10 +08:00
// mouseDownImageNewSongAlert = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\1.新歌快報_已按.jpg"));
// resizedMouseDownImageForNewSongAlert = ResizeImage(mouseDownImageNewSongAlert, targetWidth, targetHeight);
2025-04-07 16:54:10 +08:00
// normalStateImageArtistQuery = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\3.歌星查詢_未按.jpg"));
// resizedNormalStateImageForArtistQuery = ResizeImage(normalStateImageArtistQuery, targetWidth, targetHeight);
2025-04-07 16:54:10 +08:00
// mouseOverImageArtistQuery = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\3.歌星查詢_已按.jpg"));
// resizedMouseOverImageForArtistQuery = ResizeImage(mouseOverImageArtistQuery, targetWidth, targetHeight);
2025-04-07 16:54:10 +08:00
// mouseDownImageArtistQuery = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\3.歌星查詢_已按.jpg"));
// resizedMouseDownImageForArtistQuery = ResizeImage(mouseDownImageArtistQuery, targetWidth, targetHeight);
2025-04-07 16:54:10 +08:00
// normalStateImageSongQuery = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\4.歌名查詢_未按.jpg"));
// resizedNormalStateImageForSongQuery = ResizeImage(normalStateImageSongQuery, targetWidth, targetHeight);
2025-04-07 16:54:10 +08:00
// mouseOverImageSongQuery = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\4.歌名查詢_已按.jpg"));
// resizedMouseOverImageForSongQuery = ResizeImage(mouseOverImageSongQuery, targetWidth, targetHeight);
2025-04-07 16:54:10 +08:00
// mouseDownImageSongQuery = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\4.歌名查詢_已按.jpg"));
// resizedMouseDownImageForSongQuery = ResizeImage(mouseDownImageSongQuery, targetWidth, targetHeight);
2025-04-07 16:54:10 +08:00
// normalStateImageLanguageQuery = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\5.語別查詢_未按.jpg"));
// resizedNormalStateImageForLanguageQuery = ResizeImage(normalStateImageLanguageQuery, targetWidth, targetHeight);
2025-04-07 16:54:10 +08:00
// mouseOverImageLanguageQuery = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\5.語別查詢_已按.jpg"));
// resizedMouseOverImageForLanguageQuery = ResizeImage(mouseOverImageLanguageQuery, targetWidth, targetHeight);
2025-04-07 16:54:10 +08:00
// mouseDownImageLanguageQuery = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\5.語別查詢_已按.jpg"));
// resizedMouseDownImageForLanguageQuery = ResizeImage(mouseDownImageLanguageQuery, targetWidth, targetHeight);
2025-04-07 16:54:10 +08:00
// normalStateImageCategoryQuery = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\7.類別查詢_未按.jpg"));
// resizedNormalStateImageForCategoryQuery = ResizeImage(normalStateImageCategoryQuery, targetWidth, targetHeight);
2025-04-07 16:54:10 +08:00
// mouseOverImageCategoryQuery = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\7.類別查詢_已按.jpg"));
// resizedMouseOverImageForCategoryQuery = ResizeImage(mouseOverImageCategoryQuery, targetWidth, targetHeight);
2025-04-07 16:54:10 +08:00
// mouseDownImageCategoryQuery = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\7.類別查詢_已按.jpg"));
// resizedMouseDownImageForCategoryQuery = ResizeImage(mouseDownImageCategoryQuery, targetWidth, targetHeight);
2025-04-07 16:54:10 +08:00
// normalStateImageForPromotionsAndMenu = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\555021.jpg"));
// resizedNormalStateImageForPromotionsAndMenu = ResizeImage(normalStateImageForPromotionsAndMenu, targetWidth, targetHeight);
2025-04-07 16:54:10 +08:00
// try
// {
// string imagePath = Path.Combine(serverPath, "themes\\superstar\\主畫面\\選單內介面_同步畫面.jpg");
2025-04-07 16:54:10 +08:00
// if (File.Exists(imagePath))
// {
// normalStateImageForSyncScreen = new Bitmap(imagePath);
// resizedNormalStateImageForSyncScreen = ResizeImage(normalStateImageForSyncScreen, targetWidth, targetHeight);
// Console.WriteLine("Image loaded successfully.");
// }
// else
// {
// Console.WriteLine("Image file does not exist: " + imagePath);
// }
// }
// catch (Exception ex)
// {
// Console.WriteLine("Failed to load image: " + ex.Message);
// }
2025-04-07 16:54:10 +08:00
// normalStateImageForSceneSoundEffects = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\555022.jpg"));
// resizedNormalStateImageForSceneSoundEffects = ResizeImage(normalStateImageForSceneSoundEffects, targetWidth, targetHeight);
2025-04-07 16:54:10 +08:00
// normalStateImageHotSong = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\2.熱門排行_未按.jpg"));
// resizedNormalStateImageForHotSong = ResizeImage(normalStateImageHotSong, targetWidth, targetHeight);
2025-04-07 16:54:10 +08:00
// mouseDownImageHotSong = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\2.熱門排行_已按.jpg"));
// resizedMouseDownImageForHotSong = ResizeImage(mouseDownImageHotSong, targetWidth, targetHeight);
2025-04-07 16:54:10 +08:00
// normalStateImageForLightControl = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\選單內介面_燈光控制.jpg"));
// resizedNormalStateImageForLightControl = ResizeImage(normalStateImageForLightControl, targetWidth, targetHeight);
//}
#endregion
2025-04-07 16:54:10 +08:00
private Bitmap CropImage(Bitmap source, Rectangle section)
{
2025-04-07 16:54:10 +08:00
Bitmap bmp = new Bitmap(section.Width, section.Height);
using (Graphics g = Graphics.FromImage(bmp))
{
2025-04-07 16:54:10 +08:00
g.DrawImage(source, 0, 0, section, GraphicsUnit.Pixel);
}
return bmp;
}
private void DrawTextOnVodScreenPictureBox(string imagePath, SongData SongDetail)
2025-04-07 16:54:10 +08:00
{
Bitmap originalImage = new Bitmap(imagePath);
VodScreenPictureBox.Image = originalImage;
2025-04-17 15:53:19 +08:00
int screenWidth = 1440;
int screenHeight = 900;
int pictureBoxWidth = (int)(938 * 0.8f);
int pictureBoxHeight = (int)(209 * 0.8f);
2025-04-07 16:54:10 +08:00
int xPosition = (screenWidth - pictureBoxWidth) / 2;
int yPosition = (screenHeight - pictureBoxHeight) / 2;
2025-04-07 16:54:10 +08:00
using (Graphics g = Graphics.FromImage(originalImage))
{
2025-05-21 15:42:42 +08:00
// 計算文字寬度
2025-04-07 16:54:10 +08:00
float dpiX = g.DpiX;
float points = 25;
float pixels = points * (dpiX / 72);
2025-04-07 16:54:10 +08:00
Font font = new Font("微軟正黑體", points, FontStyle.Bold);
2025-05-21 15:42:42 +08:00
// 根據文字長度設置字體大小
if (SongDetail.getNameLength() > 18)
2025-05-21 15:42:42 +08:00
{
font = new Font("微軟正黑體", 17, FontStyle.Bold);
}
else if (SongDetail.getNameLength() > 13)
2025-05-21 15:42:42 +08:00
{
font = new Font("微軟正黑體", 21, FontStyle.Bold);
}
else
{
font = new Font("微軟正黑體", 25, FontStyle.Bold);
}
2025-04-07 16:54:10 +08:00
Brush textBrush = Brushes.Black;
string songInfo = SongDetail.getName() ?? "未提供歌曲信息";
g.DrawString(songInfo, font, textBrush, new PointF(121, 18));
2025-04-07 16:54:10 +08:00
}
ResizeAndPositionPictureBox(VodScreenPictureBox, xPosition, yPosition, pictureBoxWidth, pictureBoxHeight);
2025-04-07 16:54:10 +08:00
VodScreenPictureBox.Visible = true;
}
public static void ResizeAndPositionButton(Button button, int x, int y, int width, int height)
{
// 獲取螢幕尺寸
Screen screen = Screen.PrimaryScreen;
int screenWidth = screen.Bounds.Width;
int screenHeight = screen.Bounds.Height;
2025-04-07 16:54:10 +08:00
// 計算縮放比例
float widthRatio = screenWidth / 1440f;
float heightRatio = screenHeight / 900f;
2025-04-07 16:54:10 +08:00
// 調整按鈕位置和大小
button.Location = new Point(
(int)(x * widthRatio),
(int)(y * heightRatio)
);
button.Size = new Size(
(int)(width * widthRatio),
(int)(height * heightRatio)
);
}
private static void ResizeAndPositionPictureBox(PictureBox pictureBox, int originalX, int originalY, int originalWidth, int originalHeight)
{
int screenW = Screen.PrimaryScreen.Bounds.Width;
int screenH = Screen.PrimaryScreen.Bounds.Height;
float widthRatio = screenW / (float)1440;
float heightRatio = screenH / (float)900;
2025-04-07 16:54:10 +08:00
pictureBox.Location = new Point(
(int)(originalX * widthRatio),
(int)(originalY * heightRatio)
);
pictureBox.Size = new Size(
(int)(originalWidth * widthRatio),
(int)(originalHeight * heightRatio)
);
}
public static void ResizeAndPositionControl(Control control, int x, int y, int width, int height)
{
// 獲取螢幕尺寸
Screen screen = Screen.PrimaryScreen;
int screenWidth = screen.Bounds.Width;
int screenHeight = screen.Bounds.Height;
2025-04-07 16:54:10 +08:00
// 計算縮放比例
float widthRatio = screenWidth / 1440f;
float heightRatio = screenHeight / 900f;
2025-04-07 16:54:10 +08:00
// 調整控件位置和大小
control.Location = new Point(
(int)(x * widthRatio),
(int)(y * heightRatio)
);
control.Size = new Size(
(int)(width * widthRatio),
(int)(height * heightRatio)
);
}
private void DeliciousFoodButton_Click(object sender, EventArgs e)
{
var data = LoadBtnConfigData();
UpdateButtonBackgrounds(deliciousFoodButton, new Bitmap(Path.Combine(serverPath, data["PrimaryFormBtn"]["FoodActive"])));
2025-08-06 17:21:45 +08:00
2025-04-07 16:54:10 +08:00
isOnOrderedSongsPage = false;
SetHotSongButtonsVisibility(false);
SetNewSongButtonsVisibility(false);
SetSingerSearchButtonsVisibility(false);
SetSongSearchButtonsVisibility(false);
SetPictureBoxLanguageButtonsVisibility(false);
SetGroupButtonsVisibility(false);
SetZhuYinSingersAndButtonsVisibility(false);
SetZhuYinSongsAndButtonsVisibility(false);
SetEnglishSingersAndButtonsVisibility(false);
SetEnglishSongsAndButtonsVisibility(false);
SetPinYinSingersAndButtonsVisibility(false);
SetPinYinSongsAndButtonsVisibility(false);
SetPictureBoxCategoryAndButtonsVisibility(false);
2025-04-07 16:54:10 +08:00
promotionsAndMenuPanel.currentPageIndex = 0;
promotionsAndMenuPanel.LoadImages(menu);
2025-04-07 16:54:10 +08:00
promotionsAndMenuPanel.Visible = true;
promotionsAndMenuPanel.BringToFront();
previousPromotionButton.Visible = true;
previousPromotionButton.BringToFront();
nextPromotionButton.Visible = true;
nextPromotionButton.BringToFront();
2025-04-07 16:54:10 +08:00
closePromotionsButton.Visible = true;
closePromotionsButton.BringToFront();
2025-04-07 16:54:10 +08:00
if (pictureBoxQRCode != null)
{
pictureBoxQRCode.Visible = false;
closeQRCodeButton.Visible = false;
}
}
private void MobileSongRequestButton_Click(object sender, EventArgs e)
{
SetHotSongButtonsVisibility(false);
SetNewSongButtonsVisibility(false);
SetSingerSearchButtonsVisibility(false);
SetSongSearchButtonsVisibility(false);
SetPictureBoxLanguageButtonsVisibility(false);
SetZhuYinSingersAndButtonsVisibility(false);
SetZhuYinSongsAndButtonsVisibility(false);
SetEnglishSingersAndButtonsVisibility(false);
SetEnglishSongsAndButtonsVisibility(false);
SetPinYinSingersAndButtonsVisibility(false);
SetPinYinSongsAndButtonsVisibility(false);
SetGroupButtonsVisibility(false);
2025-04-07 16:54:10 +08:00
if (pictureBoxQRCode != null)
{
pictureBoxQRCode.Visible = true;
pictureBoxQRCode.BringToFront();
2025-04-07 16:54:10 +08:00
closeQRCodeButton.Visible = true;
closeQRCodeButton.BringToFront();
}
else
{
Console.WriteLine("pictureBoxQRCode is not initialized!");
}
}
public void OriginalSongButton_Click(object sender, EventArgs e)
2025-04-07 16:54:10 +08:00
{
videoPlayerForm.ToggleVocalRemoval();
2025-04-07 16:54:10 +08:00
}
private void ReplayButton_Click(object sender, EventArgs e)
{
videoPlayerForm.ReplayCurrentSong();
}
2025-06-20 13:12:10 +08:00
public void PauseButton_Click(object sender, EventArgs e)
2025-04-07 16:54:10 +08:00
{
videoPlayerForm.Pause();
pauseButton.Visible = false;
playButton.Visible = true;
}
2025-06-20 13:12:10 +08:00
public void PlayButton_Click(object sender, EventArgs e)
2025-04-07 16:54:10 +08:00
{
videoPlayerForm.Play();
playButton.Visible = false;
pauseButton.Visible = true;
}
2025-04-07 16:54:10 +08:00
/// <summary>
/// 右下角關閉按鈕事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ShouYeButton_Click(object sender, EventArgs e)
{ /*Console.WriteLine("playedSongsHistory");
foreach(var song in playedSongsHistory){
Console.WriteLine(song.ToString());
}
Console.WriteLine("userRequestedSongs");
foreach(var song in userRequestedSongs){
Console.WriteLine(song.ToString());
}*/
if (multiPagePanel.get_currentSongList() == SongList.GetHistory())
return;
2025-04-07 16:54:10 +08:00
autoRefreshTimer.Stop(); // 停止自动刷新
FindFirstNonEmptyText(inputBoxZhuYinSingers
, inputBoxZhuYinSongs
, inputBoxEnglishSingers
, inputBoxEnglishSongs
, inputBoxPinYinSingers
, inputBoxPinYinSongs
, inputBoxWordCountSingers
, inputBoxWordCountSongs
, inputBoxSongIDSearch
, handwritingInputBoxForSongs
, handwritingInputBoxForSingers);
2025-04-07 16:54:10 +08:00
foreach (var label in songLabels)
{
this.Controls.Remove(label);
label.Dispose();
}
songLabels.Clear();
2025-04-07 16:54:10 +08:00
}
2025-04-07 16:54:10 +08:00
/// <summary>
/// 查詢空字串,將第一個不為空的字串,重新刷新
/// </summary>
/// <param name="controls"></param>
private void FindFirstNonEmptyText(params Control[] controls)
{
2025-04-14 11:55:18 +08:00
var searchActions = new Dictionary<Control, Action>
{
{ inputBoxZhuYinSingers, FindZhuYiSingers },
{ inputBoxZhuYinSongs, FindZhuYiSongs },
{ inputBoxEnglishSingers, FindEnglishSingers },
{ inputBoxEnglishSongs, FindEnglishSongs },
{ inputBoxPinYinSingers, FindPinYinSingers },
{ inputBoxPinYinSongs, FindPinYinSongs },
{ inputBoxWordCountSingers, FindWordCountSingers },
{ inputBoxWordCountSongs, FindWordCountSongs },
{ inputBoxSongIDSearch, FindNumberSongs },
{ handwritingInputBoxForSongs, FindHandwritingSongs },
{ handwritingInputBoxForSingers, FindHandwritingSingers },
};
2025-04-07 16:54:10 +08:00
foreach (var control in controls)
{
if (!string.IsNullOrEmpty(control.Text))
2025-04-14 11:55:18 +08:00
{
2025-04-07 16:54:10 +08:00
var temp = control.Text;
2025-04-14 11:55:18 +08:00
ResetinputBox(); // 清除所有輸入框
control.Text = temp; // 還原唯一有內容的那個
if (searchActions.TryGetValue(control, out var action))
{
action.Invoke(); // 執行對應的查詢方法
}
break; // 只處理第一個有文字的輸入框
2025-04-07 16:54:10 +08:00
}
}
}
2025-04-14 11:55:18 +08:00
2025-04-07 16:54:10 +08:00
/// <summary>
/// 重置所有輸入框
/// </summary>
private void ResetinputBox()
{
inputBoxZhuYinSingers?.Clear();
inputBoxZhuYinSongs?.Clear();
inputBoxEnglishSingers?.Clear();
inputBoxEnglishSongs?.Clear();
inputBoxPinYinSingers?.Clear();
inputBoxPinYinSongs?.Clear();
inputBoxWordCountSingers?.Clear();
inputBoxWordCountSongs?.Clear();
inputBoxSongIDSearch?.Clear();
handwritingInputBoxForSongs?.Clear();
handwritingInputBoxForSingers?.Clear();
2025-04-07 16:54:10 +08:00
}
2025-08-07 18:32:08 +08:00
#region
2025-04-07 16:54:10 +08:00
private void MuteUnmuteButton_Click(object sender, EventArgs e)
{
2025-04-07 16:54:10 +08:00
if (videoPlayerForm.isMuted)
{
2025-04-07 16:54:10 +08:00
videoPlayerForm.SetVolume(videoPlayerForm.previousVolume);
2025-04-07 16:54:10 +08:00
videoPlayerForm.isMuted = false;
OverlayForm.MainForm.HideMuteLabel();
}
else
{
2025-04-07 16:54:10 +08:00
videoPlayerForm.previousVolume = videoPlayerForm.GetVolume();
videoPlayerForm.SetVolume(-10000);
2025-04-07 16:54:10 +08:00
videoPlayerForm.isMuted = true;
OverlayForm.MainForm.ShowMuteLabel();
}
}
2025-04-07 16:54:10 +08:00
private void MaleKeyButton_Click(object sender, EventArgs e)
{
if (SerialPortManager.mySerialPort != null && SerialPortManager.mySerialPort.IsOpen)
{
byte[] commandBytesIncreasePitch1 = new byte[] { 0xA2, 0x7F, 0xA4 };
2025-04-07 16:54:10 +08:00
SerialPortManager.mySerialPort.Write(commandBytesIncreasePitch1, 0, commandBytesIncreasePitch1.Length);
byte[] commandBytesDecreasePitch = new byte[] { 0xA2, 0xB2, 0xA4 };
SerialPortManager.mySerialPort.Write(commandBytesDecreasePitch, 0, commandBytesDecreasePitch.Length);
SerialPortManager.mySerialPort.Write(commandBytesDecreasePitch, 0, commandBytesDecreasePitch.Length);
}
else
{
MessageBox.Show("串口未開啟,無法發送降調指令。");
}
2025-04-07 16:54:10 +08:00
}
2025-04-07 16:54:10 +08:00
private void FemaleKeyButton_Click(object sender, EventArgs e)
{
if (SerialPortManager.mySerialPort != null && SerialPortManager.mySerialPort.IsOpen)
{
byte[] commandBytesIncreasePitch1 = new byte[] { 0xA2, 0x7F, 0xA4 };
SerialPortManager.mySerialPort.Write(commandBytesIncreasePitch1, 0, commandBytesIncreasePitch1.Length);
byte[] commandBytesIncreasePitch = new byte[] { 0xA2, 0xB1, 0xA4 };
SerialPortManager.mySerialPort.Write(commandBytesIncreasePitch, 0, commandBytesIncreasePitch.Length);
SerialPortManager.mySerialPort.Write(commandBytesIncreasePitch, 0, commandBytesIncreasePitch.Length);
2025-04-07 16:54:10 +08:00
}
else
{
MessageBox.Show("串口未開啟,無法發送升調指令。");
}
2025-04-07 16:54:10 +08:00
}
private void StandardKeyButton_Click(object sender, EventArgs e)
{
if (SerialPortManager.mySerialPort != null && SerialPortManager.mySerialPort.IsOpen)
{
byte[] commandBytesIncreasePitch = new byte[] { 0xA2, 0x7F, 0xA4 };
SerialPortManager.mySerialPort.Write(commandBytesIncreasePitch, 0, commandBytesIncreasePitch.Length);
}
else
{
MessageBox.Show("串口未開啟,無法發送升調指令。");
}
}
2025-04-07 16:54:10 +08:00
private void PitchUpButton_Click(object sender, EventArgs e)
{
if (SerialPortManager.mySerialPort != null && SerialPortManager.mySerialPort.IsOpen)
{
2025-04-07 16:54:10 +08:00
byte[] commandBytesIncreasePitch = new byte[] { 0xA2, 0xB1, 0xA4 };
SerialPortManager.mySerialPort.Write(commandBytesIncreasePitch, 0, commandBytesIncreasePitch.Length);
2025-04-07 16:54:10 +08:00
}
else
{
MessageBox.Show("串口未開啟,無法發送升調指令。");
}
}
private void PitchDownButton_Click(object sender, EventArgs e)
{
if (SerialPortManager.mySerialPort != null && SerialPortManager.mySerialPort.IsOpen)
{
byte[] commandBytesDecreasePitch = new byte[] { 0xA2, 0xB2, 0xA4 };
SerialPortManager.mySerialPort.Write(commandBytesDecreasePitch, 0, commandBytesDecreasePitch.Length);
2025-04-07 16:54:10 +08:00
}
else
{
MessageBox.Show("串口未開啟,無法發送降調指令。");
}
}
2025-04-07 16:54:10 +08:00
private void ApplauseButton_Click(object sender, EventArgs e)
{
PlayApplauseSound();
}
private bool isWaiting = false;
//服務鈴事件
2025-04-07 16:54:10 +08:00
private async void OnServiceBellButtonClick(object sender, EventArgs e)
{
if (isWaiting) return;
isWaiting = true;
// 显示提示信息
//OverlayForm.MainForm.HideAllLabels();
OverlayForm.MainForm.ShowTopRightLabel("服務鈴", "a2 53 a4");
2025-04-07 16:54:10 +08:00
// 延迟3秒
await Task.Delay(3000);
2025-04-07 16:54:10 +08:00
isWaiting = false;
}
2025-08-07 18:32:08 +08:00
#endregion
2025-04-07 16:54:10 +08:00
private void InitializeSendOffPanel()
{
sendOffPanel = new Panel
{
Dock = DockStyle.Fill,
2025-04-08 11:34:46 +08:00
//BackColor = Color.Black,
BackgroundImage = LoadSendOffImage(),
BackgroundImageLayout = ImageLayout.Stretch
2025-04-07 16:54:10 +08:00
};
// 初始化服務鈴圖標
serviceBellPictureBox = new PictureBox
{
2025-04-07 16:54:10 +08:00
Visible = true,
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage,
Image = LoadButtonImage("服務鈴.png"),
Cursor = System.Windows.Forms.Cursors.Hand,
};
2025-08-06 10:47:43 +08:00
2025-04-07 16:54:10 +08:00
// 添加服務鈴點擊事件
serviceBellPictureBox.Click += (sender, e) =>
{
2025-04-07 16:54:10 +08:00
if (serviceBellButton != null)
{
OnServiceBellButtonClick(sender, e);
}
};
// 使用 PictureBox 並加載小圖片
buttonMiddle = new PictureBox
{
2025-04-07 16:54:10 +08:00
Visible = true,
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage,
2025-04-08 11:34:46 +08:00
Image = null,//LoadButtonImage("巨.png")
2025-04-07 16:54:10 +08:00
Cursor = System.Windows.Forms.Cursors.Hand
};
buttonTopRight = new PictureBox
{
2025-04-07 16:54:10 +08:00
Visible = true,
BackColor = Color.Transparent,
SizeMode = PictureBoxSizeMode.StretchImage,
2025-04-08 11:34:46 +08:00
Image = null, //LoadButtonImage("級.png")
2025-04-07 16:54:10 +08:00
Cursor = System.Windows.Forms.Cursors.Hand
};
buttonTopLeft = new PictureBox
{
2025-04-07 16:54:10 +08:00
Visible = true,
2025-04-08 11:34:46 +08:00
BackColor = Color.Transparent,
2025-04-07 16:54:10 +08:00
SizeMode = PictureBoxSizeMode.StretchImage,
2025-04-08 11:34:46 +08:00
Image = null, //LoadButtonImage("超.png")
2025-04-07 16:54:10 +08:00
Cursor = System.Windows.Forms.Cursors.Hand
};
buttonThanks = new PictureBox
{
2025-04-07 16:54:10 +08:00
Visible = true,
2025-04-08 11:34:46 +08:00
BackColor = Color.Transparent,
2025-04-07 16:54:10 +08:00
SizeMode = PictureBoxSizeMode.StretchImage,
2025-04-08 11:34:46 +08:00
Image = null, //LoadButtonImage("星.png")
2025-04-07 16:54:10 +08:00
Cursor = System.Windows.Forms.Cursors.Hand
};
2025-08-06 10:47:43 +08:00
2025-04-08 11:34:46 +08:00
// 設定按鈕的初始位置和大小
UpdateSendOffButtonPositions();
2025-04-07 16:54:10 +08:00
// 添加點擊事件
buttonMiddle.Click += buttonMiddle_Click;
buttonTopRight.Click += buttonTopRight_Click;
buttonTopLeft.Click += buttonTopLeft_Click;
buttonThanks.Click += buttonThanks_Click;
// 添加控件到面板
sendOffPanel.Controls.Add(serviceBellPictureBox); // 添加服務鈴
sendOffPanel.Controls.Add(buttonMiddle);
sendOffPanel.Controls.Add(buttonTopRight);
sendOffPanel.Controls.Add(buttonTopLeft);
sendOffPanel.Controls.Add(buttonThanks);
2025-04-08 11:34:46 +08:00
// 包廂名稱顯示
sendOffPanel.Paint += SendOffPanel_Paint;
2025-04-08 11:34:46 +08:00
2025-04-07 16:54:10 +08:00
// 確保圖片在最上層
serviceBellPictureBox.BringToFront(); // 確保服務鈴在最上層
buttonMiddle.BringToFront();
buttonTopRight.BringToFront();
buttonTopLeft.BringToFront();
buttonThanks.BringToFront();
2025-04-08 11:34:46 +08:00
// 重新計算按鈕位置
sendOffPanel.Resize += (s, e) =>
{
2025-04-08 11:34:46 +08:00
UpdateSendOffButtonPositions();
sendOffPanel.Invalidate(); // 重新繪製面板以更新顯示
};
2025-04-07 16:54:10 +08:00
this.Controls.Add(sendOffPanel);
}
2025-04-08 11:34:46 +08:00
/// <summary>
/// 動態按鈕座標位置設定(依據螢幕大小)
/// </summary>
private void UpdateSendOffButtonPositions()
{
Size designSize = new Size(1920, 1080);
2025-04-08 11:34:46 +08:00
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));
// ========== 服務鈴位置與大小 ==========
2025-08-06 10:47:43 +08:00
//serviceBellPictureBox.Location = new Point((int)(757 * scaleX), (int)(151 * scaleY));
serviceBellPictureBox.Location = new Point(740, 103);
2025-08-06 10:47:43 +08:00
//serviceBellPictureBox.Size = new Size((int)(410 * scaleX), (int)(130 * scaleY));
serviceBellPictureBox.Size = new Size(430, 146);
2025-04-08 11:34:46 +08:00
}
2025-04-08 11:34:46 +08:00
/// <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;
2025-04-07 16:54:10 +08:00
2025-04-08 11:34:46 +08:00
// 計算寬高的縮放比例
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 - 3));
2025-04-08 11:34:46 +08:00
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);
}
}
2025-04-07 16:54:10 +08:00
// 添加載入按鈕圖片的方法
private Image LoadButtonImage(string imageName)
{
2025-08-06 17:21:45 +08:00
var data = LoadConfigData();
2025-04-07 16:54:10 +08:00
try
{
2025-08-07 13:09:10 +08:00
string filePath = Path.Combine(serverPath, "themes", "superstar", "ButtonImages", imageName);
2025-04-07 16:54:10 +08:00
if (File.Exists(filePath))
{
return Image.FromFile(filePath);
}
return null;
}
catch (Exception ex)
{
Console.WriteLine($"載入按鈕圖片時發生錯誤: {ex.Message}");
return null;
}
}
2025-04-07 16:54:10 +08:00
/// <summary>
/// 加載送客畫面圖片
/// </summary>
/// <returns></returns>
private Image LoadSendOffImage()
{
var data = LoadBtnConfigData();
2025-08-06 17:21:45 +08:00
2025-04-07 16:54:10 +08:00
try
{
string filePath = Path.Combine(serverPath, data["PrimaryFormBtn"]["Close"]);
2025-04-07 16:54:10 +08:00
if (File.Exists(filePath))
{
return Image.FromFile(filePath);
}
else
{
2025-08-06 10:47:43 +08:00
Console.WriteLine("選單內介面_送客畫面.jpg 文件未找到。");
2025-04-07 16:54:10 +08:00
return null;
}
}
catch (Exception ex)
{
Console.WriteLine($"加載送客畫面圖片時發生錯誤: {ex.Message}");
return null;
}
}
// 添加 Form Load 事件處理方法
private void PrimaryForm_Load(object sender, EventArgs e)
{
2025-04-07 16:54:10 +08:00
if (hotPlayButton != null)
{
HotPlayButton_Click(null, EventArgs.Empty);
}
if (Program.room.IsClose())
{
ShowSendOffScreen();
}
// 確保所有控件都已初始化完成後,再觸發熱門排行按鈕點擊
2025-04-07 16:54:10 +08:00
}
private void AutoRefreshTimer_Tick(object sender, EventArgs e)
{
if (isOnOrderedSongsPage)
{
multiPagePanel.RefreshDisplay();
}
}
private void OrderedSongsButton_Click(object sender, EventArgs e)
{
var data = LoadBtnConfigData();
2025-08-08 17:33:19 +08:00
UpdateButtonBackgrounds(orderedSongsButton,orderedSongsActiveBackground);
2025-04-07 16:54:10 +08:00
isOnOrderedSongsPage = true;
autoRefreshTimer.Start(); // 开始自动刷新
2025-04-21 13:07:01 +08:00
// 已點歌曲錨點
var List = SongList.GetHistory();
totalPages = (int)Math.Ceiling((double)List.Count / itemsPerPage);
2025-04-07 16:54:10 +08:00
multiPagePanel.currentPageIndex = 0;
SetHotSongButtonsVisibility(false);
SetNewSongButtonsVisibility(false);
SetSingerSearchButtonsVisibility(false);
SetSongSearchButtonsVisibility(false);
SetPictureBoxLanguageButtonsVisibility(false);
SetGroupButtonsVisibility(false);
SetZhuYinSingersAndButtonsVisibility(false);
SetZhuYinSongsAndButtonsVisibility(false);
SetEnglishSingersAndButtonsVisibility(false);
SetEnglishSongsAndButtonsVisibility(false);
// SetPictureBoxWordCountAndButtonsVisibility(false);
SetPinYinSingersAndButtonsVisibility(false);
SetPinYinSongsAndButtonsVisibility(false);
SetPictureBoxToggleLightAndButtonsVisibility(false);
SetPictureBoxSceneSoundEffectsAndButtonsVisibility(false);
if (pictureBoxQRCode != null)
{
pictureBoxQRCode.Visible = false;
closeQRCodeButton.Visible = false;
}
multiPagePanel.LoadPlayedSongs(List);
2025-04-07 16:54:10 +08:00
}
2025-08-06 10:47:43 +08:00
2025-08-06 17:21:45 +08:00
#region Visible屬性設定
2025-08-06 10:47:43 +08:00
private void SetUIVisible(Control parent)
{
foreach (Control ctrl in parent.Controls)
{
parent.Visible = true;
parent.BringToFront();
ctrl.Visible = true;
ctrl.BringToFront();
if (ctrl.HasChildren)
{
SetUIVisible(ctrl);
}
}
}
private void CloseUI(Control parent)
{
foreach (Control ctrl in parent.Controls)
{
parent.Visible = false;
ctrl.Visible = false;
if (ctrl.HasChildren)
{
CloseUI(ctrl);
}
}
}
2025-08-06 17:21:45 +08:00
#endregion
/// <summary>
/// 從設定檔 (config.ini) 載入 INI 設定數據。
/// </summary>
/// <returns>回傳解析後的 INI 設定數據 (IniData)。</returns>
private IniData LoadConfigData()
{
var parser = new FileIniDataParser();
string iniFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.ini");
// 使用 UTF-8 讀取 INI 檔案並解析內容
using (var reader = new StreamReader(iniFilePath, Encoding.UTF8))
{
return parser.ReadData(reader);
}
}
2025-08-07 18:32:08 +08:00
private IniData LoadBtnConfigData()
{
var parser = new FileIniDataParser();
string iniFilePath = Path.Combine(serverPath, "img.ini");
// 使用 UTF-8 讀取 INI 檔案並解析內容
using (var reader = new StreamReader(iniFilePath, Encoding.UTF8))
{
return parser.ReadData(reader);
}
}
//主畫面上排按鍵圖形狀態設置
private void UpdateButtonBackgrounds(Button activeButton, Image activeBackground)
2025-08-07 18:32:08 +08:00
{
newSongAlertButton.BackgroundImage = newSongAlertNormalBackground;
hotPlayButton.BackgroundImage = hotPlayNormalBackground;
singerSearchButton.BackgroundImage = singerSearchNormalBackground;
songSearchButton.BackgroundImage = songSearchNormalBackground;
languageSearchButton.BackgroundImage = languageSearchNormalBackground;
groupSearchButton.BackgroundImage = groupSearchNormalBackground;
categorySearchButton.BackgroundImage = categorySearchNormalBackground;
orderedSongsButton.BackgroundImage = orderedSongsNormalBackground;
myFavoritesButton.BackgroundImage = myFavoritesNormalBackground;
promotionsButton.BackgroundImage = promotionsNormalBackground;
deliciousFoodButton.BackgroundImage = deliciousFoodNormalBackground;
activeButton.BackgroundImage = activeBackground;
2025-08-07 18:32:08 +08:00
}
2025-04-07 16:54:10 +08:00
}
}