Пример #1
0
        //ドラッグ移動終了イベント時、
        //最寄りというか空いている(あるべき)場所に移動させる
        private void Thumb_DragCompleted(object sender, DragCompletedEventArgs e)
        {
            FlatThumb t        = sender as FlatThumb;
            int       imaIndex = MyThumbs.IndexOf(t);

            //元のx座標へ移動
            Canvas.SetLeft(t, MyPoints[imaIndex].X);
            Canvas.SetTop(t, MyPoints[imaIndex].Y);

            MyStatus.Content = "";
        }
Пример #2
0
        //ドラッグ移動イベント時
        private void Thumb_DragDelta(object sender, DragDeltaEventArgs e)
        {
            //移動
            FlatThumb t = sender as FlatThumb;
            double    x = Canvas.GetLeft(t) + e.HorizontalChange;
            double    y = Canvas.GetTop(t) + e.VerticalChange;

            Canvas.SetLeft(t, x);
            Canvas.SetTop(t, y);
            t.Opacity = 0.5;

            Idou移動中処理(t, x, y);
        }
Пример #3
0
        /// <summary>
        /// ドラッグ移動中のThumbとその他のThumbとの重なり合う部分の面積を計算、
        /// 一定以上の面積があった場合、場所を入れ替えて整列
        /// </summary>
        /// <param name="t">ドラッグ移動中のThumb</param>
        /// <param name="x">Canvas上でのX座標</param>
        /// <param name="y">Canvas上でのY座標</param>
        private void Idou移動中処理(FlatThumb t, double x, double y)
        {
            t.Opacity = 0.7;
            int imaIndex = MyThumbs.IndexOf(t);//ドラッグ移動中ThumbのIndex

            MyStatus.Content = imaIndex.ToString();

            //IndexPoint(元の位置)との距離
            Point  imaPoint = new(x, y);
            double ima距離    = GetDistance(MyPoints[imaIndex], imaPoint);

            //最寄りのPoint
            int    moyoriIndex = 0;
            double moyori距離    = double.MaxValue;

            for (int i = 0; i < MyPoints.Count; i++)
            {
                double distance = GetDistance(MyPoints[i], imaPoint);
                if (distance < moyori距離)
                {
                    moyori距離    = distance;
                    moyoriIndex = i;
                }
            }

            //一定距離以下の場所がある and 今の距離が直前より大きければ入れ替え処理
            if (60 > moyori距離 && ima距離 > Paste距離)
            {
                //Thumbリストのindexを入れ替え
                MyThumbs.RemoveAt(imaIndex);
                MyThumbs.Insert(moyoriIndex, t);

                //indexに従って表示位置変更
                ReplaceThumb表示位置更新(moyoriIndex);

                //入れ替えで元の位置が変更になったので再計算して直前の距離に記録
                Paste距離 = GetDistance(MyPoints[moyoriIndex], imaPoint);
            }
            else
            {
                //今の距離を直前の距離に記録
                Paste距離 = ima距離;
            }
        }
Пример #4
0
 //Thumbの表示位置指定
 private void SetThumbLocate(FlatThumb t, double left, double top)
 {
     Canvas.SetLeft(t, left);
     Canvas.SetTop(t, top);
 }