Esempio n. 1
0
        public void Paste(Vector2 position)
        {
            _selector.Clean();
            var nodes  = _copyBuffer.Select(x => _graph.GetNode(x)).ToList();
            var offset = GetPositionOffset(position, nodes);

            var map = PasteNodes(nodes, offset);

            PasteEdges(map);

            _selector.Add(map.Values.Select(_graph.GetNode));
            GUI.changed = true;
        }
Esempio n. 2
0
        private bool ProcessMouseUp(Event @event)
        {
            if (@event.button == 1)
            {
                //End of mouse right click
                if (Vector2.Distance(Zoomed(CurrentPosition), Zoomed(StartPosition)) < 1)
                {
                    ProcessContextMenu(Zoomed(CurrentPosition));
                }
                return(false);
            }

            if (@event.button != 0)
            {
                return(false);
            }

            //End of mouse left click
            if (NewEdge)
            {
                var @in = _graph.GetNodeUnder(Zoomed(CurrentPosition));
                if (@in != null && @in.Type == TinyNodeType.Regular)
                {
                    _graph.CreateEdge(_graph.GetNodeUnder(Zoomed(StartPosition)), @in);
                }
                else
                {
                    ProcessContextMenu(Zoomed(CurrentPosition));
                }
                return(true);
            }

            if (!MultiSelectionOn)
            {
                return(false);
            }

            var selection = GetSelectionRect(Zoomed(StartPosition), Zoomed(CurrentPosition));

            _selector.Add(_graph.Nodes.Where(x => selection.Overlaps(TinyGUI.GetNodeRect(x.Position))));
            return(true);
        }