コード例 #1
0
        public bool Hit_Test(int x, int y)
        {
            Point pt = new Point(x, y);

            if (!this.ControlRect.Contains(pt))
            {
                Cursor.Current = Cursors.Arrow;
                return(false);
            }
            if (this.SmallRect[0].Contains(pt))
            {
                Cursor.Current    = Cursors.SizeNWSE;
                this.CurrHitPlace = HitDownSquare.HDS_TOPLEFT;
            }
            else if (this.SmallRect[3].Contains(pt))
            {
                Cursor.Current    = Cursors.SizeNWSE;
                this.CurrHitPlace = HitDownSquare.HDS_BOTTOMRIGHT;
            }
            else if (this.SmallRect[1].Contains(pt))
            {
                Cursor.Current    = Cursors.SizeNESW;
                this.CurrHitPlace = HitDownSquare.HDS_TOPRIGHT;
            }
            else if (this.SmallRect[2].Contains(pt))
            {
                Cursor.Current    = Cursors.SizeNESW;
                this.CurrHitPlace = HitDownSquare.HDS_BOTTOMLEFT;
            }
            else if (this.SmallRect[4].Contains(pt))
            {
                Cursor.Current    = Cursors.SizeNS;
                this.CurrHitPlace = HitDownSquare.HDS_TOP;
            }
            else if (this.SmallRect[5].Contains(pt))
            {
                Cursor.Current    = Cursors.SizeNS;
                this.CurrHitPlace = HitDownSquare.HDS_BOTTOM;
            }
            else if (this.SmallRect[6].Contains(pt))
            {
                Cursor.Current    = Cursors.SizeWE;
                this.CurrHitPlace = HitDownSquare.HDS_LEFT;
            }
            else if (this.SmallRect[7].Contains(pt))
            {
                Cursor.Current    = Cursors.SizeWE;
                this.CurrHitPlace = HitDownSquare.HDS_RIGHT;
            }
            else if (this.ControlRect.Contains(pt))
            {
                Cursor.Current    = Cursors.SizeAll;
                this.CurrHitPlace = HitDownSquare.HDS_NONE;
            }
            return(true);
        }
コード例 #2
0
 /// <summary>
 /// 设置鼠标Cursor和相应位置CurrHitPlace
 /// </summary>
 /// <param name="element"></param>
 /// <param name="point"></param>
 /// <returns></returns>
 public bool Hit_Test(FrameworkElement element, Point point)
 {
     switch (element.Name)
     {
         case "SmallRect0":
             {
                 element.Cursor = Cursors.Hand; //.SizeNWSE;
                 CurrHitPlace = HitDownSquare.HDS_TOPLEFT;
                 break;
             }
         case "SmallRect3":
             {
                 element.Cursor = Cursors.Hand;//  .SizeNWSE;
                 CurrHitPlace = HitDownSquare.HDS_BOTTOMRIGHT;
                 break;
             }
         case "SmallRect1":
             {
                 element.Cursor = Cursors.Hand;//  .SizeNESW;
                 CurrHitPlace = HitDownSquare.HDS_TOPRIGHT;
                 break;
             }
         case "SmallRect2":
             {
                 element.Cursor = Cursors.Hand;//  .SizeNESW;
                 CurrHitPlace = HitDownSquare.HDS_BOTTOMLEFT;
                 break;
             }
         case "SmallRect4":
             {
                 element.Cursor = Cursors.SizeNS;
                 CurrHitPlace = HitDownSquare.HDS_TOP;
                 break;
             }
         case "SmallRect5":
             {
                 element.Cursor = Cursors.SizeNS;
                 CurrHitPlace = HitDownSquare.HDS_BOTTOM;
                 break;
             }
         case "SmallRect6":
             {
                 element.Cursor = Cursors.SizeWE;
                 CurrHitPlace = HitDownSquare.HDS_LEFT;
                 break;
             }
         case "SmallRect7":
             {
                 element.Cursor = Cursors.SizeWE;
                 CurrHitPlace = HitDownSquare.HDS_RIGHT;
                 break;
             }
         default:
             {
                 FocusRect.Cursor = Cursors.Arrow;
                 CurrHitPlace = HitDownSquare.HDS_NONE;
                 break;
             }
     }
     return true;
 }
コード例 #3
0
        /// <summary>
        /// 设置鼠标Cursor和相应位置CurrHitPlace
        /// </summary>
        /// <param name="element"></param>
        /// <param name="point"></param>
        /// <returns></returns>
        public bool Hit_Test(FrameworkElement element, Point point)
        {
            switch (element.Name)
            {
            case "SmallRect0":
            {
                element.Cursor = Cursors.Hand;         //.SizeNWSE;
                CurrHitPlace   = HitDownSquare.HDS_TOPLEFT;
                break;
            }

            case "SmallRect3":
            {
                element.Cursor = Cursors.Hand;        //  .SizeNWSE;
                CurrHitPlace   = HitDownSquare.HDS_BOTTOMRIGHT;
                break;
            }

            case "SmallRect1":
            {
                element.Cursor = Cursors.Hand;        //  .SizeNESW;
                CurrHitPlace   = HitDownSquare.HDS_TOPRIGHT;
                break;
            }

            case "SmallRect2":
            {
                element.Cursor = Cursors.Hand;        //  .SizeNESW;
                CurrHitPlace   = HitDownSquare.HDS_BOTTOMLEFT;
                break;
            }

            case "SmallRect4":
            {
                element.Cursor = Cursors.SizeNS;
                CurrHitPlace   = HitDownSquare.HDS_TOP;
                break;
            }

            case "SmallRect5":
            {
                element.Cursor = Cursors.SizeNS;
                CurrHitPlace   = HitDownSquare.HDS_BOTTOM;
                break;
            }

            case "SmallRect6":
            {
                element.Cursor = Cursors.SizeWE;
                CurrHitPlace   = HitDownSquare.HDS_LEFT;
                break;
            }

            case "SmallRect7":
            {
                element.Cursor = Cursors.SizeWE;
                CurrHitPlace   = HitDownSquare.HDS_RIGHT;
                break;
            }

            default:
            {
                FocusRect.Cursor = Cursors.Arrow;
                CurrHitPlace     = HitDownSquare.HDS_NONE;
                break;
            }
            }
            return(true);
        }
コード例 #4
0
ファイル: MyRectControl.cs プロジェクト: buweixiaomi/TempP
 private void ResetMove()
 {
     if (size_or_move_action)
     {
         Create();
         this.Visible = true;
         size_or_move_action = false;
     }
     mousedownpoint = HitDownSquare.HDS_NONE;
     mouse_point = new Point(0, 0);
     MakeLine();
 }
コード例 #5
0
ファイル: MyRectControl.cs プロジェクト: buweixiaomi/TempP
        private void MyRectControl_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button != System.Windows.Forms.MouseButtons.Left)
            {
                ResetMove();
            }
            currmousepoint = GetPositionOfMouse(e.X, e.Y);
            if (!size_or_move_action)
            {
                this.Cursor = GetMouthType(currmousepoint);
            }

            this.ParentForm.Text = string.Format("({0},{1})", e.X, e.Y);

            if (size_or_move_action)
            {
                if (e.X == mouse_point.X && e.Y == mouse_point.Y)
                {
                    return;
                }
                ResizeOrMove(e.X, e.Y);
                mouse_point = new Point(e.X, e.Y);
                MakeLine();
            }
        }
コード例 #6
0
ファイル: MyRectControl.cs プロジェクト: buweixiaomi/TempP
 private void MyRectControl_MouseDown(object sender, MouseEventArgs e)
 {
     ResetMove();
     mousedownpoint = GetPositionOfMouse(e.X, e.Y);
     if (e.Button == System.Windows.Forms.MouseButtons.Left)
     {
         if (mousedownpoint == HitDownSquare.HDS_NONE)
         {
             size_or_move_action = false;
             mouse_point = new Point(0, 0);
         }
         else
         {
             size_or_move_action = true;
             mouse_point = new Point(e.X, e.Y);
             MakeLine();
             this.Focus();
         }
     }
 }
コード例 #7
0
ファイル: MyRectControl.cs プロジェクト: buweixiaomi/TempP
 private Cursor GetMouthType(HitDownSquare i)
 {
     Cursor tempcursor = System.Windows.Forms.Cursors.Default;
     switch (i)
     {
         case HitDownSquare.HDS_WN:
             tempcursor = System.Windows.Forms.Cursors.SizeNWSE;
             break;
         case HitDownSquare.HDS_N:
             tempcursor = System.Windows.Forms.Cursors.SizeNS;
             break;
         case HitDownSquare.HDS_EN:
             tempcursor = System.Windows.Forms.Cursors.SizeNESW;
             break;
         case HitDownSquare.HDS_E:
             tempcursor = System.Windows.Forms.Cursors.SizeWE;
             break;
         case HitDownSquare.HDS_ES:
             tempcursor = System.Windows.Forms.Cursors.SizeNWSE;
             break;
         case HitDownSquare.HDS_S:
             tempcursor = System.Windows.Forms.Cursors.SizeNS;
             break;
         case HitDownSquare.HDS_WS:
             tempcursor = System.Windows.Forms.Cursors.SizeNESW;
             break;
         case HitDownSquare.HDS_W:
             tempcursor = System.Windows.Forms.Cursors.SizeWE;
             break;
         case HitDownSquare.HDS_INNER:
             tempcursor = System.Windows.Forms.Cursors.SizeAll;
             break;
         default:
             break;
     }
     return tempcursor;
 }