//-------------------------------------------------------------------------------------------------- public override void Restore(Entity instance, UndoHandler undoHandler) { var dataBlobOwner = instance as IUndoableDataBlob; Debug.Assert(dataBlobOwner != null); dataBlobOwner.SetUndoDataBlob(_StoredData); }
//-------------------------------------------------------------------------------------------------- public override void Restore(Entity instance, UndoHandler undoHandler) { _ChangeList.ForEach(change => change.RestoreValue(instance)); var shape = instance as Shapes.Shape; shape?.Invalidate(); }
//-------------------------------------------------------------------------------------------------- public override void Restore(Entity instance, UndoHandler undoHandler) { var container = undoHandler.FindEntityInstance(InstanceGuid) as IUndoableTopology; Debug.Assert(container != null, "container != null"); var child = undoHandler.FindEntityInstance(_ChildGuid); var parent = _ParentGuid.HasValue ? undoHandler.FindEntityInstance(_ParentGuid.Value) : null; switch (_TopoAction) { case UndoHandler.TopologyAction.Added: Debug.Assert(child != null); // Counter-Action: Remove. container.RemoveChildFromUndo(child); break; case UndoHandler.TopologyAction.Removed: Debug.Assert(child == null); // Counter-Action: Add. var context = new SerializationContext(SerializationScope.UndoRedo); context.SetInstance(CoreContext.Current.Document); context.SetInstance <IDocument>(CoreContext.Current.Document); context.SetInstance(CoreContext.Current.Workspace); child = Serializer.Deserialize <Entity>(_StoredData, context); if (child != null) { container.AddChildFromUndo(child, parent); foreach (var entity in context.GetInstanceList <InteractiveEntity>()) { entity.RaiseVisualChanged(); } } break; case UndoHandler.TopologyAction.Moved: Debug.Assert(child != null); // Counter-Action: Move back. undoHandler.AddTopologyChange(UndoHandler.TopologyAction.Moved, container, child); container.MoveChildFromUndo(child, parent); break; } }
public abstract void Restore(Entity instance, UndoHandler undoHandler);