private void applyChangesToolStripMenuItem_Click(object sender, EventArgs e) { if ((redoQueue.Count > 0) && (redoQueue.Peek().Name == Language.ApplyChanges)) { // ... Redo(); } List<Command> result = new List<Command>(); foreach (Command command in undoQueue) { if (command.Type == SMOz.Commands.CommandType.Group) { CommandGroup group = command as CommandGroup; if (group.Name == Language.ApplyChanges) { // Stop when the last Apply Changes is found break; } } ConvertCommands(result, command); } if (result.Count <= 0) { MessageBox.Show(Language.NothingToDoMessage, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } result.Reverse(); using (ReviewChanges review = new ReviewChanges(false)) { foreach (Command cmd in result) { MoveFileCommand cmdMove = cmd as MoveFileCommand; if (cmd.Type == SMOz.Commands.CommandType.IODelete) { review.Add(Command.TypeToString(cmdMove.Type), cmdMove.Source.Replace("Documents and Settings", "...") .Replace("Start Menu\\Programs", "..."), "Trash", cmdMove.MayFail); } else { review.Add(Command.TypeToString(cmdMove.Type), cmdMove.Source.Replace("Documents and Settings", "...") .Replace("Start Menu\\Programs", "..."), "to " + cmdMove.Target.Replace("Documents and Settings", "...") .Replace("Start Menu\\Programs", "..."), cmdMove.MayFail); } } if (review.ShowDialog(this) == DialogResult.OK) { // localWatcher.EnableRaisingEvents = false; // userWatcher.EnableRaisingEvents = false; if (ApplyRealChanges(result)) { CommandGroup group = new CommandGroup(Language.ApplyChanges, result); AddUndoCommand(group); _statusLabel.Text = "Changes successfully applied"; } // localWatcher.EnableRaisingEvents = true; // userWatcher.EnableRaisingEvents = true; } } }
void ApplyTemplate(MoveStartItemCommand[] commands, string name) { if ((commands == null) || (commands.Length <= 0)) { MessageBox.Show(Language.NothingToDoMessage, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information); return; } using (ReviewChanges review = new ReviewChanges(true)) { foreach (MoveStartItemCommand cmd in commands) { foreach (string str in AddCategoryToTree(cmd.NewCategory)) { // Ensure that the target category is visible to user AddToManager(str); } review.Add("Move", "'" + cmd.OldName + "' to '" + cmd.NewName + "'"); } if (review.ShowDialog(this) == DialogResult.OK) { CommandGroup group = new CommandGroup(Language.ApplyTemplate, commands); AddUndoCommand(group, true); UpdateItemList(); } } }