注音歌曲SQL查詢
This commit is contained in:
parent
397d8f9e5a
commit
6e8b2a36db
@ -11,7 +11,7 @@ namespace DualScreenDemo
|
||||
/* 關機 queue */
|
||||
private readonly int _maxHistoryLength = 6; // 最多保留 6 筆
|
||||
private readonly Queue<string> _indataHistory = new Queue<string>();
|
||||
|
||||
/* 顯示按鈕設定 */
|
||||
private int _wrongInputCountfor62 = 0; // 錯誤輸入計數器
|
||||
private int _wrongInputCountfor61 = 0; // 錯誤輸入計數器
|
||||
private const int MaxWrongLimit = 3; // 錯誤輸入限制次數
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System.IO;
|
||||
using IniParser;
|
||||
using IniParser.Model;
|
||||
using DBObj;
|
||||
/* Song Search with ZhuYin */
|
||||
namespace DualScreenDemo
|
||||
{
|
||||
@ -299,7 +300,27 @@ namespace DualScreenDemo
|
||||
zhuyinSearchSongButton.BackgroundImage = zhuyinSearchSongNormalBackground;
|
||||
// 隱藏注音輸入的所有按鈕與介面元素
|
||||
SetZhuYinSongsAndButtonsVisibility(false);
|
||||
FindZhuYiSongs(); // 查詢歌曲
|
||||
}
|
||||
/// <summary>
|
||||
/// 查詢歌曲(字數查詢),連接資料庫並執行 SQL 查詢。
|
||||
/// </summary>
|
||||
private void FindZhuYiSongs(){
|
||||
string searchText = inputBoxZhuYinSongs.Text;
|
||||
// 在這裡添加搜尋歌曲的邏輯
|
||||
// 例如:根據輸入框的內容搜尋歌曲
|
||||
string query = $"SELECT * FROM SongLibrary WHERE `歌曲注音` = '{searchText}' ";
|
||||
|
||||
List<SongData> searchResults = SearchSongs_Mysql(query);
|
||||
// 重置分頁
|
||||
currentPage = 0;
|
||||
currentSongList = searchResults;
|
||||
totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage);
|
||||
// 更新多頁面面板的內容
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 初始化注音輸入框 (RichTextBox),設定外觀、事件處理及位置大小
|
||||
@ -324,24 +345,6 @@ namespace DualScreenDemo
|
||||
ResizeAndPositionControl(inputBoxZhuYinSongs, inputBoxZhuYinCoords.X, inputBoxZhuYinCoords.Y,
|
||||
inputBoxZhuYinCoords.Width, inputBoxZhuYinCoords.Height);
|
||||
|
||||
// 設定文字變更事件,用來即時篩選歌曲
|
||||
inputBoxZhuYinSongs.TextChanged += (sender, e) =>
|
||||
{
|
||||
string searchText = inputBoxZhuYinSongs.Text; // 取得輸入內容
|
||||
|
||||
// 根據輸入的注音篩選歌曲清單
|
||||
var searchResults = allSongs.Where(song => song.PhoneticNotation.StartsWith(searchText)).ToList();
|
||||
|
||||
// 重置分頁
|
||||
currentPage = 0;
|
||||
currentSongList = searchResults;
|
||||
totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage);
|
||||
|
||||
// 更新多頁面面板的內容
|
||||
multiPagePanel.currentPageIndex = 0;
|
||||
multiPagePanel.LoadSongs(currentSongList);
|
||||
};
|
||||
|
||||
// 將輸入框加入到 UI 控制項
|
||||
this.Controls.Add(inputBoxZhuYinSongs);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user