using System.IO; using System.Windows; namespace Ink_Canvas { /// /// Interaction logic for NamesInputWindow.xaml /// public partial class NamesInputWindow : Window { public NamesInputWindow() { InitializeComponent(); } string originText = ""; private void Window_Loaded(object sender, RoutedEventArgs e) { if (File.Exists(App.RootPath + "Names.txt")) { TextBoxNames.Text = File.ReadAllText(App.RootPath + "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(App.RootPath + "Names.txt", TextBoxNames.Text); } } } private void Button_Click(object sender, RoutedEventArgs e) { Close(); } } }