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; } }
public bool CheckMouse(MouseEventArgs e, EPointF a_pntLocalLoc, bool a_bButtonAction, bool a_bDown) { _pntMouse.X = e.X; //a_pntLocalLoc; _pntMouse.Y = e.Y; if (e.Button != MouseButtons.Left && this.m_bMouseReactToOtherThanLeftButton == false) { return(true); } bool bReactedToButton = false; bool bReactedRoll = false; //TODO: make property of bMouseNotOutsideWhileDown bool bMouseNotOutsideWhileDown = true; if (m_bMouseDown && a_bDown && bMouseNotOutsideWhileDown) { OnMouse(e, MouseEventType.StillDown); } else { if (Rect.Contains(a_pntLocalLoc)) { if (!m_bMouseIsInside) { //enter bReactedRoll = true; m_bMouseIsInside = true; OnMouse(e, MouseEventType.Enter); } if (a_bButtonAction) { if (a_bDown) { m_pntMouseDown.X = e.X; m_pntMouseDown.Y = e.Y; m_pntMouseLast = m_pntMouseDown.Copy(); OnMouse(e, MouseEventType.Down); //EH.Put("Down:"+this.GetSceneGraphName()); } else { if (m_bMouseDown) { OnMouse(e, MouseEventType.Click); } else { OnMouse(e, MouseEventType.Up); } } bReactedToButton = true; } else if (m_bMouseDown) { OnMouse(e, MouseEventType.StillDown); bReactedToButton = true; } } else { if (m_bMouseIsInside) { //leave bReactedRoll = true; m_bMouseIsInside = false; OnMouse(e, MouseEventType.Leave); } if (a_bButtonAction && !a_bDown && m_bMouseDown) //got mouseUp event, and mouse was down before { m_bMouseDown = false; OnMouse(e, MouseEventType.UpOutside); } } } m_pntMouseLast.X = e.X; m_pntMouseLast.Y = e.Y; if (bReactedToButton) { m_bMouseDown = a_bDown; } if (!this._passEvent) { //Can't stop checking completely: sprites under might need to send Leave, or UpOutside... if (bReactedToButton && !m_bMousePassButton) { return(false); } if (m_bMouseIsInside && false) //TODO: pass? bReactedRoll { return(false); } } else { this._passEvent = false; } return(true); }
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; } }