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.
78 lines
2.3 KiB
78 lines
2.3 KiB
using System;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
using System.Windows.Threading;
|
|
|
|
namespace leak_test_project
|
|
{
|
|
public partial class MainWindow : Window
|
|
{
|
|
private DispatcherTimer _timer;
|
|
|
|
public MainWindow()
|
|
{
|
|
InitializeComponent();
|
|
StartClock();
|
|
this.Closing += MainWindow_Closing;
|
|
}
|
|
|
|
private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
|
{
|
|
var result = MessageBox.Show("프로그램을 종료하시겠습니까?", "종료 확인", MessageBoxButton.YesNo, MessageBoxImage.Question);
|
|
if (result == MessageBoxResult.No)
|
|
{
|
|
e.Cancel = true;
|
|
return;
|
|
}
|
|
_timer?.Stop();
|
|
}
|
|
|
|
private void StartClock()
|
|
{
|
|
_timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };
|
|
_timer.Tick += (s, e) => UpdateDateTime();
|
|
_timer.Start();
|
|
UpdateDateTime();
|
|
}
|
|
|
|
private void UpdateDateTime()
|
|
{
|
|
string dayOfWeek = DateTime.Now.ToString("ddd");
|
|
txtCurrentDateTime.Text = DateTime.Now.ToString($"yyyy-MM-dd [{dayOfWeek}] HH:mm:ss");
|
|
}
|
|
|
|
private void BtnMinimize_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
this.WindowState = WindowState.Minimized;
|
|
}
|
|
|
|
private void BtnMaximize_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
if (this.WindowState == WindowState.Maximized)
|
|
{
|
|
this.WindowState = WindowState.Normal;
|
|
txtMaximizeIcon.Text = "1"; // Maximize icon
|
|
btnMaximize.ToolTip = "최대화";
|
|
}
|
|
else
|
|
{
|
|
this.WindowState = WindowState.Maximized;
|
|
txtMaximizeIcon.Text = "2"; // Restore icon
|
|
btnMaximize.ToolTip = "창 모드";
|
|
}
|
|
}
|
|
|
|
private void TopBar_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
if (e.ClickCount == 2)
|
|
{
|
|
BtnMaximize_Click(sender, e);
|
|
}
|
|
else
|
|
{
|
|
this.DragMove();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|