public ErrorBox(Form parentForm, ActivationGuard activationGuard, StateMachine stateMachine) { _parentForm = parentForm; _locker = stateMachine.Lock(); if (activationGuard != null) { _keepActive = activationGuard.ActivityDetected; } InitializeComponent(); if (_parentForm != null) { _parentForm.Controls.Add(this); Enabled = true; Visible = true; UpdateZOrder(); } }
public MainForm() { InitializeComponent(); _errorProvider = new ErrorProvider(); _stateMachine = new StateMachine(StateProvider, new KioskConnector(), _scanner, _errorProvider); _errorProvider .WithContinuationAction(ex => new ErrorBox(this, _activationGuard, _stateMachine).WithMessage(ErrorTranslator.Translate(ex))) .WithContinuationAction(_ => _stateMachine.Reset()); _activationGuard = new ActivationGuard(TimeSpan.Parse((string)Configuration.Static.Merged.InactivityTimeout), _errorProvider) .OnActivate(_display.On) .OnActivate(_stateMachine.Reset) .OnDeactivate(_display.Off) .OnDeactivate(_stateMachine.Reset); _activationGuard.Start(); _imageCache = new ImageCache(new LocalFileImageCache(new DirectoryInfo(Path.Combine(Environment.CurrentDirectory, "ImageCache")), new KioskConnector())); _imageCache.Synchronize(); _finishedScreen.ImageCache = _imageCache; _priceInfoScreen.ImageCache = _imageCache; }