類別查詢代碼重構

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,14 +4,8 @@ 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)
.ToList();*/ .ToList();*/

View File

@ -4,20 +4,15 @@ namespace DualScreenDemo
{ {
private void LoveDuetButton_Click(object sender, EventArgs e) private void LoveDuetButton_Click(object sender, EventArgs e)
{ {
loveDuetButton.BackgroundImage = loveDuetActiveBackground;
talentShowButton.BackgroundImage = talentShowNormalBackground; ResetBtnStatus();
medleyDanceButton.BackgroundImage = medleyDanceNormalBackground;
ninetiesButton.BackgroundImage = ninetiesNormalBackground;
nostalgicSongsButton.BackgroundImage = nostalgicSongsNormalBackground;
chinaSongsButton.BackgroundImage = chinaNormalBackground;
/*loveDuetSongs = allSongs.Where(song => song.SongGenre.Contains("A1")) /*loveDuetSongs = allSongs.Where(song => song.SongGenre.Contains("A1"))
.OrderByDescending(song => song.Plays) .OrderByDescending(song => song.Plays)
.ToList();*/ .ToList();*/
string query = SetQueryforSQL("A1"); // Set the query for SQL to filter by genre "F1" string query = SetQueryforSQL("A1"); // Set the query for SQL to filter by genre "F1"
var loveDuetSongs = SearchSongs_Mysql(query); var loveDuetSongs = SearchSongs_Mysql(query);
currentPage = 0; currentPage = 0;
totalPages = (int)Math.Ceiling((double)loveDuetSongs.Count / itemsPerPage); totalPages = (int)Math.Ceiling((double)loveDuetSongs.Count / itemsPerPage);
multiPagePanel.currentPageIndex = 0; multiPagePanel.currentPageIndex = 0;

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,14 +4,8 @@ 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)
.ToList();*/ .ToList();*/

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
@ -28,134 +29,132 @@ namespace DualScreenDemo
private Button vietnameseSongsButton; private Button vietnameseSongsButton;
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 };
ResizeAndPositionButton(loveDuetButton, 1197, 225, 225, 50);
Rectangle loveDuetButtonCropArea = new Rectangle(1197, 225, 225, 50);
loveDuetNormalBackground = 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;
loveDuetButton.BackgroundImageLayout = ImageLayout.Stretch;
loveDuetButton.FlatStyle = FlatStyle.Flat;
loveDuetButton.FlatAppearance.BorderSize = 0;
loveDuetButton.Click += LoveDuetButton_Click;
this.Controls.Add(loveDuetButton);
loveDuetNormalBackground = new Bitmap(Path.Combine(serverPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_男女情歌(未按).png"));
talentShowButton = new Button { Text = "", Visible = false };
ResizeAndPositionButton(talentShowButton, 1197, 280, 225, 50);
Rectangle talentShowButtonCropArea = new Rectangle(1197, 280, 225, 50);
talentShowNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_選秀節目(未按).png")); talentShowNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_選秀節目(未按).png"));
talentShowActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_選秀節目(已按).png"));
talentShowButton.BackgroundImage = talentShowNormalBackground;
talentShowButton.BackgroundImageLayout = ImageLayout.Stretch;
talentShowButton.FlatStyle = FlatStyle.Flat;
talentShowButton.FlatAppearance.BorderSize = 0;
talentShowButton.Click += TalentShowButton_Click;
this.Controls.Add(talentShowButton);
medleyDanceButton = new Button { Text = "", Visible = false };
ResizeAndPositionButton(medleyDanceButton, 1197, 335, 225, 50);
Rectangle medleyDanceButtonCropArea = new Rectangle(1197, 335, 225, 50);
medleyDanceNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_串燒舞曲(未按).png")); medleyDanceNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_串燒舞曲(未按).png"));
medleyDanceActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_串燒舞曲(已按).png"));
medleyDanceButton.BackgroundImage = medleyDanceNormalBackground;
medleyDanceButton.BackgroundImageLayout = ImageLayout.Stretch;
medleyDanceButton.FlatStyle = FlatStyle.Flat;
medleyDanceButton.FlatAppearance.BorderSize = 0;
medleyDanceButton.Click += MedleyDanceButton_Click;
this.Controls.Add(medleyDanceButton);
ninetiesButton = new Button { Text = "", Visible = false };
ResizeAndPositionButton(ninetiesButton, 1197, 390, 225, 50);
Rectangle ninetiesButtonCropArea = new Rectangle(1197, 390, 225, 50);
ninetiesNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_90年代(未按).png")); ninetiesNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_90年代(未按).png"));
ninetiesActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_90年代(已按).png"));
ninetiesButton.BackgroundImage = ninetiesNormalBackground;
ninetiesButton.BackgroundImageLayout = ImageLayout.Stretch;
ninetiesButton.FlatStyle = FlatStyle.Flat;
ninetiesButton.FlatAppearance.BorderSize = 0;
ninetiesButton.Click += NinetiesButton_Click;
this.Controls.Add(ninetiesButton);
nostalgicSongsButton = new Button { Text = "", Visible = false };
ResizeAndPositionButton(nostalgicSongsButton, 1197, 445, 225, 50);
Rectangle nostalgicSongsButtonCropArea = new Rectangle(1197, 445, 225, 50);
nostalgicSongsNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_懷舊老歌(未按).png")); nostalgicSongsNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_懷舊老歌(未按).png"));
nostalgicSongsActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_懷舊老歌(已按).png"));
nostalgicSongsButton.BackgroundImage = nostalgicSongsNormalBackground;
nostalgicSongsButton.BackgroundImageLayout = ImageLayout.Stretch;
nostalgicSongsButton.FlatStyle = FlatStyle.Flat;
nostalgicSongsButton.FlatAppearance.BorderSize = 0;
nostalgicSongsButton.Click += NostalgicSongsButton_Click;
this.Controls.Add(nostalgicSongsButton);
chinaSongsButton = new Button { Text = "", Visible = false };
ResizeAndPositionButton(chinaSongsButton, 1197, 500, 225, 50);
Rectangle chinaCropArea = new Rectangle(1197, 500, 225, 50);
chinaNormalBackground = 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"));
talentShowActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_選秀節目(已按).png"));
medleyDanceActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_串燒舞曲(已按).png"));
ninetiesActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_90年代(已按).png"));
nostalgicSongsActiveBackground = 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")); chinaActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_中國大陸(已按).png"));
chinaSongsButton.BackgroundImage = chinaNormalBackground; vietnameseActiveBackground= new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_越南歌曲(已按).png"));
chinaSongsButton.BackgroundImageLayout = ImageLayout.Stretch;
chinaSongsButton.FlatStyle = FlatStyle.Flat; loveDuetButton = new Button { Text = "", Visible = false };
chinaSongsButton.FlatAppearance.BorderSize = 0; ConfigureButton(loveDuetButton, 1197, 225, 225, 50,
chinaSongsButton.Click += ChinaSongsButton_Click; loveDuetNormalBackground,
this.Controls.Add(chinaSongsButton); loveDuetNormalBackground,
loveDuetActiveBackground,
LoveDuetButton_Click);
loveDuetButton.MouseLeave += (sender, e) => loveDuetButton.BackgroundImage = loveDuetActiveBackground;
talentShowButton = new Button { Text = "", Visible = false };
ConfigureButton(talentShowButton, 1197, 280, 225, 50,
talentShowNormalBackground,
talentShowNormalBackground,
talentShowNormalBackground,
TalentShowButton_Click);
talentShowButton.MouseLeave += (sender, e) => talentShowButton.BackgroundImage = talentShowActiveBackground;
medleyDanceButton = new Button { Text = "", Visible = false };
ConfigureButton(medleyDanceButton, 1197, 335, 225, 50,
medleyDanceNormalBackground,
medleyDanceNormalBackground,
medleyDanceNormalBackground,
MedleyDanceButton_Click);
medleyDanceButton.MouseLeave += (sender, e) => medleyDanceButton.BackgroundImage = medleyDanceActiveBackground;
ninetiesButton = new Button { Text = "", Visible = false };
ConfigureButton(ninetiesButton, 1197, 390, 225, 50,
ninetiesNormalBackground,
ninetiesNormalBackground,
ninetiesNormalBackground,
NinetiesButton_Click);
ninetiesButton.MouseLeave += (sender, e) => ninetiesButton.BackgroundImage = ninetiesActiveBackground;
nostalgicSongsButton = new Button { Text = "", Visible = false };
ConfigureButton(nostalgicSongsButton, 1197, 445, 225, 50,
nostalgicSongsNormalBackground,
nostalgicSongsNormalBackground,
nostalgicSongsNormalBackground,
NostalgicSongsButton_Click);
nostalgicSongsButton.MouseLeave += (sender, e) => nostalgicSongsButton.BackgroundImage = nostalgicSongsActiveBackground;
chinaSongsButton = new Button { Text = "", Visible = false };
ConfigureButton(chinaSongsButton, 1197, 500, 225, 50,
chinaNormalBackground,
chinaNormalBackground,
chinaNormalBackground,
ChinaSongsButton_Click);
chinaSongsButton.MouseLeave += (sender, e) => chinaSongsButton.BackgroundImage = chinaActiveBackground;
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.MouseLeave += (sender, e) => vietnameseSongsButton.BackgroundImage = vietnameseActiveBackground;
vietnameseSongsButton.FlatStyle = FlatStyle.Flat;
vietnameseSongsButton.FlatAppearance.BorderSize = 0;
vietnameseSongsButton.Click += VietnameseSongsButton_Click;
this.Controls.Add(vietnameseSongsButton);
} }
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,14 +168,10 @@ 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)
.ToList();*/ .ToList();*/