コード例 #1
0
 void TimerComponent_Tick(object sender, TickEventArgs e)
 {
     var args = new TickEventArgs(e.TimeElapsed, e.TimeRemaining);
     OnTick(args);
 }
コード例 #2
0
 protected void OnTick(TickEventArgs e)
 {
     if (Tick != null)
     {
         Tick(this, e);
     }
 }
コード例 #3
0
 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));
 }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }