Esempio n. 1
0
        /// <summary>
        /// 重作到目前狀態
        ///
        /// </summary>
        public void reDo()
        {
            if (RedoStack.Count > 0)
            {
                gPath     tempPath = new gPath();
                saveState tempPA;

                tempPA = (saveState)RedoStack.Pop();

                if (tempPA.currSate >= 0 && tempPA.currSate < FullList.Count)
                {
                    tempPath.copyVal(FullList[tempPA.currSate]);


                    if (tempPA.Action == 0)
                    {
                        sroot.PathList[tempPA.GraphIndex].IsDelete = false;
                    }

                    sroot.PathList[tempPA.GraphIndex] = tempPath;
                    sroot.PathList[tempPA.GraphIndex].redraw(1);
                }
                else
                {
                    // sroot.PathList.RemoveAt(tempPA.GraphIndex);
                }
                UndoStack.Push(tempPA);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 維護 undo stack ,把目前狀態存起來.並清空redo stack,如果之前有undo 動作,是回覆到某一狀態,在此之後的動作都可清除
        /// </summary>
        /// <param name="Data"></param>
        /// <param name="Action"></param>
        public void writeIn(gPath Data, int Action)
        {
            saveState pa;

            int lens = RedoStack.Count;

            RedoStack.Clear();
            FullList.RemoveRange(FullList.Count - lens, lens);



            if (Action == 0)//新增動作
            {
                gPath g = new gPath();
                //等一下會加入到list 中,所以count 正好為其在list  所在的位置
                pa = new saveState(Action, sroot.PathList.Count, (FullList.Count));

                UndoStack.Push(pa);
                g.copyVal(Data);
                FullList.Add(Data);
                sroot.PathList.Add(g);
            }
            else  //修改動作(物件已存在)
            {
                pa = new saveState(Action, Data.ListPlace, FullList.Count);
                FullList.Add(Data);
                UndoStack.Push(pa);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// undo 回到前一狀態
        /// </summary>
        public void unDo()
        {
            //檢查是否有可undo 的事件
            if (UndoStack.Count > 0)
            {
                gPath     tempPath = new gPath();
                saveState tempPA;
                shapeLib.Data.mClick = 0;

                tempPA = (saveState)UndoStack.Pop();

                if (tempPA.currSate >= 0 && tempPA.currSate < FullList.Count)
                {
                    if (tempPA.Action == 0)
                    {
                        sroot.PathList[tempPA.GraphIndex].IsDelete = true;
                    }
                    else
                    {
                        //找出前一個state
                        int i;
                        for (i = tempPA.currSate - 1; i >= 0; i--)
                        {
                            if (FullList[i].ListPlace == tempPA.GraphIndex)
                            {
                                tempPath.copyVal(FullList[i]);
                                sroot.PathList[tempPA.GraphIndex] = tempPath;
                                sroot.PathList[tempPA.GraphIndex].redraw(1);
                                break;
                            }
                        }
                        if (i < 0) //something wrong
                        {
                            Debug.WriteLine("something wrong");
                        }
                    }
                }
                else
                {
                    //something wrong
                    Debug.WriteLine("something wrong");

                    //sroot.PathList.RemoveAt(tempPA.GraphIndex);
                }
                //將該事件放入redo stack
                RedoStack.Push(tempPA);
            }
        }