diff --git a/PrimaryFormParts/SongSearch/PrimaryForm.SongSearch.EnglishSearch.cs b/PrimaryFormParts/SongSearch/PrimaryForm.SongSearch.EnglishSearch.cs index 76c262a..f813f06 100644 --- a/PrimaryFormParts/SongSearch/PrimaryForm.SongSearch.EnglishSearch.cs +++ b/PrimaryFormParts/SongSearch/PrimaryForm.SongSearch.EnglishSearch.cs @@ -224,6 +224,24 @@ namespace DualScreenDemo pictureBoxEnglishSongs.Visible = false; englishSearchSongButton.BackgroundImage = englishSearchSongNormalBackground; SetEnglishSongsAndButtonsVisibility(false); + FindEnglishSongs(); + } + private void FindEnglishSongs(){ + string searchText = inputBoxEnglishSongs.Text; + // 在這裡添加搜尋歌曲的邏輯 + // 例如:根據輸入框的內容搜尋歌曲 + string query = $"SELECT * FROM SongLibrary WHERE `歌曲名稱` LIKE '{searchText}%' "; + + var searchResults = SearchSongs_Mysql(query); + // 重置分頁 + currentPage = 0; + currentSongList = searchResults; + totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage); + // 更新多頁面面板的內容 + multiPagePanel.currentPageIndex = 0; + multiPagePanel.LoadSongs(currentSongList); + + } private void InitializeInputBoxEnglishSongs() @@ -260,18 +278,6 @@ namespace DualScreenDemo }; ResizeAndPositionControl(inputBoxEnglishSongs, x, y, width, height); - /*搜尋結果 傳回點歌介面*/ - inputBoxEnglishSongs.TextChanged += (sender, e) => - { - string searchText = inputBoxEnglishSongs.Text; - var searchResults = allSongs.Where(song => song.Song.StartsWith(searchText)).ToList(); - currentPage = 0; - currentSongList = searchResults; - totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage); - - multiPagePanel.currentPageIndex = 0; - multiPagePanel.LoadSongs(currentSongList); - }; this.Controls.Add(inputBoxEnglishSongs); } diff --git a/PrimaryFormParts/SongSearch/PrimaryForm.SongSearch.HandwritingSearch.cs b/PrimaryFormParts/SongSearch/PrimaryForm.SongSearch.HandwritingSearch.cs index c00cace..2f6a7b4 100644 --- a/PrimaryFormParts/SongSearch/PrimaryForm.SongSearch.HandwritingSearch.cs +++ b/PrimaryFormParts/SongSearch/PrimaryForm.SongSearch.HandwritingSearch.cs @@ -116,20 +116,6 @@ namespace DualScreenDemo }; ResizeAndPositionControl(handwritingInputBoxForSongs, 366, 373, 541, 62); this.Controls.Add(handwritingInputBoxForSongs); - - handwritingInputBoxForSongs.TextChanged += (sender, e) => - { - string searchText = handwritingInputBoxForSongs.Text; - - - var searchResults = allSongs.Where(song => song.Song.StartsWith(searchText)).ToList(); - currentPage = 0; - currentSongList = searchResults; - totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage); - - multiPagePanel.currentPageIndex = 0; - multiPagePanel.LoadSongs(currentSongList); - }; } private void InitializeCandidateListBoxForSongs() @@ -293,9 +279,25 @@ namespace DualScreenDemo this.SuspendLayout(); handWritingSearchSongButton.BackgroundImage = handWritingSearchSongNormalBackground; SetHandWritingForSongsAndButtonsVisibility(false); - - + FindHandwritingSongs(); this.ResumeLayout(); } + private void FindHandwritingSongs(){ + string searchText = handwritingInputBoxForSongs.Text; + // 在這裡添加搜尋歌曲的邏輯 + // 例如:根據輸入框的內容搜尋歌曲 + string query = $"SELECT * FROM SongLibrary WHERE `歌曲名稱` LIKE '{searchText}%' "; + + var searchResults = SearchSongs_Mysql(query); + // 重置分頁 + currentPage = 0; + currentSongList = searchResults; + totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage); + // 更新多頁面面板的內容 + multiPagePanel.currentPageIndex = 0; + multiPagePanel.LoadSongs(currentSongList); + + + } } } \ No newline at end of file diff --git a/PrimaryFormParts/SongSearch/PrimaryForm.SongSearch.NumberSearch.cs b/PrimaryFormParts/SongSearch/PrimaryForm.SongSearch.NumberSearch.cs index a045240..6485825 100644 --- a/PrimaryFormParts/SongSearch/PrimaryForm.SongSearch.NumberSearch.cs +++ b/PrimaryFormParts/SongSearch/PrimaryForm.SongSearch.NumberSearch.cs @@ -622,24 +622,6 @@ namespace DualScreenDemo // 調整和定位輸入框的位置及大小 ResizeAndPositionControl(inputBoxSongIDSearch, inputBoxSongIDCoords.X, inputBoxSongIDCoords.Y, inputBoxSongIDCoords.Width, inputBoxSongIDCoords.Height); - // 設定文本變更事件,當輸入框內容改變時觸發 - /*inputBoxSongIDSearch.TextChanged += (sender, e) => - { - string searchText = inputBoxSongIDSearch.Text; // 取得輸入內容 - - // 根據輸入的注音篩選歌曲清單 - var searchResults = allSongs.Where(song => song.SongNumber.StartsWith(searchText)).ToList(); - - // 重置分頁 - currentPage = 0; - currentSongList = searchResults; - totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage); - - // 更新多頁面面板的內容 - multiPagePanel.currentPageIndex = 0; - multiPagePanel.LoadSongs(currentSongList); - };*/ - // 將輸入框加入到窗體的控件集合中 this.Controls.Add(inputBoxSongIDSearch); }