private void UpdateInputState(object sender, ElapsedEventArgs e) { var newInputDateTime = _inputSources.GetLastInputTime(); if (newInputDateTime.Subtract(_lastInputDateTime).TotalMilliseconds > 1000) { if (_lastInputDateTime.AddMilliseconds(_maxElapsedTimeMilliseconds) < newInputDateTime) { _lastInputUpdateDateTime = DateTime.Now; InputStarted?.Invoke(this, newInputDateTime); } else if (_lastInputUpdateDateTime.AddMilliseconds(_inputUpdateFrequencyMilliseconds) < DateTime.Now) { _lastInputUpdateDateTime = DateTime.Now; InputUpdated?.Invoke(this, newInputDateTime); } _lastInputDateTime = newInputDateTime; } }
void timer_Tick(object sender, EventArgs e) { lastInputTime.Content = FormatDateTime(lastInput.GetLastInputTime()); }