/// <summary> /// ドラッグ移動中のThumbとその他のThumbとの重なり合う部分の面積を計算、 /// 一定以上の面積があった場合、場所を入れ替えて整列 /// </summary> /// <param name="t">ドラッグ移動中のThumb</param> private void Idou移動中処理(FlatThumb t) { t.Opacity = 0.7; var p = MyCanvas.PointToScreen(new Point()); RectangleGeometry geometry = GetThumbGeometry(t, p); int imaIndex = MyThumbs.IndexOf(t);//ドラッグ移動中ThumbのIndex MyStatus.Content = imaIndex.ToString(); //重なり面積のリスト作成 List <double> kasanai面積 = MakeList(geometry, p); //面積最大のindex取得、これはIndexになる int sakiIndex = 0; double max = 0; for (int i = 0; i < kasanai面積.Count; i++) { if (max < kasanai面積[i] && i != imaIndex) { max = kasanai面積[i]; sakiIndex = i; } } //移動中ThumbのIndexに対応するRectと、移動中ThumbのRect重なり面積 int x = imaIndex % 3 * 100;//元のx座標 int y = imaIndex / 3 * 100; var idxGeo = new RectangleGeometry(new Rect(new Point(x, y), new Size(100, 100))); var ima重なりbound = Geometry.Combine(idxGeo, geometry, GeometryCombineMode.Intersect, null).Bounds; var ima重なり面積 = ima重なりbound.Width * ima重なりbound.Height; //重なり面積が4000(4割)以上のThumbがある //and indexRectとの重なり面積が直前より減っていたら //移動中Thumbと入れ替える if (max > 4000 && moto重なり面積 > ima重なり面積) { //Thumbのindexと場所並べ替え SortIndexPlace(sakiIndex, imaIndex, t, geometry); } else { moto重なり面積 = ima重なり面積; } }