예제 #1
0
        public void OnEdit()
        {
            if (!picture.shapes.Any(shape => shape is CompoundShape))
            {
                ToUndoStack.Push(new List <IShape>(picture.shapes.Select(shape => shape.Clone()).ToList()));
            }
            else
            {
                var cloneList = new List <IShape>();
                foreach (var shape in picture.shapes)
                {
                    if (shape is CompoundShape compoundShape)
                    {
                        cloneList.Add(GetAllCompoundShapeClones(compoundShape));
                    }
                    else
                    {
                        cloneList.Add(shape.Clone());
                    }
                }

                ToUndoStack.Push(cloneList);
            }

            ToRedoStack = new Stack <List <IShape> >();
        }
예제 #2
0
        public List <IShape> OnRedo()
        {
            if (ToRedoStack.Count != 0 && ToRedoStack.Any())
            {
                var copy = ToRedoStack.Peek().Select(shape =>
                                                     shape is CompoundShape compoundShape ? GetAllCompoundShapeClones(compoundShape) : shape.Clone()
                                                     ).ToList();

                ToUndoStack.Push(ToRedoStack.Pop());

                return(copy);
            }

            return(null);
        }