/// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(IConfiguration configuration)
        {
            ////if (IsInDesignMode)
            ////{
            ////    // Code runs in Blend --> create design time data.
            ////}
            ////else
            ////{
            ////    // Code runs "for real"
            ////}
            ///
            ChooseWzqGameRelayCommnad = new RelayCommand(OpenChooseGameWindow);
            SaveCaptureIntevalCommand = new RelayCommand <string>(SaveCaptureInteval);
            ViewLoadedCommnad         = new RelayCommand <RoutedEventArgs>(ViewLoaded);

            baseConfiguration = configuration as BaseConfiguration;
            baseConfiguration.Load();
            WzqGameProcess = UtilityTool.GetWzqGameProcess(baseConfiguration.GameUiTitle);

            chessRecognize = new ChessRecognize(configuration);
            chessRecognize.ChessRecognized += ChessRecognize_ChessRecognized;

            //检测WzqGameProcess
            new Thread(() =>
            {
                Process lastProcess = null;
                while (true)
                {
                    if (isClosing == true)
                    {
                        return;
                    }

                    if (WzqGameProcess == null || WzqGameProcess.HasExited)
                    {
                        WzqGameProcess = UtilityTool.GetWzqGameProcess(baseConfiguration.GameUiTitle);

                        if (WzqGameProcess != null && lastProcess != WzqGameProcess)
                        {
                            lastProcess = WzqGameProcess;
                            baseConfiguration.GameProcessId = WzqGameProcess.Id;
                            chessRecognize.UpdateSetting();
                        }
                    }
                    else
                    {
                        if (WzqGameProcess.Id != baseConfiguration.GameProcessId)
                        {
                            baseConfiguration.GameProcessId = WzqGameProcess.Id;
                            chessRecognize.UpdateSetting();
                        }
                    }
                    Thread.Sleep(200);
                }
            }).Start();
        }
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(IConfiguration configuration, IDialogService dialogService)
        {
            ////if (IsInDesignMode)
            ////{
            ////    // Code runs in Blend --> create design time data.
            ////}
            ////else
            ////{
            ////    // Code runs "for real"
            ////}
            ///
            ChooseWzqGameRelayCommnad = new RelayCommand(OpenChooseGameWindow);
            SaveCaptureIntevalCommand = new RelayCommand <string>(SaveCaptureInteval);
            ViewLoadedCommnad         = new RelayCommand <RoutedEventArgs>(ViewLoaded);
            SaveTurnTimeoutCommand    = new RelayCommand <string>(SaveTurnTimeout);

            DialogService = dialogService;

            string aiFilePath = Path.Combine(AppContext.BaseDirectory, "ai");

            if (Directory.Exists(aiFilePath) == false)
            {
                Directory.CreateDirectory(aiFilePath);
            }
            string[] aiFiles = Directory.GetFiles(aiFilePath, "*.exe", SearchOption.TopDirectoryOnly);
            if (aiFiles.Count() == 0)
            {
                DialogService.ShowError("缺少AI程序,请下载安装", "错误", "", () => {
                    Process.Start("https://github.com/Gomocup/GomocupDownload");
                });
            }

            AiList = (from r in aiFiles
                      select new FileInfo(r).Name).ToList();

            baseConfiguration = configuration as BaseConfiguration;
            baseConfiguration.Load();
            WzqGameProcess = UtilityTool.GetWzqGameProcess(baseConfiguration.GameUiTitle);

            chessRecognize = new ChessRecognize(configuration);
            chessRecognize.ChessRecognized += ChessRecognize_ChessRecognized;

            //检测WzqGameProcess
            new Thread(() =>
            {
                Process lastProcess = null;
                while (true)
                {
                    if (isClosing == true)
                    {
                        return;
                    }

                    try
                    {
                        if (WzqGameProcess == null || WzqGameProcess.HasExited)
                        {
                            WzqGameProcess = UtilityTool.GetWzqGameProcess(baseConfiguration.GameUiTitle);

                            if (WzqGameProcess != null && lastProcess != WzqGameProcess)
                            {
                                lastProcess = WzqGameProcess;
                                baseConfiguration.GameProcessId = WzqGameProcess.Id;
                                chessRecognize.UpdateSetting();
                            }
                        }
                        else
                        {
                            if (WzqGameProcess.Id != baseConfiguration.GameProcessId)
                            {
                                baseConfiguration.GameProcessId = WzqGameProcess.Id;
                                chessRecognize.UpdateSetting();
                            }

                            if (chessRecognize.WzqProcess == null || (WzqGameProcess.Id != chessRecognize.WzqProcess.Id))
                            {
                                chessRecognize.UpdateSetting();
                            }
                        }
                    }
                    catch { }

                    Thread.Sleep(200);
                }
            }).Start();
        }