test #1

Merged
jasonchenwork merged 64 commits from test into master 2025-03-18 17:32:23 +08:00
3 changed files with 429 additions and 283 deletions
Showing only changes of commit 97ba97bd58 - Show all commits

View File

@ -47,23 +47,23 @@ namespace DualScreenDemo
private PictureBox pictureBoxArtistSearch;
private Button[] numberButtonsArtistSearch;
private Button modifyButtonArtistSearch, closeButtonArtistSearch;
private RichTextBox inputBoxArtistSearch;
// private Button[] numberButtonsArtistSearch;
// private Button modifyButtonArtistSearch, closeButtonArtistSearch;
//private RichTextBox inputBoxArtistSearch;
private const int offsetXArtistSearch = 100;
private const int offsetYArtistSearch = 100;
private PictureBox pictureBoxWordCount;
//private PictureBox pictureBoxWordCount;
private Button[] numberButtonsWordCount;
private Button modifyButtonWordCount, closeButtonWordCount;
private RichTextBox inputBoxWordCount;
//private Button[] numberButtonsWordCount;
// private Button modifyButtonWordCount, closeButtonWordCount;
// private RichTextBox inputBoxWordCount;
private const int offsetXWordCount = 100;
private const int offsetYWordCount = 100;
//private PictureBox pictureBoxSongIDSearch;
private Button[] numberButtonsSongIDSearch;
//private Button[] numberButtonsSongIDSearch;
//private Button modifyButtonSongIDSearch, closeButtonSongIDSearch;
//private RichTextBox inputBoxSongIDSearch;
private const int offsetXSongID = 100;
@ -943,7 +943,7 @@ namespace DualScreenDemo
}
}
private void ModifyButtonArtist_Click(object sender, EventArgs e)
/* private void ModifyButtonArtist_Click(object sender, EventArgs e)
{
if (inputBoxArtistSearch.Text.Length > 0)
@ -951,9 +951,9 @@ namespace DualScreenDemo
inputBoxArtistSearch.Text = inputBoxArtistSearch.Text.Substring(0, inputBoxArtistSearch.Text.Length - 1);
}
}
} */
private void ModifyButtonWordCount_Click(object sender, EventArgs e)
/* private void ModifyButtonWordCount_Click(object sender, EventArgs e)
{
if (inputBoxWordCount.Text.Length > 0)
@ -961,7 +961,7 @@ namespace DualScreenDemo
inputBoxWordCount.Text = inputBoxWordCount.Text.Substring(0, inputBoxWordCount.Text.Length - 1);
}
}
} */
private void BtnBrightnessUp1_MouseDown(object sender, MouseEventArgs e)
{
@ -1126,7 +1126,7 @@ namespace DualScreenDemo
MessageBox.Show("Show All button clicked!");
}
/*
private void SetPictureBoxArtistSearchAndButtonsVisibility(bool isVisible)
{
System.Action action = () =>
@ -1174,7 +1174,8 @@ namespace DualScreenDemo
action();
}
}
*/
/*
private void SetPictureBoxWordCountAndButtonsVisibility(bool isVisible)
{
System.Action action = () =>
@ -1222,7 +1223,7 @@ namespace DualScreenDemo
action();
}
}
*/
private void ConfigureButton(Button button, int posX, int posY, int width, int height,
Bitmap normalStateImage, Bitmap mouseOverImage, Bitmap mouseDownImage,
EventHandler clickEventHandler)
@ -1734,7 +1735,15 @@ public class MultiPagePanel : Panel
if (currentPageIndex < totalPages - 1)
{
currentPageIndex++;
RefreshDisplay();
// 如果歌單為0(沒有歌單),則刷新歌手列表
if(currentSongList.Count == 0)
{
RefreshDisplayBase_Singer();
}
else
{
RefreshDisplay();
}
}
}
@ -1764,7 +1773,7 @@ public class MultiPagePanel : Panel
currentSongList.Clear();
currentPageIndex = 0;
totalPages = (int)Math.Ceiling(artists.Count / (double)itemsPerPage);
RefreshDisplay();
RefreshDisplayBase_Singer();
}
public void LoadPlayedSongs(List<SongData> songs, List<PlayState> states)
@ -1780,263 +1789,410 @@ public class MultiPagePanel : Panel
public void RefreshDisplay()
{
this.Controls.Clear();
RefreshDisplayBase();
this.Invalidate();
this.Controls.Clear(); // 清除所有 UI 元件
RefreshDisplayBase(); // 重新建立 UI
this.Invalidate(); // 通知系統需要重新繪製
}
private void RefreshDisplayBase()
{
if (this.InvokeRequired)
{
this.Invoke(new Action(() => RefreshDisplayBase()));
return;
}
this.SuspendLayout();
this.Controls.Clear();
int startIndex = currentPageIndex * itemsPerPage;
int endIndex = Math.Min(startIndex + itemsPerPage, currentSongList.Count);
for (int i = startIndex; i < endIndex; i++)
{
CreateSongLabel(currentSongList[i], i - startIndex, startIndex); // 修改處
}
this.ResumeLayout();
}
private void CreateSongLabel(SongData song, int index, int pageOffset)
{
Label songLabel = new Label();
string statusText = "";
bool isCurrentlyPlaying = false;
bool hasBeenPlayed = false;
bool isLatestInstance = true;
// 只在已点歌曲页面显示状态
if (PrimaryForm.Instance.isOnOrderedSongsPage)
{
// 判断是否正在播放公播歌单
bool isPlayingPublicList = userRequestedSongs.Count == 0 ||
(currentSongIndexInHistory >= userRequestedSongs.Count - 1 && PrimaryForm.Instance.videoPlayerForm.IsPlayingPublicSong);
if (isPlayingPublicList)
{
// 如果在播放公播歌单,说明所有已点歌曲都已播放完成
hasBeenPlayed = true;
songLabel.ForeColor = Color.Gray;
statusText = IsSimplified ? "(播毕)" : "(播畢)";
}
else
{
// 计算已完成播放的歌曲数量
int completedCount = 0;
// 遍历播放历史,计算实际的已完成数量
for (int i = 0; i <= currentSongIndexInHistory && i < playedSongsHistory.Count; i++) {
if (i == currentSongIndexInHistory) {
completedCount = i + 1; // 当前播放的歌曲
break;
private void RefreshDisplayBase()
{
if (this.InvokeRequired) // 確保 UI 操作在主執行緒執行
{
this.Invoke(new Action(() => RefreshDisplayBase()));
return;
}
// 检查播放状态
if (i < playStates.Count) {
if (playStates[i] == PlayState.Played || playStates[i] == PlayState.Playing) {
completedCount++;
}
// 如果是切歌状态,不增加计数
this.SuspendLayout(); // 暫停 UI 更新,提高效能
this.Controls.Clear(); // 清空 UI (這裡會再清除一次)
int startIndex = currentPageIndex * itemsPerPage;
int endIndex = Math.Min(startIndex + itemsPerPage, currentSongList.Count);
for (int i = startIndex; i < endIndex; i++)
{
CreateSongLabel(currentSongList[i], i - startIndex, startIndex); // 這行負責新增 UI
}
this.ResumeLayout(); // 恢復 UI 更新
}
private void RefreshDisplayBase_Singer()
{
this.Controls.Clear();
if (this.InvokeRequired) // 確保 UI 操作在主執行緒執行
{
this.Invoke(new Action(() => RefreshDisplayBase_Singer()));
return;
}
this.SuspendLayout(); // 暫停 UI 更新,提高效能
this.Controls.Clear(); // 清空 UI (這裡會再清除一次)
int startIndex = currentPageIndex * itemsPerPage;
int endIndex = Math.Min(startIndex + itemsPerPage, currentArtistList.Count);
for (int i = startIndex; i < endIndex; i++)
{
CreateSingerLabel(currentArtistList[i], i - startIndex, startIndex); // 這行負責新增 UI
}
this.ResumeLayout(); // 恢復 UI 更新
this.Invalidate();
}
// 获取当前歌曲在全局列表中的位置
int songPosition = pageOffset + index;
private void CreateSingerLabel(Artist artist, int index, int pageOffset)
{
// 創建歌手標籤
Label artistLabel = new Label();
artistLabel.Text = artist.Name;
artistLabel.Tag = artist;
artistLabel.AutoSize = false;
// 計算文字寬度
Font normalFont = new Font("微軟正黑體", 26, FontStyle.Bold);
Font mediumFont = new Font("微軟正黑體", 20, FontStyle.Bold);
Font smallFont = new Font("微軟正黑體", 16, FontStyle.Bold);
// 根據文字長度設置字體大小
if (artistLabel.Text.Length > 18)
{
artistLabel.Font = smallFont;
}
else if (artistLabel.Text.Length > 13)
{
artistLabel.Font = mediumFont;
}
else
{
artistLabel.Font = normalFont;
}
// 判断状态
if (songPosition < completedCount - 1)
{
// 已播放完成
hasBeenPlayed = true;
songLabel.ForeColor = Color.Gray;
statusText = IsSimplified ? "(播毕)" : "(播畢)";
}
else if (songPosition == completedCount - 1)
{
// 当前正在播放
isCurrentlyPlaying = true;
songLabel.ForeColor = Color.LimeGreen;
statusText = IsSimplified ? "(播放中)" : "(播放中)";
}
else
{
// 等待播放
songLabel.ForeColor = Color.White;
statusText = string.Empty;
}
}
}
else
{
// 非已点歌曲页面,使用默认白色
songLabel.ForeColor = Color.White;
statusText = string.Empty;
}
// 計算位置 - 修改為先左邊8個,再右邊8個的順序
bool isLeftColumn = index < 8; // 前8个在左边
int row = isLeftColumn ? index : index - 8; // 如果是右边,需要减去8来计算正确的行号
float startX = isLeftColumn ? LeftColumnX : RightColumnX;
int y = row * (ItemHeight + RowGap);
// 計算歌手標籤的位置和大小
int singerX = (int)(this.Width * startX);
int singerWidth = (int)(this.Width * (SongWidth+ArtistWidth));
// 字體顏色
artistLabel.ForeColor = Color.White;
// 標籤座標設定
artistLabel.Location = new Point(singerX, y);
artistLabel.Size = new Size(singerWidth + 20, ItemHeight);
Panel separatorPanel = new Panel
{
Location = new Point(singerX , y + ItemHeight),
Size = new Size(singerWidth + 20, 2),
BackColor = Color.FromArgb(80, 255, 255, 255),
Name = "SeparatorPanel_" + index.ToString()
};
// 字體調整和字體背景顏色
artistLabel.TextAlign = ContentAlignment.TopLeft;
artistLabel.BackColor = Color.Transparent;
// 設置滑鼠事件
EventHandler mouseEnter = (sender, e) => {
// 變更歌手名稱為黃色
artistLabel.ForeColor = Color.Yellow;
// 增強分隔線的亮度,使其更明顯
separatorPanel.BackColor = Color.FromArgb(120, 255, 255, 255);
// 根據簡繁體設置選擇要顯示的文字
string songText = IsSimplified ?
(!string.IsNullOrEmpty(song.SongSimplified) ? song.SongSimplified : song.Song) :
song.Song;
string artistText = IsSimplified ?
(!string.IsNullOrEmpty(song.ArtistASimplified) ? song.ArtistASimplified : song.ArtistA) :
song.ArtistA;
};
EventHandler mouseLeave = (sender, e) => {
// 還原歌手名稱為白色
artistLabel.ForeColor = Color.White;
// 還原分隔線的亮度
separatorPanel.BackColor = Color.FromArgb(80, 255, 255, 255);
};
string fullText = songText + statusText;
int textLength = fullText.Length;
// 先计算状态文字宽度
Font normalFont = new Font("微軟正黑體", 26, FontStyle.Bold);
Font mediumFont = new Font("微軟正黑體", 20, FontStyle.Bold);
Font smallFont = new Font("微軟正黑體", 16, FontStyle.Bold);
artistLabel.Click += (sender, e) =>
{
string searchText = artistLabel.Text; // 取得輸入內容
// 调整阈值并考虑状态文字的长度
if (textLength > 18)
{
songLabel.Font = smallFont;
}
else if (textLength > 13)
{
songLabel.Font = mediumFont;
}
else
{
songLabel.Font = normalFont;
}
// 根據輸入的注音篩選歌曲清單
var searchResults = PrimaryForm.Instance.allSongs.Where(song => song.ArtistA.StartsWith(searchText) || song.ArtistB.StartsWith(searchText)).ToList();
songLabel.Text = fullText;
songLabel.Tag = song;
songLabel.AutoSize = false;
// 重置分頁
PrimaryForm.Instance.currentPage = 0;
currentSongList = searchResults;
totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage);
// 创建歌手标签
Label artistLabel = new Label();
artistLabel.Text = artistText;
artistLabel.Tag = song;
artistLabel.AutoSize = false;
// 更新多頁面面板的內容
PrimaryForm.Instance.multiPagePanel.currentPageIndex = 0;
PrimaryForm.Instance.multiPagePanel.LoadSongs(currentSongList);
};
// 计算位置 - 修改为先左边8个,再右边8个的顺序
bool isLeftColumn = index < 8; // 前8个在左边
int row = isLeftColumn ? index : index - 8; // 如果是右边,需要减去8来计算正确的行号
float startX = isLeftColumn ? LeftColumnX : RightColumnX;
int y = row * (ItemHeight + RowGap);
// 添加滑鼠事件
artistLabel.MouseEnter += mouseEnter;
artistLabel.MouseLeave += mouseLeave;
separatorPanel.MouseEnter += mouseEnter;
separatorPanel.MouseLeave += mouseLeave;
// 设置标签位置和大小
int songX = (int)(this.Width * startX);
int songWidth = (int)(this.Width * SongWidth);
int artistWidth = (int)(this.Width * ArtistWidth);
int artistX = songX + songWidth + 10;
// 添加到畫面上
this.Controls.Add(separatorPanel);
this.Controls.Add(artistLabel);
// 如果有人声,添加人声图标
if (song.HumanVoice == 1)
{
PictureBox icon = new PictureBox()
{
Image = Image.FromFile(Path.Combine(Application.StartupPath, @"themes\superstar\其他符號_人聲\其他符號_人聲.png")),
SizeMode = PictureBoxSizeMode.Zoom,
Size = new Size(32, 32),
Location = new Point(songX + 5, y + 8)
};
this.Controls.Add(icon);
icon.BringToFront();
// 有图标时歌名需要右移
songLabel.Location = new Point(songX + 42, y);
songLabel.Size = new Size(songWidth - 47, ItemHeight - 20);
}
else
{
// 无图标时歌名位置正常
songLabel.Location = new Point(songX, y);
songLabel.Size = new Size(songWidth - 10, ItemHeight - 20);
}
// 调整歌手标签位置
artistLabel.Location = new Point(artistX, y + 33);
artistLabel.Size = new Size(artistWidth - 10, ItemHeight - 35);
// 创建分隔线面板
Panel separatorPanel = new Panel
{
Location = new Point(songX - 5, y + ItemHeight - 2),
Size = new Size(songWidth + artistWidth + 20, 2),
BackColor = Color.FromArgb(80, 255, 255, 255),
Name = "SeparatorPanel_" + index.ToString()
};
// 设置字体和样式
artistLabel.Font = new Font("微軟正黑體", 16, FontStyle.Bold);
artistLabel.ForeColor = Color.FromArgb(30,144,255);
songLabel.TextAlign = ContentAlignment.MiddleLeft;
artistLabel.TextAlign = ContentAlignment.MiddleRight;
// 确保背景完全透明
songLabel.BackColor = Color.Transparent;
artistLabel.BackColor = Color.Transparent;
// 添加悬停效果
EventHandler mouseEnter = (sender, e) => {
if (!PrimaryForm.Instance.isOnOrderedSongsPage ||
(!isCurrentlyPlaying && (!hasBeenPlayed || !isLatestInstance)))
{
songLabel.ForeColor = Color.Yellow;
artistLabel.ForeColor = Color.Yellow;
separatorPanel.BackColor = Color.FromArgb(120, 255, 255, 255);
}
};
EventHandler mouseLeave = (sender, e) => {
if (PrimaryForm.Instance.isOnOrderedSongsPage)
{
if (isCurrentlyPlaying)
{
songLabel.ForeColor = Color.LimeGreen;
// 將歌手標籤置於最上層
artistLabel.BringToFront();
}
else if (hasBeenPlayed && isLatestInstance)
private void CreateSongLabel(SongData song, int index, int pageOffset)
{
songLabel.ForeColor = Color.Gray;
// 創建歌曲標籤
Label songLabel = new Label();
string statusText = ""; // 狀態文字
bool isCurrentlyPlaying = false; // 是否正在播放
bool hasBeenPlayed = false; // 是否已播放完成
bool isLatestInstance = true; // 是否是最新的歌曲
// 僅在 "已點歌曲" 頁面顯示播放狀態
if (PrimaryForm.Instance.isOnOrderedSongsPage)
{
// 判斷是否正在播放公播歌單 (若用戶點播歌單為空,則播放公播歌單)
bool isPlayingPublicList = userRequestedSongs.Count == 0 ||
(currentSongIndexInHistory >= userRequestedSongs.Count - 1 && PrimaryForm.Instance.videoPlayerForm.IsPlayingPublicSong);
if (isPlayingPublicList)
{
// 若播放公播歌單,代表已點歌曲皆已播放完畢
hasBeenPlayed = true;
songLabel.ForeColor = Color.Gray;
statusText = IsSimplified ? "(播毕)" : "(播畢)";
}
else
{
// 計算已完成播放的歌曲數量
int completedCount = 0;
// 遍歷已點歌曲歷史
for (int i = 0; i <= currentSongIndexInHistory && i < playedSongsHistory.Count; i++) {
if (i == currentSongIndexInHistory) {
completedCount = i + 1; // 当前播放的歌曲
break;
}
// 检查播放状态
if (i < playStates.Count) {
if (playStates[i] == PlayState.Played || playStates[i] == PlayState.Playing) {
completedCount++;
}
// 如果是切歌状态,不增加计数
}
}
// 計算歌曲在歷史中的位置
int songPosition = pageOffset + index;
// 判斷歌曲狀態
if (songPosition < completedCount - 1)
{
// 已播放完成
hasBeenPlayed = true;
songLabel.ForeColor = Color.Gray;
statusText = IsSimplified ? "(播毕)" : "(播畢)";
}
else if (songPosition == completedCount - 1)
{
// 正在播放
isCurrentlyPlaying = true;
songLabel.ForeColor = Color.LimeGreen;
statusText = IsSimplified ? "(播放中)" : "(播放中)";
}
else
{
// 未播放
songLabel.ForeColor = Color.White;
statusText = string.Empty;
}
}
}
else
{
// 未在 "已點歌曲" 頁面顯示白色
songLabel.ForeColor = Color.White;
statusText = string.Empty;
}
// 根據簡繁體設置選擇要顯示的文字
string songText = IsSimplified ?
(!string.IsNullOrEmpty(song.SongSimplified) ? song.SongSimplified : song.Song) :
song.Song;
string artistText = IsSimplified ?
(!string.IsNullOrEmpty(song.ArtistASimplified) ? song.ArtistASimplified : song.ArtistA) :
song.ArtistA;
string fullText = songText + statusText;
int textLength = fullText.Length;
// 計算文字寬度
Font normalFont = new Font("微軟正黑體", 26, FontStyle.Bold);
Font mediumFont = new Font("微軟正黑體", 20, FontStyle.Bold);
Font smallFont = new Font("微軟正黑體", 16, FontStyle.Bold);
// 根據文字長度設置字體大小
if (textLength > 18)
{
songLabel.Font = smallFont;
}
else if (textLength > 13)
{
songLabel.Font = mediumFont;
}
else
{
songLabel.Font = normalFont;
}
songLabel.Text = fullText;
songLabel.Tag = song;
songLabel.AutoSize = false;
// 創建歌手標籤
Label artistLabel = new Label();
artistLabel.Text = artistText;
artistLabel.Tag = song;
artistLabel.AutoSize = false;
// 計算位置 - 修改為先左邊8個,再右邊8個的順序
bool isLeftColumn = index < 8; // 前8个在左边
int row = isLeftColumn ? index : index - 8; // 如果是右边,需要减去8来计算正确的行号
float startX = isLeftColumn ? LeftColumnX : RightColumnX;
int y = row * (ItemHeight + RowGap);
// 設置位置和大小
int songX = (int)(this.Width * startX);
int songWidth = (int)(this.Width * SongWidth);
int artistWidth = (int)(this.Width * ArtistWidth);
int artistX = songX + songWidth + 10;
// 添加人聲標籤
if (song.HumanVoice == 1)
{
PictureBox icon = new PictureBox()
{
Image = Image.FromFile(Path.Combine(Application.StartupPath, @"themes\superstar\其他符號_人聲\其他符號_人聲.png")),
SizeMode = PictureBoxSizeMode.Zoom,
Size = new Size(32, 32),
Location = new Point(songX + 5, y + 8)
};
this.Controls.Add(icon);
icon.BringToFront();
// 有圖標時歌名右移
songLabel.Location = new Point(songX + 42, y);
songLabel.Size = new Size(songWidth - 47, ItemHeight - 20);
}
else
{
// 沒有圖標時歌名置中
songLabel.Location = new Point(songX, y);
songLabel.Size = new Size(songWidth - 10, ItemHeight - 20);
}
// 歌手標籤位置調整
artistLabel.Location = new Point(artistX, y + 33);
artistLabel.Size = new Size(artistWidth - 10, ItemHeight - 35);
// 創建分隔線面板
Panel separatorPanel = new Panel
{
Location = new Point(songX - 5, y + ItemHeight - 2),
Size = new Size(songWidth + artistWidth + 20, 2),
BackColor = Color.FromArgb(80, 255, 255, 255),
Name = "SeparatorPanel_" + index.ToString()
};
// 設置字體樣式
artistLabel.Font = new Font("微軟正黑體", 16, FontStyle.Bold);
artistLabel.ForeColor = Color.FromArgb(30,144,255);
songLabel.TextAlign = ContentAlignment.MiddleLeft;
artistLabel.TextAlign = ContentAlignment.MiddleRight;
// 確保背景透明
songLabel.BackColor = Color.Transparent;
artistLabel.BackColor = Color.Transparent;
// 定義滑鼠進入 (MouseEnter) 事件的處理程序
EventHandler mouseEnter = (sender, e) => {
// 當不在「已點歌曲」頁面,或者該歌曲不是當前正在播放的歌曲,
// 且(該歌曲未播放過或不是該歌曲的最新實例)時,改變顯示樣式
if (!PrimaryForm.Instance.isOnOrderedSongsPage ||
(!isCurrentlyPlaying && (!hasBeenPlayed || !isLatestInstance)))
{
// 當滑鼠移到歌曲上時,變更歌曲名稱為黃色
songLabel.ForeColor = Color.Yellow;
// 變更歌手名稱為黃色
artistLabel.ForeColor = Color.Yellow;
// 增強分隔線的亮度,使其更明顯
separatorPanel.BackColor = Color.FromArgb(120, 255, 255, 255);
}
};
// 定義滑鼠離開 (MouseLeave) 事件的處理程序
EventHandler mouseLeave = (sender, e) => {
// 判斷是否處於「已點歌曲」頁面
if (PrimaryForm.Instance.isOnOrderedSongsPage)
{
// 如果當前歌曲正在播放,則維持綠色顯示
if (isCurrentlyPlaying)
{
songLabel.ForeColor = Color.LimeGreen;
}
// 如果該歌曲已播放完成,且是該歌曲的最新實例,則變為灰色
else if (hasBeenPlayed && isLatestInstance)
{
songLabel.ForeColor = Color.Gray;
}
// 其他情況,則維持白色
else
{
songLabel.ForeColor = Color.White;
}
}
else
{
// 若不在「已點歌曲」頁面,則默認為白色
songLabel.ForeColor = Color.White;
}
// 恢復歌手名稱的顏色為預設的藍色
artistLabel.ForeColor = Color.FromArgb(30, 144, 255);
// 恢復分隔線的顏色為半透明白色
separatorPanel.BackColor = Color.FromArgb(80, 255, 255, 255);
};
// 添加事件处理
songLabel.Click += PrimaryForm.Instance.Label_Click;
artistLabel.Click += PrimaryForm.Instance.Label_Click;
songLabel.MouseEnter += mouseEnter;
songLabel.MouseLeave += mouseLeave;
artistLabel.MouseEnter += mouseEnter;
artistLabel.MouseLeave += mouseLeave;
separatorPanel.MouseEnter += mouseEnter;
separatorPanel.MouseLeave += mouseLeave;
// 按正确顺序添加控件
this.Controls.Add(separatorPanel);
this.Controls.Add(songLabel);
this.Controls.Add(artistLabel);
// 确保控件层次正确
songLabel.BringToFront();
artistLabel.BringToFront();
}
else
{
songLabel.ForeColor = Color.White;
}
}
else
{
songLabel.ForeColor = Color.White;
}
artistLabel.ForeColor = Color.FromArgb(30,144,255);
separatorPanel.BackColor = Color.FromArgb(80, 255, 255, 255);
};
// 添加事件处理
songLabel.Click += PrimaryForm.Instance.Label_Click;
artistLabel.Click += PrimaryForm.Instance.Label_Click;
songLabel.MouseEnter += mouseEnter;
songLabel.MouseLeave += mouseLeave;
artistLabel.MouseEnter += mouseEnter;
artistLabel.MouseLeave += mouseLeave;
separatorPanel.MouseEnter += mouseEnter;
separatorPanel.MouseLeave += mouseLeave;
// 按正确顺序添加控件
this.Controls.Add(separatorPanel);
this.Controls.Add(songLabel);
this.Controls.Add(artistLabel);
// 确保控件层次正确
songLabel.BringToFront();
artistLabel.BringToFront();
}
private bool IsLatestInstanceBeforeIndex(SongData song, int currentIndex)
{
if (currentSongList == null) return true;
@ -2830,7 +2986,7 @@ private void RefreshDisplayBase()
SetZhuYinSongsAndButtonsVisibility(false);
SetEnglishSingersAndButtonsVisibility(false);
SetEnglishSongsAndButtonsVisibility(false);
SetPictureBoxWordCountAndButtonsVisibility(false);
// SetPictureBoxWordCountAndButtonsVisibility(false);
SetPinYinSingersAndButtonsVisibility(false);
SetPinYinSongsAndButtonsVisibility(false);
SetPictureBoxToggleLightAndButtonsVisibility(false);
@ -2840,7 +2996,7 @@ private void RefreshDisplayBase()
inputBoxEnglishSongs.Text = "";
inputBoxPinYinSingers.Text = "";
inputBoxPinYinSongs.Text = "";
inputBoxWordCount.Text = "";
// inputBoxWordCount.Text = "";
foreach (var label in songLabels)
@ -3333,7 +3489,7 @@ private void RefreshDisplayBase()
SetZhuYinSongsAndButtonsVisibility(false);
SetEnglishSingersAndButtonsVisibility(false);
SetEnglishSongsAndButtonsVisibility(false);
SetPictureBoxWordCountAndButtonsVisibility(false);
// SetPictureBoxWordCountAndButtonsVisibility(false);
SetPinYinSingersAndButtonsVisibility(false);
SetPinYinSongsAndButtonsVisibility(false);
SetPictureBoxToggleLightAndButtonsVisibility(false);

View File

@ -588,20 +588,16 @@ namespace DualScreenDemo
{
string searchText = inputBoxZhuYinSingers.Text;
// 根據輸入文本來篩選符合條件的歌曲
var relatedSongs = allSongs
.Where(song => (song.ArtistAPhonetic?.StartsWith(searchText, StringComparison.OrdinalIgnoreCase) ?? false) ||
(song.ArtistBPhonetic?.StartsWith(searchText, StringComparison.OrdinalIgnoreCase) ?? false))
.ToList();
// 更新當前頁面及歌單
// 使用注音符號開頭的歌手名稱進行搜索
var searchResults = allArtists.Where(artist => artist.Phonetic.StartsWith(searchText)).ToList();
// 使用注音符號包含的歌手名稱進行搜索
currentPage = 0;
currentSongList = relatedSongs;
totalPages = (int)Math.Ceiling((double)relatedSongs.Count / itemsPerPage);
// 重新載入歌單並顯示頁面
currentArtistList = searchResults;
totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage);
multiPagePanel.currentPageIndex = 0;
multiPagePanel.LoadSongs(relatedSongs);
multiPagePanel.LoadSingers(currentArtistList);
};
// 將輸入框加入到窗體的控件集合中

View File

@ -608,23 +608,17 @@ namespace DualScreenDemo
{
string searchText = inputBoxWordCountSingers.Text; // 取得輸入內容
if (int.TryParse(searchText, out int length))
{
// 顯示搜尋結果
var searchResults = allSongs
.Where(song => song.ArtistA.Length == length || song.ArtistB.Length == length)
.ToList();
{
var searchResults = allArtists.Where(artist => artist.Name.Length == length).ToList();
// 重置分頁
// 設定當前頁數為 0並加載搜索結果
currentPage = 0;
currentSongList = searchResults;
currentArtistList = searchResults;
totalPages = (int)Math.Ceiling((double)searchResults.Count / itemsPerPage);
// 更新多頁面面板的內容
multiPagePanel.currentPageIndex = 0;
multiPagePanel.LoadSongs(currentSongList);
multiPagePanel.LoadSingers(currentArtistList);
}
};
// 將輸入框加入到窗體的控件集合中
this.Controls.Add(inputBoxWordCountSingers);