遙控器相關問題修正

This commit is contained in:
jasonchenwork 2025-05-26 15:21:07 +08:00
parent eb1db3c8c8
commit 2502ac41c5
5 changed files with 51 additions and 56 deletions

View File

@ -10,7 +10,7 @@ namespace DualScreenDemo
public static bool readyForSongListInput = false;
/* 關機 queue */
private readonly int _maxHistoryLength = 6; // 最多保留 6 筆
private readonly Queue<string> _indataHistory = new Queue<string>();
public static readonly Queue<string> _indataHistory = new Queue<string>();
/* 顯示按鈕設定 */
private int _wrongInputCountfor62 = 0; // 錯誤輸入計數器
private int _wrongInputCountfor61 = 0; // 錯誤輸入計數器
@ -28,7 +28,7 @@ namespace DualScreenDemo
{
AddToHistory(indata);
// 遙控器測試
Console.WriteLine("遙控器:" + indata);
Console.WriteLine("遙控器: " + indata);
switch (indata)
{
case "A261A4": // 輸入
@ -301,7 +301,7 @@ namespace DualScreenDemo
OverlayForm.displayTimer.Stop();
string input = "a";
// 輸入歌曲
string songNumber = OverlayForm.ReadSongNumber();
var song = songListManager.SearchSongByNumber(songNumber);
@ -558,7 +558,8 @@ namespace DualScreenDemo
Console.WriteLine("ClearDisplay called.");
// 重設狀態標記與 UI 狀態
readyForSongListInput = false;
// 嘗試 true
readyForSongListInput = true;
OverlayForm.SetUIState(OverlayForm.UIState.Initial);
Console.WriteLine("Display cleared.");
}

View File

@ -17,14 +17,14 @@ namespace DBObj
{
if (category == "全部")
{
string query = $"SELECT * FROM ArtistLibrary WHERE 歌手筆畫 >= {minStrokes} AND 歌手筆畫 <={maxStrokes}";
string query = $"SELECT * FROM artists WHERE strokes_abbr >= {minStrokes} AND strokes_abbr <={maxStrokes}";
var searchResults = PrimaryForm.SearchSingers_Mysql(query);
return searchResults;
//return AllArtists.Where(artist => artist.Strokes >= minStrokes && artist.Strokes <= maxStrokes).ToList();
}
else
{
string query = $"SELECT * FROM ArtistLibrary WHERE 歌手分類 = '{category}' AND 歌手筆畫 >= {minStrokes} AND 歌手筆畫 <={maxStrokes}";
string query = $"SELECT * FROM artists WHERE category = '{category}' AND strokes_abbr >= {minStrokes} AND strokes_abbr <={maxStrokes}";
var searchResults = PrimaryForm.SearchSingers_Mysql(query);
return searchResults;
//return AllArtists.Where(artist => artist.Category == category && artist.Strokes >= minStrokes && artist.Strokes <= maxStrokes).ToList();

View File

@ -63,7 +63,7 @@ namespace DualScreenDemo
string externalQrContent = !string.IsNullOrEmpty(externalAddress) ?
String.Format("http://{0}:{1}/{2}/windows.html", externalAddress, externalPort, randomFolderName) :
localQrContent;
GenerateQRCode(externalQrContent, Path.Combine(baseDirectory, randomFolderName, "qrcode.png"));
_qrReadyTcs?.TrySetResult(randomFolderName); // safe callnull-safe

View File

@ -474,56 +474,48 @@ private static void SongDisplayTimer_Elapsed(object sender, EventArgs e)
private readonly object _lockObject = new object();
private bool _handlingTimeout = false;
private async void UnifiedTimer_Elapsed(object sender, EventArgs e)
{
// Console.WriteLine("UnifiedTimer_Elapsed called");
if (_handlingTimeout) return;
_handlingTimeout = true;
if (MainForm.InvokeRequired)
{
MainForm.Invoke(new System.Action<object, EventArgs>(UnifiedTimer_Elapsed), new object[] { sender, e });
}
else
{
displayLabel.Text = "";
switch (CurrentUIState)
try
{
case UIState.SelectingLanguage:
SetUIState(UIState.Initial);
await HandleTimeout("");
break;
case UIState.SelectingArtistCategory:
SetUIState(UIState.Initial);
await HandleTimeout("");
break;
case UIState.SelectingAction:
SetUIState(UIState.Initial);
await HandleTimeout("");
break;
case UIState.SelectingSong:
SetUIState(UIState.Initial);
await HandleTimeout("");
break;
case UIState.SelectingArtist:
SetUIState(UIState.Initial);
await HandleTimeout("");
break;
case UIState.PlayHistory:
SetUIState(UIState.Initial);
await HandleTimeout("");
break;
if (MainForm.InvokeRequired)
{
MainForm.BeginInvoke((Action)(() => UnifiedTimer_Elapsed(sender, e)));
return;
}
displayLabel.Text = "";
switch (CurrentUIState)
{
case UIState.SelectingLanguage:
case UIState.SelectingArtistCategory:
case UIState.SelectingAction:
case UIState.SelectingSong:
case UIState.SelectingArtist:
case UIState.PlayHistory:
SetUIState(UIState.Initial);
await HandleTimeout("操作逾時,已返回主畫面");
break;
}
}
finally
{
_handlingTimeout = false;
}
}
}
private async Task HandleTimeout(string message)
{
Console.WriteLine("HandleTimeout called with message: " + message);
unifiedTimer.Stop();
SetUIState(UIState.Initial);
DisplayMessage(message, 2000);
//DisplayMessage(message, 2000);
CommandHandler._indataHistory.Clear(); // 清空歷史紀錄
await Task.Delay(2000);
}
@ -880,10 +872,11 @@ private static void SongDisplayTimer_Elapsed(object sender, EventArgs e)
control != MainForm.dynamicLabel &&
control != MainForm.tintLabel &&
control != MainForm.blackBackgroundPanel &&
control != MainForm.nextSongLabel)
control != MainForm.nextSongLabel)
{
MainForm.Controls.Remove(control);
control.Dispose();
// control.Dispose();
control.Visible = false;
}
}
@ -1012,7 +1005,7 @@ private static void SongDisplayTimer_Elapsed(object sender, EventArgs e)
if (songIndex >= 0 && songIndex < totalSongs)
{
selectedSong = LanguageSongList[songIndex];
Console.WriteLine("Adding song to playlist: " + LanguageSongList[songIndex].Song);
Console.WriteLine("Adding song to playlist A: " + LanguageSongList[songIndex].Song + " " + selectedSong.SongFilePathHost1);
// DisplayActionWithSong(currentPage, songIndex, "點播");
@ -1044,7 +1037,7 @@ private static void SongDisplayTimer_Elapsed(object sender, EventArgs e)
if (songIndex < totalSongs)
{
selectedSong = LanguageSongList[songIndex];
Console.WriteLine("Adding song to playlist: " + LanguageSongList[songIndex].Song);
Console.WriteLine("Adding song to playlist B: " + LanguageSongList[songIndex].Song + " " + selectedSong.SongFilePathHost1 );
// DisplayActionWithSong(currentPage, songIndex, "插播");
@ -1127,11 +1120,12 @@ private static void SongDisplayTimer_Elapsed(object sender, EventArgs e)
if (songIndex < totalSongs)
{
selectedSong = LanguageSongList[songIndex];
Console.WriteLine("Adding song to playlist: " + LanguageSongList[songIndex].Song);
selectedSong = LanguageSongList[songIndex];
Console.WriteLine("Adding song to playlist C: " + LanguageSongList[songIndex].Song + " " + selectedSong.SongFilePathHost1);
DisplaySongsWithArrows(currentPage, songIndex);
// DisplaySongsWithArrows(currentPage, songIndex);
AddSongToPlaylist(selectedSong);
}
@ -1486,7 +1480,7 @@ private void DisplayArtists(List<Artist> artists, int page)//歌星點進去後
}
else if (category == Category.HotSongs)
{
sqlQuery = $"SELECT * FROM song_library_cache WHERE language_name = '{language}' ORDER BY add_date DESC LIMIT {PrimaryForm.ReadHotSongLimit()}";
sqlQuery = $"SELECT * FROM song_library_cache WHERE language_name = '{language}' ORDER BY song_counts DESC LIMIT {PrimaryForm.ReadHotSongLimit()}";
}
else
{

View File

@ -68,7 +68,7 @@ namespace DualScreenDemo
UpdateSongList(guoYuSongs);
SetButtonsVisibility();
HideQRCode();
//HideQRCode();
}
private void UpdateButtonBackgrounds(Button activeButton, Image activeBackground)