Esempio n. 1
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);
        }
        public static TinyNode GetNodeUnder(this TinyGraph graph, Vector2 point, TinySelector selector = null)
        {
            var nodes = graph.Nodes.Where(x => TinyGUI.GetNodeRect(x.Position).Contains(point));

            return(selector == null?nodes.FirstOrDefault() : nodes.OrderByDescending(selector.IsSelected).FirstOrDefault());
        }