修正部分SQL,修正遙控器已點歌曲
This commit is contained in:
parent
2502ac41c5
commit
4466c457fd
@ -3,6 +3,7 @@ using System.Text.RegularExpressions;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using DBObj;
|
using DBObj;
|
||||||
using OverlayFormObj;
|
using OverlayFormObj;
|
||||||
|
using NAudio.Wave;
|
||||||
namespace DualScreenDemo
|
namespace DualScreenDemo
|
||||||
{
|
{
|
||||||
public class CommandHandler
|
public class CommandHandler
|
||||||
@ -83,6 +84,7 @@ namespace DualScreenDemo
|
|||||||
ToggleMute();
|
ToggleMute();
|
||||||
break;
|
break;
|
||||||
case "A274A4":
|
case "A274A4":
|
||||||
|
OverlayForm.MainForm.currentPage = 1;
|
||||||
HandleArtistAnnouncements();
|
HandleArtistAnnouncements();
|
||||||
break;
|
break;
|
||||||
case "A2B3A4":
|
case "A2B3A4":
|
||||||
@ -589,12 +591,25 @@ namespace DualScreenDemo
|
|||||||
// 準備要傳給 UpdateHistoryLabel 的兩個清單:歌曲資料與播放狀態
|
// 準備要傳給 UpdateHistoryLabel 的兩個清單:歌曲資料與播放狀態
|
||||||
List<SongData> historySongs = new List<SongData>();
|
List<SongData> historySongs = new List<SongData>();
|
||||||
List<PlayState> playStates = new List<PlayState>();
|
List<PlayState> playStates = new List<PlayState>();
|
||||||
|
// 錨點 遙控器
|
||||||
// 從播放紀錄中取出當前頁面應顯示的歌曲與狀態
|
// 從播放紀錄中取出當前頁面應顯示的歌曲與狀態
|
||||||
|
int completedCount = PrimaryForm.currentSongIndexInHistory;
|
||||||
for (int i = startIndex; i < endIndex; i++)
|
for (int i = startIndex; i < endIndex; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
historySongs.Add(PrimaryForm.playedSongsHistory[i]); // 加入歌曲
|
historySongs.Add(PrimaryForm.playedSongsHistory[i]); // 加入歌曲
|
||||||
playStates.Add(PrimaryForm.playStates[i]); // 加入狀態 (已播、播放中、未播)
|
if (i < completedCount)
|
||||||
|
{
|
||||||
|
playStates.Add(PlayState.Played);
|
||||||
|
}
|
||||||
|
else if (i == completedCount)
|
||||||
|
{
|
||||||
|
playStates.Add(PlayState.Playing);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
playStates.Add(PlayState.NotPlayed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,14 +55,14 @@ namespace DBObj
|
|||||||
return PrimaryForm.Instance.SearchSongs_Mysql(query);
|
return PrimaryForm.Instance.SearchSongs_Mysql(query);
|
||||||
}
|
}
|
||||||
public List<SongData> SearchHotSongs(){
|
public List<SongData> SearchHotSongs(){
|
||||||
string query= $"SELECT * FROM song_library_cache WHERE language_name = '國語' ORDER BY add_date DESC LIMIT {PrimaryForm.ReadHotSongLimit()}";
|
string query= $"SELECT * FROM song_library_cache WHERE language_name = '國語' ORDER BY song_conts DESC LIMIT {PrimaryForm.ReadHotSongLimit()}";
|
||||||
return PrimaryForm.Instance.SearchSongs_Mysql(query);
|
return PrimaryForm.Instance.SearchSongs_Mysql(query);
|
||||||
}
|
}
|
||||||
public List<SongData> SearchSongsBySinger(string keyword)
|
public List<SongData> SearchSongsBySinger(string keyword)
|
||||||
{
|
{
|
||||||
Console.WriteLine("keyword : " + keyword);
|
Console.WriteLine("keyword : " + keyword);
|
||||||
var keywordLower = keyword.ToLower();
|
var keywordLower = keyword.ToLower();
|
||||||
string query = $"SELECT * FROM song_library_cache WHERE artistA LIKE '%{keywordLower}%' OR artistB LIKE'%{keywordLower}%'";
|
string query = $"SELECT * FROM song_library_cache WHERE artistA LIKE '%{keywordLower}%' OR artistB LIKE'%{keywordLower}% ORDER BY song_counts DESC;'";
|
||||||
return PrimaryForm.Instance.SearchSongs_Mysql(query);
|
return PrimaryForm.Instance.SearchSongs_Mysql(query);
|
||||||
}
|
}
|
||||||
public List<SongData> SearchSongsByName(string keyword)
|
public List<SongData> SearchSongsByName(string keyword)
|
||||||
|
@ -1098,7 +1098,7 @@ private static void SongDisplayTimer_Elapsed(object sender, EventArgs e)
|
|||||||
selectedArtist = currentArtistList[artistIndex];
|
selectedArtist = currentArtistList[artistIndex];
|
||||||
currentLanguage = selectedArtist.Name;
|
currentLanguage = selectedArtist.Name;
|
||||||
SetUIState(UIState.SelectingSong);
|
SetUIState(UIState.SelectingSong);
|
||||||
string query = $"SELECT * FROM song_library_cache WHERE artistA ='{selectedArtist.Name}' OR artistB='{selectedArtist.Name}' ";
|
string query = $"SELECT * FROM song_library_cache WHERE artistA ='{selectedArtist.Name}' OR artistB='{selectedArtist.Name}' ORDER BY song_counts DESC;";
|
||||||
LanguageSongList = PrimaryForm.Instance.SearchSongs_Mysql(query);
|
LanguageSongList = PrimaryForm.Instance.SearchSongs_Mysql(query);
|
||||||
//LanguageSongList = SongListManager.Instance.GetSongsByArtist(selectedArtist.Name);
|
//LanguageSongList = SongListManager.Instance.GetSongsByArtist(selectedArtist.Name);
|
||||||
currentPage = 1;
|
currentPage = 1;
|
||||||
@ -1274,7 +1274,9 @@ private static void SongDisplayTimer_Elapsed(object sender, EventArgs e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 計算目前這首歌的 Y 座標位置
|
// 計算目前這首歌的 Y 座標位置
|
||||||
int y = startY + i * (songBitmap.Height + verticalSpacing);
|
int fixedRowHeight = 80;
|
||||||
|
int y = startY + i * (fixedRowHeight + verticalSpacing);
|
||||||
|
//int y = startY + i * (songBitmap.Height + verticalSpacing);
|
||||||
|
|
||||||
// 加入歌名圖片到畫面左側
|
// 加入歌名圖片到畫面左側
|
||||||
AddPicture(songBitmap, leftMargin, y);
|
AddPicture(songBitmap, leftMargin, y);
|
||||||
@ -1289,47 +1291,65 @@ private static void SongDisplayTimer_Elapsed(object sender, EventArgs e)
|
|||||||
}
|
}
|
||||||
public void UpdateDisplayLabels(string[] messages)//新歌歌星排行首頁
|
public void UpdateDisplayLabels(string[] messages)//新歌歌星排行首頁
|
||||||
{
|
{
|
||||||
// 清除舊的圖片控件
|
// 移除畫面上現有的所有 PictureBox(舊的文字圖片)
|
||||||
this.Controls.OfType<PictureBox>().ToList().ForEach(p => this.Controls.Remove(p));
|
this.Controls.OfType<PictureBox>().ToList().ForEach(p => this.Controls.Remove(p));
|
||||||
|
|
||||||
|
// 如果沒有訊息內容,直接跳出,不進行後續繪製
|
||||||
if (messages.Length == 0) return;
|
if (messages.Length == 0) return;
|
||||||
|
|
||||||
int mainTitleFontSize = 60;
|
// 設定主標題字體大小
|
||||||
int optionFontSize = 50;
|
int mainTitleFontSize = 60;
|
||||||
int lineSpacing = 15;
|
// 設定選項字體大小
|
||||||
//int columnSpacing = 400;
|
int optionFontSize = 50;
|
||||||
|
// 每行之間的垂直間距(像素)
|
||||||
|
int lineSpacing = 15;
|
||||||
|
|
||||||
// 主標題
|
// 取得主標題文字(第一行)
|
||||||
string mainTitle = messages[0];
|
string mainTitle = messages[0];
|
||||||
|
// 建立主標題用的字型:微軟正黑體、粗體
|
||||||
Font mainTitleFont = new Font("Microsoft JhengHei", mainTitleFontSize, FontStyle.Bold);
|
Font mainTitleFont = new Font("Microsoft JhengHei", mainTitleFontSize, FontStyle.Bold);
|
||||||
|
// 使用自定義方法產生主標題的文字圖像(白色字+透明底)
|
||||||
Bitmap mainTitleBitmap = GenerateTextImage(mainTitle, mainTitleFont, Color.White, Color.Transparent);
|
Bitmap mainTitleBitmap = GenerateTextImage(mainTitle, mainTitleFont, Color.White, Color.Transparent);
|
||||||
|
// 主標題起始的 Y 座標
|
||||||
int startY = 130;
|
int startY = 130;
|
||||||
|
// 將主標題圖片水平置中並加入畫面
|
||||||
AddCenteredPicture(mainTitleBitmap, startY);
|
AddCenteredPicture(mainTitleBitmap, startY);
|
||||||
|
// 更新 Y 座標位置,準備繪製下一區塊(選項),加上主標題高度與間距
|
||||||
startY += mainTitleBitmap.Height + lineSpacing;
|
startY += mainTitleBitmap.Height + lineSpacing;
|
||||||
|
|
||||||
// 選項
|
// 取得剩下的訊息文字(第二行起):當作選項
|
||||||
string[] options = messages.Skip(1).ToArray();
|
string[] options = messages.Skip(1).ToArray();
|
||||||
|
// 選項的起始 Y 座標
|
||||||
int optionsStartY = startY;
|
int optionsStartY = startY;
|
||||||
|
// 每欄最多可放幾個項目(以兩欄平均分配)
|
||||||
int maxItemsPerColumn = (int)Math.Ceiling(options.Length / 2.0);
|
int maxItemsPerColumn = (int)Math.Ceiling(options.Length / 2.0);
|
||||||
|
|
||||||
int leftColumnX = 200;
|
// 設定左右欄的 X 座標(用於放置圖片)
|
||||||
|
int leftColumnX = 200;
|
||||||
int rightColumnX = this.Width / 2 + 150;
|
int rightColumnX = this.Width / 2 + 150;
|
||||||
|
|
||||||
|
// 開始逐一處理每個選項
|
||||||
for (int i = 0; i < options.Length; i++)
|
for (int i = 0; i < options.Length; i++)
|
||||||
{
|
{
|
||||||
|
// 設定每個選項的字型
|
||||||
Font optionFont = new Font("Microsoft JhengHei", optionFontSize, FontStyle.Bold);
|
Font optionFont = new Font("Microsoft JhengHei", optionFontSize, FontStyle.Bold);
|
||||||
|
// 建立文字對應的圖像(白色字+透明底)
|
||||||
Bitmap optionBitmap = GenerateTextImage(options[i], optionFont, Color.White, Color.Transparent);
|
Bitmap optionBitmap = GenerateTextImage(options[i], optionFont, Color.White, Color.Transparent);
|
||||||
|
|
||||||
|
// 根據目前索引,決定放在左欄還是右欄
|
||||||
int x = (i < maxItemsPerColumn) ? leftColumnX : rightColumnX;
|
int x = (i < maxItemsPerColumn) ? leftColumnX : rightColumnX;
|
||||||
|
// 決定目前這張圖的 Y 座標位置(依序向下排列)
|
||||||
int currentY = optionsStartY + ((i % maxItemsPerColumn) * (optionBitmap.Height + lineSpacing));
|
int currentY = optionsStartY + ((i % maxItemsPerColumn) * (optionBitmap.Height + lineSpacing));
|
||||||
|
|
||||||
|
// 加入圖片到畫面上
|
||||||
AddPicture(optionBitmap, x, currentY);
|
AddPicture(optionBitmap, x, currentY);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private string strokeRange;
|
private string strokeRange;
|
||||||
private int totalArtists = 0;
|
private int totalArtists = 0;
|
||||||
private const int artistsPerPage = 10;
|
private const int artistsPerPage = 8;
|
||||||
private List<Artist> currentArtistList = new List<Artist>();
|
private List<Artist> currentArtistList = new List<Artist>();
|
||||||
|
|
||||||
private void ProcessStrokeCountSelection(int number)
|
private void ProcessStrokeCountSelection(int number)
|
||||||
@ -1387,7 +1407,7 @@ private void DisplayArtists(List<Artist> artists, int page)//歌星點進去後
|
|||||||
|
|
||||||
this.Controls.OfType<PictureBox>().ToList().ForEach(p => this.Controls.Remove(p));
|
this.Controls.OfType<PictureBox>().ToList().ForEach(p => this.Controls.Remove(p));
|
||||||
|
|
||||||
int artistsPerColumn = 5;
|
int artistsPerColumn = 4;
|
||||||
int startIndex = (page - 1) * artistsPerPage;
|
int startIndex = (page - 1) * artistsPerPage;
|
||||||
int endIndex = Math.Min(startIndex + artistsPerPage, artists.Count);
|
int endIndex = Math.Min(startIndex + artistsPerPage, artists.Count);
|
||||||
|
|
||||||
@ -1637,7 +1657,7 @@ private void DisplayArtists(List<Artist> artists, int page)//歌星點進去後
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 測試
|
||||||
public int currentPage = 1;
|
public int currentPage = 1;
|
||||||
public int songsPerPage = 5;
|
public int songsPerPage = 5;
|
||||||
public int totalSongs = 0;
|
public int totalSongs = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user