From 612f995b4f41215d8555783d78c4bff449e178f6 Mon Sep 17 00:00:00 2001 From: "allen.yan" Date: Fri, 8 Aug 2025 17:33:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=AA=E9=99=A4=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PrimaryFormParts/PrimaryForm.cs | 82 +++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 30 deletions(-) diff --git a/PrimaryFormParts/PrimaryForm.cs b/PrimaryFormParts/PrimaryForm.cs index 3470091..65a927b 100644 --- a/PrimaryFormParts/PrimaryForm.cs +++ b/PrimaryFormParts/PrimaryForm.cs @@ -174,8 +174,10 @@ namespace DualScreenDemo private static Bitmap resizedMouseDownImageForHotSong; private PictureBox serviceBellPictureBox; // 添加为类成员变量 - private Timer autoRefreshTimer; + private TimeSpan remainingTime; + private Timer timerCountdown; + string Rtime; //private Label pageNumberLabel; // 添加頁碼標籤 public PrimaryForm() @@ -226,6 +228,11 @@ namespace DualScreenDemo multiPagePanel.PageIndexChanged += HandlePageChanged; // 添加 Load 事件處理 this.Load += PrimaryForm_Load; + + timerCountdown = new Timer(); + timerCountdown.Interval = 1000; // 1 second + timerCountdown.Tick += TimerCountdown_Tick; + } // 添加 DPI 感知支持 @@ -245,6 +252,34 @@ namespace DualScreenDemo } } + + public void RoomTimeStart() + { + //DateTime now = DateTime.Now; + //DateTime tenMinutesLater = now.AddMinutes(120); + //remainingTime = tenMinutesLater - now; + remainingTime = Program.room.timePeriod; + timerCountdown.Start(); + } + + private async void TimerCountdown_Tick(object sender, EventArgs e) + { + 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); + Program.room.setDB("closed"); + Program.room.set(""); + } + } + + private void PrimaryForm_Paint(object sender, PaintEventArgs e) { // 取得本機電腦的主機名稱 (hostname) @@ -252,7 +287,7 @@ namespace DualScreenDemo string version = Program.verSion; // 顯示包廂名稱 // 取主機名稱的最後 20 個字元 (如果長度不足 20,則取全部) - string displayName = "包廂" + hostName.Substring(Math.Max(0, hostName.Length - 3)); + string displayName = "包廂" + hostName.Substring(Math.Max(0, hostName.Length - 3)) + " " + Rtime; string totalPages = multiPagePanel.totalPages.ToString() == "0" ? "1" : multiPagePanel.totalPages.ToString(); string pageNumber = (multiPagePanel.currentPageIndex + 1).ToString() + "/" + totalPages; @@ -509,7 +544,7 @@ namespace DualScreenDemo InitializeButtonsForFavoritePictureBox(); InitializePromotionsButton(); InitializeButtonsForPictureBoxToggleLight(); - InitializeButtonsForVodScreenPictureBox(); + //InitializeButtonsForVodScreenPictureBox(); InitializeSoundEffectButtons(); InitializeSyncScreen(); @@ -1007,7 +1042,7 @@ namespace DualScreenDemo { var data = LoadBtnConfigData(); - InitializeButton(ref newSongAlertButton, ref newSongAlertNormalBackground, ref newSongAlertActiveBackground, "newSongAlertButton", 20, 98, 105, 120, data["PrimaryFormBtn"]["AlertNormal"],data["PrimaryFormBtn"]["AlertActive"], NewSongAlertButton_Click); + InitializeButton(ref newSongAlertButton, ref newSongAlertNormalBackground, ref newSongAlertActiveBackground, "newSongAlertButton", 20, 98, 105, 120, data["PrimaryFormBtn"]["AlertNormal"], data["PrimaryFormBtn"]["AlertActive"], NewSongAlertButton_Click); InitializeButton(ref hotPlayButton, ref hotPlayNormalBackground, ref hotPlayActiveBackground, "hotPlayButton", 137, 98, 106, 120, data["PrimaryFormBtn"]["HotNormal"], data["PrimaryFormBtn"]["HotActive"], HotPlayButton_Click); @@ -1111,9 +1146,11 @@ namespace DualScreenDemo ReplayButton_Click); - pauseButton = new Button{ + pauseButton = new Button + { Text = "", - Name = "pauseButton" }; + Name = "pauseButton" + }; ConfigureButton(pauseButton, 456, 738, 93, 62, new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\1.主類別\\主類別下方_暫停.png")), new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\1.主類別\\主類別下方_暫停.png")), @@ -1147,7 +1184,7 @@ namespace DualScreenDemo maleKeyButton.Name = "maleKeyButton"; ConfigureButton(maleKeyButton, 564, 738, 93, 62, new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\1.主類別\\主類別下方_男調.png")), - new Bitmap(Path.Combine(serverPath , "themes\\superstar\\button\\1.主類別\\主類別下方_男調.png")), + new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\1.主類別\\主類別下方_男調.png")), new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\1.主類別\\主類別下方_男調.png")), MaleKeyButton_Click); @@ -1245,7 +1282,7 @@ namespace DualScreenDemo btnApplause = new Button { Text = "" }; btnApplause.Name = "btnApplause"; ConfigureButton(btnApplause, 1110, 823, 93, 62, - new Bitmap(Path.Combine(serverPath , "themes\\superstar\\button\\1.主類別\\主類別下方_掌聲.png")), + new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\1.主類別\\主類別下方_掌聲.png")), new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\1.主類別\\主類別下方_掌聲.png")), new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\1.主類別\\主類別下方_掌聲.png")), ApplauseButton_Click); @@ -1328,6 +1365,8 @@ namespace DualScreenDemo public void Label_Click(object sender, EventArgs e) { + InitializeButtonsForVodScreenPictureBox(); + var data = LoadConfigData(); var label = sender as Label; if (label != null && label.Tag is SongData) @@ -1458,7 +1497,7 @@ namespace DualScreenDemo resizedMouseDownImageForArtistQuery = ResizeImage(mouseDownImageArtistQuery, targetWidth, targetHeight); - normalStateImageSongQuery = new Bitmap(Path.Combine(serverPath , "themes\\superstar\\主畫面\\4.歌名查詢_未按.jpg")); + normalStateImageSongQuery = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\主畫面\\4.歌名查詢_未按.jpg")); resizedNormalStateImageForSongQuery = ResizeImage(normalStateImageSongQuery, targetWidth, targetHeight); @@ -1661,16 +1700,7 @@ namespace DualScreenDemo { var data = LoadConfigData(); - 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; + ResetPrimaryBtnStatus(); deliciousFoodButton.BackgroundImage = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\1.主類別\\主類別上方_美味菜單(已按).png")); isOnOrderedSongsPage = false; @@ -2220,19 +2250,11 @@ namespace DualScreenDemo private void OrderedSongsButton_Click(object sender, EventArgs e) { - var data= LoadConfigData(); + var data = LoadConfigData(); - newSongAlertButton.BackgroundImage = newSongAlertNormalBackground; - hotPlayButton.BackgroundImage = hotPlayNormalBackground; - singerSearchButton.BackgroundImage = singerSearchNormalBackground; - songSearchButton.BackgroundImage = songSearchNormalBackground; - languageSearchButton.BackgroundImage = languageSearchNormalBackground; - groupSearchButton.BackgroundImage = groupSearchNormalBackground; - categorySearchButton.BackgroundImage = categorySearchNormalBackground; + ResetPrimaryBtnStatus(); orderedSongsButton.BackgroundImage = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\1.主類別\\主類別上方_已點歌曲(已按).png")); - myFavoritesButton.BackgroundImage = myFavoritesNormalBackground; - promotionsButton.BackgroundImage = promotionsNormalBackground; - deliciousFoodButton.BackgroundImage = deliciousFoodNormalBackground; + isOnOrderedSongsPage = true; autoRefreshTimer.Start(); // 开始自动刷新