protected override void Animate() { base.Animate(); if (this.IsDisposing || this.IsDisposed) { return; } Rectangle start = this.minimum; Rectangle end = this.maximum; if (!this.AnimateMinimumToMaximum) { end = this.minimum; start = this.maximum; } AnimationValueRectangleCalculator threadCalculator = new AnimationValueRectangleCalculator(); for (int i = 0; i < this.AnimationFrames; i++) { //keep in mind that at any execution line the calling thread may have disposed this instance, so always check for the state of the object if (this.IsDisposing || this.IsDisposed) { return; } if (cancel) { cancel = false; break; } this.currentFrameValue = (Rectangle)threadCalculator.CalculateAnimatedValue(start, end, null, null, i, this.frames, this.calculator); //keep in mind that at any execution line the calling thread may have disposed this instance, so always check for the state of the object if (this.IsDisposing || this.IsDisposed) { return; } this.OnAnimating(new AnimationEventArgs(this.currentFrameValue, false)); Thread.Sleep(20); } //keep in mind that at any execution line the calling thread may have disposed this instance, so always check for the state of the object if (this.IsDisposing || this.IsDisposed) { return; } this.OnAnimationFinished(new AnimationEventArgs(this.Maximum, true)); }
protected override void Animate() { base.Animate(); if (this.IsDisposing || this.IsDisposed) { return; } Rectangle rectangle1 = this.minimum; Rectangle rectangle2 = this.maximum; if (!this.AnimateMinimumToMaximum) { rectangle2 = this.minimum; rectangle1 = this.maximum; } AnimationValueRectangleCalculator rectangleCalculator = new AnimationValueRectangleCalculator(); for (int currFrameNum = 0; currFrameNum < this.AnimationFrames; ++currFrameNum) { if (this.IsDisposing || this.IsDisposed) { return; } if (this.cancel) { this.cancel = false; break; } this.currentFrameValue = (Rectangle)rectangleCalculator.CalculateAnimatedValue((object)rectangle1, (object)rectangle2, (object)null, (object)null, currFrameNum, this.frames, (EasingCalculator)this.calculator); if (this.IsDisposing || this.IsDisposed) { return; } this.OnAnimating(new AnimationEventArgs((object)this.currentFrameValue, false)); Thread.Sleep(20); } if (this.IsDisposing || this.IsDisposed) { return; } this.OnAnimationFinished(new AnimationEventArgs((object)this.Maximum, true)); }