Exemplo n.º 1
0
 private void EditWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (shutdown)
     {
     }
     else
     {
         e.Cancel = true;
         if (tbxEdit.Text != content)
         {
             MessageBoxResult result = MessageBox.Show("Are you sure you want to Close this window?\nAll your changes will be undone.", "Warning!", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
             if (result == MessageBoxResult.Yes)
             {
                 tbxEdit.Text     = "";
                 EditWindow.Title = "";
                 EditWindow.Hide();
             }
         }
         else
         {
             tbxEdit.Text     = "";
             EditWindow.Title = "";
             EditWindow.Hide();
         }
     }
 }
Exemplo n.º 2
0
 private void btnCancel_Click(object sender, RoutedEventArgs e)
 {
     if (tbxEdit.Text != content)
     {
         MessageBoxResult result = MessageBox.Show("Are you sure you want to Close this window?\nAll your changes will be undone.", "Warning!", MessageBoxButton.YesNo, MessageBoxImage.Exclamation);
         if (result == MessageBoxResult.Yes)
         {
             tbxEdit.Text     = "";
             EditWindow.Title = "";
             EditWindow.Hide();
         }
     }
     else
     {
         tbxEdit.Text     = "";
         EditWindow.Title = "";
         EditWindow.Hide();
     }
 }
Exemplo n.º 3
0
 private void btnSave_Click(object sender, RoutedEventArgs e)
 {
     if (tbxEdit.Text != content)
     {
         MessageBoxResult result = MessageBox.Show("Are you sure you want to Save?\nThis will overwrite the current file and may cause problems or break the program.\nThis action can not be undone.", "Warning!", MessageBoxButton.YesNo, MessageBoxImage.Warning);
         if (result == MessageBoxResult.Yes)
         {
             System.IO.File.WriteAllText(filePath, tbxEdit.Text);
             tbxEdit.Text     = "";
             EditWindow.Title = "";
             EditWindow.Hide();
         }
     }
     else
     {
         tbxEdit.Text     = "";
         EditWindow.Title = "";
         EditWindow.Hide();
     }
 }