test #1
@ -1618,38 +1618,57 @@ private void DisplaySongsInLanguage(string language, Category category)
|
|||||||
|
|
||||||
public void DisplaySongs(int page)
|
public void DisplaySongs(int page)
|
||||||
{
|
{
|
||||||
|
// 檢查 LanguageSongList 是否為空,避免發生錯誤
|
||||||
if (LanguageSongList == null || LanguageSongList.Count == 0)
|
if (LanguageSongList == null || LanguageSongList.Count == 0)
|
||||||
{
|
{
|
||||||
Console.WriteLine("LanguageSongList is null or empty.");
|
Console.WriteLine("LanguageSongList is null or empty.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 清除介面上所有 PictureBox 控件,避免重複顯示舊的內容
|
||||||
this.Controls.OfType<PictureBox>().ToList().ForEach(p => this.Controls.Remove(p));
|
this.Controls.OfType<PictureBox>().ToList().ForEach(p => this.Controls.Remove(p));
|
||||||
|
|
||||||
|
// 每列顯示 5 首歌
|
||||||
int songsPerColumn = 5;
|
int songsPerColumn = 5;
|
||||||
|
|
||||||
|
// 計算當前頁面的起始與結束索引
|
||||||
int startIndex = (page - 1) * songsPerPage;
|
int startIndex = (page - 1) * songsPerPage;
|
||||||
int endIndex = Math.Min(startIndex + songsPerPage, LanguageSongList.Count);
|
int endIndex = Math.Min(startIndex + songsPerPage, LanguageSongList.Count);
|
||||||
|
|
||||||
|
// 計算總頁數
|
||||||
int totalPages = (int)Math.Ceiling((double)LanguageSongList.Count / songsPerPage);
|
int totalPages = (int)Math.Ceiling((double)LanguageSongList.Count / songsPerPage);
|
||||||
|
|
||||||
|
// 根據當前分類選擇標題文字
|
||||||
string categoryText = OverlayForm.CurrentCategory switch
|
string categoryText = OverlayForm.CurrentCategory switch
|
||||||
{
|
{
|
||||||
OverlayForm.Category.NewSongs => "新歌",
|
OverlayForm.Category.NewSongs => "新歌",
|
||||||
OverlayForm.Category.HotSongs => "熱門",
|
OverlayForm.Category.HotSongs => "熱門",
|
||||||
_ => ""
|
_ => ""
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 設定標題格式,包含語言、分類與當前頁碼
|
||||||
string headerText = $"{currentLanguage} - {categoryText} ({page} / {totalPages})";
|
string headerText = $"{currentLanguage} - {categoryText} ({page} / {totalPages})";
|
||||||
|
|
||||||
|
// 設定標題的字體樣式
|
||||||
Font headerFont = new Font("Microsoft JhengHei", 60, FontStyle.Bold);
|
Font headerFont = new Font("Microsoft JhengHei", 60, FontStyle.Bold);
|
||||||
|
|
||||||
|
// 生成標題圖片
|
||||||
Bitmap headerBitmap = GenerateTextImage(headerText, headerFont, Color.White, Color.Transparent);
|
Bitmap headerBitmap = GenerateTextImage(headerText, headerFont, Color.White, Color.Transparent);
|
||||||
|
|
||||||
|
// 顯示標題圖片,垂直置於 150px 處
|
||||||
AddCenteredPicture(headerBitmap, 150);
|
AddCenteredPicture(headerBitmap, 150);
|
||||||
|
|
||||||
|
// 設定歌名顯示區域的起始 Y 位置
|
||||||
int startY = 250;
|
int startY = 250;
|
||||||
|
|
||||||
|
// 左列與右列的 X 位置
|
||||||
int leftColumnX = 100;
|
int leftColumnX = 100;
|
||||||
int rightColumnX = this.Width / 2 + 100;
|
int rightColumnX = this.Width / 2 + 100;
|
||||||
|
|
||||||
// 計算當前頁面最大歌名和歌手文字長度
|
// 計算當前頁面最大歌名和歌手文字長度,決定適合的字體大小
|
||||||
int maxSongLength = 0;
|
int maxSongLength = 0;
|
||||||
int maxArtistLength = 0;
|
int maxArtistLength = 0;
|
||||||
|
|
||||||
for (int i = startIndex; i < endIndex; i++)
|
for (int i = startIndex; i < endIndex; i++)
|
||||||
{
|
{
|
||||||
string songText = $"{i - startIndex + 1}. {LanguageSongList[i].Song}";
|
string songText = $"{i - startIndex + 1}. {LanguageSongList[i].Song}";
|
||||||
@ -1661,11 +1680,14 @@ public void DisplaySongs(int page)
|
|||||||
maxArtistLength = Math.Max(maxArtistLength, artistText.Length);
|
maxArtistLength = Math.Max(maxArtistLength, artistText.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 根據最大字數決定適當的字體大小
|
||||||
int songFontSize = maxSongLength > 20 ? 35 : 45;
|
int songFontSize = maxSongLength > 20 ? 35 : 45;
|
||||||
int artistFontSize = maxArtistLength > 20 ? 30 : 35;
|
int artistFontSize = maxArtistLength > 20 ? 30 : 35;
|
||||||
|
|
||||||
|
// 設定歌曲行間距
|
||||||
int verticalSpacing = songFontSize == 30 ? 25 : 10;
|
int verticalSpacing = songFontSize == 30 ? 25 : 10;
|
||||||
|
|
||||||
// 統一行高
|
// 設定統一的行高
|
||||||
int rowHeight = 0;
|
int rowHeight = 0;
|
||||||
|
|
||||||
// 計算行高
|
// 計算行高
|
||||||
@ -1685,6 +1707,7 @@ public void DisplaySongs(int page)
|
|||||||
rowHeight = Math.Max(rowHeight, Math.Max(songBitmap.Height, artistBitmap.Height));
|
rowHeight = Math.Max(rowHeight, Math.Max(songBitmap.Height, artistBitmap.Height));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 依據計算出的行高,逐行顯示歌曲與歌手名稱
|
||||||
for (int i = startIndex; i < endIndex; i++)
|
for (int i = startIndex; i < endIndex; i++)
|
||||||
{
|
{
|
||||||
int songNumber = i - startIndex + 1;
|
int songNumber = i - startIndex + 1;
|
||||||
@ -1700,30 +1723,43 @@ public void DisplaySongs(int page)
|
|||||||
Bitmap songBitmap = GenerateTextImage(songText, songFont, Color.White, Color.Transparent);
|
Bitmap songBitmap = GenerateTextImage(songText, songFont, Color.White, Color.Transparent);
|
||||||
Bitmap artistBitmap = GenerateTextImage(artistText, artistFont, Color.White, Color.Transparent);
|
Bitmap artistBitmap = GenerateTextImage(artistText, artistFont, Color.White, Color.Transparent);
|
||||||
|
|
||||||
|
// 根據索引決定左側或右側顯示
|
||||||
int x = (i - startIndex) < songsPerColumn ? leftColumnX : rightColumnX;
|
int x = (i - startIndex) < songsPerColumn ? leftColumnX : rightColumnX;
|
||||||
|
|
||||||
|
// 計算 Y 位置
|
||||||
int y = startY + ((i - startIndex) % songsPerColumn) * (rowHeight + verticalSpacing);
|
int y = startY + ((i - startIndex) % songsPerColumn) * (rowHeight + verticalSpacing);
|
||||||
|
|
||||||
|
// 顯示歌曲名稱圖片
|
||||||
AddPicture(songBitmap, x, y);
|
AddPicture(songBitmap, x, y);
|
||||||
|
|
||||||
|
// 顯示歌手名稱圖片(稍微右移)
|
||||||
AddPicture(artistBitmap, x + songBitmap.Width + 20, y);
|
AddPicture(artistBitmap, x + songBitmap.Width + 20, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void DisplaySongsWithArrows(int page, int highlightIndex)
|
public void DisplaySongsWithArrows(int page, int highlightIndex)
|
||||||
{
|
{
|
||||||
|
// 檢查 LanguageSongList 是否為空,避免發生錯誤
|
||||||
if (LanguageSongList == null || LanguageSongList.Count == 0)
|
if (LanguageSongList == null || LanguageSongList.Count == 0)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Error: LanguageSongList is null or empty.");
|
Console.WriteLine("Error: LanguageSongList is null or empty.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 清除介面上所有 PictureBox 控件,避免重複顯示舊的內容
|
||||||
this.Controls.OfType<PictureBox>().ToList().ForEach(p => this.Controls.Remove(p));
|
this.Controls.OfType<PictureBox>().ToList().ForEach(p => this.Controls.Remove(p));
|
||||||
|
|
||||||
|
// 每列顯示 5 首歌
|
||||||
int songsPerColumn = 5;
|
int songsPerColumn = 5;
|
||||||
|
// 計算當前頁面的起始與結束索引
|
||||||
int startIndex = (page - 1) * songsPerPage;
|
int startIndex = (page - 1) * songsPerPage;
|
||||||
int endIndex = Math.Min(startIndex + songsPerPage, LanguageSongList.Count);
|
int endIndex = Math.Min(startIndex + songsPerPage, LanguageSongList.Count);
|
||||||
|
|
||||||
|
// 計算總頁數
|
||||||
int totalPages = (int)Math.Ceiling((double)LanguageSongList.Count / songsPerPage);
|
int totalPages = (int)Math.Ceiling((double)LanguageSongList.Count / songsPerPage);
|
||||||
|
|
||||||
|
// 根據當前分類選擇標題文字
|
||||||
string categoryText = OverlayForm.CurrentCategory switch
|
string categoryText = OverlayForm.CurrentCategory switch
|
||||||
{
|
{
|
||||||
OverlayForm.Category.NewSongs => "新歌",
|
OverlayForm.Category.NewSongs => "新歌",
|
||||||
@ -1731,16 +1767,22 @@ public void DisplaySongsWithArrows(int page, int highlightIndex)
|
|||||||
_ => ""
|
_ => ""
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 設定標題格式,包含語言、分類與當前頁碼
|
||||||
string headerText = $"{currentLanguage} - {categoryText} ({page} / {totalPages})";
|
string headerText = $"{currentLanguage} - {categoryText} ({page} / {totalPages})";
|
||||||
|
// 設定標題的字體樣式
|
||||||
Font headerFont = new Font("Microsoft JhengHei", 60, FontStyle.Bold);
|
Font headerFont = new Font("Microsoft JhengHei", 60, FontStyle.Bold);
|
||||||
|
// 生成標題圖片
|
||||||
Bitmap headerBitmap = GenerateTextImage(headerText, headerFont, Color.White, Color.Transparent);
|
Bitmap headerBitmap = GenerateTextImage(headerText, headerFont, Color.White, Color.Transparent);
|
||||||
|
// 顯示標題圖片,垂直置於 150px 處
|
||||||
AddCenteredPicture(headerBitmap, 150);
|
AddCenteredPicture(headerBitmap, 150);
|
||||||
|
|
||||||
|
// 設定歌名顯示區域的起始 Y 位置
|
||||||
int startY = 250;
|
int startY = 250;
|
||||||
|
// 左列與右列的 X 位置
|
||||||
int leftColumnX = 100;
|
int leftColumnX = 100;
|
||||||
int rightColumnX = this.Width / 2 + 100;
|
int rightColumnX = this.Width / 2 + 100;
|
||||||
|
|
||||||
// 找到当前页面中最长的 songText 和 artistText 长度
|
// 找到當前頁面中最長的 songText 和 artistText 長度
|
||||||
int maxSongLength = 0;
|
int maxSongLength = 0;
|
||||||
int maxArtistLength = 0;
|
int maxArtistLength = 0;
|
||||||
for (int i = startIndex; i < endIndex; i++)
|
for (int i = startIndex; i < endIndex; i++)
|
||||||
@ -1754,12 +1796,12 @@ public void DisplaySongsWithArrows(int page, int highlightIndex)
|
|||||||
maxArtistLength = Math.Max(maxArtistLength, artistText.Length);
|
maxArtistLength = Math.Max(maxArtistLength, artistText.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 动态调整字体大小
|
// 動態調整字體大小
|
||||||
int songFontSize = maxSongLength > 20 ? 35 : 45;
|
int songFontSize = maxSongLength > 20 ? 35 : 45;
|
||||||
int artistFontSize = maxArtistLength > 20 ? 30 : 35;
|
int artistFontSize = maxArtistLength > 20 ? 30 : 35;
|
||||||
int verticalSpacing = songFontSize == 30 ? 25 : 10;
|
int verticalSpacing = songFontSize == 30 ? 25 : 10;
|
||||||
|
|
||||||
// 统一行高計算
|
// 統一行高計算
|
||||||
int rowHeight = 0;
|
int rowHeight = 0;
|
||||||
for (int i = startIndex; i < endIndex; i++)
|
for (int i = startIndex; i < endIndex; i++)
|
||||||
{
|
{
|
||||||
@ -1777,6 +1819,7 @@ public void DisplaySongsWithArrows(int page, int highlightIndex)
|
|||||||
rowHeight = Math.Max(rowHeight, Math.Max(tempSongBitmap.Height, tempArtistBitmap.Height));
|
rowHeight = Math.Max(rowHeight, Math.Max(tempSongBitmap.Height, tempArtistBitmap.Height));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 依據計算出的行高,逐行顯示歌曲與歌手名稱
|
||||||
for (int i = startIndex; i < endIndex; i++)
|
for (int i = startIndex; i < endIndex; i++)
|
||||||
{
|
{
|
||||||
int songNumber = i - startIndex + 1;
|
int songNumber = i - startIndex + 1;
|
||||||
@ -1786,7 +1829,7 @@ public void DisplaySongsWithArrows(int page, int highlightIndex)
|
|||||||
? $"{LanguageSongList[i].ArtistA} - {LanguageSongList[i].ArtistB}"
|
? $"{LanguageSongList[i].ArtistA} - {LanguageSongList[i].ArtistB}"
|
||||||
: LanguageSongList[i].ArtistA;
|
: LanguageSongList[i].ArtistA;
|
||||||
|
|
||||||
// 设置颜色,选中的索引显示为亮绿色
|
// 設定顏色,選中的索引顯示為亮綠色
|
||||||
Color songColor = (i == highlightIndex) ? Color.LimeGreen : Color.White;
|
Color songColor = (i == highlightIndex) ? Color.LimeGreen : Color.White;
|
||||||
Color artistColor = (i == highlightIndex) ? Color.LimeGreen : Color.White;
|
Color artistColor = (i == highlightIndex) ? Color.LimeGreen : Color.White;
|
||||||
|
|
||||||
@ -1799,7 +1842,9 @@ public void DisplaySongsWithArrows(int page, int highlightIndex)
|
|||||||
int x = (i - startIndex) < songsPerColumn ? leftColumnX : rightColumnX;
|
int x = (i - startIndex) < songsPerColumn ? leftColumnX : rightColumnX;
|
||||||
int y = startY + ((i - startIndex) % songsPerColumn) * (rowHeight + verticalSpacing);
|
int y = startY + ((i - startIndex) % songsPerColumn) * (rowHeight + verticalSpacing);
|
||||||
|
|
||||||
|
// 顯示歌曲名稱圖片
|
||||||
AddPicture(songBitmap, x, y);
|
AddPicture(songBitmap, x, y);
|
||||||
|
// 顯示歌手名稱圖片(稍微右移)
|
||||||
AddPicture(artistBitmap, x + songBitmap.Width + 20, y);
|
AddPicture(artistBitmap, x + songBitmap.Width + 20, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,9 @@ ZhuYinSongs = themes\superstar\歌名\注音\VOD_歌名查詢_注音查詢(按
|
|||||||
EnglishSongs = themes\superstar\歌名\英文\VOD_歌名查詢_英文查詢(按鍵)_歌星查詢-注音查詢_未按.png
|
EnglishSongs = themes\superstar\歌名\英文\VOD_歌名查詢_英文查詢(按鍵)_歌星查詢-注音查詢_未按.png
|
||||||
PinYinSongs = themes\superstar\歌星\拼音\VOD_歌星查詢_拼音查詢(按鍵)_歌星查詢-注音查詢_未按.png
|
PinYinSongs = themes\superstar\歌星\拼音\VOD_歌星查詢_拼音查詢(按鍵)_歌星查詢-注音查詢_未按.png
|
||||||
HandWritingSongs = themes\superstar\歌星\手寫\3.歌星查詢(手寫按鍵)_未按.png
|
HandWritingSongs = themes\superstar\歌星\手寫\3.歌星查詢(手寫按鍵)_未按.png
|
||||||
WordCountSongs = themes\superstar\歌名\字數\VOD_歌名查詢_編號查詢(按鍵)_未按_沒有確認.png
|
WordCountSongs = themes\superstar\歌名\字數\VOD_歌名查詢_編號查詢(按鍵)_未按.png
|
||||||
WordCountSingers = themes\superstar\歌星\字數\VOD_歌星查詢_編號查詢(按鍵)_未按_沒有確認.png
|
WordCountSingers = themes\superstar\歌星\字數\VOD_歌星查詢_編號查詢(按鍵)_未按.png
|
||||||
SongIDSearch = themes\superstar\歌名\編號\VOD_歌名查詢_編號查詢(按鍵)_未按_沒有確認.png
|
SongIDSearch = themes\superstar\歌名\編號\VOD_歌名查詢_編號查詢(按鍵)_未按.png
|
||||||
|
|
||||||
[PictureBoxZhuYinSingers]
|
[PictureBoxZhuYinSingers]
|
||||||
X = 130
|
X = 130
|
||||||
|
Reference in New Issue
Block a user