Esempio n. 1
0
 public T LoadFromUndoStack()
 {
     if (IsUndoStackEmpty)
     {
         return(null);
     }
     using (MemoryStream memStream = new MemoryStream(undoStack.Pop()))
     {
         var ret = bf.Deserialize(memStream) as T ?? throw new InvalidCastException();
         UpdateUndo?.Invoke(this, EventArgs.Empty);
         return(ret);
     }
 }
Esempio n. 2
0
        public T LoadFromUndoStack()
        {
            if (IsUndoStackEmpty)
            {
                return(null);
            }
            using (MemoryStream memStream = new MemoryStream(undoStack.Pop())) {
#pragma warning disable SYSLIB0011 // 类型或成员已过时
                var ret = bf.Deserialize(memStream) as T ?? throw new InvalidCastException();
#pragma warning restore SYSLIB0011 // 类型或成员已过时
                UpdateUndo?.Invoke(this, EventArgs.Empty);
                return(ret);
            }
        }
Esempio n. 3
0
        public void SaveToUndoStack(T fileInfoCollection, bool clearRedoStack = true, [CallerMemberName] string caller = "", [CallerLineNumber] int line = 0)
        {
            using (MemoryStream memStream = new MemoryStream())
            {
                bf.Serialize(memStream, fileInfoCollection ?? throw new ArgumentNullException());
                undoStack.Push(memStream.ToArray());
            }

            if (clearRedoStack)
            {
                ClearRedoStack();
            }

            UpdateUndo?.Invoke(this, EventArgs.Empty);
        }