This commit is contained in:
jasonchenwork 2025-08-08 11:00:23 +08:00
commit 9e48f712db
2 changed files with 114 additions and 79 deletions

View File

@ -6,7 +6,8 @@ using System.Text;
namespace DualScreenDemo namespace DualScreenDemo
{ {
public partial class PrimaryForm : Form{ public partial class PrimaryForm : Form
{
public class MultiPagePanel : Panel public class MultiPagePanel : Panel
{ {
private const int ItemHeight = 70; private const int ItemHeight = 70;
@ -57,7 +58,8 @@ namespace DualScreenDemo
} }
private bool _isShowingSinger = true; private bool _isShowingSinger = true;
private List<SongData> currentSongList = new List<SongData>(); private List<SongData> currentSongList = new List<SongData>();
public List<SongData> get_currentSongList(){ public List<SongData> get_currentSongList()
{
return currentSongList; return currentSongList;
} }
private List<Artist> currentArtistList = new List<Artist>(); private List<Artist> currentArtistList = new List<Artist>();
@ -125,12 +127,12 @@ namespace DualScreenDemo
int deltaX = e.X - mouseDownLocation.X; int deltaX = e.X - mouseDownLocation.X;
if (Math.Abs(deltaX) > 20) // 滑動距離超過50像素才觸發 if (Math.Abs(deltaX) > 20) // 滑動距離超過50像素才觸發
{ {
if (deltaX > 0 && currentPageIndex > 0) if (deltaX > 0 )
{ {
// 向右滑動,上一頁 // 向右滑動,上一頁
LoadPreviousPage(); LoadPreviousPage();
} }
else if (deltaX < 0 && currentPageIndex < totalPages - 1) else if (deltaX < 0)
{ {
// 向左滑動,下一頁 // 向左滑動,下一頁
LoadNextPage(); LoadNextPage();
@ -158,6 +160,15 @@ namespace DualScreenDemo
RefreshDisplay(); RefreshDisplay();
} }
} }
else
{
if (totalPages > 1)
{
currentPageIndex = -1;
LoadNextPage();
}
}
} }
public void LoadPreviousPage() public void LoadPreviousPage()
{ {
@ -168,11 +179,22 @@ namespace DualScreenDemo
{ {
RefreshDisplayBase_Singer(); RefreshDisplayBase_Singer();
} }
else else
{ {
RefreshDisplay(); RefreshDisplay();
} }
} }
else
{
if (totalPages > 1)
{
currentPageIndex = totalPages;
LoadPreviousPage();
}
}
} }
public void LoadSongs(List<SongData> songs, bool clearHistory = false) public void LoadSongs(List<SongData> songs, bool clearHistory = false)
@ -308,14 +330,16 @@ namespace DualScreenDemo
artistLabel.BackColor = Color.Transparent; artistLabel.BackColor = Color.Transparent;
// 設置滑鼠事件 // 設置滑鼠事件
EventHandler mouseEnter = (sender, e) => { EventHandler mouseEnter = (sender, e) =>
{
// 變更歌手名稱為黃色 // 變更歌手名稱為黃色
artistLabel.ForeColor = Color.Yellow; artistLabel.ForeColor = Color.Yellow;
// 增強分隔線的亮度,使其更明顯 // 增強分隔線的亮度,使其更明顯
separatorPanel.BackColor = Color.FromArgb(120, 255, 255, 255); separatorPanel.BackColor = Color.FromArgb(120, 255, 255, 255);
}; };
EventHandler mouseLeave = (sender, e) => { EventHandler mouseLeave = (sender, e) =>
{
// 還原歌手名稱為白色 // 還原歌手名稱為白色
artistLabel.ForeColor = Color.White; artistLabel.ForeColor = Color.White;
// 還原分隔線的亮度 // 還原分隔線的亮度
@ -455,18 +479,20 @@ namespace DualScreenDemo
// 歌手標籤位置調整 // 歌手標籤位置調整
artistLabel.Location = new Point(artistX, y + 33); artistLabel.Location = new Point(artistX, y + 33);
artistLabel.Size = new Size(artistWidth - 10, ItemHeight - 35); artistLabel.Size = new Size(artistWidth - 10, ItemHeight - 35);
if (artistText.Length > 3)
{
artistLabel.Location = new Point(artistX - 95, y + 33);
artistLabel.Size = new Size(artistWidth + 90, ItemHeight - 35);
}
if (song.getB() != null) if (song.getB() != null)
{ {
artistText += " + " + song.getArtist_B(IsSimplified); artistText += " + " + song.getArtist_B(IsSimplified);
artistLabel.Location = new Point(artistX - 95, y + 33); //artistLabel.Location = new Point(artistX - 95, y + 33);
artistLabel.Size = new Size(artistWidth + 90, ItemHeight - 35); //artistLabel.Size = new Size(artistWidth + 90, ItemHeight - 35);
} }
if (artistText.Length > 3)
{
artistLabel.Location = new Point(artistX - 581, y + 33);
artistLabel.Size = new Size(artistWidth + 573, ItemHeight - 35);
}
artistLabel.Text = artistText; artistLabel.Text = artistText;
// 創建分隔線面板 // 創建分隔線面板
Panel separatorPanel = new Panel Panel separatorPanel = new Panel
@ -494,14 +520,16 @@ namespace DualScreenDemo
songLabel.BackColor = Color.Transparent; songLabel.BackColor = Color.Transparent;
artistLabel.BackColor = Color.Transparent; artistLabel.BackColor = Color.Transparent;
// 定義滑鼠進入 (MouseEnter) 事件的處理程序 // 定義滑鼠進入 (MouseEnter) 事件的處理程序
EventHandler mouseEnter = (sender, e) => { EventHandler mouseEnter = (sender, e) =>
{
songLabel.ForeColor = Color.Yellow; songLabel.ForeColor = Color.Yellow;
artistLabel.ForeColor = Color.Yellow; artistLabel.ForeColor = Color.Yellow;
separatorPanel.BackColor = Color.FromArgb(120, 255, 255, 255); separatorPanel.BackColor = Color.FromArgb(120, 255, 255, 255);
}; };
// 定義滑鼠離開 (MouseLeave) 事件的處理程序 // 定義滑鼠離開 (MouseLeave) 事件的處理程序
EventHandler mouseLeave = (sender, e) => { EventHandler mouseLeave = (sender, e) =>
{
songLabel.ForeColor = color; songLabel.ForeColor = color;
//artistLabel.ForeColor = Color.FromArgb(30, 144, 255); //artistLabel.ForeColor = Color.FromArgb(30, 144, 255);
artistLabel.ForeColor = Color.FromArgb(36, 209, 216); artistLabel.ForeColor = Color.FromArgb(36, 209, 216);

View File

@ -659,6 +659,13 @@ namespace DualScreenDemo
// 從配置中加載字體屬性 // 從配置中加載字體屬性
inputBoxFontName = data["InputBoxZhuYinSingers"]["FontName"]; // 字體名稱 inputBoxFontName = data["InputBoxZhuYinSingers"]["FontName"]; // 字體名稱
inputBoxFontSize = float.Parse(data["InputBoxZhuYinSingers"]["FontSize"]); // 字體大小 inputBoxFontSize = float.Parse(data["InputBoxZhuYinSingers"]["FontSize"]); // 字體大小
Screen screen = Screen.PrimaryScreen;
int screenWidth = screen.Bounds.Width;
int screenHeight = screen.Bounds.Height;
if (screenWidth < 1920 && screenHeight < 1080)
{
inputBoxFontSize = 22;
}
inputBoxFontStyle = (FontStyle)Enum.Parse(typeof(FontStyle), data["InputBoxZhuYinSingers"]["FontStyle"]); // 字體樣式 inputBoxFontStyle = (FontStyle)Enum.Parse(typeof(FontStyle), data["InputBoxZhuYinSingers"]["FontStyle"]); // 字體樣式
inputBoxForeColor = Color.FromName(data["InputBoxZhuYinSingers"]["ForeColor"]); // 字體顏色 inputBoxForeColor = Color.FromName(data["InputBoxZhuYinSingers"]["ForeColor"]); // 字體顏色