類別查詢代碼重構

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)
{
loveDuetButton.BackgroundImage = loveDuetNormalBackground;
talentShowButton.BackgroundImage = talentShowNormalBackground;
medleyDanceButton.BackgroundImage = medleyDanceNormalBackground;
ninetiesButton.BackgroundImage = ninetiesNormalBackground;
nostalgicSongsButton.BackgroundImage = nostalgicSongsNormalBackground;
chinaSongsButton.BackgroundImage = chinaActiveBackground;
ResetBtnStatus();
/*chinaSongs = allSongs.Where(song => song.SongGenre.Contains("F1"))
.OrderByDescending(song => song.Plays)
.ToList();*/

View File

@ -4,20 +4,15 @@ namespace DualScreenDemo
{
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"))
.OrderByDescending(song => song.Plays)
.ToList();*/
string query = SetQueryforSQL("A1"); // Set the query for SQL to filter by genre "F1"
var loveDuetSongs = SearchSongs_Mysql(query);
currentPage = 0;
var loveDuetSongs = SearchSongs_Mysql(query);
currentPage = 0;
totalPages = (int)Math.Ceiling((double)loveDuetSongs.Count / itemsPerPage);
multiPagePanel.currentPageIndex = 0;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,5 @@
using System.IO;
using System.IO;
using Utils;
namespace DualScreenDemo
{
public partial class PrimaryForm
@ -28,134 +29,132 @@ namespace DualScreenDemo
private Button vietnameseSongsButton;
private Bitmap vietnameseNormalBackground;
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()
{
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.Name = "categorySearchButton";
ResizeAndPositionButton(categorySearchButton, 731, 97, 99, 99);
Rectangle categorySearchCropArea = new Rectangle(731, 97, 99, 99);
categorySearchNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\1.主類別\\主類別上方_類別查詢-07.png"));
categorySearchActiveBackground = mouseDownImage.Clone(categorySearchCropArea, mouseDownImage.PixelFormat);
categorySearchButton.BackgroundImage = categorySearchNormalBackground;
categorySearchButton.BackgroundImageLayout = ImageLayout.Stretch;
categorySearchButton.FlatStyle = FlatStyle.Flat;
categorySearchButton.FlatAppearance.BorderSize = 0;
categorySearchButton.Click += CategorySearchButton_Click;
this.Controls.Add(categorySearchButton);
ConfigureButton(categorySearchButton, 731, 97, 99, 99,
categorySearchNormalBackground,
categorySearchActiveBackground,
categorySearchActiveBackground,
CategorySearchButton_Click);
}
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);
talentShowButton = new Button { Text = "", Visible = false };
ResizeAndPositionButton(talentShowButton, 1197, 280, 225, 50);
Rectangle talentShowButtonCropArea = new Rectangle(1197, 280, 225, 50);
loveDuetNormalBackground = new Bitmap(Path.Combine(serverPath, "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"));
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"));
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"));
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"));
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"));
chinaSongsButton.BackgroundImage = chinaNormalBackground;
chinaSongsButton.BackgroundImageLayout = ImageLayout.Stretch;
chinaSongsButton.FlatStyle = FlatStyle.Flat;
chinaSongsButton.FlatAppearance.BorderSize = 0;
chinaSongsButton.Click += ChinaSongsButton_Click;
this.Controls.Add(chinaSongsButton);
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 };
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 };
ResizeAndPositionButton(vietnameseSongsButton, 1197, 555, 225, 50);
Rectangle vietnameseCropArea = new Rectangle(1197, 555, 225, 50);
vietnameseNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_越南歌曲(未按).png"));
vietnameseActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\7.類別查詢_越南歌曲(已按).png"));
vietnameseSongsButton.BackgroundImage = vietnameseNormalBackground;
vietnameseSongsButton.BackgroundImageLayout = ImageLayout.Stretch;
vietnameseSongsButton.FlatStyle = FlatStyle.Flat;
vietnameseSongsButton.FlatAppearance.BorderSize = 0;
vietnameseSongsButton.Click += VietnameseSongsButton_Click;
this.Controls.Add(vietnameseSongsButton);
ConfigureButton(vietnameseSongsButton, 1197, 555, 225, 50,
vietnameseNormalBackground,
vietnameseNormalBackground,
vietnameseNormalBackground,
VietnameseSongsButton_Click);
vietnameseSongsButton.MouseLeave += (sender, e) => vietnameseSongsButton.BackgroundImage = vietnameseActiveBackground;
}
private void CategorySearchButton_Click(object sender, EventArgs e)
{
newSongAlertButton.BackgroundImage = newSongAlertNormalBackground;
hotPlayButton.BackgroundImage = hotPlayNormalBackground;
singerSearchButton.BackgroundImage = singerSearchNormalBackground;
@ -169,14 +168,10 @@ namespace DualScreenDemo
deliciousFoodButton.BackgroundImage = deliciousFoodNormalBackground;
isOnOrderedSongsPage = false;
loveDuetButton.BackgroundImage = loveDuetActiveBackground;
talentShowButton.BackgroundImage = talentShowNormalBackground;
medleyDanceButton.BackgroundImage = medleyDanceNormalBackground;
ninetiesButton.BackgroundImage = ninetiesNormalBackground;
nostalgicSongsButton.BackgroundImage = nostalgicSongsNormalBackground;
chinaSongsButton.BackgroundImage = chinaNormalBackground;
ResetBtnStatus();
loveDuetButton.BackgroundImage = loveDuetActiveBackground;
/*loveDuetSongs = allSongs.Where(song => song.SongGenre.Contains("A1"))
.OrderByDescending(song => song.Plays)
.ToList();*/