/// <summary> /// save surrent state for undo /// </summary> /// <param name="state"></param> public void SaveCurrentState(T state) { if (undoStatck == null) { undoStatck = new List <T>(); } if (undoPointer < 0 || undoStatck.Count == 0) { undoPointer = -1; undoStatck.Insert(0, (T)state.Clone()); newState = false; } else { if (newState) { newState = false; undoStatck.Insert(undoPointer, (T)state.Clone()); } else { newState = true; } } _owner.FireStateChange(); }