移除錨點+遙控關機+貼圖調整

This commit is contained in:
jasonchenwork 2025-04-10 14:16:34 +08:00
parent 6cbf5f5106
commit d57de0b616
4 changed files with 32 additions and 27 deletions

View File

@ -8,7 +8,8 @@ namespace DualScreenDemo
public class CommandHandler
{
public static bool readyForSongListInput = false;
private readonly int _maxHistoryLength = 6; // 最多保留 100 筆
private readonly Queue<string> _indataHistory = new Queue<string>();
private readonly SongListManager songListManager;
public CommandHandler(SongListManager songListManager)
@ -18,7 +19,7 @@ namespace DualScreenDemo
public async Task ProcessData(string indata)
{ //關機錨點
string filePath = Path.Combine(Application.StartupPath, "dataLog.txt");
/*string filePath = Path.Combine(Application.StartupPath, "dataLog.txt");
// 使用 Path.Combine 方法安全地將應用程式的啟動路徑與 "dataLog.txt" 檔案名結合,
// 建立完整的檔案路徑。Application.StartupPath 通常指向應用程式的可執行檔所在的目錄。
@ -31,7 +32,10 @@ namespace DualScreenDemo
// 在控制台輸出訊息,告知使用者已滿足關機條件,應用程式即將關閉。
ShutdownComputer();
// 呼叫 ShutdownComputer 方法,這個方法預期會執行關閉電腦的操作。
}
}*/
AddToHistory(indata);
switch (indata)
{
case "A261A4":
@ -188,6 +192,29 @@ namespace DualScreenDemo
}
}
private void AddToHistory(string indata)
{
if (_indataHistory.Count >= _maxHistoryLength)
{
_indataHistory.Dequeue(); // 移除最舊的項目
}
_indataHistory.Enqueue(indata); // 添加新的項目
CheckSequenceforClose(); // 每次更新完 queue 後檢查
}
private void CheckSequenceforClose()
{
string[] targetSequence = { "A262A4", "A262A4", "A262A4", "A261A4", "A261A4", "A261A4" };
if (_indataHistory.Count == targetSequence.Length &&
_indataHistory.SequenceEqual(targetSequence))
{
// 👇 這裡就是條件符合時要做的事情
Console.WriteLine("Shutdown condition met. Application will now close.");
ShutdownComputer();
// 你可以呼叫其他方法、觸發事件、改狀態等等
}
}
void InvokeAction(Action action)
{
if (OverlayForm.MainForm.InvokeRequired)

View File

@ -67,8 +67,6 @@ namespace DualScreenDemo
// 如果有外网地址,也添加外网地址前缀
if (!string.IsNullOrEmpty(externalAddress))
{
// 錨點 2
// 外網 IP 和 port 調整
string[] parts = externalAddress.Split(':');
string host = parts[0];

View File

@ -69,9 +69,9 @@ namespace OverlayFormObj
MainForm = this;
InitializeFormSettings();
ConfigureTimers();
ConfigureImageDisplay();
InitializeLabels();
ConfigureSegmentTimer();
imageYPos = (screenHeight / 3) - 1024 / 6;
}
private void ConfigureSegmentTimer()
{
@ -525,25 +525,6 @@ private static void SongDisplayTimer_Elapsed(object sender, EventArgs e)
unifiedTimer.Start();
}
private void ConfigureImageDisplay()
{
try
{
firstStickerImage = Image.FromFile(Path.Combine(Application.StartupPath, "superstar-pic/1-1.png"));
firstStickerXPos = this.Width / 2;
imageYPos = (screenHeight / 3) - firstStickerImage.Height / 6;
stickerTimer1.Start();
}
catch (Exception ex)
{
Console.WriteLine("Error loading initial sticker image: " + ex.Message);
firstStickerImage = null;
}
}
private void HideImages()
{
@ -771,7 +752,7 @@ private static void SongDisplayTimer_Elapsed(object sender, EventArgs e)
Console.WriteLine("Form Height: " + this.Height);
string imagePath = String.Format("{0}\\superstar-pic\\{1}.png", Application.StartupPath, stickerId);
string imagePath = String.Format("{0}\\themes\\superstar\\superstar-pic\\{1}.png", Application.StartupPath, stickerId);
Console.WriteLine("Image path: " + imagePath);
try
{

View File

@ -250,7 +250,6 @@ namespace DualScreenDemo
public Timer micControlTimer;
private SequenceManager sequenceManager = new SequenceManager();
/* 關機圖片調整區域 錨點3 */
private PictureBox buttonMiddle;
private PictureBox buttonTopRight;
private PictureBox buttonTopLeft;