예제 #1
0
        /// <inheritdoc />
        public Task ExecuteUserActionAsync()
        {
            if (UndoStack.Count > 0)
            {
                List <PaintBase> newState = UndoStack.Pop();
                RedoStack.Push(ShapeList.DeepCopy());

                ShapeList.Clear();
                ShapeList.AddRange(newState);

                _page.Draw();
                _page.UpdateList();
            }

            return(Task.CompletedTask);
        }
예제 #2
0
        /// <inheritdoc />
        public Task ExecuteUserActionAsync()
        {
            // Get all selected elements that are of the type PaintGroup
            List <PaintBase> selected = ShapeList.Where(pb => pb.Selected &&
                                                        !(pb is PaintShape) &&
                                                        (pb is PaintGroup || (pb as TextDecoration).InnerPaintBase is PaintGroup)).ToList();

            // Only run if 1 or more groups are selected
            if (selected.Count > 0)
            {
                // Add undo entry to the undo stack
                UndoStack.Push(ShapeList.DeepCopy());
                RedoStack.Clear();

                foreach (PaintBase paintBase in selected)
                {
                    PaintBase element = paintBase;
                    // Check if element is wrapped in a decorator
                    if (element is TextDecoration decor)
                    {
                        // If so, get inner group
                        element = decor.GetDrawable();
                    }

                    if (element is PaintGroup group)
                    {
                        // Remove group from canvas
                        ShapeList.Remove(paintBase);

                        // Add the groups children back onto the canvas
                        foreach (PaintBase groupChild in group.Children.ToList())
                        {
                            group.Remove(groupChild);
                            ShapeList.Add(groupChild);
                        }
                    }
                }

                _page.Draw();
                _page.UpdateList();
            }

            return(Task.CompletedTask);
        }
예제 #3
0
        /// <inheritdoc />
        public Task ExecuteUserActionAsync()
        {
            // Add undo entry
            UndoStack.Push(ShapeList.DeepCopy());
            RedoStack.Clear();

            // Get selected items
            List <PaintBase> selected = ShapeList.Where(pb => pb.Selected).ToList();

            foreach (PaintBase paintBase in selected)
            {
                ShapeList.Remove(paintBase);
            }

            _page.Draw();
            _page.UpdateList();

            return(Task.CompletedTask);
        }
예제 #4
0
        /// <inheritdoc />
        public Task ExecuteUserActionAsync()
        {
            if (RedoStack.Count > 0)
            {
                // Pop prior state from stack
                List <PaintBase> newState = RedoStack.Pop();
                // Push current state onto the undo stack
                UndoStack.Push(ShapeList.DeepCopy());

                // Add prior state as current state
                ShapeList.Clear();
                ShapeList.AddRange(newState);

                _page.Draw();
                _page.UpdateList();
            }

            return(Task.CompletedTask);
        }
예제 #5
0
        public Task ExecuteUserActionAsync()
        {
            // Get selected items from ShapeList
            List <PaintBase> selected = ShapeList.Where(pb => pb.Selected).ToList();

            // Only group if 2 or more items are selected
            if (selected.Count > 1)
            {
                // Add undo entry
                UndoStack.Push(ShapeList.DeepCopy());
                RedoStack.Clear();

                // Create new group
                PaintGroup newGroup = new PaintGroup()
                {
                    Selected = true
                };

                // Add selected items to the group
                // Remove selected items from the canvas itself
                foreach (PaintBase paintBase in selected)
                {
                    ShapeList.Remove(paintBase);
                    paintBase.Selected = false;

                    newGroup.Add(paintBase);
                }

                ShapeList.Add(newGroup);

                _page.Draw();
                _page.UpdateList();
            }

            return(Task.CompletedTask);
        }