public static void FillMenu(DuplPairViewModel res, out string firstToSecond, out string secondToFirst, out IUCommand firstToSecondCommand, out IUCommand secondToFirstCommand) { string menuText; if (Path.GetDirectoryName(res.FirstFile.Path) == Path.GetDirectoryName(res.SecondFile.Path)) { menuText = "Переименовать {0} в {1}"; string firstNewName = GetSimilarName(res.SecondFile.Path, res.FirstFile.Path); firstToSecond = String.Format(menuText, Path.GetFileName(res.FirstFile.Path), Path.GetFileName(firstNewName)); firstToSecondCommand = new RenameLikeCommand(res, firstNewName, PositionInDuplPair.First); string secondNewName = GetSimilarName(res.FirstFile.Path, res.SecondFile.Path); secondToFirst = String.Format(menuText, Path.GetFileName(res.SecondFile.Path), Path.GetFileName(secondNewName)); secondToFirstCommand = new RenameLikeCommand(res, secondNewName, PositionInDuplPair.Second); } else { menuText = "Переместить в {0} и переименовать {1} в {2}"; string firstNewName = GetSimilarName(res.SecondFile.Path, res.FirstFile.Path); firstToSecond = String.Format(menuText, Path.GetDirectoryName(res.SecondFile.Path), Path.GetFileName(res.FirstFile.Path), Path.GetFileName(firstNewName)); firstToSecondCommand = new RenameLikeCommand(res, firstNewName, PositionInDuplPair.First); string secondNewName = GetSimilarName(res.FirstFile.Path, res.SecondFile.Path); secondToFirst = String.Format(menuText, Path.GetDirectoryName(res.FirstFile.Path), Path.GetFileName(res.SecondFile.Path), Path.GetFileName(secondNewName)); secondToFirstCommand = new RenameLikeCommand(res, secondNewName, PositionInDuplPair.Second); } }
public bool Redo() { if (_redoCommandStack.Count > 0) { IUCommand command = _redoCommandStack.Pop(); command.Execute(); _undoCommandStack.Push(command); // if (OnActoinAppledEvent != null) // OnActoinAppledEvent(); RaisePropertyChangedEvent("UndoEnable"); RaisePropertyChangedEvent("RedoEnable"); return(true); } return(false); }
public void ExecuteCommand(IUCommand command) { if (_undoCommandStack.Count + 1 > _configuration.UndoRedoStackSize) { IUCommand commandForDispose = _undoCommandStack.Pop(); commandForDispose.Dispose(); } _undoCommandStack.Push(command); command.Execute(); //if (OnActoinAppledEvent != null) // OnActoinAppledEvent(); RaisePropertyChangedEvent("UndoEnable"); RaisePropertyChangedEvent("UndoTooltip"); if (_redoCommandStack.Any()) { _redoCommandStack.Clear(); RaisePropertyChangedEvent("RedoEnable"); } }
public bool Undo() { //if (_UndoStack.Count > 0) //{ // ListDuplicates = _UndoStack.Pop(); // OnActoinAppledEvent(); // return true; //} //return false; if (_undoCommandStack.Count > 0) { IUCommand command = _undoCommandStack.Pop(); command.UnExecute(); //ListDuplicates = command. _redoCommandStack.Push(command); //if (OnActoinAppledEvent != null) // OnActoinAppledEvent(); RaisePropertyChangedEvent("UndoEnable"); RaisePropertyChangedEvent("RedoEnable"); return(true); } return(false); }