Example #1
0
 private void App_OnStartup(object sender, StartupEventArgs e)
 {
     AppearanceManager.Current.AccentColor = Color.FromRgb(0x76, 0x60, 0x8a);  // mauve
     var environment = new CascadeProtocolRuntimeEnvironment();
     var viewModel = new ProtocolViewModel(new ProtocolRunner(environment), environment);
     new MainWindow{ DataContext = viewModel }.Show();
 }
Example #2
0
 public ProtocolRunner(CascadeProtocolRuntimeEnvironment environment)
 {
     _environment = environment;
     _stepHandle = new ManualResetEvent(false);
     _logger = new FileLogger("runner.log");
     _worker = new BackgroundWorker();
     _worker.DoWork += DoWorkerTask;
 }
Example #3
0
        public ProtocolViewModel(ProtocolRunner runner, CascadeProtocolRuntimeEnvironment environment)
        {
            _runner = runner;
            _environment = environment;
            NextStepCommand = new RelayCommand(_ => _runner.NextStep());
            StartProcessCommand = new RelayCommand(_ => { _runner.Start(); _runner.NextStep(); });

            _screenCapture = new ScreenCapture("images");

            _runner.StepStarted += RunnerOnStepStarted;
            _runner.StepFinished += RunnerOnStepFinished;

            AliceKey = environment.AliceKey.Select(item => new KeyItemViewModel(item)).ToList();
            BobKey = environment.BobKey.Select(item => new KeyItemViewModel(item)).ToList();
            ErrorItems =
                environment.BobKey.Where((model, i) => environment.AliceKey[i].Value != model.Value)
                           .Select(model => new KeyItemViewModel(model))
                           .ToList();

            const int numberOfPasses = 4;
            AliceBlocks = new BlockSetViewModel[numberOfPasses];
            for (var i = 0; i < numberOfPasses; ++i)
            {
                AliceBlocks[i] = new BlockSetViewModel
                    {
                        Blocks = environment.AliceBlocks[i].Select(block => new BlockViewModel(block, AliceKey)).ToList()
                    };
            }

            BobBlocks = new BlockSetViewModel[numberOfPasses];
            for (var i = 0; i < numberOfPasses; ++i)
            {
                BobBlocks[i] = new BlockSetViewModel
                {
                    Blocks = environment.BobBlocks[i].Select(block => new BlockViewModel(block, BobKey)).ToList()
                };
            }
        }