/// <summary> /// Get (or create) an UndoRoot for the specified object or document instance. /// </summary> /// <param name="root">The object that represents the root of the document or object hierarchy.</param> /// <returns>An UndoRoot instance for this object.</returns> public UndoRoot this[object root] { get { if (null == root) { return(null); } UndoRoot ret = null; WeakReference wRef = new WeakReference(root); if (_Roots.ContainsKey(wRef)) { ret = _Roots[wRef]; } if (null == ret) { ret = new UndoRoot(root); _Roots.Add(wRef, ret); } return(ret); } }
/// <summary> /// Get (or create) an UndoRoot for the specified object or document instance. /// </summary> /// <param name="root">The object that represents the root of the document or object hierarchy.</param> /// <returns>An UndoRoot instance for this object.</returns> public UndoRoot this[object root] { get { if (null == root) { return(null); } UndoRoot ret = null; if (_Roots.ContainsKey(root)) { ret = _Roots[root]; } if (null == ret) { ret = new UndoRoot(root); _Roots.Add(root, ret); } return(ret); } }
/// <summary> /// Starts an undo batch, which is ended when this instance is disposed. Designed for use in a using statement. /// </summary> /// <param name="root">The UndoRoot related to this instance.</param> /// <param name="description">The description of this batch of changes.</param> /// <param name="consolidateChangesForSameInstance">Should the batch consolidate changes.</param> public UndoBatch(UndoRoot root, string description, bool consolidateChangesForSameInstance) { if (null == root) { return; } _UndoRoot = root; root.BeginChangeSetBatch(description, consolidateChangesForSameInstance); }
/// <summary> /// Create a ChangeSet for the specified UndoRoot. /// </summary> /// <param name="undoRoot">The UndoRoot that this ChangeSet belongs to.</param> /// <param name="description">A description of the change.</param> /// <param name="change">The Change instance that can perform the undo / redo as needed.</param> public ChangeSet(UndoRoot undoRoot, string description, Change change) { _UndoRoot = undoRoot; _Changes = new List <Change>(); _Description = description; if (null != change) { AddChange(change); } }