private void But_Save_Click(object sender, EventArgs e)
 {
     ArcadeGameStartAndStopService.MainConfig.ServerCredential.UserName = TexBox_UserName.Text;
     ArcadeGameStartAndStopService.MainConfig.ServerCredential.Password = TexBox_Password.Text;
     JSONServiceConfig.SaveJSONServiceConfig(ArcadeGameStartAndStopService.MainConfig);
     Close();
 }
        private void But_Save_Click(object sender, EventArgs e)
        {
            if (TexBox_MachineGUID.Text.Trim() != "")
            {
                ArcadeGameStartAndStopService.MainConfig.MachineGUID = TexBox_MachineGUID.Text;
            }
            if (TexBox_LocalLogOutput.Text.Trim() != "")
            {
                ArcadeGameStartAndStopService.MainConfig.LocalLogOutput = TexBox_LocalLogOutput.Text;
            }
            if (TexBox_MachineName.Text.Trim() != "")
            {
                ArcadeGameStartAndStopService.MainConfig.MachineName = TexBox_MachineName.Text;
            }
            if (TexBox_MasterServerURL.Text.Trim() != "")
            {
                ArcadeGameStartAndStopService.MainConfig.MasterServerURL = TexBox_MasterServerURL.Text;
            }
            if (TexBox_MasterStarterMasterLoc.Text.Trim() != "")
            {
                ArcadeGameStartAndStopService.MainConfig.MasterStarterMasterLoc = TexBox_MasterStarterMasterLoc.Text;
            }
            if (TexBox_Password.Text.Trim() != "")
            {
                ArcadeGameStartAndStopService.MainConfig.ServerCredential.Password = TexBox_Password.Text;
            }
            if (TexBox_UserName.Text.Trim() != "")
            {
                ArcadeGameStartAndStopService.MainConfig.ServerCredential.UserName = TexBox_UserName.Text;
            }
            if (TexBox_ServerLogOutput.Text.Trim() != "")
            {
                ArcadeGameStartAndStopService.MainConfig.ServerLogOutput = TexBox_ServerLogOutput.Text;
            }
            //if (TexBox_ServerLogOutput.Text.Trim() != "") //depreciated with game selector
            //    Config.DefualtGameGUID = TexBox_DefualtGameGUID.Text;
            ArcadeGameStartAndStopService.MainConfig.StarterMode = GetGameStartModeFromString(LisBox_GameStarterMode.Items[LisBox_GameStarterMode.SelectedIndex].ToString());

            ArcadeGameStartAndStopService.MainConfig.ServerMode = GetServerModeFromString(LisBox_GameStarterMode.Items[LisBox_GameStarterMode.SelectedIndex].ToString());

            ArcadeGameStartAndStopService.MainConfig.CardModeMode = GetCardModeFromString(LisBox_GameStarterMode.Items[LisBox_GameStarterMode.SelectedIndex].ToString());

            Dictionary <string, List <string> > Errors;

            if (!ConfigHelpers.ValidateConfig(ArcadeGameStartAndStopService.MainConfig, out Errors))
            {
                ShowingErrorAlready = true;
                MessageBox.Show(ConfigHelpers.ConvertErrorsToMessage(Errors));
                return;
            }
            ShowingErrorAlready = true;

            ArcadeGameStartAndStopService.Logger.WriteLog("'Arcade Game Start And Stop Service' has changed config.");

            JSONServiceConfig.SaveJSONServiceConfig(ArcadeGameStartAndStopService.MainConfig);
            Close();
        }
 public static void Save(GameServiceConfig Settings)
 {
     JSONServiceConfig.SaveJSONServiceConfig(Settings);
 }
        };                                                                                              //Our key
        //readonly static byte[] AuthenticationKeys = new byte[6] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; //Blank key

        public ArcadeGameStartAndStopService()
        {
            InitializeComponent();
            MainConfig = JSONServiceConfig.GetJSONServiceConfig();
            Logger     = new Logger();

            SlaveLocationModel slaveLocationModel = new SlaveLocationModel();

            //GameServicePipeServer.Service = this;

            TheServerClient = new ServerClient(MainConfig);

            GameServicePipeServer ServerController = new GameServicePipeServer();

            ServerController.PlayGameEvent += StartGameRequested;

            GameMenu = new GameMenu(ServerController);



            #region depreciated
            //ACR122UManager.GlobalCardCheck = (e) =>
            //{
            //    return AcceptedATRS.Any(x =>
            //    {
            //        bool CeckSuccess = false;
            //        if (e.ATR.Length == x.Length)
            //        {
            //            CeckSuccess = true;
            //            for (int i = 0; i < e.ATR.Length; i++)
            //            {
            //                if (e.ATR[i] != x[i])
            //                {
            //                    CeckSuccess = false;
            //                    break;
            //                }
            //            }
            //        }
            //        return CeckSuccess;
            //    });
            //};

            //if (MainConfig.DefualtGameGUID == null || !GameStarter.Config.Games.Any(x => x.GUID == MainConfig.DefualtGameGUID))
            //{
            //    Logger.WriteLog("Game GUID doesnt exist. Will attempt revert to first game in list.", LoggerWarringLevel.Warring);
            //    MainConfig.DefualtGameGUID = GameStarter.Config.Games.FirstOrDefault(x=>true)?.GUID;
            //    if (MainConfig.DefualtGameGUID == null)
            //    {
            //        Logger.WriteLog("Game list seems to be empty. Please populate game list before starting service. Service will now Stop.", LoggerWarringLevel.Danger);
            //        MessageBox.Show("Game list seems to be empty.\nPlease populate game list before starting service.\nService will now Stop.");
            //        throw new Exception("Game list seems to be empty.\nPlease populate game list before starting service.\nService will now Stop.");
            //    }
            //}

            //GameGUID = MainConfig.DefualtGameGUID;

            #endregion

            #region Kernel32EventTieing
            CloseEventHandle += new CloseEvent(CloseEventAction);
            SetConsoleCtrlHandler(CloseEventHandle);
            #endregion
        }