開台時隱藏關台畫面

This commit is contained in:
jasonchenwork 2025-06-18 10:43:11 +08:00
parent 99ae486567
commit e77b4f4fec

View File

@ -86,28 +86,30 @@ namespace DualScreenDemo
//heartbeatSender sender = new heartbeatSender("127.0.0.1", 8888); //heartbeatSender sender = new heartbeatSender("127.0.0.1", 8888);
//sender.Start(); //sender.Start();
// Console.WriteLine($"heart beat for server{sender.RemoteEndPoint.Address}:{sender.RemoteEndPoint.Port}"); // Console.WriteLine($"heart beat for server{sender.RemoteEndPoint.Address}:{sender.RemoteEndPoint.Port}");
try { try {
string stateFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"txt","states.txt"); string stateFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "txt", "states.txt");
string initialState = ReadStateFile(stateFilePath); string initialState = ReadStateFile(stateFilePath);
/*
if (initialState.Equals("CLOSE", StringComparison.OrdinalIgnoreCase)) if (initialState.Equals("CLOSE", StringComparison.OrdinalIgnoreCase))
{ {
_ = SafeInvoke(PrimaryForm.Instance, () => _ = SafeInvoke(PrimaryForm.Instance, () =>
{ {
try { try {
/*foreach (Control ctrl in PrimaryForm.Instance.Controls) foreach (Control ctrl in PrimaryForm.Instance.Controls)
{ {
ctrl.Enabled = false; ctrl.Enabled = false;
}*/ }
PrimaryForm.Instance.ShowSendOffScreen(); PrimaryForm.Instance.ShowSendOffScreen();
} }
catch (Exception ex) { catch (Exception ex) {
Console.WriteLine($"顯示送客畫面時發生錯誤: {ex.Message}"); Console.WriteLine($"顯示送客畫面時發生錯誤: {ex.Message}");
} }
}); });
} } */
while (true) while (true)
{ {
@ -152,12 +154,13 @@ namespace DualScreenDemo
PrimaryForm.Instance.ShowSendOffScreen(); PrimaryForm.Instance.ShowSendOffScreen();
Console.WriteLine("開始設置新的播放列表"); Console.WriteLine("開始設置新的播放列表");
string closePath = @"D:\video\CLOSE.MPG"; string closePath = @"D:\video\CLOSE.MPG";
if (File.Exists(closePath)) if (File.Exists(closePath))
{ {
SongData closeSong = new SongData( SongData closeSong = new SongData(
"0", "結束播放", "", "", "", "0", "結束播放", "", "", "",
closePath, "", "", "", "", closePath, "", "", "", "",
1 1
); );
VideoPlayerForm.publicPlaylist = new List<SongData>(); VideoPlayerForm.publicPlaylist = new List<SongData>();
@ -167,7 +170,7 @@ namespace DualScreenDemo
{ {
VideoPlayerForm.playingSongList.Add(VideoPlayerForm.Instance.currentPlayingSong); VideoPlayerForm.playingSongList.Add(VideoPlayerForm.Instance.currentPlayingSong);
} }
VideoPlayerForm.playingSongList.Add(closeSong); VideoPlayerForm.playingSongList.Add(closeSong);
VideoPlayerForm.publicPlaylist.Add(closeSong); VideoPlayerForm.publicPlaylist.Add(closeSong);
@ -208,14 +211,16 @@ namespace DualScreenDemo
if (command.Trim().Equals("O", StringComparison.OrdinalIgnoreCase)) if (command.Trim().Equals("O", StringComparison.OrdinalIgnoreCase))
{ {
// 開台時跳至首頁 // 開台時跳至首頁
VideoPlayerForm.publicPlaylist = new List<SongData>(); VideoPlayerForm.publicPlaylist = new List<SongData>();
VideoPlayerForm.playingSongList = new List<SongData>(); VideoPlayerForm.playingSongList = new List<SongData>();
VideoPlayerForm.Instance.PlayPublicPlaylist(); VideoPlayerForm.Instance.PlayPublicPlaylist();
PrimaryForm.currentSongIndexInHistory = -1; PrimaryForm.currentSongIndexInHistory = -1;
PrimaryForm.Instance.HotPlayButton_Click(null, EventArgs.Empty); PrimaryForm.Instance.HotPlayButton_Click(null, EventArgs.Empty);
UpdateStateFile(stateFilePath, "OPEN"); UpdateStateFile(stateFilePath, "OPEN");
PrimaryForm.Instance.HideSendOffScreen();
byte[] okResponse = Encoding.UTF8.GetBytes("OK\n"); byte[] okResponse = Encoding.UTF8.GetBytes("OK\n");
stream.Write(okResponse, 0, okResponse.Length); stream.Write(okResponse, 0, okResponse.Length);
continue; continue;
@ -237,8 +242,8 @@ namespace DualScreenDemo
continue; continue;
} }
} }
if (IsFormReady(OverlayForm.MainForm)) if (IsFormReady(OverlayForm.MainForm))