開台時隱藏關台畫面

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

View File

@ -86,27 +86,29 @@ 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,6 +154,7 @@ 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))
{ {
@ -215,6 +218,8 @@ namespace DualScreenDemo
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);