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 ClockGadget { /// /// Interaction logic for MainWindow.xaml /// public partial class MainWindow : Window { private DispatcherTimer _timer; public MainWindow() { InitializeComponent(); } private void SetDateTime() { tbDate.Text = DateTime.Now.ToString("yyyy-MM-dd"); tbTime.Text = DateTime.Now.ToString("tt hh:mm:ss"); } private void btnClose_Click(object sender, RoutedEventArgs e) { this.Close(); } private void Window_Loaded(object sender, RoutedEventArgs e) { SetDateTime(); _timer = new DispatcherTimer(); _timer.Interval = TimeSpan.FromSeconds(1); _timer.Tick += On_timer_Tick; _timer.Start(); } private void On_timer_Tick(object? sender, EventArgs e) { SetDateTime(); } private void Ellipse_MouseDown(object sender, MouseButtonEventArgs e) { this.DragMove(); } } }