private void SetButton(MyMasterMindCommands command, bool state)
        {
            State[(int)command] = state;
            switch (command)
            {
            case MyMasterMindCommands.Check:
                ButtonCommandCheck.IsEnabled = state;
                break;

            case MyMasterMindCommands.ComputerFast:
                ButtonCommandComputerFast.IsEnabled = state;
                break;

            case MyMasterMindCommands.ComputerSlow:
                ButtonCommandComputerSlow.IsEnabled = state;
                break;

            case MyMasterMindCommands.User:
                ButtonCommandUser.IsEnabled = state;
                break;

            case MyMasterMindCommands.Cancel:
                ButtonCommandCancel.IsEnabled = state;
                break;

            case MyMasterMindCommands.Clear:
                ButtonCommandClear.IsEnabled = state;
                break;
            }
        }
 public void RaiseCommandEventHandler(MyMasterMindCommands command)
 {
     if (EventHandler.ContainsKey(command))
     {
         EventHandler[command].Invoke(this, null);
     }
 }
        private void ExecuteComputerCommand(MyMasterMindCommands command)
        {
            ComputerCommand = command;
            ClearBoard();
            EnableCommands(new List <MyMasterMindCommands>()
            {
                MyMasterMindCommands.Cancel
            });
            DisableCommands(new List <MyMasterMindCommands>()
            {
                MyMasterMindCommands.ComputerSlow, MyMasterMindCommands.ComputerFast,
                MyMasterMindCommands.User, MyMasterMindCommands.Clear,
                MyMasterMindCommands.Check
            });

            Game             = new MyMasterMindGame();
            BackgroundWorker = new BackgroundWorker {
                WorkerReportsProgress = true
            };
            BackgroundWorker.DoWork                    += BackGroundComputerDoWork;
            BackgroundWorker.RunWorkerCompleted        += BackGroundComputerCompleted;
            BackgroundWorker.ProgressChanged           += BackgroundWorkerComputerProgressChanged;
            BackgroundWorker.WorkerSupportsCancellation = true;
            BackgroundWorker.RunWorkerAsync(this);
        }
 public void SetCommandEventHandler(MyMasterMindCommands command, EventHandler eventHandler)
 {
     if (EventHandler.ContainsKey(command))
     {
         EventHandler[command] += eventHandler;
     }
     else
     {
         EventHandler.Add(command, eventHandler);
     }
 }
 public void SetButtonState(MyMasterMindCommands command, bool state)
 {
     SetButton(command, state);
 }
 public bool GetButtonState(MyMasterMindCommands command)
 {
     return(State[(int)command]);
 }
示例#7
0
 public ButtonCommand(IMasterMindCommandView masterMindCommandView,
                      MyMasterMindCommands command)
 {
     MasterMindCommandView = masterMindCommandView;
     Command = command;
 }