類別查詢代碼重構

This commit is contained in:
allen.yan 2025-08-07 12:03:07 +08:00
parent f97501c1af
commit c663bd8ea8
8 changed files with 121 additions and 167 deletions

View File

@ -4,13 +4,7 @@ namespace DualScreenDemo
{ {
private void ChinaSongsButton_Click(object sender, EventArgs e) private void ChinaSongsButton_Click(object sender, EventArgs e)
{ {
loveDuetButton.BackgroundImage = loveDuetNormalBackground; ResetBtnStatus();
talentShowButton.BackgroundImage = talentShowNormalBackground;
medleyDanceButton.BackgroundImage = medleyDanceNormalBackground;
ninetiesButton.BackgroundImage = ninetiesNormalBackground;
nostalgicSongsButton.BackgroundImage = nostalgicSongsNormalBackground;
chinaSongsButton.BackgroundImage = chinaActiveBackground;
/*chinaSongs = allSongs.Where(song => song.SongGenre.Contains("F1")) /*chinaSongs = allSongs.Where(song => song.SongGenre.Contains("F1"))
.OrderByDescending(song => song.Plays) .OrderByDescending(song => song.Plays)

View File

@ -4,13 +4,8 @@ namespace DualScreenDemo
{ {
private void LoveDuetButton_Click(object sender, EventArgs e) private void LoveDuetButton_Click(object sender, EventArgs e)
{ {
loveDuetButton.BackgroundImage = loveDuetActiveBackground;
talentShowButton.BackgroundImage = talentShowNormalBackground;
medleyDanceButton.BackgroundImage = medleyDanceNormalBackground;
ninetiesButton.BackgroundImage = ninetiesNormalBackground;
nostalgicSongsButton.BackgroundImage = nostalgicSongsNormalBackground;
chinaSongsButton.BackgroundImage = chinaNormalBackground;
ResetBtnStatus();
/*loveDuetSongs = allSongs.Where(song => song.SongGenre.Contains("A1")) /*loveDuetSongs = allSongs.Where(song => song.SongGenre.Contains("A1"))
.OrderByDescending(song => song.Plays) .OrderByDescending(song => song.Plays)

View File

@ -4,13 +4,7 @@ namespace DualScreenDemo
{ {
private void MedleyDanceButton_Click(object sender, EventArgs e) private void MedleyDanceButton_Click(object sender, EventArgs e)
{ {
loveDuetButton.BackgroundImage = loveDuetNormalBackground; ResetBtnStatus();
talentShowButton.BackgroundImage = talentShowNormalBackground;
medleyDanceButton.BackgroundImage = medleyDanceActiveBackground;
ninetiesButton.BackgroundImage = ninetiesNormalBackground;
nostalgicSongsButton.BackgroundImage = nostalgicSongsNormalBackground;
chinaSongsButton.BackgroundImage = chinaNormalBackground;
/*medleyDanceSongs = allSongs.Where(song => song.SongGenre.Contains("C1")) /*medleyDanceSongs = allSongs.Where(song => song.SongGenre.Contains("C1"))
.OrderByDescending(song => song.Plays) .OrderByDescending(song => song.Plays)

View File

@ -4,13 +4,7 @@ namespace DualScreenDemo
{ {
private void NinetiesButton_Click(object sender, EventArgs e) private void NinetiesButton_Click(object sender, EventArgs e)
{ {
loveDuetButton.BackgroundImage = loveDuetNormalBackground; ResetBtnStatus();
talentShowButton.BackgroundImage = talentShowNormalBackground;
medleyDanceButton.BackgroundImage = medleyDanceNormalBackground;
ninetiesButton.BackgroundImage = ninetiesActiveBackground;
nostalgicSongsButton.BackgroundImage = nostalgicSongsNormalBackground;
chinaSongsButton.BackgroundImage = chinaNormalBackground;
/*ninetiesSongs = allSongs.Where(song => song.SongGenre.Contains("D1")) /*ninetiesSongs = allSongs.Where(song => song.SongGenre.Contains("D1"))
.OrderByDescending(song => song.Plays) .OrderByDescending(song => song.Plays)

View File

@ -4,13 +4,7 @@ namespace DualScreenDemo
{ {
private void NostalgicSongsButton_Click(object sender, EventArgs e) private void NostalgicSongsButton_Click(object sender, EventArgs e)
{ {
loveDuetButton.BackgroundImage = loveDuetNormalBackground; ResetBtnStatus();
talentShowButton.BackgroundImage = talentShowNormalBackground;
medleyDanceButton.BackgroundImage = medleyDanceNormalBackground;
ninetiesButton.BackgroundImage = ninetiesNormalBackground;
nostalgicSongsButton.BackgroundImage = nostalgicSongsActiveBackground;
chinaSongsButton.BackgroundImage = chinaNormalBackground;
/*nostalgicSongs = allSongs.Where(song => song.SongGenre.Contains("E1")) /*nostalgicSongs = allSongs.Where(song => song.SongGenre.Contains("E1"))
.OrderByDescending(song => song.Plays) .OrderByDescending(song => song.Plays)

View File

@ -4,13 +4,7 @@ namespace DualScreenDemo
{ {
private void TalentShowButton_Click(object sender, EventArgs e) private void TalentShowButton_Click(object sender, EventArgs e)
{ {
loveDuetButton.BackgroundImage = loveDuetNormalBackground; ResetBtnStatus();
talentShowButton.BackgroundImage = talentShowActiveBackground;
medleyDanceButton.BackgroundImage = medleyDanceNormalBackground;
ninetiesButton.BackgroundImage = ninetiesNormalBackground;
nostalgicSongsButton.BackgroundImage = nostalgicSongsNormalBackground;
chinaSongsButton.BackgroundImage = chinaNormalBackground;
/*talentShowSongs = allSongs.Where(song => song.SongGenre.Contains("B1")) /*talentShowSongs = allSongs.Where(song => song.SongGenre.Contains("B1"))
.OrderByDescending(song => song.Plays) .OrderByDescending(song => song.Plays)

View File

@ -4,13 +4,7 @@ namespace DualScreenDemo
{ {
private void VietnameseSongsButton_Click(object sender, EventArgs e) private void VietnameseSongsButton_Click(object sender, EventArgs e)
{ {
loveDuetButton.BackgroundImage = loveDuetNormalBackground; ResetBtnStatus();
talentShowButton.BackgroundImage = talentShowNormalBackground;
medleyDanceButton.BackgroundImage = medleyDanceNormalBackground;
ninetiesButton.BackgroundImage = ninetiesNormalBackground;
nostalgicSongsButton.BackgroundImage = nostalgicSongsNormalBackground;
chinaSongsButton.BackgroundImage = chinaNormalBackground;
/*vietnameseSongs = allSongs.Where(song => song.SongGenre.Contains("G1")) /*vietnameseSongs = allSongs.Where(song => song.SongGenre.Contains("G1"))
.OrderByDescending(song => song.Plays) .OrderByDescending(song => song.Plays)

View File

@ -1,4 +1,5 @@
using System.IO; using System.IO;
using Utils;
namespace DualScreenDemo namespace DualScreenDemo
{ {
public partial class PrimaryForm public partial class PrimaryForm
@ -29,133 +30,131 @@ namespace DualScreenDemo
private Bitmap vietnameseNormalBackground; private Bitmap vietnameseNormalBackground;
private Bitmap vietnameseActiveBackground; private Bitmap vietnameseActiveBackground;
string serverPath = Utils.Env.GetPath("", "");
private void ResetBtnStatus()
{
loveDuetButton.BackgroundImage = loveDuetNormalBackground;
talentShowButton.BackgroundImage = talentShowNormalBackground;
medleyDanceButton.BackgroundImage = medleyDanceNormalBackground;
ninetiesButton.BackgroundImage = ninetiesNormalBackground;
nostalgicSongsButton.BackgroundImage = nostalgicSongsNormalBackground;
chinaSongsButton.BackgroundImage = chinaNormalBackground;
vietnameseSongsButton.BackgroundImage = vietnameseNormalBackground;
}
private void InitializeButtonsForCategorySearch() private void InitializeButtonsForCategorySearch()
{ {
var data=LoadConfigData();
categorySearchNormalBackground = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\1.主類別\\主類別上方_類別查詢(未按).png"));
categorySearchActiveBackground = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\1.主類別\\主類別上方_類別查詢(已按).png"));
categorySearchButton = new Button { Text = "" }; categorySearchButton = new Button { Text = "" };
categorySearchButton.Name = "categorySearchButton"; categorySearchButton.Name = "categorySearchButton";
ResizeAndPositionButton(categorySearchButton, 731, 97, 99, 99); ConfigureButton(categorySearchButton, 731, 97, 99, 99,
Rectangle categorySearchCropArea = new Rectangle(731, 97, 99, 99); categorySearchNormalBackground,
categorySearchNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\1.主類別\\主類別上方_類別查詢-07.png")); categorySearchActiveBackground,
categorySearchActiveBackground = mouseDownImage.Clone(categorySearchCropArea, mouseDownImage.PixelFormat); categorySearchActiveBackground,
categorySearchButton.BackgroundImage = categorySearchNormalBackground; CategorySearchButton_Click);
categorySearchButton.BackgroundImageLayout = ImageLayout.Stretch;
categorySearchButton.FlatStyle = FlatStyle.Flat;
categorySearchButton.FlatAppearance.BorderSize = 0;
categorySearchButton.Click += CategorySearchButton_Click;
this.Controls.Add(categorySearchButton);
} }
private void InitializeCategorySearchButtons() private void InitializeCategorySearchButtons()
{ {
loveDuetButton = new Button { Text = "", Visible = false }; loveDuetNormalBackground = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_男女情歌(未按).png"));
ResizeAndPositionButton(loveDuetButton, 1197, 225, 225, 50); talentShowNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_選秀節目(未按).png"));
Rectangle loveDuetButtonCropArea = new Rectangle(1197, 225, 225, 50); medleyDanceNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_串燒舞曲(未按).png"));
loveDuetNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_男女情歌(未按).png")); ninetiesNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_90年代(未按).png"));
nostalgicSongsNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_懷舊老歌(未按).png"));
chinaNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_中國大陸(未按).png"));
vietnameseNormalBackground= new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_越南歌曲(未按).png"));
loveDuetActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_男女情歌(已按).png")); loveDuetActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_男女情歌(已按).png"));
loveDuetButton.BackgroundImage = loveDuetNormalBackground; talentShowActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_選秀節目(已按).png"));
loveDuetButton.BackgroundImageLayout = ImageLayout.Stretch; medleyDanceActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_串燒舞曲(已按).png"));
loveDuetButton.FlatStyle = FlatStyle.Flat; ninetiesActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_90年代(已按).png"));
loveDuetButton.FlatAppearance.BorderSize = 0; nostalgicSongsActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_懷舊老歌(已按).png"));
loveDuetButton.Click += LoveDuetButton_Click; chinaActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_中國大陸(已按).png"));
this.Controls.Add(loveDuetButton); vietnameseActiveBackground= new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_越南歌曲(已按).png"));
loveDuetButton = new Button { Text = "", Visible = false };
ConfigureButton(loveDuetButton, 1197, 225, 225, 50,
loveDuetNormalBackground,
loveDuetNormalBackground,
loveDuetActiveBackground,
LoveDuetButton_Click);
loveDuetButton.MouseLeave += (sender, e) => loveDuetButton.BackgroundImage = loveDuetActiveBackground;
talentShowButton = new Button { Text = "", Visible = false }; talentShowButton = new Button { Text = "", Visible = false };
ResizeAndPositionButton(talentShowButton, 1197, 280, 225, 50); ConfigureButton(talentShowButton, 1197, 280, 225, 50,
Rectangle talentShowButtonCropArea = new Rectangle(1197, 280, 225, 50); talentShowNormalBackground,
talentShowNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_選秀節目(未按).png")); talentShowNormalBackground,
talentShowActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_選秀節目(已按).png")); talentShowNormalBackground,
talentShowButton.BackgroundImage = talentShowNormalBackground; TalentShowButton_Click);
talentShowButton.BackgroundImageLayout = ImageLayout.Stretch;
talentShowButton.FlatStyle = FlatStyle.Flat; talentShowButton.MouseLeave += (sender, e) => talentShowButton.BackgroundImage = talentShowActiveBackground;
talentShowButton.FlatAppearance.BorderSize = 0;
talentShowButton.Click += TalentShowButton_Click;
this.Controls.Add(talentShowButton);
medleyDanceButton = new Button { Text = "", Visible = false }; medleyDanceButton = new Button { Text = "", Visible = false };
ResizeAndPositionButton(medleyDanceButton, 1197, 335, 225, 50); ConfigureButton(medleyDanceButton, 1197, 335, 225, 50,
Rectangle medleyDanceButtonCropArea = new Rectangle(1197, 335, 225, 50); medleyDanceNormalBackground,
medleyDanceNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_串燒舞曲(未按).png")); medleyDanceNormalBackground,
medleyDanceActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_串燒舞曲(已按).png")); medleyDanceNormalBackground,
medleyDanceButton.BackgroundImage = medleyDanceNormalBackground; MedleyDanceButton_Click);
medleyDanceButton.BackgroundImageLayout = ImageLayout.Stretch;
medleyDanceButton.FlatStyle = FlatStyle.Flat; medleyDanceButton.MouseLeave += (sender, e) => medleyDanceButton.BackgroundImage = medleyDanceActiveBackground;
medleyDanceButton.FlatAppearance.BorderSize = 0;
medleyDanceButton.Click += MedleyDanceButton_Click;
this.Controls.Add(medleyDanceButton);
ninetiesButton = new Button { Text = "", Visible = false }; ninetiesButton = new Button { Text = "", Visible = false };
ResizeAndPositionButton(ninetiesButton, 1197, 390, 225, 50); ConfigureButton(ninetiesButton, 1197, 390, 225, 50,
Rectangle ninetiesButtonCropArea = new Rectangle(1197, 390, 225, 50); ninetiesNormalBackground,
ninetiesNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_90年代(未按).png")); ninetiesNormalBackground,
ninetiesActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_90年代(已按).png")); ninetiesNormalBackground,
ninetiesButton.BackgroundImage = ninetiesNormalBackground; NinetiesButton_Click);
ninetiesButton.BackgroundImageLayout = ImageLayout.Stretch;
ninetiesButton.FlatStyle = FlatStyle.Flat; ninetiesButton.MouseLeave += (sender, e) => ninetiesButton.BackgroundImage = ninetiesActiveBackground;
ninetiesButton.FlatAppearance.BorderSize = 0;
ninetiesButton.Click += NinetiesButton_Click;
this.Controls.Add(ninetiesButton);
nostalgicSongsButton = new Button { Text = "", Visible = false }; nostalgicSongsButton = new Button { Text = "", Visible = false };
ResizeAndPositionButton(nostalgicSongsButton, 1197, 445, 225, 50); ConfigureButton(nostalgicSongsButton, 1197, 445, 225, 50,
Rectangle nostalgicSongsButtonCropArea = new Rectangle(1197, 445, 225, 50); nostalgicSongsNormalBackground,
nostalgicSongsNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_懷舊老歌(未按).png")); nostalgicSongsNormalBackground,
nostalgicSongsActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_懷舊老歌(已按).png")); nostalgicSongsNormalBackground,
nostalgicSongsButton.BackgroundImage = nostalgicSongsNormalBackground; NostalgicSongsButton_Click);
nostalgicSongsButton.BackgroundImageLayout = ImageLayout.Stretch;
nostalgicSongsButton.FlatStyle = FlatStyle.Flat; nostalgicSongsButton.MouseLeave += (sender, e) => nostalgicSongsButton.BackgroundImage = nostalgicSongsActiveBackground;
nostalgicSongsButton.FlatAppearance.BorderSize = 0;
nostalgicSongsButton.Click += NostalgicSongsButton_Click;
this.Controls.Add(nostalgicSongsButton);
chinaSongsButton = new Button { Text = "", Visible = false }; chinaSongsButton = new Button { Text = "", Visible = false };
ResizeAndPositionButton(chinaSongsButton, 1197, 500, 225, 50); ConfigureButton(chinaSongsButton, 1197, 500, 225, 50,
Rectangle chinaCropArea = new Rectangle(1197, 500, 225, 50); chinaNormalBackground,
chinaNormalBackground,
chinaNormalBackground,
ChinaSongsButton_Click);
chinaSongsButton.MouseLeave += (sender, e) => chinaSongsButton.BackgroundImage = chinaActiveBackground;
chinaNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_中國大陸(未按).png"));
chinaActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_中國大陸(已按).png"));
chinaSongsButton.BackgroundImage = chinaNormalBackground;
chinaSongsButton.BackgroundImageLayout = ImageLayout.Stretch;
chinaSongsButton.FlatStyle = FlatStyle.Flat;
chinaSongsButton.FlatAppearance.BorderSize = 0;
chinaSongsButton.Click += ChinaSongsButton_Click;
this.Controls.Add(chinaSongsButton);
vietnameseSongsButton = new Button { Text = "", Visible = false }; vietnameseSongsButton = new Button { Text = "", Visible = false };
ResizeAndPositionButton(vietnameseSongsButton, 1197, 555, 225, 50); ConfigureButton(vietnameseSongsButton, 1197, 555, 225, 50,
Rectangle vietnameseCropArea = new Rectangle(1197, 555, 225, 50); vietnameseNormalBackground,
vietnameseNormalBackground,
vietnameseNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_越南歌曲(未按).png")); vietnameseNormalBackground,
vietnameseActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_越南歌曲(已按).png")); VietnameseSongsButton_Click);
vietnameseSongsButton.BackgroundImage = vietnameseNormalBackground;
vietnameseSongsButton.BackgroundImageLayout = ImageLayout.Stretch;
vietnameseSongsButton.FlatStyle = FlatStyle.Flat;
vietnameseSongsButton.FlatAppearance.BorderSize = 0;
vietnameseSongsButton.Click += VietnameseSongsButton_Click;
this.Controls.Add(vietnameseSongsButton);
vietnameseSongsButton.MouseLeave += (sender, e) => vietnameseSongsButton.BackgroundImage = vietnameseActiveBackground;
} }
private void CategorySearchButton_Click(object sender, EventArgs e) private void CategorySearchButton_Click(object sender, EventArgs e)
{ {
newSongAlertButton.BackgroundImage = newSongAlertNormalBackground; newSongAlertButton.BackgroundImage = newSongAlertNormalBackground;
hotPlayButton.BackgroundImage = hotPlayNormalBackground; hotPlayButton.BackgroundImage = hotPlayNormalBackground;
singerSearchButton.BackgroundImage = singerSearchNormalBackground; singerSearchButton.BackgroundImage = singerSearchNormalBackground;
@ -169,13 +168,9 @@ namespace DualScreenDemo
deliciousFoodButton.BackgroundImage = deliciousFoodNormalBackground; deliciousFoodButton.BackgroundImage = deliciousFoodNormalBackground;
isOnOrderedSongsPage = false; isOnOrderedSongsPage = false;
loveDuetButton.BackgroundImage = loveDuetActiveBackground; ResetBtnStatus();
talentShowButton.BackgroundImage = talentShowNormalBackground;
medleyDanceButton.BackgroundImage = medleyDanceNormalBackground;
ninetiesButton.BackgroundImage = ninetiesNormalBackground;
nostalgicSongsButton.BackgroundImage = nostalgicSongsNormalBackground;
chinaSongsButton.BackgroundImage = chinaNormalBackground;
loveDuetButton.BackgroundImage = loveDuetActiveBackground;
/*loveDuetSongs = allSongs.Where(song => song.SongGenre.Contains("A1")) /*loveDuetSongs = allSongs.Where(song => song.SongGenre.Contains("A1"))
.OrderByDescending(song => song.Plays) .OrderByDescending(song => song.Plays)