Пример #1
0
 private void undo()
 {
     if (CanUndo)
     {
         MessageBoxResult response = MessageBox.Show("Undo will revert modified file(s) back to their original state. Any changes made to the file(s) after the replace will be overwritten. Are you sure you want to procede?",
             "Undo", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning, MessageBoxResult.Cancel);
         if (response == MessageBoxResult.Yes)
         {
             GrepCore core = new GrepCore();
             bool result = core.Undo(UndoFolder);
             if (result)
             {
                 MessageBox.Show("Files have been successfully reverted.", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
                 Utils.DeleteTempFolder();
             }
             else
             {
                 MessageBox.Show("There was an error reverting files. Please examine the error log.", "Failure", MessageBoxButton.OK, MessageBoxImage.Error);
             }
             CanUndo = false;
         }
     }
 }
Пример #2
0
		private void undoToolStripMenuItem_Click(object sender, EventArgs e)
		{
			if (CanUndo)
			{
				DialogResult response = MessageBox.Show("Undo will revert modified file(s) back to their original state. Any changes made to the file(s) after the replace will be overwritten. Are you sure you want to procede?", "Undo", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button3);
				if (response == DialogResult.Yes)
				{
					GrepCore core = new GrepCore();
					core.ShowLinesInContext = Properties.Settings.Default.ShowLinesInContext;
					core.LinesBefore = Properties.Settings.Default.ContextLinesBefore;
					core.LinesAfter = Properties.Settings.Default.ContextLinesAfter;
					core.PreviewFilesDuringSearch = Properties.Settings.Default.PreviewResults;

					bool result = core.Undo(undoFolder);
					if (result)
					{
						MessageBox.Show("Files have been successfully reverted.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
						Utils.DeleteTempFolder();
					}
					else
					{
						MessageBox.Show("There was an error reverting files. Please examine the error log.", "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
					}
					CanUndo = false;
				}
			}
		}