InkCanvasForClass/Ink Canvas/NamesInputWindow.xaml.cs
2023-02-12 22:50:17 +08:00

45 lines
1.3 KiB
C#

using System.IO;
using System.Windows;
namespace Ink_Canvas
{
/// <summary>
/// Interaction logic for NamesInputWindow.xaml
/// </summary>
public partial class NamesInputWindow : Window
{
public NamesInputWindow()
{
InitializeComponent();
}
string originText = "";
private void Window_Loaded(object sender, RoutedEventArgs e)
{
if (File.Exists(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "Names.txt"))
{
TextBoxNames.Text = File.ReadAllText(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "Names.txt");
originText = TextBoxNames.Text;
}
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
if (originText != TextBoxNames.Text)
{
var result = MessageBox.Show("是否保存?", "名单导入", MessageBoxButton.YesNo);
if (result == MessageBoxResult.Yes)
{
File.WriteAllText(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "Names.txt", TextBoxNames.Text);
}
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Close();
}
}
}