Example #1
0
        private void PackThis()
        {
            _undoUnits.Reset();
            Interop.IOleUndoUnit[] startunits   = new Interop.IOleUndoUnit[(uint)_startIndex];
            Interop.IOleUndoUnit[] currentunits = new Interop.IOleUndoUnit[(uint)_numUndos];
            //IntPtr j1 = IntPtr.Zero;
            Interop.IOleUndoUnit unit = null;
            int su = 0;

            for (int k = 0; k < _startIndex; k++)
            {
                _undoUnits.Next(1, out unit, out su);
                startunits[k] = unit;
            }
            for (int i = 0; i < _numUndos; i++)
            {
                _undoUnits.Next(1, out unit, out su);
                currentunits[i] = unit;
            }
            ((Interop.IOleUndoManager)_undoManager).DiscardFrom(null);
            for (int j = 0; j < _startIndex; j++)
            {
                if (startunits[j] == null)
                {
                    continue;
                }
                ((Interop.IOleUndoManager)_undoManager).Add(startunits[j]);
            }
            if (unit != null)
            {
                UndoUnit uu = new UndoUnit(unit, ((Interop.IOleUndoManager)_undoManager));
                ((Interop.IOleUndoManager)_undoManager).Add(uu);
            }
        }
Example #2
0
        /// <summary>
        /// Returns the collection of Undo/Redo objects available.
        /// </summary>
        /// <remarks>
        /// The current type of unit object decided whether this method returns the Undo or Redo history.
        /// The collections consists of <see cref="UndoObject"/> objects, which implement <see cref="IUndoObject"/>.
        /// These objects may have information about subobjects, which the undo manager creates if the user
        /// requests packed undo sequences.
        /// </remarks>
        /// <seealso cref="NumChildUndos"/>
        /// <seealso cref="HasChildUndos"/>
        /// <seealso cref="UndoObject"/>
        /// <seealso cref="Type"/>
        /// <returns>Returns a collection of objects of type <see cref="IUndoObject"/>.</returns>
        public System.Collections.Generic.List <IUndoObject> GetUndoHistory()
        {
            int i = 0;

            //IntPtr k = IntPtr.Zero;
            Interop.IOleUndoUnit      unit;
            Interop.IEnumOleUndoUnits undoUnits = null;
            if (_type == BatchedUndoType.Undo)
            {
                undoUnits = ((HtmlEditor)_editor).UndoManager.EnumUndoable();
            }
            else
            {
                undoUnits = ((HtmlEditor)_editor).UndoManager.EnumRedoable();
            }
            System.Collections.Generic.List <IUndoObject> undos = new System.Collections.Generic.List <IUndoObject>();
            if (undoUnits != null)
            {
                undoUnits.Reset();
                try
                {
                    while (i == 0)
                    {
                        undoUnits.Next(1, out unit, out i);
                        if (undoUnits == null || i == 0)
                        {
                            break;
                        }                        //Interop.IOleUndoUnit unit = (Interop.IOleUndoUnit) Marshal.GetObjectForIUnknown(k);
                        string s;
                        unit.GetDescription(out s);
                        UndoUnit managedUndo = null;
                        if (unit is UndoUnit)
                        {
                            managedUndo = (UndoUnit)unit;
                        }
                        else
                        {
                            managedUndo = new UndoUnit(unit, ((HtmlEditor)_editor).UndoManager);
                        }
                        UndoObject wrappedObject = new UndoObject(s, managedUndo, ((HtmlEditor)_editor).UndoManager);
                        undos.Add(wrappedObject);
                        i = 0;
                    }
                }
                catch
                {
                }
            }
            return(undos);
        }
Example #3
0
 internal UndoObject(string description, UndoUnit unit, Interop.IOleUndoManager undoManager)
 {
     this.description = description;
     this.unit        = unit;
     this.undoManager = undoManager;
 }