public void AddUndoUnitImpl(object owningObject, string name, object value) { UndoUnitImpl undoUnitImpl = new UndoUnitImpl(); undoUnitImpl.OwningObject = owningObject; undoUnitImpl.Name = name; undoUnitImpl.Value = value; bool repeat = false; if (undoStockImpl.Count > 0) { UndoUnitImpl checkUnit = undoStockImpl[undoStockImpl.Count - 1]; if (checkUnit.Name == undoUnitImpl.Name && checkUnit.OwningObject == undoUnitImpl.OwningObject && checkUnit.Value == undoUnitImpl.Value) { repeat = true; } } if (repeat == false) { undoStockImpl.Add(undoUnitImpl); } redoStockImpl.Clear(); }
private void UndoUnits(object owningObject) { UndoEngineImpl undoEngineImpl = designerhost.GetService(typeof(UndoEngine)) as UndoEngineImpl; if (undoEngineImpl.UndoInProgress == true && undoEngineImpl.UndoUnitName != null && undoEngineImpl.UndoUnitName.IndexOf("删除") == -1 && undoEngineImpl.UndoUnitName.IndexOf("创建") == -1 && undoEngineImpl.UndoUnitName.ToLower().IndexOf("remove") == -1 && undoEngineImpl.UndoUnitName.ToLower().IndexOf("create") == -1) { for (int i = undoStockImpl.Count - 1; i >= 0; i--) { UndoUnitImpl undoUnitImpl = undoStockImpl[i]; undoUnitImpl.Undo(); undoStockImpl.Remove(undoUnitImpl); redoStockImpl.Add(undoUnitImpl); if (owningObject == undoUnitImpl.OwningObject) { break; } } ISelectionService selection = designerhost.GetService(typeof(ISelectionService)) as ISelectionService; selection.SetSelectedComponents(selection.GetSelectedComponents()); } }