コード例 #1
0
        private void mnuGroup_Click(object sender, EventArgs e)
        {
            BaseController canvasController = serviceManager.Get <IFlowSharpCanvasService>().ActiveController;

            if (canvasController.SelectedElements.Any())
            {
                List <GraphicElement> selectedShapes = canvasController.SelectedElements.ToList();
                FlowSharpLib.GroupBox groupBox       = new FlowSharpLib.GroupBox(canvasController.Canvas);

                canvasController.UndoStack.UndoRedo("Group",
                                                    () =>
                {
                    // ElementCache.Instance.Remove(groupBox);
                    canvasController.GroupShapes(groupBox);
                    canvasController.DeselectCurrentSelectedElements();
                    canvasController.SelectElement(groupBox);
                },
                                                    () =>
                {
                    // ElementCache.Instance.Add(groupBox);
                    canvasController.UngroupShapes(groupBox, false);
                    canvasController.DeselectCurrentSelectedElements();
                    canvasController.SelectElements(selectedShapes);
                });
            }
        }
コード例 #2
0
        private void mnuUngroup_Click(object sender, EventArgs e)
        {
            // At this point, we can only ungroup one group.
            if (canvasController.SelectedElements.Count == 1)
            {
                FlowSharpLib.GroupBox groupBox = canvasController.SelectedElements[0] as FlowSharpLib.GroupBox;

                if (groupBox != null)
                {
                    List <GraphicElement> groupedShapes = new List <GraphicElement>(groupBox.GroupChildren);

                    canvasController.UndoStack.UndoRedo("Ungroup",
                                                        () =>
                    {
                        ElementCache.Instance.Add(groupBox);
                        canvasController.UngroupShapes(groupBox, false);
                        canvasController.DeselectCurrentSelectedElements();
                        canvasController.SelectElements(groupedShapes);
                    },
                                                        () =>
                    {
                        ElementCache.Instance.Remove(groupBox);
                        canvasController.GroupShapes(groupBox);
                        canvasController.DeselectCurrentSelectedElements();
                        canvasController.SelectElement(groupBox);
                    });
                }
            }
        }
コード例 #3
0
ファイル: MenuController.cs プロジェクト: nagyistge/FlowSharp
 private void mnuGroup_Click(object sender, EventArgs e)
 {
     if (canvasController.SelectedElements.Any())
     {
         FlowSharpLib.GroupBox groupBox = canvasController.GroupShapes(canvasController.SelectedElements);
         canvasController.DeselectCurrentSelectedElements();
         canvasController.SelectElement(groupBox);
     }
 }
コード例 #4
0
 private void CollapseGroupBox(BaseController canvasController, FlowSharpLib.GroupBox gb, IEnumerable <GraphicElement> children)
 {
     canvasController.Redraw(gb, _ =>
     {
         gb.SetCollapsedState();
         gb.SaveExpandedSize();
         canvasController.Elements.Where(el => el.Parent == gb).ForEach(el => el.Visible = false);
         Rectangle r         = gb.DisplayRectangle;
         gb.DisplayRectangle = new Rectangle(r.Location, new Size(r.Width, 30));
         // Update connections after display rectangle has been updated, as this adjusts the connection points.
         canvasController.UpdateConnections(gb);
     });
     // In a collapse, the children, being intersecting with the groupbox, will be redrawn.
 }
コード例 #5
0
        private void ExpandGroupBox(BaseController canvasController, FlowSharpLib.GroupBox gb, IEnumerable <GraphicElement> children)
        {
            canvasController.Redraw(gb, _ =>
            {
                gb.SetExpandedState();
                Rectangle r         = gb.DisplayRectangle;
                gb.DisplayRectangle = new Rectangle(r.Location, gb.ExpandedSize);
                // Update connections after display rectangle has been updated, as this adjusts the connection points.
                canvasController.UpdateConnections(gb);
            });

            // In an expand , not all the children may redraw because the collapsed groupbox does not intersect them!
            children.ForEach(el =>
            {
                el.Visible = true;
                el.Redraw();
            });
        }
コード例 #6
0
        private void mnuUngroup_Click(object sender, EventArgs e)
        {
            BaseController canvasController = serviceManager.Get <IFlowSharpCanvasService>().ActiveController;

            // At this point, we can only ungroup one group.
            if (canvasController.SelectedElements.Count == 1)
            {
                FlowSharpLib.GroupBox groupBox = canvasController.SelectedElements[0] as FlowSharpLib.GroupBox;

                if (groupBox != null)
                {
                    List <GraphicElement> groupedShapes = new List <GraphicElement>(groupBox.GroupChildren);
                    bool collapsed = groupBox.State == FlowSharpLib.GroupBox.CollapseState.Collapsed;            // For closure.

                    canvasController.UndoStack.UndoRedo("Ungroup",
                                                        () =>
                    {
                        if (collapsed)
                        {
                            var children = canvasController.Elements.Where(el => el.Parent == groupBox);
                            ExpandGroupBox(canvasController, groupBox, children);
                        }

                        // ElementCache.Instance.Add(groupBox);
                        canvasController.UngroupShapes(groupBox, false);
                        canvasController.DeselectCurrentSelectedElements();
                        canvasController.SelectElements(groupedShapes);
                    },
                                                        () =>
                    {
                        // ElementCache.Instance.Remove(groupBox);
                        canvasController.GroupShapes(groupBox);
                        canvasController.DeselectCurrentSelectedElements();
                        canvasController.SelectElement(groupBox);

                        if (collapsed)
                        {
                            var children = canvasController.Elements.Where(el => el.Parent == groupBox);
                            CollapseGroupBox(canvasController, groupBox, children);
                        }
                    });
                }
            }
        }