void TimerComponent_Tick(object sender, TickEventArgs e) { var args = new TickEventArgs(e.TimeElapsed, e.TimeRemaining); OnTick(args); }
protected void OnTick(TickEventArgs e) { if (Tick != null) { Tick(this, e); } }
public void Tick_Returns_Positive_TimeRemaining_Value() { var actual = TimeSpan.Zero; timer.Tick += (sender, args) => actual = args.TimeRemaining; var expected = new TimeSpan(0, 0, 2, 0); var expArgs = new TickEventArgs(TimeSpan.MinValue, expected); timerComponent.Raise(tc => tc.Tick += null, this, expArgs); Assert.True(actual > TimeSpan.Zero, string.Format( "Tick Has Not Raised Expected Positive TimeRemaining Value.\r\nTimeSpan Returned: {0}", actual)); }
public void Tick_Returns_Elapsed_Value_From_TimerComponent() { var actual = TimeSpan.MinValue; timer.Tick += (sender, args) => actual = args.TimeElapsed; var expected = new TimeSpan(0, 0, 42, 0); var expectedArgs = new TickEventArgs(expected, TimeSpan.MinValue); timerComponent.Raise(tc => tc.Tick += null, this, expectedArgs); Assert.Equal(expected, actual); }
private void timer_Tick(object sender, TickEventArgs e) { var t = e.TimeRemaining; Console.WriteLine(string.Format("Timer TimeRemaining: {0}\tElapsed: {1}", e.TimeRemaining, e.TimeElapsed)); var ticksRemaining = t.Ticks; var ticksMax = ProgRemaining.Maximum; var ticksComplete = (ticksRemaining / ticksMax) * 100; // RC: Do NOT Repaint the Progress Bar if Minimised // This is bloody expensive! if (WindowState != WindowState.Minimized) { LblRemaining.Content = t.ToFriendly(); ProgRemaining.Value = ticksRemaining; var brush = BrushExtensions.BasedOnProgress((int)ticksComplete); ProgRemaining.Foreground = brush; } mini.Update(t, (int)ticksComplete); }