示例#1
0
        public void EndSelect(GraphApp app, GraphAppGUI appGUI, Point p, bool shiftHeld)
        {
            Console.WriteLine("Selection end: " + p.ToString());
            Started = false;

            endPoint = p;
            Rectangle selectionRect = getSelectionRectangle(startPoint, endPoint);

            GraphPanel gp = appGUI.CurrentGraphPanel;

            if (!shiftHeld)
            {
                gp.Deselect();
            }
            List <ISelectable> selectables = gp.Selectables;

            int selectTotal = 0;

            foreach (ISelectable s in selectables)
            {
                if (s.Intersects(selectionRect))
                {
                    bool filterPass = false;
                    foreach (SelectionFilter filter in filters)
                    {
                        if (filter.PassesFilter(s.GetItem()))
                        {
                            filterPass = true;
                        }
                    }

                    if (!filterPass)
                    {
                        continue;
                    }
                    gp.Select(s);
                    s.Select();
                    selectTotal++;
                    Console.WriteLine("Selected " + s.ToString());
                }
            }

            if (selectTotal == 0)
            {
                Console.WriteLine("Selected nothing");
                gp.Deselect();
            }

            gp.Refresh();
        }