public void Reset() { _running = false; _timer.Stop(); _timer.Interval = 0xfffffff; _timer.Tick -= TimerElapsed; if (_stillStartTimer.Enabled) { _stillStartTimer.Stop(); _stillStartTimer.Interval = 0xfffffff; _stillStartTimer.Tick -= StillStartElapsed; } if (Tick != null && _tickHandler != null) { Tick -= _tickHandler; _tickHandler = null; } _start.Reset(); _end.Reset(); _current.Reset(); _startTime = _endTime = DateTime.Now; _progress = 0.0f; _frameCount = 0; _rotation = 0.0f; _deltaWidth = _deltaHeight = 0; _translation = new Vector2(); }
//BblAnimType type, public void Init(ImageViewingParams start, ImageViewingParams end, BblAnimationTickDelegate tickHandler, int duration, int stillStartDelay = 0, int fps = 0) { //if (type == BblAnimType.IvpRestoration || _curType != BblAnimType.IvpRestoration) //{ // if (isRunning && !_current.isReset) // { // EndNow(); // } //} //else if (isRunning && !_current.isReset) { float x = _end.center.X - _current.center.X; float y = _end.center.Y - _current.center.Y; float hw = (_end.rect.Width - _current.rect.Width) / 2; float hh = (_end.rect.Height - _current.rect.Height) / 2; start = _current; end.Set(end.l + x - hw, end.t + y - hh, end.r + x + hw, end.b + y + hh, end.rotation); Reset(); } _start = start; _end = end; _duration = duration; _tickHandler = tickHandler; Tick += tickHandler; if (fps <= 0) { fps = 100; } _timer.Interval = (int)(1000.0f / (float)fps); _timer.Tick += TimerElapsed; _stillStartDelay = stillStartDelay; if (stillStartDelay > 0) { _stillStartTimer.Interval = stillStartDelay; _stillStartTimer.Tick += StillStartElapsed; } _rotation = _end.rotation - _start.rotation; if (_rotation > 180) { _rotation = -(360 - _rotation); } _deltaWidth = _end.rect.Width - _start.rect.Width; _deltaHeight = _end.rect.Height - _start.rect.Height; float xTrans = _end.center.X - _start.center.X; float yTrans = _end.center.Y - _start.center.Y; _translation = new Vector2(xTrans, yTrans); _frameCount = 0; _running = true; if (_stillStartDelay > 0) { Tick(this, _start); _stillStartTimer.Start(); } else { _startTime = DateTime.Now; _endTime = _startTime + new TimeSpan(0, 0, 0, 0, _duration); _timer.Start(); } }