Как заставить приложение обратного отсчета считать месяцы и дни
Я могу заставить приложение отсчитывать минуты и секунды
Что я уже пробовал:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Windows.Threading; namespace count_down { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { private int time = 30; private DispatcherTimer timer; public MainWindow() { InitializeComponent(); timer = new DispatcherTimer(); timer.Interval = new TimeSpan(0,0,1); timer.Tick += Timer_Tick; timer.Start(); } public void Timer_Tick(object sender, EventArgs e) { if (time > 0) { if (time <= 20) { if (time % 2 == 0) { tbCountDown.Foreground = Brushes.Orange; } else { tbCountDown.Foreground = Brushes.Orange; } if (time <= 10) { if (time % 2 == 0) { tbCountDown.Foreground = Brushes.Red; } else { tbCountDown.Foreground = Brushes.White; } } time--; tbCountDown.Text = string.Format("00:0{0}:{1}", time / 60, time % 60); } else { time--; tbCountDown.Text = string.Format("00:0{0}:{1}", time / 60, time % 60); } } else { timer.Stop(); MessageBox.Show("BOOM!"); } } private void button_Click(object sender, RoutedEventArgs e) { if (txtB.Text == string.Empty) { MessageBox.Show("Please enter value"); } else { MessageBox.Show(txtB.Text); } } } }