Exemplo n.º 1
0
        public static Gesture_Event_Cutting_Sorting Detect(List <My_Point> points, Gesture_Controler controler)
        {
            List <My_Point> result = new List <My_Point>();
            Gesture_Event_Cutting_Sorting cuttingEvent = null;

            if (Group_List.CardGroups.Count > 0 && controler.Control.MainWindow.SortingGestureLayer.GroupLinks.Count > 0)
            {
                Menu_Sort_Box[] keys = controler.Control.MainWindow.SortingGestureLayer.GroupLinks.Keys.ToArray();
                foreach (My_Point p in points)
                {
                    if (p.Sender is Card_Layer)
                    {
                        foreach (Menu_Sort_Box key in keys)
                        {
                            if (Group_List.CardGroups.ContainsKey(key))
                            {
                                Card[] cards = Group_List.CardGroups[key].ToArray();
                                foreach (Card c in cards)
                                {
                                    bool isIntersect = Calculator.DoLinesIntersect(new Point(key.CurrentPosition.X, key.CurrentPosition.Y),
                                                                                   new Point(c.CurrentPosition.X, c.CurrentPosition.Y),
                                                                                   new Point(p.StartPoint.Position.X, p.StartPoint.Position.Y),
                                                                                   new Point(p.CurrentPoint.Position.X, p.CurrentPoint.Position.Y));
                                    if (isIntersect)
                                    {
                                        result.Add(p);
                                        My_Point[] argPoints = result.ToArray();
                                        object[]   objects   = new object[2];
                                        objects[0]          = key;
                                        objects[1]          = c;
                                        cuttingEvent        = new Gesture_Event_Cutting_Sorting();
                                        cuttingEvent.Points = argPoints;
                                        Gesture_List.addGesture(cuttingEvent);
                                        Gesture_Cutting_Sorting_Listener gestureListener = new Gesture_Cutting_Sorting_Listener(controler, cuttingEvent);
                                        cuttingEvent.Register(objects, argPoints);
                                        foreach (My_Point p2 in result)
                                        {
                                            points.Remove(p2);
                                        }
                                        return(cuttingEvent);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(null);
        }
        public static Gesture_Event_Cutting_Link Detect(List <My_Point> points, Gesture_Controler controler)
        {
            List <My_Point>            result       = new List <My_Point>();
            Gesture_Event_Cutting_Link cuttingEvent = null;

            if (Link_List.CardLinks.Count > 0 && controler.Control.MainWindow.LinkingGestureLayer.CardLinks.Count > 0)
            {
                Gesture_Event_Linking[] links = Link_List.CardLinks.ToArray();
                foreach (My_Point p in points)
                {
                    if (p.Sender is Card_Layer)
                    {
                        foreach (Gesture_Event_Linking link in links)
                        {
                            if (link.Card1 != null && link.Card2 != null)
                            {
                                bool isIntersect = Calculator.DoLinesIntersect(new Point(link.Card1.CurrentPosition.X, link.Card1.CurrentPosition.Y),
                                                                               new Point(link.Card2.CurrentPosition.X, link.Card2.CurrentPosition.Y),
                                                                               new Point(p.StartPoint.Position.X, p.StartPoint.Position.Y),
                                                                               new Point(p.CurrentPoint.Position.X, p.CurrentPoint.Position.Y));
                                if (isIntersect)
                                {
                                    result.Add(p);
                                    My_Point[] argPoints = result.ToArray();
                                    object[]   objects   = new object[2];
                                    objects[0]          = link;
                                    cuttingEvent        = new Gesture_Event_Cutting_Link();
                                    cuttingEvent.Points = argPoints;
                                    Gesture_List.addGesture(cuttingEvent);
                                    Gesture_Cutting_Link_Listener gestureListener = new Gesture_Cutting_Link_Listener(controler, cuttingEvent);
                                    cuttingEvent.Register(objects, argPoints);
                                    foreach (My_Point p2 in result)
                                    {
                                        points.Remove(p2);
                                    }
                                    return(cuttingEvent);
                                }
                            }
                        }
                    }
                }
            }
            return(null);
        }