namespace DualScreenDemo
{        
    public partial class PrimaryForm : Form{
    private class SequenceManager
        {
            private List<string> correctSequence = new List<string> { "超", "級", "巨", "星" };
            private List<string> currentSequence = new List<string>();

            public void ProcessClick(string buttonName)
            {
                currentSequence.Add(buttonName);

                // 檢查是否點擊錯誤
                if (currentSequence.Count <= correctSequence.Count)
                {
                    if (currentSequence[currentSequence.Count - 1] != correctSequence[currentSequence.Count - 1])
                    {
                        Console.WriteLine(currentSequence[currentSequence.Count - 1] +" 比對 " + correctSequence[currentSequence.Count - 1] +" 順序錯誤，重置序列");
                        // 順序錯誤，重置序列
                        currentSequence.Clear();
                        return;
                    }
                }

                // 檢查是否完成正確序列
                if (currentSequence.Count == correctSequence.Count)
                {
                    try
                    {
                        // ✅ 這行要在主執行緒執行，避免 UI 錯誤
                        Cursor.Show();  

                        Console.WriteLine("使用 Windows 命令關機");

                        // ✅ 關機動作移到背景執行緒
                        new System.Threading.Thread(() =>
                        {
                            System.Diagnostics.Process.Start("shutdown", "/s /t 0");
                        }).Start();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show($"關機失敗: {ex.Message}");
                    }
                }

            }
        }
    }
}