You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.5 KiB

2 years ago
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
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
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();
}
}
}