public static Item GroupItems(Vector2 mousePos, Group grp, Graph graph, int priority = 3)
        {
            Item genItems = new Item("Group");

            genItems.onDraw   = RightClick.DrawItem;
            genItems.icon     = RightClick.texturesCache.GetTexture("MapMagic/Popup/Generator");
            genItems.color    = Color.gray;
            genItems.subItems = new List <Item>();
            genItems.priority = priority;

            //genItems.disabled = grp == null;

            genItems.subItems.Add(new Item("Create", onDraw: RightClick.DrawItem, priority: 12)
            {
                icon    = RightClick.texturesCache.GetTexture("MapMagic/Popup/GroupAdd"),
                color   = Color.gray,
                onClick = () => CreateGroup(mousePos, graph)
            });

            genItems.subItems.Add(new Item("Group Selected", onDraw: RightClick.DrawItem, priority: 12)
            {
                icon     = RightClick.texturesCache.GetTexture("MapMagic/Popup/GroupSelected"),
                color    = Color.gray,
                disabled = GraphWindow.current.selected == null || GraphWindow.current.selected.Count == 0,
                onClick  = () => { Group ngrp = CreateGroup(mousePos, graph); GroupSelected(ngrp); }
            });

            //genItems.subItems.Add( new Item("Export", onDraw:DrawItem, priority:10) { icon = texturesCache.GetTexture("MapMagic/Popup/Export"), color = Color.gray } );
            //genItems.subItems.Add( new Item("Import", onDraw:DrawItem, priority:9) { icon = texturesCache.GetTexture("MapMagic/Popup/Import"), color = Color.gray } );
            //genItems.subItems.Add( new Item("Duplicate", onDraw:DrawItem, priority:8) { icon = texturesCache.GetTexture("MapMagic/Popup/Duplicate"), color = Color.gray } );
            //genItems.subItems.Add( new Item("Update", onDraw:DrawItem, priority:7) { icon = texturesCache.GetTexture("MapMagic/Popup/Update"), color = Color.gray } );

            genItems.subItems.Add(new Item("Ungroup", onDraw: RightClick.DrawItem, priority: 5)
            {
                icon    = RightClick.texturesCache.GetTexture("MapMagic/Popup/Ungroup"),
                color   = Color.gray,
                onClick = () => graph.Remove(grp)
            });

            genItems.subItems.Add(new Item("Remove", onDraw: RightClick.DrawItem, priority: 4)
            {
                icon    = RightClick.texturesCache.GetTexture("MapMagic/Popup/Remove"),
                color   = Color.gray,
                onClick = () =>
                {
                    GraphWindow.current.graphUI.undo.Record();
                    GroupDraw.RemoveGroupContents(grp, graph);
                    graph.Remove(grp);
                }
            });

            return(genItems);
        }
Пример #2
0
        public static void RemoveGroup(Group grp, Graph graph, bool withContent = false)
        {
            GraphWindow.RecordCompleteUndo();

            if (withContent)
            {
                GroupDraw.RemoveGroupContents(grp, graph);
            }

            graph.Remove(grp);

            GraphWindow.current.Focus();
            GraphWindow.current.Repaint();

            if (withContent)
            {
                GraphWindow.RefreshMapMagic();
            }
        }