202508041725
搖控器 加入歌曲先判斷包廂狀態 搖控器 加入後只顯示歌曲名稱
This commit is contained in:
parent
09b6244f4c
commit
e787918be8
@ -13,9 +13,6 @@ namespace DualScreenDemo
|
||||
private readonly int _maxHistoryLength = 6; // 最多保留 6 筆
|
||||
public static readonly Queue<string> _indataHistory = new Queue<string>();
|
||||
/* 顯示按鈕設定 */
|
||||
private int _wrongInputCountfor62 = 0; // 錯誤輸入計數器
|
||||
private int _wrongInputCountfor61 = 0; // 錯誤輸入計數器
|
||||
private const int MaxWrongLimit = 3; // 錯誤輸入限制次數
|
||||
private readonly SQLManager songListManager;
|
||||
|
||||
public CommandHandler(SQLManager songListManager)
|
||||
@ -33,15 +30,13 @@ namespace DualScreenDemo
|
||||
switch (indata)
|
||||
{
|
||||
case "A261A4": // 輸入
|
||||
HandleInputA();
|
||||
HandleInput("a");
|
||||
break;
|
||||
case "A262A4": // 插播
|
||||
HandleInputB();
|
||||
HandleInput("b");
|
||||
break;
|
||||
case "A263A4":
|
||||
ClearDisplay();
|
||||
_wrongInputCountfor62 = 0; // 重置計數器
|
||||
_wrongInputCountfor61 = 0; // 重置計數器
|
||||
_indataHistory.Clear(); // 清空歷史紀錄
|
||||
break;
|
||||
case "A268A4":
|
||||
@ -199,7 +194,7 @@ namespace DualScreenDemo
|
||||
}
|
||||
}
|
||||
|
||||
void InvokeAction(Action action)
|
||||
static void InvokeAction(Action action)
|
||||
{
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
@ -213,39 +208,21 @@ namespace DualScreenDemo
|
||||
|
||||
|
||||
|
||||
private static void SkipToNextSong()
|
||||
private void SkipToNextSong()
|
||||
{
|
||||
if (PrimaryForm.Instance.InvokeRequired)
|
||||
PrimaryForm.Instance.Invoke(new System.Action(() => PrimaryForm.Instance.videoPlayerForm.PlayNextSong()));
|
||||
else
|
||||
PrimaryForm.Instance.videoPlayerForm.PlayNextSong();
|
||||
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() => { OverlayForm.MainForm.ShowTopRightEchoLabel("標準迴音"); } ) );
|
||||
InvokeAction(() => PrimaryForm.Instance.videoPlayerForm.PlayNextSong());
|
||||
InvokeAction(() => OverlayForm.MainForm.ShowTopRightEchoLabel("標準迴音"));
|
||||
}
|
||||
|
||||
|
||||
private static void ReplayCurrentSong()
|
||||
private void ReplayCurrentSong()
|
||||
{
|
||||
if (PrimaryForm.Instance.InvokeRequired)
|
||||
{
|
||||
PrimaryForm.Instance.Invoke(new System.Action(() => PrimaryForm.Instance.videoPlayerForm.ReplayCurrentSong()));
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimaryForm.Instance.videoPlayerForm.ReplayCurrentSong();
|
||||
}
|
||||
InvokeAction(() => PrimaryForm.Instance.videoPlayerForm.ReplayCurrentSong());
|
||||
}
|
||||
|
||||
private static void PauseOrResumeSong()
|
||||
{
|
||||
if (PrimaryForm.Instance.InvokeRequired)
|
||||
{
|
||||
PrimaryForm.Instance.Invoke(new System.Action(() => PrimaryForm.Instance.videoPlayerForm.PauseOrResumeSong()));
|
||||
}
|
||||
else
|
||||
{
|
||||
PrimaryForm.Instance.videoPlayerForm.PauseOrResumeSong();
|
||||
}
|
||||
InvokeAction(() => PrimaryForm.Instance.videoPlayerForm.PauseOrResumeSong());
|
||||
}
|
||||
|
||||
public static void ToggleMute()
|
||||
@ -277,205 +254,63 @@ namespace DualScreenDemo
|
||||
}
|
||||
|
||||
|
||||
private void HandleInputA()
|
||||
private void HandleInput(string input)
|
||||
{
|
||||
|
||||
|
||||
OverlayForm.displayTimer.Stop();
|
||||
string input = "a";
|
||||
|
||||
// 輸入歌曲
|
||||
string songNumber = OverlayForm.ReadSongNumber();
|
||||
//Console.WriteLine("輸入A " + songNumber + " readyForSongListInput : " + readyForSongListInput);
|
||||
var song = songListManager.SearchSongByNumber(songNumber);
|
||||
|
||||
|
||||
|
||||
if (readyForSongListInput)
|
||||
{
|
||||
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
InvokeAction(() =>
|
||||
{
|
||||
Console.WriteLine("F sign for input :" + input);
|
||||
OverlayForm.MainForm.OnUserInput(input);
|
||||
}));
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("A sign for input :" + input);
|
||||
OverlayForm.MainForm.OnUserInput(input);
|
||||
}
|
||||
}
|
||||
else
|
||||
InvokeAction(() =>
|
||||
{
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
if (song != null)
|
||||
{
|
||||
ClearDisplay();
|
||||
OverlayForm.MainForm.displayLabel.Text = String.Format("已點歌曲:{0}", song);
|
||||
SongList.Add(song);
|
||||
OverlayForm.MainForm.topLeftLabel.Visible = false;
|
||||
OverlayForm.displayTimer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearDisplay();
|
||||
_wrongInputCountfor61++;
|
||||
if(_wrongInputCountfor61 <= MaxWrongLimit)
|
||||
{
|
||||
string old ="";
|
||||
OverlayForm.MainForm.displayLabel.Text = check_control(old);
|
||||
}
|
||||
else
|
||||
{
|
||||
OverlayForm.MainForm.displayLabel.Text = "輸入錯誤!!!";
|
||||
_indataHistory.Clear(); // 清空歷史紀錄
|
||||
_wrongInputCountfor61 = 0; // 重置計數器
|
||||
}
|
||||
OverlayForm.MainForm.topLeftLabel.Visible = false;
|
||||
OverlayForm.displayTimer.Start();
|
||||
}
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (song != null)
|
||||
{
|
||||
ClearDisplay();
|
||||
OverlayForm.MainForm.displayLabel.Text = String.Format("{0}", song);
|
||||
SongList.Add(song);
|
||||
OverlayForm.MainForm.topLeftLabel.Visible = false;
|
||||
OverlayForm.displayTimer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearDisplay();
|
||||
_wrongInputCountfor61++;
|
||||
if(_wrongInputCountfor61 <= MaxWrongLimit)
|
||||
{
|
||||
string old ="";
|
||||
OverlayForm.MainForm.displayLabel.Text = check_control(old);
|
||||
}
|
||||
else
|
||||
{
|
||||
OverlayForm.MainForm.displayLabel.Text = "輸入錯誤!!!";
|
||||
_indataHistory.Clear(); // 清空歷史紀錄
|
||||
_wrongInputCountfor61 = 0; // 重置計數器
|
||||
}
|
||||
OverlayForm.MainForm.topLeftLabel.Visible = false;
|
||||
OverlayForm.displayTimer.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private string check_control(string old){
|
||||
foreach(string item in _indataHistory)
|
||||
{
|
||||
if(item == "A261A4")
|
||||
old += "#";
|
||||
else if(item == "A262A4")
|
||||
old += "*";
|
||||
}
|
||||
return old;
|
||||
}
|
||||
|
||||
|
||||
private void HandleInputB()
|
||||
{
|
||||
|
||||
OverlayForm.displayTimer.Stop();
|
||||
string input = "b";
|
||||
|
||||
|
||||
string songNumber = OverlayForm.ReadSongNumber();
|
||||
var song = songListManager.SearchSongByNumber(songNumber);
|
||||
|
||||
|
||||
|
||||
if (readyForSongListInput)
|
||||
{
|
||||
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
Console.WriteLine("B sign for input :" + input);
|
||||
OverlayForm.MainForm.OnUserInput(input);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("C sign for input :" + input);
|
||||
OverlayForm.MainForm.OnUserInput(input);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
ClearDisplay();
|
||||
if (song != null)
|
||||
{
|
||||
ClearDisplay();
|
||||
OverlayForm.MainForm.displayLabel.Text = String.Format("插播歌曲{0}", song);
|
||||
SongList.Insert(song);
|
||||
OverlayForm.MainForm.topLeftLabel.Visible = false;
|
||||
OverlayForm.displayTimer.Start();
|
||||
}
|
||||
else
|
||||
if (Program.room.IsOpen())
|
||||
{
|
||||
ClearDisplay();
|
||||
_wrongInputCountfor62++;
|
||||
if(_wrongInputCountfor62 <= MaxWrongLimit)
|
||||
if (input.Equals("a"))
|
||||
{
|
||||
string old ="";
|
||||
OverlayForm.MainForm.displayLabel.Text = check_control(old);
|
||||
}
|
||||
else
|
||||
{
|
||||
OverlayForm.MainForm.displayLabel.Text = "輸入錯誤!!!";
|
||||
_indataHistory.Clear(); // 清空歷史紀錄
|
||||
_wrongInputCountfor62 = 0; // 重置計數器
|
||||
}
|
||||
OverlayForm.MainForm.topLeftLabel.Visible = false;
|
||||
OverlayForm.displayTimer.Start();
|
||||
}
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (song != null)
|
||||
{
|
||||
ClearDisplay();
|
||||
OverlayForm.MainForm.displayLabel.Text = String.Format("已點歌曲:{0}", song);
|
||||
OverlayForm.MainForm.topLeftLabel.Visible = false;
|
||||
SongList.Add(song);
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearDisplay();
|
||||
_wrongInputCountfor62++;
|
||||
if(_wrongInputCountfor62 <= MaxWrongLimit)
|
||||
{
|
||||
string old ="";
|
||||
OverlayForm.MainForm.displayLabel.Text = check_control(old);
|
||||
OverlayForm.MainForm.displayLabel.Text = String.Format("插播歌曲:{0}", song);
|
||||
SongList.Insert(song);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OverlayForm.MainForm.displayLabel.Text = "輸入錯誤!!!";
|
||||
OverlayForm.MainForm.displayLabel.Text = "包廂己關閉";
|
||||
}
|
||||
|
||||
_indataHistory.Clear(); // 清空歷史紀錄
|
||||
_wrongInputCountfor62 = 0; // 重置計數器
|
||||
}
|
||||
else
|
||||
OverlayForm.MainForm.displayLabel.Text = check_control();
|
||||
OverlayForm.MainForm.topLeftLabel.Visible = false;
|
||||
OverlayForm.displayTimer.Start();
|
||||
});
|
||||
}
|
||||
}
|
||||
private string check_control(){
|
||||
string str = "";
|
||||
foreach (string item in _indataHistory)
|
||||
{
|
||||
if (item == "A261A4")
|
||||
str += "#";
|
||||
else if (item == "A262A4")
|
||||
str += "*";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -487,14 +322,7 @@ namespace DualScreenDemo
|
||||
OverlayForm.displayTimer.Stop();
|
||||
|
||||
// 判斷是否需要透過 Invoke 回 UI 執行緒執行
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new Action(ClearControlsAndReset));
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearControlsAndReset();
|
||||
}
|
||||
InvokeAction(() => ClearControlsAndReset());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -566,23 +394,14 @@ namespace DualScreenDemo
|
||||
// 錨點 遙控器
|
||||
|
||||
// 安全更新 UI:若非 UI 執行緒則使用 Invoke 切換
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
InvokeAction(() =>
|
||||
{
|
||||
// 更新主畫面的歷史播放顯示區
|
||||
OverlayForm.MainForm.UpdateHistoryLabel(historySongs, OverlayForm.MainForm.currentPage, totalPages);
|
||||
|
||||
// 隱藏下一首提示
|
||||
OverlayForm.MainForm.topLeftLabel.Visible = false;
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
// 若已在 UI 執行緒,直接操作
|
||||
OverlayForm.MainForm.UpdateHistoryLabel(historySongs, OverlayForm.MainForm.currentPage, totalPages);
|
||||
OverlayForm.MainForm.topLeftLabel.Visible = false;
|
||||
}
|
||||
});
|
||||
|
||||
// 切換 UI 狀態為播放歷史模式(可做為內部狀態管理用途)
|
||||
OverlayForm.SetUIState(OverlayForm.UIState.PlayHistory);
|
||||
@ -595,55 +414,18 @@ namespace DualScreenDemo
|
||||
{
|
||||
if (OverlayForm.CurrentUIState == OverlayForm.UIState.SelectingSong)
|
||||
{
|
||||
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
|
||||
OverlayForm.MainForm.PreviousPage();
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
OverlayForm.MainForm.PreviousPage();
|
||||
}
|
||||
InvokeAction(() =>OverlayForm.MainForm.PreviousPage());
|
||||
}
|
||||
else if (OverlayForm.CurrentUIState == OverlayForm.UIState.SelectingArtist)
|
||||
{
|
||||
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
|
||||
OverlayForm.MainForm.PreviousPage();
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
OverlayForm.MainForm.PreviousPage();
|
||||
}
|
||||
InvokeAction(() =>OverlayForm.MainForm.PreviousPage());
|
||||
}
|
||||
else if (OverlayForm.CurrentUIState == OverlayForm.UIState.PlayHistory)
|
||||
{
|
||||
if (OverlayForm.MainForm.currentPage > 1)
|
||||
{
|
||||
OverlayForm.MainForm.currentPage--;
|
||||
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
DisplaySongHistory();
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplaySongHistory();
|
||||
}
|
||||
InvokeAction(() => DisplaySongHistory());
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -656,37 +438,11 @@ namespace DualScreenDemo
|
||||
{
|
||||
if (OverlayForm.CurrentUIState == OverlayForm.UIState.SelectingSong)
|
||||
{
|
||||
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
|
||||
OverlayForm.MainForm.NextPage();
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
OverlayForm.MainForm.NextPage();
|
||||
}
|
||||
InvokeAction(() => OverlayForm.MainForm.NextPage());
|
||||
}
|
||||
else if (OverlayForm.CurrentUIState == OverlayForm.UIState.SelectingArtist)
|
||||
{
|
||||
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
|
||||
OverlayForm.MainForm.NextPage();
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
OverlayForm.MainForm.NextPage();
|
||||
}
|
||||
InvokeAction(() => OverlayForm.MainForm.NextPage() );
|
||||
}
|
||||
else if (OverlayForm.CurrentUIState == OverlayForm.UIState.PlayHistory)
|
||||
{
|
||||
@ -695,17 +451,7 @@ namespace DualScreenDemo
|
||||
OverlayForm.MainForm.currentPage++;
|
||||
if (OverlayForm.CurrentUIState == OverlayForm.UIState.PlayHistory)
|
||||
{
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
DisplaySongHistory();
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplaySongHistory();
|
||||
}
|
||||
InvokeAction(() => DisplaySongHistory() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -803,11 +549,8 @@ namespace DualScreenDemo
|
||||
|
||||
private static void UpdateDisplayLabels(string[] messages)
|
||||
{
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
InvokeAction(() =>
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
{
|
||||
|
||||
foreach (var control in OverlayForm.MainForm.Controls.OfType<Control>().ToArray())
|
||||
{
|
||||
if (control != OverlayForm.MainForm.displayLabel &&
|
||||
@ -822,26 +565,7 @@ namespace DualScreenDemo
|
||||
}
|
||||
}
|
||||
OverlayForm.MainForm.UpdateDisplayLabels(messages);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
foreach (var control in OverlayForm.MainForm.Controls.OfType<Control>().ToArray())
|
||||
{
|
||||
if (control != OverlayForm.MainForm.displayLabel &&
|
||||
control != OverlayForm.MainForm.pauseLabel &&
|
||||
control != OverlayForm.MainForm.muteLabel &&
|
||||
control != OverlayForm.MainForm.topRightLabel &&
|
||||
control != OverlayForm.MainForm.blackBackgroundPanel &&
|
||||
control != OverlayForm.MainForm.topLeftLabel)
|
||||
{
|
||||
OverlayForm.MainForm.Controls.Remove(control);
|
||||
control.Dispose();
|
||||
}
|
||||
}
|
||||
OverlayForm.MainForm.UpdateDisplayLabels(messages);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void HandleNumberInput(string trimmedData)
|
||||
@ -861,38 +585,19 @@ namespace DualScreenDemo
|
||||
|
||||
if (readyForSongListInput)
|
||||
{
|
||||
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
InvokeAction(() =>
|
||||
{
|
||||
Console.WriteLine("D sign for number :" + number);
|
||||
OverlayForm.MainForm.OnUserInput(number);
|
||||
}));
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("E sign for number :" + number);
|
||||
OverlayForm.MainForm.OnUserInput(number);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (OverlayForm.MainForm.InvokeRequired)
|
||||
{
|
||||
OverlayForm.MainForm.Invoke(new System.Action(() =>
|
||||
InvokeAction(() =>
|
||||
{
|
||||
OverlayForm.MainForm.HideTopRightLabels();
|
||||
OverlayForm.DisplayNumberAtTopLeft(number);
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
OverlayForm.MainForm.HideTopRightLabels();
|
||||
OverlayForm.DisplayNumberAtTopLeft(number);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,10 +141,7 @@ namespace DBObj
|
||||
public int getHumanVoice() { return basic.getHumanVoice(); }
|
||||
public override string ToString()
|
||||
{
|
||||
|
||||
return B!=null
|
||||
? String.Format("{0} - {1} - {2} - {3}", state, A.getName(), B.getName(), basic.getName())
|
||||
: String.Format("{0} - {1} - {2}", state, A.getName(), basic.getName());
|
||||
return String.Format("{0} {1}", basic.getName(),state.GetDescription() );
|
||||
}
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ namespace DualScreenDemo
|
||||
private static PrimaryForm primaryForm; // 儲存實例的參考
|
||||
public static Room room = new Room();
|
||||
|
||||
public static string verSion = "Server V2.7 202508041108";
|
||||
public static string verSion = "Server V2.7 202508041725";
|
||||
|
||||
[STAThread]
|
||||
static void Main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user