public void TouchMove(object sdr, Type t, TouchDevice touchDevice, TouchPoint touchPoint) { My_Point point = Point_List.UpdatePoint(sdr, t, touchDevice.Id, touchPoint); if (point != null && (t == typeof(Card_Layer))) { ///Show gesture indicator if (point.Life > STATICS.MIN_GESTURE_LIFE) { FrameworkElement sender = point.Sender as FrameworkElement; lock (Point_List.TouchPointList) { if (!control.MainWindow.GestureIndicatorLayer.Contain(touchDevice.Id)) { control.MainWindow.GestureIndicatorLayer.Add(touchDevice.Id, touchPoint.Position); } else { control.MainWindow.GestureIndicatorLayer.Move(touchDevice.Id, touchPoint.Position); } } } } }
public override void Terminate(object[] senders, My_Point[] myPoints) { if (myPoints != null && senders != null) { Gesture_Event_Args gestureEventArgs = new Gesture_Event_Args(); gestureEventArgs.GesturePoints = myPoints; My_Point point = myPoints[0]; foreach (Card card in Card_List.CardList) { if (card.Contain(point.CurrentPoint.Position)) { Senders[1] = card; card2 = card; break; } else { this.Senders = senders; } } gestureEventArgs.GestureObjects = this.Senders; this.Status = GESTURESTATUS.TERMINATE; OnTerminated(this, gestureEventArgs); } }
public override void Continue(object[] senders, My_Point[] myPoints) { if (myPoints != null && senders != null && checkValid(null, null)) { Gesture_Event_Args gestureEventArgs = new Gesture_Event_Args(); gestureEventArgs.GesturePoints = myPoints; gestureEventArgs.Senders = senders; this.Status = GESTURESTATUS.CONTINUE; double xAvg = 0; double yAvg = 0; for (int i = 0; i < 4; i++) { xAvg += myPoints[i].CurrentPoint.Position.X - previousPoint[i].X; yAvg += myPoints[i].CurrentPoint.Position.Y - previousPoint[i].Y; previousPoint[i] = new Point(myPoints[i].CurrentPoint.Position.X, myPoints[i].CurrentPoint.Position.Y); } xAvg = xAvg / 4; yAvg = yAvg / 4; vector = new Vector(xAvg, yAvg); vectorDistance.X += xAvg; vectorDistance.Y += yAvg; OnContinued(this, gestureEventArgs); } if (!checkValid(null,null)) { Fail(); return; } if (checkTerminate(null, null)) { Terminate(senders, myPoints); } }
private void updateGesture() { newGesturePoints.Clear(); My_Point[] myPoints = new My_Point[Point_List.TouchPointList.Count]; myPoints = Point_List.TouchPointList.Values.ToArray(); foreach (My_Point point in myPoints) { if (point.Life > STATICS.MIN_GESTURE_LIFE) { bool inUse = false; Gesture_Event[] gestures = Gesture_List.GestureList.ToArray(); foreach (Gesture_Event gesture in gestures) { if ((gesture.Status == GESTURESTATUS.CONTINUE || gesture.Status == GESTURESTATUS.REGISTER) && gesture.ContainPoint(point)) { inUse = true; break; } } if (!inUse) { newGesturePoints.Add(point); } } } lock (Gesture_List.GestureList) { foreach (Gesture_Event gesture in Gesture_List.GestureList.ToArray()) { gesture.Continue(gesture.Senders, gesture.Points); } } }
protected override bool checkTerminate(object[] senders, My_Point[] myPoints) { foreach (My_Point p in myPoints) { if (!p.IsLive) { return true; } } return false; }
public override void Terminate(object[] senders, My_Point[] myPoints) { if (myPoints != null && senders != null) { Gesture_Event_Args gestureEventArgs = new Gesture_Event_Args(); gestureEventArgs.GesturePoints = myPoints; gestureEventArgs.Senders = senders; this.Status = GESTURESTATUS.TERMINATE; OnTerminated(this, gestureEventArgs); } }
public static bool PNPoly(My_Point[] Newpoint, double testx, double testy) { int i, j; bool c = false; for (i = 0, j = 3; i < 4; j = i++) { if (((Newpoint[i].CurrentPoint.Position.Y > testy) != (Newpoint[j].CurrentPoint.Position.Y > testy)) && (testx < (Newpoint[j].CurrentPoint.Position.X - Newpoint[i].CurrentPoint.Position.X) * (testy - Newpoint[i].CurrentPoint.Position.Y) / (Newpoint[j].CurrentPoint.Position.Y - Newpoint[i].CurrentPoint.Position.Y) + Newpoint[i].CurrentPoint.Position.X)) c = !c; } return c; }
public override void Terminate(object[] senders, My_Point[] myPoints) { if (myPoints != null && senders != null) { Gesture_Event_Args gestureEventArgs = new Gesture_Event_Args(); gestureEventArgs.GesturePoints = myPoints; My_Point point = myPoints[0]; gestureEventArgs.GestureObjects = this.Senders; this.Status = GESTURESTATUS.TERMINATE; OnTerminated(this, gestureEventArgs); } }
public override void Register(object[] senders, My_Point[] myPoints) { if (myPoints != null && senders != null) { Points = myPoints; Senders = senders; Gesture_Event_Args gestureEventArgs = new Gesture_Event_Args(); gestureEventArgs.GesturePoints = myPoints; gestureEventArgs.GestureObjects = senders; this.Status = GESTURESTATUS.REGISTER; OnRegistered(this, gestureEventArgs); } }
public My_Point TouchUp(TouchDevice touchDevice, TouchPoint touchPoint) { if (control.MainWindow.GestureIndicatorLayer.Contain(touchDevice.Id)) { control.MainWindow.GestureIndicatorLayer.Remove(touchDevice.Id); } My_Point point = Point_List.ReleasePoint(touchDevice.Id); if (!isTouched()) { control.MainWindow.GestureIndicatorLayer.Clear(); } return(point); }
public static My_Point ReleasePoint(int pointIndex) { if (touchPointList.ContainsKey(pointIndex)) { touchPointList[pointIndex].KillMyPoint(DateTime.Now); My_Point myPoint = touchPointList[pointIndex]; myPoint.IsLive = false; touchPointList.Remove(pointIndex); listSize--; return(myPoint); } else { return(null); } }
protected override bool checkValid(object[] senders, My_Point[] myPoints) { Card c = senders[0] as Card; Menu_Sort_Button b = senders[1] as Menu_Sort_Button; bool crit1 = c.Contain(b.CurrentPosition); bool isLeave = false; foreach (My_Point p in myPoints) { if (!p.IsLive) { isLeave = true; break; } } bool crit2 = isLeave && Group_List.ContainCard(b.GroupID, c); return crit1 && !crit2; }
public override void Register(object[] senders, My_Point[] myPoints) { if (myPoints != null && senders != null) { Points = myPoints; Senders = senders; Gesture_Event_Args gestureEventArgs = new Gesture_Event_Args(); gestureEventArgs.GesturePoints = myPoints; gestureEventArgs.Senders = senders; this.Status = GESTURESTATUS.REGISTER; for (int i = 0; i < 4; i++) { previousPoint[i] = new Point(myPoints[i].CurrentPoint.Position.X, myPoints[i].CurrentPoint.Position.Y); } OnRegistered(this, gestureEventArgs); } }
public override void Continue(object[] senders, My_Point[] myPoints) { if (myPoints != null && senders != null && checkValid(senders, myPoints)) { Gesture_Event_Args gestureEventArgs = new Gesture_Event_Args(); gestureEventArgs.GesturePoints = myPoints; gestureEventArgs.GestureObjects = senders; this.Status = GESTURESTATUS.CONTINUE; OnContinued(this, gestureEventArgs); } if (!checkValid(senders, myPoints)) { Fail(); return; } if (checkTerminate(null, null)) { Terminate(senders, myPoints); } }
public static bool AddPoint(object sdr, Type t, int touchDevice, TouchPoint touchPoint) { bool isSuccess = false; if (touchPointList.ContainsKey(touchDevice)) { touchPointList[touchDevice].UpdateMyPoint(touchPoint, DateTime.Now); } else { if (touchPointList.Count < STATICS.MAX_TOUCH_POINT) { int senderCount = 0; if (sdr is Card) { lock (touchPointList) { foreach (My_Point p in touchPointList.Values) { if (p.Sender == sdr) { senderCount++; } } } } if (senderCount < (STATICS.MAX_TOUCH_POINT / STATICS.USER_NUMER)) { My_Point newPoint = new My_Point(touchDevice, sdr, t, touchPoint, DateTime.Now); newPoint.IsLive = true; touchPointList.Add(touchDevice, newPoint); listSize++; } } } isSuccess = true; return(isSuccess); }
public static bool AddPoint(object sdr, Type t, int touchDevice, TouchPoint touchPoint) { bool isSuccess = false; if (touchPointList.ContainsKey(touchDevice)) { touchPointList[touchDevice].UpdateMyPoint(touchPoint, DateTime.Now); } else { if (touchPointList.Count < STATICS.MAX_TOUCH_POINT) { int senderCount = 0; if (sdr is Card) { lock (touchPointList) { foreach (My_Point p in touchPointList.Values) { if (p.Sender == sdr) { senderCount++; } } } } if (senderCount < (STATICS.MAX_TOUCH_POINT / STATICS.USER_NUMER)) { My_Point newPoint = new My_Point(touchDevice, sdr, t, touchPoint, DateTime.Now); newPoint.IsLive = true; touchPointList.Add(touchDevice, newPoint); listSize++; } } } isSuccess = true; return isSuccess; }
public override void TerminateGesture(object sender, Gesture_Event_Args gEventArgs) { Card c = gEventArgs.GestureObjects[0] as Card; Menu_Sort_Box b = gEventArgs.GestureObjects[1] as Menu_Sort_Box; if (!gestureControler.Control.MainWindow.MenuLayer.IsButtonInOriginPos(b)) { c.SortToGroup(b); Group_List.Add(b, c); My_Point point = gEventArgs.GesturePoints[0]; Vector v = new Vector(c.PreviousPostion.X - c.CurrentPosition.X, c.PreviousPostion.Y - c.CurrentPosition.Y); v.Normalize(); c.MoveCard(v.X * 150, v.Y * 150, 0.5); } if (Group_List.CardGroups.ContainsKey(b)) { Card[] cards = Group_List.CardGroups[b].ToArray(); foreach (Card cc in cards) { cc.Dehightlight(); } } base.TerminateGesture(sender, gEventArgs); }
protected override bool checkValid(object[] senders, My_Point[] myPoints) { if (STATICS.COLLABORATIVE_ZOON.Contains((int)myPoints[0].CurrentPoint.Position.X, (int)myPoints[0].CurrentPoint.Position.Y)) { return true; } return false; }
public bool ContainPoint(My_Point point) { return(points.Contains(point)); }
public static Gesture_Event_Grouping Detect(List <My_Point> points, Gesture_Controler controler) { List <My_Point> result = new List <My_Point>(); if (points.Count == 4) { foreach (My_Point p in points) { if (p.Sender is Card_Layer) { result.Add(p); } } } if (result.Count == 4) { My_Point[] argPoints = result.ToArray(); Card[] cards = Card_List.CardList.ToArray(); My_Point[] Newpoint = new My_Point[4]; for (int i = 0; i < 4; i++) { Newpoint[i] = argPoints[i]; } double maxX_1 = Math.Max(Math.Min(Newpoint[0].CurrentPoint.Position.X, Newpoint[1].CurrentPoint.Position.X), Math.Min(Newpoint[2].CurrentPoint.Position.X, Newpoint[3].CurrentPoint.Position.X)); double maxX_2 = Math.Min(Math.Max(Newpoint[0].CurrentPoint.Position.X, Newpoint[1].CurrentPoint.Position.X), Math.Max(Newpoint[2].CurrentPoint.Position.X, Newpoint[3].CurrentPoint.Position.X)); double maxY_1 = Math.Max(Math.Min(Newpoint[0].CurrentPoint.Position.Y, Newpoint[1].CurrentPoint.Position.Y), Math.Min(Newpoint[2].CurrentPoint.Position.Y, Newpoint[3].CurrentPoint.Position.Y)); double maxY_2 = Math.Min(Math.Max(Newpoint[0].CurrentPoint.Position.Y, Newpoint[1].CurrentPoint.Position.Y), Math.Max(Newpoint[2].CurrentPoint.Position.Y, Newpoint[3].CurrentPoint.Position.Y)); double midX = (maxX_1 + maxX_2) / 2; double midY = (maxY_1 + maxY_2) / 2; My_Point[] orderedPoints = new My_Point[4]; int count1 = 0; int count2 = 0; int count3 = 0; int count4 = 0; for (int i = 0; i < 4; i++) { if (Newpoint[i].CurrentPoint.Position.X > midX && Newpoint[i].CurrentPoint.Position.Y <= midY) { count1++; } if (Newpoint[i].CurrentPoint.Position.X <= midX && Newpoint[i].CurrentPoint.Position.Y < midY) { count2++; } if (Newpoint[i].CurrentPoint.Position.X < midX && Newpoint[i].CurrentPoint.Position.Y >= midY) { count3++; } if (Newpoint[i].CurrentPoint.Position.X >= midX && Newpoint[i].CurrentPoint.Position.Y > midY) { count4++; } } if (count1 > 1 || count2 > 1 || count3 > 1 || count4 > 1) { if (count1 > 1) { int countIndexRight1 = 0; int countIndexRight2 = 0; for (int i = 0; i < 4; i++) { if (Newpoint[i].CurrentPoint.Position.X > midX && Newpoint[i].CurrentPoint.Position.Y <= midY) { countIndexRight1++; if (countIndexRight1 > 1) { if (Newpoint[i].CurrentPoint.Position.X < orderedPoints[0].CurrentPoint.Position.X) { orderedPoints[1] = argPoints[i]; } else { orderedPoints[1] = orderedPoints[0]; orderedPoints[0] = argPoints[i]; } break; } orderedPoints[0] = argPoints[i]; } } double disRight = 0; for (int i = 0; i < 4; i++) { if (Newpoint[i].CurrentPoint.Position.X < midX && Newpoint[i].CurrentPoint.Position.Y >= midY) { countIndexRight2++; if (countIndexRight2 > 1) { double temp = Math.Pow((Newpoint[i].CurrentPoint.Position.X - orderedPoints[1].CurrentPoint.Position.X), 2) + Math.Pow((Newpoint[i].CurrentPoint.Position.Y - orderedPoints[1].CurrentPoint.Position.Y), 2); if (temp > disRight) { orderedPoints[3] = argPoints[i]; } else { orderedPoints[3] = orderedPoints[2]; orderedPoints[2] = argPoints[i]; } break; } orderedPoints[2] = argPoints[i]; disRight = Math.Pow((Newpoint[i].CurrentPoint.Position.X - orderedPoints[1].CurrentPoint.Position.X), 2) + Math.Pow((Newpoint[i].CurrentPoint.Position.Y - orderedPoints[1].CurrentPoint.Position.Y), 2); } } } else if (count2 > 1) { int countIndexLeft1 = 0; int countIndexLeft2 = 0; for (int i = 0; i < 4; i++) { if (Newpoint[i].CurrentPoint.Position.X <= midX && Newpoint[i].CurrentPoint.Position.Y < midY) { countIndexLeft1++; if (countIndexLeft1 > 1) { if (Newpoint[i].CurrentPoint.Position.X < orderedPoints[0].CurrentPoint.Position.X) { orderedPoints[1] = argPoints[i]; } else { orderedPoints[1] = orderedPoints[0]; orderedPoints[0] = argPoints[i]; } break; } orderedPoints[0] = argPoints[i]; } } double disLeft = 0; for (int i = 0; i < 4; i++) { if (Newpoint[i].CurrentPoint.Position.X >= midX && Newpoint[i].CurrentPoint.Position.Y > midY) { countIndexLeft2++; if (countIndexLeft2 > 1) { double temp = Math.Pow((Newpoint[i].CurrentPoint.Position.X - orderedPoints[1].CurrentPoint.Position.X), 2) + Math.Pow((Newpoint[i].CurrentPoint.Position.Y - orderedPoints[1].CurrentPoint.Position.Y), 2); if (temp > disLeft) { orderedPoints[3] = argPoints[i]; } else { orderedPoints[3] = orderedPoints[2]; orderedPoints[2] = argPoints[i]; } break; } orderedPoints[2] = argPoints[i]; disLeft = Math.Pow((Newpoint[i].CurrentPoint.Position.X - orderedPoints[1].CurrentPoint.Position.X), 2) + Math.Pow((Newpoint[i].CurrentPoint.Position.Y - orderedPoints[1].CurrentPoint.Position.Y), 2); } } } } else { for (int i = 0; i < 4; i++) { if (Newpoint[i].CurrentPoint.Position.X > midX && Newpoint[i].CurrentPoint.Position.Y < midY) { orderedPoints[0] = argPoints[i]; } else if (Newpoint[i].CurrentPoint.Position.X < midX && Newpoint[i].CurrentPoint.Position.Y < midY) { orderedPoints[1] = argPoints[i]; } else if (Newpoint[i].CurrentPoint.Position.X <midX && Newpoint[i].CurrentPoint.Position.Y> midY) { orderedPoints[2] = argPoints[i]; } else if (Newpoint[i].CurrentPoint.Position.X > midX && Newpoint[i].CurrentPoint.Position.Y > midY) { orderedPoints[3] = argPoints[i]; } } } List <Card> objects = new List <Card>(); lock (cards) { foreach (Card c in cards) { if (Enclose_Helper.PNPoly(orderedPoints, c.CurrentPosition.X, c.CurrentPosition.Y)) { objects.Add(c); } } } if (objects.Count > 0) { Gesture_Event_Grouping gestureEvent = new Gesture_Event_Grouping(); gestureEvent.Points = orderedPoints; gestureEvent.Senders = objects.ToArray(); Gesture_List.addGesture(gestureEvent); Gesture_Grouping_Listener gestureListener = new Gesture_Grouping_Listener(controler, gestureEvent); gestureEvent.Register(objects.ToArray(), orderedPoints); foreach (My_Point p in result) { points.Remove(p); } return(gestureEvent); } return(null); } else { return(null); } }
public bool ContainPoint(My_Point point) { return points.Contains(point); }
protected override bool checkValid(object[] senders, My_Point[] myPoints) { return true; }
protected override bool checkValid(object[] senders, My_Point[] myPoints) { Card c = senders[0] as Card; Menu_Sort_Box b = senders[1] as Menu_Sort_Box; bool crit1 = c.Contain(b.CurrentPosition); bool crit2 = !Group_List.ContainCard(b, c); return crit1 && crit2; }
protected override bool checkValid(object[] senders, My_Point[] myPoints) { //DONG: TO DO check if the the gesture is still valid return true; }
public override void Terminate(object[] senders, My_Point[] myPoints) { if (myPoints != null && senders != null) { Gesture_Event_Args gestureEventArgs = new Gesture_Event_Args(); gestureEventArgs.GesturePoints = myPoints; My_Point point = myPoints[0]; foreach (Card card in Card_List.CardList) { if (card.Contain(point.CurrentPoint.Position)) { Senders[1] = card; card2 = card; break; } else { this.Senders = senders; } } gestureEventArgs.Senders = this.Senders; this.Status = GESTURESTATUS.TERMINATE; OnTerminated(this, gestureEventArgs); } }
public override void Terminate(object[] senders, My_Point[] myPoints) { if (myPoints != null && senders != null) { Gesture_Event_Args gestureEventArgs = new Gesture_Event_Args(); gestureEventArgs.GesturePoints = myPoints; gestureEventArgs.GestureObjects = senders; this.Status = GESTURESTATUS.TERMINATE; OnTerminated(this, gestureEventArgs); } Menu_Recycle_Bin mc = senders[1] as Menu_Recycle_Bin; if (mc != null) { mc.Mc.removeRecycleNotification(); } }
public virtual void Terminate(object[] senders, My_Point[] myPoints) { }
protected override bool checkTerminate(object[] senders, My_Point[] myPoints) { return !myPoints[0].IsLive && Calculator.CalDistance(myPoints[0].StartPoint, myPoints[0].CurrentPoint) >= STATICS.MIN_DISTANCE_FOR_MOVE; }
//senders: UI elements associated with the gesture, myPoints: Points associated with the gesture public virtual void Register(object[] senders, My_Point[] myPoints) { }
protected override bool checkValid(object[] senders, My_Point[] myPoints) { Menu_Sort_Box categoryBox = senders[0] as Menu_Sort_Box; Menu_Recycle_Bin recycleBox = senders[1] as Menu_Recycle_Bin; if (recycleBox != null && categoryBox != null && Math.Sqrt(Math.Pow((categoryBox.CurrentPosition.X - recycleBox.XCoord), 2) + Math.Pow((categoryBox.CurrentPosition.Y - recycleBox.YCoord), 2)) < 50) { return true; } return false; }
protected virtual bool checkValid(object[] senders, My_Point[] myPoints) { //TO DO check if the the gesture is still valid return true; }
protected override bool checkValid(object[] senders, My_Point[] myPoints) { return Calculator.CalDistance(Points[0].StartPoint, Points[0].CurrentPoint) < STATICS.MIN_DISTANCE_FOR_MOVE; }
public virtual void Continue(object[] senders, My_Point[] myPoints) { }
protected override bool checkTerminate(object[] senders, My_Point[] myPoints) { //DONG: TO DO check if the the gesture is terminated return !Points[0].IsLive; }
protected virtual bool checkTerminate(object[] senders, My_Point[] myPoints) { return false; }
protected override bool checkTerminate(object[] senders, My_Point[] myPoints) { return !Points[0].IsLive; }
private Gesture_Event_Grouping detectGroupingRegister(List<My_Point> points) { List<My_Point> result = new List<My_Point>(); if (points.Count == 4) { foreach (My_Point p in points) { if(p.Sender is Card_Layer) result.Add(p); } } if (result.Count ==4) { My_Point[] argPoints = result.ToArray(); Card[] cards = Card_List.CardList.ToArray(); My_Point[] Newpoint = new My_Point[4]; for (int i = 0; i < 4; i++) { Newpoint[i] = argPoints[i]; } double maxX_1 = Math.Max(Math.Min(Newpoint[0].CurrentPoint.Position.X, Newpoint[1].CurrentPoint.Position.X), Math.Min(Newpoint[2].CurrentPoint.Position.X, Newpoint[3].CurrentPoint.Position.X)); double maxX_2 = Math.Min(Math.Max(Newpoint[0].CurrentPoint.Position.X, Newpoint[1].CurrentPoint.Position.X), Math.Max(Newpoint[2].CurrentPoint.Position.X, Newpoint[3].CurrentPoint.Position.X)); double maxY_1 = Math.Max(Math.Min(Newpoint[0].CurrentPoint.Position.Y, Newpoint[1].CurrentPoint.Position.Y), Math.Min(Newpoint[2].CurrentPoint.Position.Y, Newpoint[3].CurrentPoint.Position.Y)); double maxY_2 = Math.Min(Math.Max(Newpoint[0].CurrentPoint.Position.Y, Newpoint[1].CurrentPoint.Position.Y), Math.Max(Newpoint[2].CurrentPoint.Position.Y, Newpoint[3].CurrentPoint.Position.Y)); double midX = (maxX_1 + maxX_2) / 2; double midY = (maxY_1 + maxY_2) / 2; My_Point[] orderedPoints = new My_Point[4]; int count1 = 0; int count2 = 0; int count3 = 0; int count4 = 0; for (int i = 0; i < 4; i++) { if (Newpoint[i].CurrentPoint.Position.X > midX && Newpoint[i].CurrentPoint.Position.Y <= midY) { count1++; } if (Newpoint[i].CurrentPoint.Position.X <= midX && Newpoint[i].CurrentPoint.Position.Y < midY) { count2++; } if (Newpoint[i].CurrentPoint.Position.X < midX && Newpoint[i].CurrentPoint.Position.Y >= midY) { count3++; } if (Newpoint[i].CurrentPoint.Position.X >= midX && Newpoint[i].CurrentPoint.Position.Y > midY) { count4++; } } if (count1 > 1 || count2 > 1 || count3 > 1 || count4 > 1) { if (count1 > 1) { int countIndexRight1 = 0; int countIndexRight2 = 0; for (int i = 0; i < 4; i++) { if (Newpoint[i].CurrentPoint.Position.X > midX && Newpoint[i].CurrentPoint.Position.Y <= midY) { countIndexRight1++; if (countIndexRight1 > 1) { if (Newpoint[i].CurrentPoint.Position.X < orderedPoints[0].CurrentPoint.Position.X) { orderedPoints[1] = argPoints[i]; } else { orderedPoints[1] = orderedPoints[0]; orderedPoints[0] = argPoints[i]; } break; } orderedPoints[0] = argPoints[i]; } } double disRight = 0; for (int i = 0; i < 4; i++) { if (Newpoint[i].CurrentPoint.Position.X < midX && Newpoint[i].CurrentPoint.Position.Y >= midY) { countIndexRight2++; if (countIndexRight2 > 1) { double temp = Math.Pow((Newpoint[i].CurrentPoint.Position.X - orderedPoints[1].CurrentPoint.Position.X), 2) + Math.Pow((Newpoint[i].CurrentPoint.Position.Y - orderedPoints[1].CurrentPoint.Position.Y), 2); if (temp > disRight) { orderedPoints[3] = argPoints[i]; } else { orderedPoints[3] = orderedPoints[2]; orderedPoints[2] = argPoints[i]; } break; } orderedPoints[2] = argPoints[i]; disRight = Math.Pow((Newpoint[i].CurrentPoint.Position.X - orderedPoints[1].CurrentPoint.Position.X), 2) + Math.Pow((Newpoint[i].CurrentPoint.Position.Y - orderedPoints[1].CurrentPoint.Position.Y), 2); } } } else if (count2 > 1) { int countIndexLeft1 = 0; int countIndexLeft2 = 0; for (int i = 0; i < 4; i++) { if (Newpoint[i].CurrentPoint.Position.X <= midX && Newpoint[i].CurrentPoint.Position.Y < midY) { countIndexLeft1++; if (countIndexLeft1 > 1) { if (Newpoint[i].CurrentPoint.Position.X < orderedPoints[0].CurrentPoint.Position.X) { orderedPoints[1] = argPoints[i]; } else { orderedPoints[1] = orderedPoints[0]; orderedPoints[0] = argPoints[i]; } break; } orderedPoints[0] = argPoints[i]; } } double disLeft = 0; for (int i = 0; i < 4; i++) { if (Newpoint[i].CurrentPoint.Position.X >= midX && Newpoint[i].CurrentPoint.Position.Y > midY) { countIndexLeft2++; if (countIndexLeft2 > 1) { double temp = Math.Pow((Newpoint[i].CurrentPoint.Position.X - orderedPoints[1].CurrentPoint.Position.X), 2) + Math.Pow((Newpoint[i].CurrentPoint.Position.Y - orderedPoints[1].CurrentPoint.Position.Y), 2); if (temp > disLeft) { orderedPoints[3] = argPoints[i]; } else { orderedPoints[3] = orderedPoints[2]; orderedPoints[2] = argPoints[i]; } break; } orderedPoints[2] = argPoints[i]; disLeft = Math.Pow((Newpoint[i].CurrentPoint.Position.X - orderedPoints[1].CurrentPoint.Position.X), 2) + Math.Pow((Newpoint[i].CurrentPoint.Position.Y - orderedPoints[1].CurrentPoint.Position.Y), 2); } } } } else { for (int i = 0; i < 4; i++) { if (Newpoint[i].CurrentPoint.Position.X > midX && Newpoint[i].CurrentPoint.Position.Y < midY) { orderedPoints[0] = argPoints[i]; } else if (Newpoint[i].CurrentPoint.Position.X < midX && Newpoint[i].CurrentPoint.Position.Y < midY) { orderedPoints[1] = argPoints[i]; } else if (Newpoint[i].CurrentPoint.Position.X < midX && Newpoint[i].CurrentPoint.Position.Y > midY) { orderedPoints[2] = argPoints[i]; } else if (Newpoint[i].CurrentPoint.Position.X > midX && Newpoint[i].CurrentPoint.Position.Y > midY) { orderedPoints[3] = argPoints[i]; } } } List<Card> objects = new List<Card>(); lock (cards) { foreach (Card c in cards) { if (pnpoly(orderedPoints, c.CurrentPosition.X, c.CurrentPosition.Y)) { objects.Add(c); } } } if (objects.Count > 0) { Gesture_Event_Grouping gestureEvent = new Gesture_Event_Grouping(); gestureEvent.Points = orderedPoints; gestureEvent.Senders = objects.ToArray(); Gesture_List.addGesture(gestureEvent); Gesture_Grouping_Listener gestureListener = new Gesture_Grouping_Listener(this, gestureEvent); gestureEvent.Register(objects.ToArray(), orderedPoints); foreach (My_Point p in result) { points.Remove(p); } return gestureEvent; } return null; } else { return null; } }