From 0a69e4a3d701fe3196d973873f3c56015291f4a3 Mon Sep 17 00:00:00 2001 From: jasonchenwork Date: Fri, 11 Apr 2025 16:19:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=8B=E8=AA=9E=E5=8F=B0=E8=AA=9E=E6=96=B0?= =?UTF-8?q?=E6=AD=8C=E6=8E=92=E8=A1=8CSQL=E6=9F=A5=E8=A9=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HotSong/PrimaryForm.HotSongMandarinNew.cs | 9 +-- .../PrimaryForm.HotSongTaiwaneseNew.cs | 9 +-- .../PrimaryForm.SongSearch.WordCountSearch.cs | 56 +------------------ 3 files changed, 7 insertions(+), 67 deletions(-) diff --git a/PrimaryFormParts/HotSong/PrimaryForm.HotSongMandarinNew.cs b/PrimaryFormParts/HotSong/PrimaryForm.HotSongMandarinNew.cs index 6c318d7..8509bff 100644 --- a/PrimaryFormParts/HotSong/PrimaryForm.HotSongMandarinNew.cs +++ b/PrimaryFormParts/HotSong/PrimaryForm.HotSongMandarinNew.cs @@ -8,13 +8,10 @@ namespace DualScreenDemo UpdateHotSongButtons(guoYuNewSongButtonHotSong, guoYuNewSongHotSongActiveBackground); int songLimit = ReadHotSongLimit(); - - // 使用 AddedTime 排序 - var selectedSongs = allSongs.Where(song => song.Category == "國語") - .OrderByDescending(song => song.AddedTime) - .Take(songLimit) - .ToList(); + string query = $"SELECT * FROM SongLibrary WHERE `語別` = '國語' ORDER BY `新增日期` DESC LIMIT {songLimit}"; + var selectedSongs = PrimaryForm.Instance.SearchSongs_Mysql(query); + currentPage = 0; currentSongList = selectedSongs; totalPages = (int)Math.Ceiling((double)selectedSongs.Count / itemsPerPage); diff --git a/PrimaryFormParts/HotSong/PrimaryForm.HotSongTaiwaneseNew.cs b/PrimaryFormParts/HotSong/PrimaryForm.HotSongTaiwaneseNew.cs index 4115211..bc0d6af 100644 --- a/PrimaryFormParts/HotSong/PrimaryForm.HotSongTaiwaneseNew.cs +++ b/PrimaryFormParts/HotSong/PrimaryForm.HotSongTaiwaneseNew.cs @@ -8,12 +8,9 @@ namespace DualScreenDemo UpdateHotSongButtons(taiYuNewSongButtonHotSong, taiYuNewSongHotSongActiveBackground); int songLimit = ReadHotSongLimit(); - - // 使用 AddedTime 排序 - var selectedSongs = allSongs.Where(song => song.Category == "台語") - .OrderByDescending(song => song.AddedTime) - .Take(songLimit) - .ToList(); + + string query = $"SELECT * FROM SongLibrary WHERE `語別` = '台語' ORDER BY `新增日期` DESC LIMIT {songLimit}"; + var selectedSongs = PrimaryForm.Instance.SearchSongs_Mysql(query); currentPage = 0; currentSongList = selectedSongs; diff --git a/PrimaryFormParts/SongSearch/PrimaryForm.SongSearch.WordCountSearch.cs b/PrimaryFormParts/SongSearch/PrimaryForm.SongSearch.WordCountSearch.cs index f1cecdf..7ef801b 100644 --- a/PrimaryFormParts/SongSearch/PrimaryForm.SongSearch.WordCountSearch.cs +++ b/PrimaryFormParts/SongSearch/PrimaryForm.SongSearch.WordCountSearch.cs @@ -15,21 +15,10 @@ namespace DualScreenDemo private Button clearButtonWordCountSongs; private Button closeButtonWordCountSongs; - //private string[] numberWordCountSymbols; - //private (int X, int Y, int Width, int Height)[] numberWordCountButtonCoords; - //private Dictionary numberWordCountButtonImages; - - //private (int X, int Y, int Width, int Height) modifyButtonWordCountCoords; - //private (int X, int Y, int Width, int Height) clearButtonWordCountCoords; - //private (int X, int Y, int Width, int Height) closeButtonWordCountCoords; private RichTextBox inputBoxWordCountSongs; - //private (int X, int Y, int Width, int Height) inputBoxWordCountCoords; - //private string inputBoxWordCountFontName; - //private float inputBoxWordCountFontSize; - //private FontStyle inputBoxWordCountFontStyle; - //private Color inputBoxWordCountForeColor; + /// /// 點擊「注音歌手搜尋」按鈕時執行的事件處理函式。 @@ -71,35 +60,6 @@ namespace DualScreenDemo pictureBoxWordCountSongs.Visible = true; } - - /// - /// 從 config.ini 設定檔中載入注音符號(NumberWordCount Symbols)。 - /// 讀取 ini 檔的 [NumberWordCountSymbols] 區塊,並將「Symbols」欄位的值解析為陣列。 - /// - /*private void LoadNumberWordCountSymbolsFromConfig() - { - // 建立 INI 檔案解析器 - var parser = new FileIniDataParser(); - - // 設定檔路徑 - string iniFilePath = "config.ini"; - - IniData data; - - // 以 UTF-8 編碼開啟並讀取 INI 檔案 - using (var reader = new StreamReader(iniFilePath, Encoding.UTF8)) - { - // 解析 INI 檔內容 - data = parser.ReadData(reader); - } - - // 取得 [NumberWordCountSymbols] 區塊中的 "Symbols" 欄位內容 - string symbols = data["NumberWordCountSymbols"]["Symbols"]; - - // 將符號字串以逗號分隔,轉換為字串陣列 - numberWordCountSymbols = symbols.Split(','); - }*/ - /// /// 從設定檔 (config.ini) 載入 INI 設定數據。 @@ -117,20 +77,6 @@ namespace DualScreenDemo } } - /// - /// 從 INI 設定數據中讀取注音符號 (NumberWordCount Symbols)。 - /// - /// 已解析的 INI 設定數據。 - /// 回傳包含注音符號的字串陣列。 - /*private string[] LoadNumberWordCountSymbols(IniData data) - { - // 從 INI 檔案的 [NumberWordCountSymbols] 區塊取得 Symbols 欄位值 - string symbols = data["NumberWordCountSymbols"]["Symbols"]; - - // 以逗號分隔字串並轉換為字串陣列 - return symbols.Split(','); - }*/ - /// /// 從 INI 設定數據中載入按鈕座標資料。