using DBObj; namespace DualScreenDemo { public partial class PrimaryForm { private Button hotPlayButton; private Bitmap hotPlayNormalBackground; private Bitmap hotPlayActiveBackground; private Button guoYuButtonHotSong; private Bitmap guoYuHotSongNormalBackground; private Bitmap guoYuHotSongActiveBackground; private Button taiYuButtonHotSong; private Bitmap taiYuHotSongNormalBackground; private Bitmap taiYuHotSongActiveBackground; private Button taiYuNewSongButtonHotSong; private Bitmap taiYuNewSongHotSongNormalBackground; private Bitmap taiYuNewSongHotSongActiveBackground; private Button guoYuNewSongButtonHotSong; private Bitmap guoYuNewSongHotSongNormalBackground; private Bitmap guoYuNewSongHotSongActiveBackground; private Button yingWenButtonHotSong; private Bitmap yingWenHotSongNormalBackground; private Bitmap yingWenHotSongActiveBackground; private Button riYuButtonHotSong; private Bitmap riYuHotSongNormalBackground; private Bitmap riYuHotSongActiveBackground; private Button hanYuButtonHotSong; private Bitmap hanYuHotSongNormalBackground; private Bitmap hanYuHotSongActiveBackground; private void UpdateHotSongButtons(Button activeButton, Image activeBackground) { guoYuButtonHotSong.BackgroundImage = guoYuHotSongNormalBackground; taiYuButtonHotSong.BackgroundImage = taiYuHotSongNormalBackground; taiYuNewSongButtonHotSong.BackgroundImage = taiYuNewSongHotSongNormalBackground; guoYuNewSongButtonHotSong.BackgroundImage = guoYuNewSongHotSongNormalBackground; yingWenButtonHotSong.BackgroundImage = yingWenHotSongNormalBackground; riYuButtonHotSong.BackgroundImage = riYuHotSongNormalBackground; hanYuButtonHotSong.BackgroundImage = hanYuHotSongNormalBackground; activeButton.BackgroundImage = activeBackground; } private void InitializeButtonsForHotSong() { var data = LoadBtnConfigData(); InitializeButton(ref guoYuNewSongButtonHotSong, ref guoYuNewSongHotSongNormalBackground, ref guoYuNewSongHotSongActiveBackground, "guoYuNewSongButtonHotSong", 1197, 225, 225, 50, data["HotSongSubBtn"]["GuoYuNewNormal"], data["HotSongSubBtn"]["GuoYuNewActive"], GuoYuNewSongButtonHotSong_Click); InitializeButton(ref taiYuNewSongButtonHotSong, ref taiYuNewSongHotSongNormalBackground, ref taiYuNewSongHotSongActiveBackground, "taiYuNewSongButtonHotSong", 1197, 280, 225, 50, data["HotSongSubBtn"]["TaiYuNewNormal"], data["HotSongSubBtn"]["TaiYuNewActive"], TaiYuNewSongButtonHotSong_Click); InitializeButton(ref taiYuButtonHotSong, ref taiYuHotSongNormalBackground, ref taiYuHotSongActiveBackground, "taiYuButtonHotSong", 1197, 335, 225, 50, data["HotSongSubBtn"]["TaiYuHotNormal"], data["HotSongSubBtn"]["TaiYuHotActive"], TaiYuButtonHotSong_Click); InitializeButton(ref guoYuButtonHotSong, ref guoYuHotSongNormalBackground, ref guoYuHotSongActiveBackground, "guoYuButtonHotSong", 1197, 390, 225, 50, data["HotSongSubBtn"]["GuoYuHotNormal"], data["HotSongSubBtn"]["GuoYuHotActive"], GuoYuButtonHotSong_Click); InitializeButton(ref yingWenButtonHotSong, ref yingWenHotSongNormalBackground, ref yingWenHotSongActiveBackground, "yingWenButtonHotSong", 1197, 445, 225, 50, data["HotSongSubBtn"]["EngHotNormal"], data["HotSongSubBtn"]["EngHotActive"], YingWenButtonHotSong_Click); InitializeButton(ref riYuButtonHotSong, ref riYuHotSongNormalBackground, ref riYuHotSongActiveBackground, "riYuButtonHotSong", 1197, 500, 225, 50, data["HotSongSubBtn"]["JapHotNormal"], data["HotSongSubBtn"]["JapHotActive"], RiYuButtonHotSong_Click); InitializeButton(ref hanYuButtonHotSong, ref hanYuHotSongNormalBackground, ref hanYuHotSongActiveBackground, "hanYuButtonHotSong", 1197, 555, 225, 50, data["HotSongSubBtn"]["KrHotNormal"], data["HotSongSubBtn"]["KrHotActive"], HanYuButtonHotSong_Click); } private void SetHotSongButtonsVisibility(bool isVisible) { Button[] hotSongButtons = { guoYuButtonHotSong, taiYuButtonHotSong, taiYuNewSongButtonHotSong, guoYuNewSongButtonHotSong, yingWenButtonHotSong, riYuButtonHotSong, hanYuButtonHotSong }; foreach (var button in hotSongButtons) { button.Visible = isVisible; if (isVisible) { button.BringToFront(); } } } public void HotPlayButton_Click(object sender, EventArgs e) { UpdateButtonBackgrounds(hotPlayButton, hotPlayActiveBackground); isOnOrderedSongsPage = false; /* 清空搜尋欄 */ ResetinputBox(); string query = $"SELECT * FROM song_library_cache WHERE language_name = '國語' ORDER BY `song_counts` DESC LIMIT 1000;"; var guoYuSongs = SearchSongs_Mysql(query); UpdateSongList(guoYuSongs); SetButtonsVisibility(); UpdateHotSongButtons(guoYuNewSongButtonHotSong, guoYuNewSongHotSongActiveBackground); //HideQRCode(); } private void OnHotSongButtonClick(Button activeButton, Bitmap activeBackground, string category) { UpdateHotSongButtons(activeButton, activeBackground); string query = $"SELECT * FROM song_library_cache WHERE language_name = '{category}' ORDER BY `song_counts` DESC LIMIT 1000;"; var selectedSongs = SearchSongs_Mysql(query); UpdateSongList(selectedSongs); } private void UpdateSongList(List songs) { currentPage = 0; totalPages = (int)Math.Ceiling((double)songs.Count / itemsPerPage); multiPagePanel.currentPageIndex = 0; multiPagePanel.LoadSongs(songs); } private void SetButtonsVisibility() { SetNewSongButtonsVisibility(false); SetSingerSearchButtonsVisibility(false); SetSongSearchButtonsVisibility(false); SetPictureBoxLanguageButtonsVisibility(false); SetGroupButtonsVisibility(false); SetPictureBoxCategoryAndButtonsVisibility(false); SetZhuYinSingersAndButtonsVisibility(false); SetZhuYinSongsAndButtonsVisibility(false); SetEnglishSingersAndButtonsVisibility(false); SetEnglishSongsAndButtonsVisibility(false); SetPinYinSingersAndButtonsVisibility(false); SetPinYinSongsAndButtonsVisibility(false); SetPictureBoxToggleLightAndButtonsVisibility(false); SetPictureBoxSceneSoundEffectsAndButtonsVisibility(false); SetHotSongButtonsVisibility(true); } private void HideQRCode() { pictureBoxQRCode.Visible = false; closeQRCodeButton.Visible = false; } } }