using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; 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; namespace BPASmartClient.SCADAControl.CustomerControls { /// /// DateTimeUI.xaml 的交互逻辑 /// public partial class DateTimeUI : UserControl { public DateTimeUI() { InitializeComponent(); Task.Run(new Action(() => { while (true) { this.Dispatcher.Invoke(new Action(() => { time.Text = DateTime.Now.ToString("HH:mm:ss"); date.Text = DateTime.Now.ToString("yyyy-MM-dd"); if (DateTime.Now.DayOfWeek == DayOfWeek.Monday) dateRL.Text = "星期一"; else if (DateTime.Now.DayOfWeek == DayOfWeek.Tuesday) dateRL.Text = "星期二"; else if (DateTime.Now.DayOfWeek == DayOfWeek.Wednesday) dateRL.Text = "星期三"; else if (DateTime.Now.DayOfWeek == DayOfWeek.Thursday) dateRL.Text = "星期四"; else if (DateTime.Now.DayOfWeek == DayOfWeek.Friday) dateRL.Text = "星期五"; else if (DateTime.Now.DayOfWeek == DayOfWeek.Saturday) dateRL.Text = "星期六"; else if (DateTime.Now.DayOfWeek == DayOfWeek.Sunday) dateRL.Text = "星期天"; })); Thread.Sleep(500); } })); } } }