From 7ee24657e8f36774ddb78ca5a8e73cc22297bfd1 Mon Sep 17 00:00:00 2001 From: "nguyentien.work410@gmail.com" Date: Tue, 18 Mar 2025 17:25:02 +0700 Subject: [PATCH] add clock --- ClockUC.xaml | 23 +++++++++++++++++++++++ ClockUC.xaml.cs | 42 ++++++++++++++++++++++++++++++++++++++++++ MainWindow.xaml | 7 ++++++- 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 ClockUC.xaml create mode 100644 ClockUC.xaml.cs diff --git a/ClockUC.xaml b/ClockUC.xaml new file mode 100644 index 0000000..351e390 --- /dev/null +++ b/ClockUC.xaml @@ -0,0 +1,23 @@ + + + + + + + + diff --git a/ClockUC.xaml.cs b/ClockUC.xaml.cs new file mode 100644 index 0000000..51fefac --- /dev/null +++ b/ClockUC.xaml.cs @@ -0,0 +1,42 @@ +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.Threading; +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 SafeBagDE70 +{ + /// + /// Interaction logic for ClockUC.xaml + /// + public partial class ClockUC : UserControl + { + private DispatcherTimer _timer; + public ClockUC() + { + InitializeComponent(); + _timer = new DispatcherTimer() + { + Interval = TimeSpan.FromSeconds(1) + }; + _timer.Tick += Timer_Tick; + _timer.Start(); + } + + private void Timer_Tick(object sender, EventArgs e) + { + txtTime.Text = DateTime.Now.ToString("HH:mm:ss"); + txtDate.Text = DateTime.Now.ToString("dd/MM/yyyy"); + } + } +} diff --git a/MainWindow.xaml b/MainWindow.xaml index fa4856d..cc86a2c 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -10,7 +10,12 @@ ShowInTaskbar="False" ShowNonClientArea="False" IsFullScreen="True"> - + + + +