public void OnTick(object sender, EventArgs e) { DisplayStruct disp = GetGroupValues(); TimeSpan when = TargetEvent - DateTime.Now; Color color = Color.Red; if (when.TotalDays > 3) { color = Color.Green; } else if (when.TotalDays > 1) { color = Color.Yellow; } else if (when.TotalSeconds < 0) { color = Color.Purple; } int a; //a.ToString() label4.Text = disp.seconds.ToString(disp.secondFormat); label3.Text = disp.minutes.ToString(disp.minuteFormat); label2.Text = disp.hours.ToString(disp.hourFormat); label1.Text = disp.days.ToString("D2"); }
protected DisplayStruct GetGroupValues() { TimeSpan ts = TargetEvent - DateTime.Now; DisplayStruct disp = new DisplayStruct(); if (ts.TotalSeconds > 0) { disp.days = ts.Days; disp.hours += ts.Hours; disp.minutes += ts.Minutes; disp.seconds += ts.Seconds; } return(disp); }