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
{
public partial class PrimaryForm : Form{
public partial class PrimaryForm : Form
{
public class MultiPagePanel : Panel
{
private const int ItemHeight = 70;
@ -18,15 +19,15 @@ namespace DualScreenDemo
Screen screen = Screen.PrimaryScreen;
int screenWidth = screen.Bounds.Width;
int screenHeight = screen.Bounds.Height;
if(screenWidth==1440 && screenHeight==900)
if (screenWidth == 1440 && screenHeight == 900)
{
return 14;
}
else if(screenWidth==1024 && screenHeight==768)
else if (screenWidth == 1024 && screenHeight == 768)
{
return 12;
}
else if(screenWidth == 1920 && screenHeight == 1080)
else if (screenWidth == 1920 && screenHeight == 1080)
{
return 16;
}
@ -48,7 +49,7 @@ namespace DualScreenDemo
if (_isSimplified != value)
{
_isSimplified = value;
if(currentArtistList != null && currentArtistList.Count > 0)
if (currentArtistList != null && currentArtistList.Count > 0)
RefreshDisplayBase_Singer();
else
RefreshDisplay();
@ -57,7 +58,8 @@ namespace DualScreenDemo
}
private bool _isShowingSinger = true;
private List<SongData> currentSongList = new List<SongData>();
public List<SongData> get_currentSongList(){
public List<SongData> get_currentSongList()
{
return currentSongList;
}
private List<Artist> currentArtistList = new List<Artist>();
@ -125,12 +127,12 @@ namespace DualScreenDemo
int deltaX = e.X - mouseDownLocation.X;
if (Math.Abs(deltaX) > 20) // 滑動距離超過50像素才觸發
{
if (deltaX > 0 && currentPageIndex > 0)
if (deltaX > 0 )
{
// 向右滑動,上一頁
LoadPreviousPage();
}
else if (deltaX < 0 && currentPageIndex < totalPages - 1)
else if (deltaX < 0)
{
// 向左滑動,下一頁
LoadNextPage();
@ -149,7 +151,7 @@ namespace DualScreenDemo
{
currentPageIndex++;
// 如果歌單為0(沒有歌單),則刷新歌手列表
if(_isShowingSinger)
if (_isShowingSinger)
{
RefreshDisplayBase_Singer();
}
@ -158,21 +160,41 @@ namespace DualScreenDemo
RefreshDisplay();
}
}
else
{
if (totalPages > 1)
{
currentPageIndex = -1;
LoadNextPage();
}
}
}
public void LoadPreviousPage()
{
if (currentPageIndex - 1 >= 0)
{
currentPageIndex--;
if(_isShowingSinger)
if (_isShowingSinger)
{
RefreshDisplayBase_Singer();
}
else
{
RefreshDisplay();
}
}
else
{
if (totalPages > 1)
{
currentPageIndex = totalPages;
LoadPreviousPage();
}
}
}
public void LoadSongs(List<SongData> songs, bool clearHistory = false)
@ -288,7 +310,7 @@ namespace DualScreenDemo
int y = row * (ItemHeight + RowGap);
// 計算歌手標籤的位置和大小
int singerX = (int)(this.Width * startX);
int singerWidth = (int)(this.Width * (SongWidth+ArtistWidth));
int singerWidth = (int)(this.Width * (SongWidth + ArtistWidth));
// 字體顏色
artistLabel.ForeColor = Color.White;
// 標籤座標設定
@ -297,7 +319,7 @@ namespace DualScreenDemo
Panel separatorPanel = new Panel
{
Location = new Point(singerX , y + ItemHeight),
Location = new Point(singerX, y + ItemHeight),
//Size = new Size(singerWidth + 20, 2),
Size = new Size(730, 2),
BackColor = Color.FromArgb(80, 255, 255, 255),
@ -308,18 +330,20 @@ namespace DualScreenDemo
artistLabel.BackColor = Color.Transparent;
// 設置滑鼠事件
EventHandler mouseEnter = (sender, e) => {
// 變更歌手名稱為黃色
artistLabel.ForeColor = Color.Yellow;
// 增強分隔線的亮度,使其更明顯
separatorPanel.BackColor = Color.FromArgb(120, 255, 255, 255);
EventHandler mouseEnter = (sender, e) =>
{
// 變更歌手名稱為黃色
artistLabel.ForeColor = Color.Yellow;
// 增強分隔線的亮度,使其更明顯
separatorPanel.BackColor = Color.FromArgb(120, 255, 255, 255);
};
EventHandler mouseLeave = (sender, e) => {
// 還原歌手名稱為白色
artistLabel.ForeColor = Color.White;
// 還原分隔線的亮度
separatorPanel.BackColor = Color.FromArgb(80, 255, 255, 255);
EventHandler mouseLeave = (sender, e) =>
{
// 還原歌手名稱為白色
artistLabel.ForeColor = Color.White;
// 還原分隔線的亮度
separatorPanel.BackColor = Color.FromArgb(80, 255, 255, 255);
};
artistLabel.Click += (sender, e) =>
{
@ -327,7 +351,7 @@ namespace DualScreenDemo
// 歌星 轉 歌曲
string query = IsSimplified ?
(
!string.IsNullOrEmpty(artist.NameSimplified)?
!string.IsNullOrEmpty(artist.NameSimplified) ?
$"SELECT * FROM song_library_cache WHERE artistA_simplified = '{searchText}' OR artistB_simplified = '{searchText}'"
: $"SELECT * FROM song_library_cache WHERE artistA = '{searchText}' OR artistB = '{searchText}'"
)
@ -402,15 +426,15 @@ namespace DualScreenDemo
int screenWidth = screen.Bounds.Width;
int screenHeight = screen.Bounds.Height;
int NumberOfItem = 0;
if(screenWidth==1440 && screenHeight==900)
if (screenWidth == 1440 && screenHeight == 900)
{
NumberOfItem = 7;
}
else if(screenWidth==1024 && screenHeight==768)
else if (screenWidth == 1024 && screenHeight == 768)
{
NumberOfItem = 6;
}
else if(screenWidth == 1920 && screenHeight == 1080)
else if (screenWidth == 1920 && screenHeight == 1080)
{
NumberOfItem = 8;
}
@ -455,18 +479,20 @@ namespace DualScreenDemo
// 歌手標籤位置調整
artistLabel.Location = new Point(artistX, y + 33);
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)
{
artistText += " + " + song.getArtist_B(IsSimplified);
artistLabel.Location = new Point(artistX - 95, y + 33);
artistLabel.Size = new Size(artistWidth + 90, ItemHeight - 35);
//artistLabel.Location = new Point(artistX - 95, y + 33);
//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;
// 創建分隔線面板
Panel separatorPanel = new Panel
@ -487,24 +513,26 @@ namespace DualScreenDemo
artistLabel.Font = new Font("微軟正黑體", fold, FontStyle.Bold);
//artistLabel.ForeColor = Color.FromArgb(30,144,255);
artistLabel.ForeColor = Color.FromArgb(36,209,216);
artistLabel.ForeColor = Color.FromArgb(36, 209, 216);
songLabel.TextAlign = ContentAlignment.MiddleLeft;
artistLabel.TextAlign = ContentAlignment.MiddleRight;
// 確保背景透明
songLabel.BackColor = Color.Transparent;
artistLabel.BackColor = Color.Transparent;
// 定義滑鼠進入 (MouseEnter) 事件的處理程序
EventHandler mouseEnter = (sender, e) => {
EventHandler mouseEnter = (sender, e) =>
{
songLabel.ForeColor = Color.Yellow;
artistLabel.ForeColor = Color.Yellow;
separatorPanel.BackColor = Color.FromArgb(120, 255, 255, 255);
};
// 定義滑鼠離開 (MouseLeave) 事件的處理程序
EventHandler mouseLeave = (sender, e) => {
EventHandler mouseLeave = (sender, e) =>
{
songLabel.ForeColor = color;
//artistLabel.ForeColor = Color.FromArgb(30, 144, 255);
artistLabel.ForeColor = Color.FromArgb(36,209,216);
artistLabel.ForeColor = Color.FromArgb(36, 209, 216);
separatorPanel.BackColor = Color.FromArgb(80, 255, 255, 255);
};
// 添加事件处理

View File

@ -659,6 +659,13 @@ namespace DualScreenDemo
// 從配置中加載字體屬性
inputBoxFontName = data["InputBoxZhuYinSingers"]["FontName"]; // 字體名稱
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"]); // 字體樣式
inputBoxForeColor = Color.FromName(data["InputBoxZhuYinSingers"]["ForeColor"]); // 字體顏色