From b4b8ecfa8ecc77d0efdd8e3a61d9b2129961a817 Mon Sep 17 00:00:00 2001 From: fyf <11621@LAPTOP-04QQU0AO> Date: Fri, 22 Apr 2022 10:02:21 +0800 Subject: [PATCH] 11 --- .../UserControls/DateTimeUI.xaml | 32 +++++++++++ .../UserControls/DateTimeUI.xaml.cs | 56 +++++++++++++++++++ BPASmartClient/MainWindow.xaml | 16 +----- 3 files changed, 90 insertions(+), 14 deletions(-) create mode 100644 BPASmartClient.CustomResource/UserControls/DateTimeUI.xaml create mode 100644 BPASmartClient.CustomResource/UserControls/DateTimeUI.xaml.cs diff --git a/BPASmartClient.CustomResource/UserControls/DateTimeUI.xaml b/BPASmartClient.CustomResource/UserControls/DateTimeUI.xaml new file mode 100644 index 00000000..c09fc508 --- /dev/null +++ b/BPASmartClient.CustomResource/UserControls/DateTimeUI.xaml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + 14:48:30 + + + + 星期一 + + 2021-11-13 + + + diff --git a/BPASmartClient.CustomResource/UserControls/DateTimeUI.xaml.cs b/BPASmartClient.CustomResource/UserControls/DateTimeUI.xaml.cs new file mode 100644 index 00000000..87cae49f --- /dev/null +++ b/BPASmartClient.CustomResource/UserControls/DateTimeUI.xaml.cs @@ -0,0 +1,56 @@ +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.CustomResource.UserControls +{ + /// + /// 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); + } + })); + } + } +} diff --git a/BPASmartClient/MainWindow.xaml b/BPASmartClient/MainWindow.xaml index bb00d3c4..c8ad4ccb 100644 --- a/BPASmartClient/MainWindow.xaml +++ b/BPASmartClient/MainWindow.xaml @@ -6,6 +6,7 @@ xmlns:local="clr-namespace:BPASmartClient" xmlns:vm="clr-namespace:BPASmartClient.ViewModel;assembly=BPASmartClient.ViewModel" xmlns:pry="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" + xmlns:control="clr-namespace:BPASmartClient.CustomResource.UserControls;assembly=BPASmartClient.CustomResource" Title="MainWindow" Width="1600" Height="900" AllowsTransparency="True" @@ -92,20 +93,7 @@ - - - - - - - - - - - 星期一 - 2021-11-13 - - +