private UndoRedoSetup() { UtilTrace.Ini(); UndoEnable = new UndoEnableEnt(); //UndoEnable.redoRect = new System.Drawing.Rectangle(912, 95, 16, 18); //UndoEnable.undoRect = new System.Drawing.Rectangle(884, 95, 16, 18); //this.tabControl1.OnDrawControl += new PaintEventHandler(UndoEnable.ShowIcons); RegEnt = new RegUndoEnt(); RegEnt.funHandler += delegate() { //BindToControl(); }; RegEnt.enable = UndoEnable; //newUtilTrace.UtilTrace.ViewModel = this; //UtilTrace.tbMain = tabControl1; //regEnt.vm = this; //regEnt.tb = tabControl1; //UtilTrace.SaveHistoryTraces(); //UtilTrace.SaveHistoryTraces("tab", this.tabControl1.SelectedTab, null); UtilTrace.RegUndo(RegEnt); UtilTrace.ChkMainUndo += delegate() { //BindToControl(); RegEnt.ChkUndoEnable(); //this.Invalidate(); }; IsInitialized = false; }
/// <summary> /// 保存历史痕迹 /// </summary> /// <param name="type">类型</param> /// <param name="data">数据</param> /// <param name="ent">注册实体</param> public static void SaveHistoryTraces(string type, object data, RegUndoEnt ent) { var index = 0; for (var i = 0; i < _PrjList.Count; i++) { if (_PrjList[i].id == _currentHistoryId) { index = i; break; } } index = index + 1; if (index < _PrjList.Count) { _PrjList.RemoveRange(index, _PrjList.Count - index); } var _his_data = new TraceEnt(); _his_data.id = Guid.NewGuid().ToString(); if (!string.IsNullOrEmpty(type) && data != null) { _his_data.type = type; _his_data.data = data; if (type == "tab") { //定义实现选项卡切换撤销方法 _his_data.eventHandler += delegate() { isTabSwitching = true; //tbMain.SelectedTab = (TabPage)_his_data.data; isTabSwitching = false; }; } } else { _his_data.type = "prj"; //ViewModel.DoSavePipingStructure(); _his_data.data = Project.GetProjectInstance.DeepClone(); } _PrjList.Add(_his_data); _currentHistoryId = _his_data.id; if (ChkMainUndo != null) { ChkMainUndo(); } if (ent != null) { ent.ChkUndoEnable(); } EnableUndo?.Invoke(); EnableRedo?.Invoke(); }