superstar_v2/PrimaryFormParts/SongSearch/PrimaryForm.SongSearch.cs

157 lines
9.2 KiB
C#
Raw Normal View History

2025-08-06 10:47:43 +08:00
using System.IO;
2025-04-07 16:54:10 +08:00
namespace DualScreenDemo
{
/*
* (PrimaryForm)
* UI
*/
public partial class PrimaryForm
{
// 各種歌曲搜尋按鈕及其對應的背景圖片 (一般狀態 / 啟動狀態)
private Button zhuyinSearchSongButton;
2025-08-06 10:47:43 +08:00
private Bitmap zhuyinSearchSongNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\4.歌名查詢_注音查詢(未按).png"));
private Bitmap zhuyinSearchSongActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\4.歌名查詢_注音查詢(已按).png"));
2025-04-07 16:54:10 +08:00
private Button englishSearchSongButton;
2025-08-06 10:47:43 +08:00
private Bitmap englishSearchSongNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\4.歌名查詢_英文查詢(未按).png"));
private Bitmap englishSearchSongActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\4.歌名查詢_英文查詢(已按).png"));
2025-04-07 16:54:10 +08:00
private Button wordCountSearchSongButton;
2025-08-06 10:47:43 +08:00
private Bitmap wordCountSearchSongNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\4.歌名查詢_字數查詢(未按).png"));
private Bitmap wordCountSearchSongActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\4.歌名查詢_字數查詢(已按).png"));
2025-04-07 16:54:10 +08:00
private Button pinyinSearchSongButton;
2025-08-06 10:47:43 +08:00
private Bitmap pinyinSearchSongNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\4.歌名查詢_拼音查詢(未按).png"));
private Bitmap pinyinSearchSongActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\4.歌名查詢_拼音查詢(已按).png"));
2025-04-07 16:54:10 +08:00
private Button handWritingSearchSongButton;
2025-08-06 10:47:43 +08:00
private Bitmap handWritingSearchSongNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\4.歌名查詢_手寫查詢(未按).png"));
private Bitmap handWritingSearchSongActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\4.歌名查詢_手寫查詢(已按).png"));
2025-04-07 16:54:10 +08:00
private Button numberSearchSongButton;
2025-08-06 10:47:43 +08:00
private Bitmap numberSearchSongNormalBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\4.歌名查詢_編號查詢(未按).png"));
private Bitmap numberSearchSongActiveBackground = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\2.次類別\\4.歌名查詢_編號查詢(已按).png"));
2025-04-07 16:54:10 +08:00
/// <summary>
/// 點擊「歌曲搜尋」按鈕時的事件處理函式
/// 1. 更新導航按鈕的背景圖片,使「歌曲搜尋」按鈕顯示為啟動狀態
/// 2. 隱藏其他搜尋/分類 UI僅顯示歌曲搜尋選單
/// 3. 若有 QR Code 顯示,則將其隱藏
/// </summary>
private void SongSearchButton_Click(object sender, EventArgs e)
{
// 更新導航按鈕的背景圖片
newSongAlertButton.BackgroundImage = newSongAlertNormalBackground;
hotPlayButton.BackgroundImage = hotPlayNormalBackground;
singerSearchButton.BackgroundImage = singerSearchNormalBackground;
songSearchButton.BackgroundImage = songSearchActiveBackground;
2025-08-06 10:47:43 +08:00
songSearchButton.BackgroundImage = new Bitmap(Path.Combine(Application.StartupPath, "themes\\superstar\\button\\1.主類別\\主類別上方_歌名查詢(已按).png"));
2025-04-07 16:54:10 +08:00
languageSearchButton.BackgroundImage = languageSearchNormalBackground;
groupSearchButton.BackgroundImage = groupSearchNormalBackground;
categorySearchButton.BackgroundImage = categorySearchNormalBackground;
orderedSongsButton.BackgroundImage = orderedSongsNormalBackground;
myFavoritesButton.BackgroundImage = myFavoritesNormalBackground;
promotionsButton.BackgroundImage = promotionsNormalBackground;
deliciousFoodButton.BackgroundImage = deliciousFoodNormalBackground;
isOnOrderedSongsPage = false;
ResetinputBox();
2025-08-06 10:47:43 +08:00
string query = $"SELECT * FROM song_library_cache WHERE language_name = '國語' LIMIT 1000;";
var searchResult = SearchSongs_Mysql(query);
currentPage = 0;
totalPages = (int)Math.Ceiling((double)searchResult.Count / itemsPerPage);
multiPagePanel.currentPageIndex = 0;
multiPagePanel.LoadSongs(searchResult);
2025-04-07 16:54:10 +08:00
// 隱藏其他 UI
SetHotSongButtonsVisibility(false);
SetNewSongButtonsVisibility(false);
SetSingerSearchButtonsVisibility(false);
SetPictureBoxLanguageButtonsVisibility(false);
SetGroupButtonsVisibility(false);
SetPictureBoxCategoryAndButtonsVisibility(false);
SetZhuYinSingersAndButtonsVisibility(false);
SetZhuYinSongsAndButtonsVisibility(false);
SetEnglishSingersAndButtonsVisibility(false);
SetPinYinSingersAndButtonsVisibility(false);
SetPinYinSongsAndButtonsVisibility(false);
SetPictureBoxToggleLightAndButtonsVisibility(false);
SetPictureBoxSceneSoundEffectsAndButtonsVisibility(false);
// 顯示歌曲搜尋選單按鈕
SetSongSearchButtonsVisibility(true);
// 隱藏 QR Code (若有)
if (pictureBoxQRCode != null)
{
pictureBoxQRCode.Visible = false;
closeQRCodeButton.Visible = false;
}
}
/// <summary>
/// 設定「歌曲搜尋」相關按鈕的可見性
/// </summary>
/// <param name="isVisible">是否顯示</param>
private void SetSongSearchButtonsVisibility(bool isVisible)
{
pictureBox4.Visible = isVisible; // 控制搜尋 UI 背景的可見性
// 歌曲搜尋的按鈕陣列
Button[] songSearchButtons = {
zhuyinSearchSongButton,
englishSearchSongButton,
wordCountSearchSongButton,
pinyinSearchSongButton,
handWritingSearchSongButton,
numberSearchSongButton
};
// 設定按鈕可見性,若顯示則移至最前
foreach (var button in songSearchButtons)
{
button.Visible = isVisible;
if (isVisible)
{
button.BringToFront();
}
}
}
/// <summary>
/// 初始化所有「歌曲搜尋」按鈕
/// 依據不同的搜尋方式 (注音、英文、拼音、筆劃、手寫、數字) 建立對應按鈕
/// </summary>
private void InitializeButtonsForSongSearch()
{
// 初始化「注音搜尋」按鈕
InitializeSearchButton(ref zhuyinSearchSongButton, "zhuyinSearchSongButton",
2025-08-06 10:47:43 +08:00
1197, 225, 225, 50, ref zhuyinSearchSongNormalBackground, ref zhuyinSearchSongActiveBackground,
2025-04-07 16:54:10 +08:00
normalStateImageSongQuery, mouseDownImageSongQuery, ZhuyinSearchSongsButton_Click);
// 初始化「英文搜尋」按鈕
InitializeSearchButton(ref englishSearchSongButton, "englishSearchSongButton",
2025-08-06 10:47:43 +08:00
1197, 280, 225, 50, ref englishSearchSongNormalBackground, ref englishSearchSongActiveBackground,
2025-04-07 16:54:10 +08:00
normalStateImageSongQuery, mouseDownImageSongQuery, EnglishSearchSongsButton_Click);
// 初始化「拼音搜尋」按鈕
InitializeSearchButton(ref pinyinSearchSongButton, "pinyinSearchSongButton",
2025-08-06 10:47:43 +08:00
1197, 335, 225, 50, ref pinyinSearchSongNormalBackground, ref pinyinSearchSongActiveBackground,
2025-04-07 16:54:10 +08:00
normalStateImageSongQuery, mouseDownImageSongQuery, PinyinSearchSongsButton_Click);
// 初始化「筆劃搜尋」按鈕
InitializeSearchButton(ref wordCountSearchSongButton, "wordCountSearchSongButton",
2025-08-06 10:47:43 +08:00
1197, 390, 225, 50, ref wordCountSearchSongNormalBackground, ref wordCountSearchSongActiveBackground,
2025-04-07 16:54:10 +08:00
normalStateImageSongQuery, mouseDownImageSongQuery, WordCountSearchSongsButton_Click);
// 初始化「手寫搜尋」按鈕
InitializeSearchButton(ref handWritingSearchSongButton, "handWritingSearchSongButton",
2025-08-06 10:47:43 +08:00
1197, 445, 225, 50, ref handWritingSearchSongNormalBackground, ref handWritingSearchSongActiveBackground,
2025-04-07 16:54:10 +08:00
normalStateImageSongQuery, mouseDownImageSongQuery, HandWritingSearchButtonForSongs_Click);
// 初始化「數字搜尋」按鈕
InitializeSearchButton(ref numberSearchSongButton, "numberSearchSongButton",
2025-08-06 10:47:43 +08:00
1197, 500, 225, 50, ref numberSearchSongNormalBackground, ref numberSearchSongActiveBackground,
2025-04-07 16:54:10 +08:00
normalStateImageSongQuery, mouseDownImageSongQuery, SongIDSearchSongsButton_Click);
}
}
}