コード例 #1
0
ファイル: ProtocolViewModel.cs プロジェクト: rombolshak/Requc
        private void RunnerOnStepStarted(object sender, ProtocolStepStartedEventArgs protocolStepStartedEventArgs)
        {
            CurrentStepDescriptionVisualState = "Invisible";
            TypeSwitch.Do(protocolStepStartedEventArgs.Step,
                          TypeSwitch.Case<FillBlocksWithRandomPermutationStep>(step =>
                              {
                                  AliceBlocks[_environment.Pass].State = BlockSetViewModel.VisualStateE.Invisible;
                                  BobBlocks[_environment.Pass].State = BlockSetViewModel.VisualStateE.Invisible;
                              }),
                          TypeSwitch.Case<CalculateParitiesStep>(step =>
                              {
                                  foreach (
                                      var blockViewModel in
                                          AliceBlocks[_environment.Pass].Blocks.Concat(BobBlocks[_environment.Pass].Blocks))
                                  {
                                      blockViewModel.State = BlockViewModel.VisualStateE.NothingVisible;
                                  }
                              }),
                          TypeSwitch.Case<FindSmallestOddErrorBlockStep>(step =>
                              {
                                  foreach (var block in GetAllBlocks(BobBlocks)
                                      .Where(
                                          block =>
                                          block.State ==
                                          BlockViewModel.VisualStateE.OddError))
                                  {
                                      block.State = BlockViewModel.VisualStateE.OddErrorNotSelected;
                                  }
                              }),
                          TypeSwitch.Case<InitializeBinaryCorrectionStep>(step =>
                              {
                                  GetWorkingBlock().State = BlockViewModel.VisualStateE.Normal;
                              }),
                          TypeSwitch.Case<LookAtFirstHalfOfWorkingPositionsStep>(() =>
                              {
                                  GetWorkingBlock().State = BlockViewModel.VisualStateE.ParityTextInvisible;
                                  GetSampleBlock().State = BlockViewModel.VisualStateE.ParityTextInvisible;
                              }),
                              TypeSwitch.Case<CorrectErrorInFoundPositionStep>(() =>
                                  {
                                      GetWorkingBlock().State = BlockViewModel.VisualStateE.NothingVisible;
                                      GetSampleBlock().State = BlockViewModel.VisualStateE.NothingVisible;
                                      GetWorkingBlock().Items[_environment.BinaryEnvironment.StartPosition].State = KeyItemViewModel.VisualStateE.HighlightError;
                                  }));

            StateManager.WaitAnimations();
            protocolStepStartedEventArgs.Handle.Set();

            _screenCapture.CaptureWindowToFile(Process.GetCurrentProcess().MainWindowHandle,
                                               DateTime.Now.ToString("hhmmss_") + protocolStepStartedEventArgs.Step + "_started.png",
                                               ImageFormat.Png);
            // OnStepStarted(protocolStepStartedEventArgs);
        }
コード例 #2
0
ファイル: ProtocolRunner.cs プロジェクト: rombolshak/Requc
        private void OnStepStarted(IProtocolStep step)
        {
            _logger.Write("OnStepStarted " + step);
            var handler = StepStarted;
            if (handler == null) return;

            _logger.Write("Raising event, handler not null");
            var stepStartedEventArgs = new ProtocolStepStartedEventArgs(step);
            handler(this, stepStartedEventArgs);
            stepStartedEventArgs.Handle.WaitOne(2000);
        }