Ejemplo n.º 1
0
        /// <summary>
        /// 检查撤销按钮状态
        /// </summary>
        /// <param name="lockkey"></param>
        /// <returns></returns>
        public static UndoEnableEnt ChkUndoEnable(string lockkey)
        {
            var ret = new UndoEnableEnt();

            ret.revoke = true;
            ret.back   = true;
            for (var i = 0; i < _PrjList.Count; i++)
            {
                if (_PrjList[i].id == _currentHistoryId)
                {
                    if ((i - 1) >= 0)
                    {
                        ret.revoke = false;
                    }
                    if ((i + 1) < _PrjList.Count)
                    {
                        ret.back = false;
                    }
                    if (_PrjList[i].lockkey != null && _PrjList[i].lockkey == lockkey)
                    {
                        ret.revoke = true;
                    }
                    break;
                }
            }
            return(ret);
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 后后撤销
        /// </summary>
        /// <returns></returns>
        public static UndoEnableEnt BackTrace()
        {
            var ret = new UndoEnableEnt();

            for (var i = 0; i < _PrjList.Count; i++)
            {
                if (_PrjList[i].id == _currentHistoryId)
                {
                    var ent = _PrjList[i + 1];
                    if ((i + 1) == (_PrjList.Count - 1))
                    {
                        ret.back = true;
                    }
                    _currentHistoryId = ent.id;
                    if (ent.type == "prj")
                    {
                        for (var m = i + 1; m >= 0; m--)
                        {
                            if (_PrjList[m].type != "prj")
                            {
                                _PrjList[m].doWork();
                                break;
                            }
                        }
                        //frmMan.thisProject = (Project)ent.data;
                        //frmMan.DoSavePipingStructure();
                        //ent.data = frmMan.thisProject.DeepClone();
                        Project.CurrentProject = (Project)ent.data;
                        //frmMan.DoSavePipingStructure();
                        ent.data = Project.GetProjectInstance.DeepClone();
                    }
                    else
                    {
                        for (var m = i + 1; m >= 0; m--)
                        {
                            if (_PrjList[m].type == "prj")
                            {
                                //frmMan.thisProject = (Project)_PrjList[m].data;
                                //frmMan.DoSavePipingStructure();
                                //_PrjList[m].data = frmMan.thisProject.DeepClone();

                                Project.CurrentProject = (Project)_PrjList[m].data;
                                _PrjList[m].data       = Project.GetProjectInstance.DeepClone();
                                break;
                            }
                        }
                        ent.doWork();
                    }
                    break;
                }
            }
            return(ret);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 向前撤销
        /// </summary>
        /// <param name="lockkey"></param>
        /// <returns></returns>
        public static UndoEnableEnt RevokeTrace(string lockkey)
        {
            var ret = new UndoEnableEnt();

            for (var i = 0; i < _PrjList.Count; i++)
            {
                if (_PrjList[i].id == _currentHistoryId)
                {
                    var ent = _PrjList[i - 1];
                    if (ent.lockkey != null && ent.lockkey == lockkey)
                    {
                        ret.revoke = true;
                    }
                    if ((i - 1) == 0)
                    {
                        ret.revoke = true;
                    }
                    _currentHistoryId = ent.id;
                    if (ent.type == "prj")
                    {
                        for (var m = i - 1; m >= 0; m--)
                        {
                            if (_PrjList[m].type != "prj")
                            {
                                _PrjList[m].doWork();
                                break;
                            }
                        }
                        Project.CurrentProject = (Project)ent.data;
                        //frmMan.DoSavePipingStructure();
                        ent.data = Project.GetProjectInstance.DeepClone();
                    }
                    else
                    {
                        for (var m = i - 1; m >= 0; m--)
                        {
                            if (_PrjList[m].type == "prj")
                            {
                                //frmMan.thisProject = (Project)_PrjList[m].data;
                                Project.CurrentProject = (Project)_PrjList[m].data;
                                //frmMan.DoSavePipingStructure();
                                //_PrjList[m].data = frmMan.thisProject.DeepClone();
                                _PrjList[m].data = Project.GetProjectInstance.DeepClone();
                                break;
                            }
                        }
                        ent.doWork();
                    }
                    break;
                }
            }
            return(ret);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 构造函数
 /// </summary>
 public RegUndoEnt()
 {
     enable = new UndoEnableEnt();
 }