Пример #1
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);
        }
Пример #2
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);
        }
Пример #3
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);
        }