1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
| private Timer _questionIndexTimer = new Timer(); _questionIndexTimer.Interval = 50; _questionIndexTimer.AutoReset = true; _questionIndexTimer.Elapsed += new ElapsedEventHandler(OnQuestionIndexTimer); _questionIndexStatus = 0;
private void OnQuestionIndexTimer(object source, ElapsedEventArgs e) { double deltaTime = (e.SignalTime - _questionIndexTime).TotalMilliseconds; _questionIndexTime = e.SignalTime; this.Dispatcher.Invoke((System.Windows.Forms.MethodInvoker)delegate { _questionIndexOffset += _questionIndexStatus * deltaTime / 1000 * QUESTION_INDEX_MOVE_SPEED; QuestionViewer.Margin = new Thickness(_questionIndexOffset, 0, 0, 0); InvisQuestionViewer.Margin = new Thickness(_mainWindow.Width * 2 + QuestionViewer.Width*2 + _questionIndexOffset, 0, 0, 0); if (Math.Abs(_questionIndexOffset) > _mainWindow.Width * 2 + QuestionViewer.Width*2) { _questionIndexTimer.Enabled = false; } }); } |