2025-04-07 16:54:10 +08:00
using System.IO ;
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 yueYuButtonHotSong ;
private Bitmap yueYuHotSongNormalBackground ;
private Bitmap yueYuHotSongActiveBackground ;
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 SetHotSongButtonsVisibility ( bool isVisible )
{
Button [ ] hotSongButtons = { guoYuButtonHotSong , taiYuButtonHotSong , taiYuNewSongButtonHotSong , guoYuNewSongButtonHotSong , yingWenButtonHotSong , riYuButtonHotSong , hanYuButtonHotSong } ;
foreach ( var button in hotSongButtons )
{
button . Visible = isVisible ;
if ( isVisible )
{
button . BringToFront ( ) ;
}
}
}
2025-05-08 10:09:14 +08:00
public void HotPlayButton_Click ( object sender , EventArgs e )
2025-04-07 16:54:10 +08:00
{
UpdateButtonBackgrounds ( hotPlayButton , hotPlayActiveBackground ) ;
UpdateHotSongButtons ( guoYuButtonHotSong , guoYuHotSongActiveBackground ) ;
isOnOrderedSongsPage = false ;
2025-04-23 13:55:11 +08:00
/* 清空搜尋欄 */
ResetinputBox ( ) ;
2025-07-03 18:15:21 +08:00
string query = $"SELECT * FROM song_library_cache WHERE language_name = '國語' ORDER BY `song_counts` DESC LIMIT {Utils.Env.GetInt(" HotSongLimit ", 100)};" ;
2025-04-14 16:33:06 +08:00
var guoYuSongs = SearchSongs_Mysql ( query ) ;
2025-04-07 16:54:10 +08:00
UpdateSongList ( guoYuSongs ) ;
2025-05-19 13:23:09 +08:00
2025-04-07 16:54:10 +08:00
SetButtonsVisibility ( ) ;
2025-05-26 15:21:07 +08:00
//HideQRCode();
2025-04-07 16:54:10 +08:00
}
private void UpdateButtonBackgrounds ( Button activeButton , Image activeBackground )
{
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 ;
}
private void OnHotSongButtonClick ( Button activeButton , Bitmap activeBackground , string category )
{
UpdateHotSongButtons ( activeButton , activeBackground ) ;
2025-07-03 18:15:21 +08:00
string query = $"SELECT * FROM song_library_cache WHERE language_name = '{category}' ORDER BY `song_counts` DESC LIMIT {Utils.Env.GetInt(" HotSongLimit ", 100)};" ;
2025-04-11 17:16:59 +08:00
var selectedSongs = SearchSongs_Mysql ( query ) ;
2025-04-07 16:54:10 +08:00
UpdateSongList ( selectedSongs ) ;
}
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 UpdateSongList ( List < SongData > songs )
{
currentPage = 0 ;
currentSongList = songs ;
totalPages = ( int ) Math . Ceiling ( ( double ) songs . Count / itemsPerPage ) ;
multiPagePanel . currentPageIndex = 0 ;
multiPagePanel . LoadSongs ( currentSongList ) ;
}
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 ( )
{
2025-05-19 13:23:09 +08:00
pictureBoxQRCode . Visible = false ;
closeQRCodeButton . Visible = false ;
2025-04-07 16:54:10 +08:00
}
private void InitializeButtonsForHotSong ( )
{
InitializeHotSongButton ( ref guoYuNewSongButtonHotSong , "國語新歌" , 1214 , 230 , 209 , 58 ,
normalStateImageHotSong ,
out guoYuNewSongHotSongNormalBackground ,
mouseDownImageHotSong ,
out guoYuNewSongHotSongActiveBackground ,
GuoYuNewSongButtonHotSong_Click ) ;
InitializeHotSongButton ( ref taiYuNewSongButtonHotSong , "台語新歌" , 1214 , 293 , 209 , 58 ,
normalStateImageHotSong ,
out taiYuNewSongHotSongNormalBackground ,
mouseDownImageHotSong ,
out taiYuNewSongHotSongActiveBackground ,
TaiYuNewSongButtonHotSong_Click ) ;
InitializeHotSongButton ( ref taiYuButtonHotSong , "台語" , 1214 , 418 , 209 , 58 ,
normalStateImageHotSong ,
out taiYuHotSongNormalBackground ,
mouseDownImageHotSong ,
out taiYuHotSongActiveBackground ,
TaiYuButtonHotSong_Click ) ;
InitializeHotSongButton ( ref yueYuButtonHotSong , "粵語" , 1214 , 356 , 209 , 58 ,
normalStateImageHotSong ,
out yueYuHotSongNormalBackground ,
mouseDownImageHotSong ,
out yueYuHotSongActiveBackground ,
YueYuButtonHotSong_Click ) ;
InitializeHotSongButton ( ref guoYuButtonHotSong , "國語" , 1214 , 356 , 209 , 59 ,
normalStateImageHotSong ,
out guoYuHotSongNormalBackground ,
mouseDownImageHotSong ,
out guoYuHotSongActiveBackground ,
GuoYuButtonHotSong_Click ) ;
InitializeHotSongButton ( ref yingWenButtonHotSong , "英文" , 1214 , 481 , 209 , 59 ,
normalStateImageHotSong ,
out yingWenHotSongNormalBackground ,
mouseDownImageHotSong ,
out yingWenHotSongActiveBackground ,
YingWenButtonHotSong_Click ) ;
InitializeHotSongButton ( ref riYuButtonHotSong , "日語" , 1214 , 544 , 209 , 59 ,
normalStateImageHotSong ,
out riYuHotSongNormalBackground ,
mouseDownImageHotSong ,
out riYuHotSongActiveBackground ,
RiYuButtonHotSong_Click ) ;
InitializeHotSongButton ( ref hanYuButtonHotSong , "韓語" , 1214 , 607 , 209 , 58 ,
normalStateImageHotSong ,
out hanYuHotSongNormalBackground ,
mouseDownImageHotSong ,
out hanYuHotSongActiveBackground ,
HanYuButtonHotSong_Click ) ;
}
private void InitializeHotSongButton ( ref Button button , string buttonText , int x , int y , int width , int height ,
Image normalBackground , out Bitmap normalBackgroundOut ,
Image activeBackground , out Bitmap activeBackgroundOut ,
EventHandler clickEventHandler )
{
button = new Button {
Text = "" , // 移除文字
Visible = false
} ;
ResizeAndPositionButton ( button , x , y , width , height ) ;
// 修改裁剪區域,避開文字部分
Rectangle cropArea = new Rectangle ( 1214 , y , 209 , 58 ) ; // 使用固定的裁剪區域
normalBackgroundOut = new Bitmap ( normalBackground ) . Clone ( cropArea , normalBackground . PixelFormat ) ;
activeBackgroundOut = new Bitmap ( activeBackground ) . Clone ( cropArea , activeBackground . PixelFormat ) ;
button . BackgroundImage = normalBackgroundOut ;
button . BackgroundImageLayout = ImageLayout . Stretch ;
button . FlatStyle = FlatStyle . Flat ;
button . FlatAppearance . BorderSize = 0 ;
button . Click + = clickEventHandler ;
this . Controls . Add ( button ) ;
}
}
}