/// <summary> /// 注销撤销实体方法 /// </summary> /// <param name="regEnt"></param> public void Unregister(UndoRedoHandler handler) { if (!Handlers.Contains(handler)) { Handlers.Remove(handler); } }
/// <summary> /// 状态改变 /// </summary> public void RefreshStatus(UndoRedoHandler handler) { bool isReachedBegin = true; bool isReachedEnd = true; for (var i = 0; i < historyList.Count; i++) { if (historyList[i].id == _currentHistoryId) { if ((i - 1) >= 0) { isReachedBegin = false; } if ((i + 1) < historyList.Count) { isReachedEnd = false; } if (historyList[i].lockkey != null && historyList[i].lockkey == handler.LockKey) { isReachedBegin = true; } break; } } handler.ReachedBegin = isReachedBegin; handler.ReachedEnd = isReachedEnd; handler.RefreshButtonStatusEventHandler?.Invoke(); }
/// <summary> /// 注册撤销实体方法 /// </summary> /// <param name="regEnt"></param> public void Register(UndoRedoHandler handler) { //注册当前锁定标识位 for (var i = 0; i < historyList.Count; i++) { var ent = historyList[i]; if (ent.id == _currentHistoryId) { ent.lockkey = handler.LockKey; break; } } if (!Handlers.Contains(handler)) { Handlers.Add(handler); } }
static UndoRedoHandler() { MainInstance = new UndoRedoHandler(); }