/// <summary> /// Start transition /// </summary> /// <param name="cmd">The transition direction</param> public void Move(BackgroundImageCommand cmd) { if (!_inTransition) { _sourceImage = _backgroundPictureManagerBlock.Picture; _targetImage = cmd == BackgroundImageCommand.NextImage ? _backgroundPictureManagerBlock.NextPicture : _backgroundPictureManagerBlock.PreviousPicture; _imageBorderLocation = 0; _originalTransitionCommand = _currentTransitionCommand = cmd; _dx = cmd == BackgroundImageCommand.NextImage ? -Pace : Pace; _inTransition = true; _timer.Enabled = true; _timer.Start(); } else { lock (this) { if (cmd == _currentTransitionCommand) { _dx *= 1.8; } else { _dx = -Math.Sign(_dx) * Pace; } _currentTransitionCommand = cmd; } } }
/// <summary> /// Called when a new gesture command is received /// </summary> /// <param name="command">The green command</param> private void OnNewCommand(BackgroundImageCommand command) { //Check if we are already in the desire state if (!_inTransition && (command == BackgroundImageCommand.ToGreenScreen && _inGreenOnlyState || command == BackgroundImageCommand.FromGreenScreen && _inImageOnlyState)) { return; } //To or from green _step = command == BackgroundImageCommand.ToGreenScreen ? Math.Abs(_step) : -Math.Abs(_step); _inTransition = true; _timer.Enabled = true; _timer.Start(); }