Пример #1
0
 private void label1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (m_pntMouseDownLoc == null)
     {
         return;
     }
     m_bMouseMoveDown = false;
     System.Windows.Forms.Cursor.Position = label1.PointToScreen(m_pntMouseDownLoc.ToPoint());
 }
Пример #2
0
        private void label1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (!m_bMouseMoveDown)
            {
//				string sText = this.label1.Text.Split(" ".ToCharArray())[0];
                EPoint  pntMid   = new EPoint(this.label1.Left, this.label1.Top) + new EPoint(this.label1.Width, this.label1.Height) / 2;
                EPoint  pntMouse = new EPoint(e.X, e.Y);                //this.label1.PointToClient(new Point(e.X, e.Y))
                EPointF pntDiff  = (pntMouse - pntMid).ToEPointF();
                if (pntDiff.Length < 0.8f * this.label1.Width / 2)
                {
                    m_pntActiveAxes = new EPoint(1, 1);
                }
                else
                {
                    if ((pntDiff.Angle > Math.PI / 4 && pntDiff.Angle < 3 * Math.PI / 4) ||
                        (pntDiff.Angle < -Math.PI / 4 && pntDiff.Angle > -3 * Math.PI / 4))
                    {
                        m_pntActiveAxes = new EPoint(1, 0);
                    }
                    else
                    {
                        m_pntActiveAxes = new EPoint(0, 1);
                    }
                }


                if (m_pntActiveAxes.X == 1 && m_pntActiveAxes.Y == 1)
                {
//					sText+=" XY";
                    this.Cursor = System.Windows.Forms.Cursors.SizeAll;
                }
                else if (m_pntActiveAxes.X == 1)
                {
//					sText+=" X";
                    this.Cursor = System.Windows.Forms.Cursors.SizeWE;
                }
                else if (m_pntActiveAxes.Y == 1)
                {
//					sText+=" Y";
                    this.Cursor = System.Windows.Forms.Cursors.SizeNS;
                }

//				this.label1.Text = sText;
            }
            else
            {
                EPoint pntNow  = new EPoint(e.X, e.Y);
                EPoint pntDiff = pntNow - m_pntMouseLastLoc;
                //CameraMove(pntDiff.ToEPointF());

                //If mouse moves outside screen, wrap it around the edges:

                EPoint pntScreen = new EPoint(label1.PointToScreen(m_pntMouseLastLoc.ToPoint()));
                EPoint pntOrg    = pntScreen.Copy();

                ERectangle rct = new ERectangle(System.Windows.Forms.Screen.PrimaryScreen.WorkingArea);
                rct = rct + new ERectangle(5, 5, -10, -10);
                rct.WrapPointInside(pntScreen);

                if (!pntOrg.Equals(pntScreen))
                {
                    System.Windows.Forms.Cursor.Position = pntScreen.ToPoint();
                    pntNow           = new EPoint(label1.PointToClient(pntScreen.ToPoint()));
                    m_pntWrappedAdd += pntOrg - pntScreen;
                }

                //when using timer - don't send on mouse move
                if (timer1.Enabled == false)
                {
                    if (DraggingEvent != null)
                    {
                        DraggingEvent(this, pntDiff.ToEPointF() * m_pntFactor * m_pntActiveAxes);
                    }
                }

                m_pntMouseLastLoc = pntNow;
            }
        }
Пример #3
0
        private void label1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (!m_bMouseMoveDown)
            {
            //				string sText = this.label1.Text.Split(" ".ToCharArray())[0];
                EPoint pntMid = new EPoint(this.label1.Left, this.label1.Top) + new EPoint(this.label1.Width, this.label1.Height)/2;
                EPoint pntMouse = new EPoint(e.X, e.Y); //this.label1.PointToClient(new Point(e.X, e.Y))
                EPointF pntDiff = (pntMouse-pntMid).ToEPointF();
                if (pntDiff.Length < 0.8f*this.label1.Width/2)
                    m_pntActiveAxes = new EPoint(1,1);
                else
                {
                    if ((pntDiff.Angle > Math.PI/4 && pntDiff.Angle < 3*Math.PI/4) ||
                        (pntDiff.Angle < -Math.PI/4 && pntDiff.Angle > -3*Math.PI/4))
                        m_pntActiveAxes = new EPoint(1,0);
                    else
                        m_pntActiveAxes = new EPoint(0,1);
                }

                if (m_pntActiveAxes.X == 1 && m_pntActiveAxes.Y == 1)
                {
            //					sText+=" XY";
                    this.Cursor = System.Windows.Forms.Cursors.SizeAll;
                }
                else if (m_pntActiveAxes.X == 1)
                {
            //					sText+=" X";
                    this.Cursor = System.Windows.Forms.Cursors.SizeWE;
                }
                else if (m_pntActiveAxes.Y == 1)
                {
            //					sText+=" Y";
                    this.Cursor = System.Windows.Forms.Cursors.SizeNS;
                }

            //				this.label1.Text = sText;
            }
            else
            {
                EPoint pntNow = new EPoint(e.X, e.Y);
                EPoint pntDiff = pntNow-m_pntMouseLastLoc;
                //CameraMove(pntDiff.ToEPointF());

                //If mouse moves outside screen, wrap it around the edges:

                EPoint pntScreen = new EPoint(label1.PointToScreen(m_pntMouseLastLoc.ToPoint()));
                EPoint pntOrg = pntScreen.Copy();

                ERectangle rct = new ERectangle(System.Windows.Forms.Screen.PrimaryScreen.WorkingArea);
                rct = rct + new ERectangle(5,5,-10,-10);
                rct.WrapPointInside(pntScreen);

                if (!pntOrg.Equals(pntScreen))
                {
                    System.Windows.Forms.Cursor.Position = pntScreen.ToPoint();
                    pntNow = new EPoint(label1.PointToClient(pntScreen.ToPoint()));
                    m_pntWrappedAdd+=pntOrg-pntScreen;
                }

                //when using timer - don't send on mouse move
                if (timer1.Enabled == false)
                    if (DraggingEvent!=null) DraggingEvent(this, pntDiff.ToEPointF()*m_pntFactor*m_pntActiveAxes);

                m_pntMouseLastLoc = pntNow;
            }
        }