public static void MoveItemToTop <T>(this FastObservableCollection <T> collection, T item) { using (collection.SuspendChangeNotifications()) { collection.Remove(item); collection.Insert(0, item); } }
//A More exact Mouse In PolygonCheck public static bool MouseIsInPolygon(FastObservableCollection<INode> poly, PolyPoint point) { Vector3 vecPoint = new Vector3(point.X, point.Y,0); var tempList = new FastObservableCollection<INode>(); foreach (var node in poly) { tempList.Add(node); } //Copy the list so we can add the last two verts into the start so we can get a full circle check easy. tempList.Insert(0,tempList[tempList.Count-2]); tempList.Insert(0,tempList[tempList.Count-1]); for (int i = 1; i < tempList.Count - 2; i++) { //we'll feed 3 verts at a time to PointInTriangle to see if it returns true or not. If one time returns true then we can stop calculating Vector3 A = new Vector3((tempList[0] as PolyPoint).X, (tempList[0] as PolyPoint).Y ,0); Vector3 B = new Vector3((tempList[i + 1] as PolyPoint).X, (tempList[i + 1] as PolyPoint).Y,0); Vector3 C = new Vector3((tempList[i + 2] as PolyPoint).X, (tempList[i + 2] as PolyPoint).Y,0); if (PointInTriangle(ref A, ref B, ref C, ref vecPoint)) { return true; } } return false; }