예제 #1
0
        public Momento undo(Momento currentScreen)
        {
            Momento tempMomento = actionList.Last();

            //undoneList.Add(tempMomento);
            if (firstUndo == 0)
            {
                undoneList.Clear();
                undoneList.Add(new Momento(currentScreen.getCanvasGraphicList()));
                firstUndo = 1;
                return(new Momento(tempMomento.getCanvasGraphicList()));
            }
            else
            {
                actionList.Remove(tempMomento);
                undoneList.Add(new Momento(tempMomento.getCanvasGraphicList()));
                if (actionList.Any())
                {
                    return(new Momento(actionList.Last().getCanvasGraphicList()));
                }
                else
                {
                    return(new Momento(tempMomento.getCanvasGraphicList()));
                }
            }
        }
예제 #2
0
        public Momento redo()
        {
            Momento tempMomento = undoneList.Last();

            actionList.Add(new Momento(tempMomento.getCanvasGraphicList()));
            undoneList.Remove(tempMomento);
            return(new Momento(tempMomento.getCanvasGraphicList()));
        }