private void InitializeSteps()
        {
            StopAnimations();

            this.Controls.Clear();

            foreach (ZeroitProgressStep step in _steps)
            {
                ZeroitEXPicBoxAnimated animatedPictureBox = new ZeroitEXPicBoxAnimated();
                animatedPictureBox.Image = step.Image;
                animatedPictureBox.ExtraImageAlignment   = _extraImageAlignment;
                animatedPictureBox.TextAlign             = _textAlignment;
                animatedPictureBox.AnimationIntervall    = _animationIntervall;
                animatedPictureBox.AnimationStepSize     = _animationStepSize;
                animatedPictureBox.AllowDisabledPainting = false;
                animatedPictureBox.Text = step.Text;

                ZeroitStepAnimators stepAnimators = new ZeroitStepAnimators(_animateExtraImage, _animateBackColor, _inProgressState.BackColor, _inProgressState.BackColor2, animatedPictureBox);
                animatedPictureBox.Tag = stepAnimators;

                this.Controls.Add(animatedPictureBox);
            }

            Reset();
            RepositionIcons();
        }
        /// <summary>
        /// Transforms the <see cref="CurrentStep"/> to <see cref="FinishedState"/>,
        /// sets <see cref="CurrentStep"/> to the next following step and transforms it
        /// into <see cref="InProgressState"/> also change the extra images to
        /// the appropriate values.
        /// If <see cref="BlockNextStepCall"/> is set to true than this call will not
        /// return until the animations are still runnning.
        /// </summary>
        public void NextStep()
        {
            ZeroitEXPicBoxAnimated finishingAnimatedPictureBox  = null;
            ZeroitEXPicBoxAnimated inProgressAnimatedPictureBox = null;

            if (_currentStep >= 0 && _currentStep < _steps.Count)
            {
                finishingAnimatedPictureBox             = GetAnimatedPictureBox(_currentStep);
                finishingAnimatedPictureBox.BorderStyle = ButtonBorderStyle.None;
                ZeroitStepAnimators stepAnimators = (ZeroitStepAnimators)finishingAnimatedPictureBox.Tag;
                stepAnimators.Stop();
                if (_showExtraImages)
                {
                    finishingAnimatedPictureBox.ExtraImage = _finishedExtraImage;
                }
                finishingAnimatedPictureBox.Animate(_finishedState);
            }

            _currentStep++;

            if (_currentStep >= 0 && _currentStep < _steps.Count)
            {
                inProgressAnimatedPictureBox             = GetAnimatedPictureBox(_currentStep);
                inProgressAnimatedPictureBox.BorderStyle = ButtonBorderStyle.Dashed;
                inProgressAnimatedPictureBox.Animate(_inProgressState);
                if (_showExtraImages)
                {
                    inProgressAnimatedPictureBox.ExtraImage = _inProgressExtraImage;
                }
                if (_stepNotificationControl != null)
                {
                    _stepNotificationControl.Text = string.Format(CurrentStep.Description, CurrentStep.Name, _currentStep + 1, _steps.Count);
                }
                ZeroitStepAnimators stepAnimators = (ZeroitStepAnimators)inProgressAnimatedPictureBox.Tag;
                stepAnimators.Start(_animateExtraImage, _animateBackColor);
            }
            if (inProgressAnimatedPictureBox == null && _stepNotificationControl != null)
            {
                _stepNotificationControl.Text = string.Format(_finishedNotificationText, _steps.Count);
            }

            if (_blockNextStepCall)
            {
                while ((inProgressAnimatedPictureBox != null && inProgressAnimatedPictureBox.IsAnimationRunning) || (finishingAnimatedPictureBox != null && finishingAnimatedPictureBox.IsAnimationRunning))
                {
                    System.Threading.Thread.Sleep(10);
                    Application.DoEvents();
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a new instance.
        /// </summary>
        /// <param name="animateExtraImageRotationAngle">Indicates whether the the extra image should be rotated.</param>
        /// <param name="animateColor">Indicates whether the colors should be animated.</param>
        /// <param name="color1">First color of the animation.</param>
        /// <param name="color2">Second color of the animation.</param>
        /// <param name="pictureBox">AnimatedPictureBox.</param>
        internal ZeroitStepAnimators(bool animateExtraImageRotationAngle, bool animateColor, Color color1, Color color2, ZeroitEXPicBoxAnimated pictureBox)
        {
            _pictureBox = pictureBox;

            _extraImageRotationAngleAnimator = new ZeroitEXPicBoxImageAnimator();
            _extraImageRotationAngleAnimator.ZeroitEXPicBox     = pictureBox;
            _extraImageRotationAngleAnimator.StartRotationAngle = 0f;
            _extraImageRotationAngleAnimator.EndRotationAngle   = 360f;
            _extraImageRotationAngleAnimator.LoopMode           = LoopMode.Repeat;

            _backColorAnimator            = new ControlBackColorAnimator();
            _backColorAnimator.Control    = pictureBox;
            _backColorAnimator.StartColor = color1;
            _backColorAnimator.EndColor   = color2;
            _backColorAnimator.LoopMode   = LoopMode.Bidirectional;

            _backColor2Animator = new ZeroitEXPicBoxColorAnimator();
            _backColor2Animator.ZeroitEXPicBox = pictureBox;
            _backColor2Animator.StartColor     = color2;
            _backColor2Animator.EndColor       = color1;
            _backColor2Animator.ParentAnimator = _backColorAnimator;
        }