public void OnPaint(System.Windows.Forms.PaintEventArgs e) { //TODO: DK Ej OnPaint!! //Application.DoEvents(); System.Drawing.Point pnt = this.Stage.RenderControl.PointToScreen(new Point(0, 0)); m_pntMouseLoc.X = System.Windows.Forms.Form.MousePosition.X - pnt.X; m_pntMouseLoc.Y = System.Windows.Forms.Form.MousePosition.Y - pnt.Y; if (Stage == null) { return; } if (EnterFrameEvent != null) { EnterFrameEvent(); } if (m_bSendMouseEventsToSprites || true) //TODO: .... { Stage.RootSprite.CheckChildrenMouse(new MouseEventArgs(System.Windows.Forms.Control.MouseButtons, 0, m_pntMouseLoc.X, m_pntMouseLoc.Y, 0), m_pntMouseLoc.ToEPointF(), false, m_bMouseDown); //TODO: unnecessary to check sprites again. Optimize! ArrayList aSprites = Stage.RootSprite.GetSpritesUnderLoc(m_pntMouseLoc.ToEPointF(), 1); if (aSprites.Count > 0 && ((Sprite)aSprites[0]).Cursor != null) { object cursor = ((Sprite)aSprites[0]).Cursor; if (cursor.GetType() == typeof(System.Windows.Forms.Cursor)) { this.Stage.RenderControl.Cursor = (System.Windows.Forms.Cursor)cursor; } } else { this.Stage.RenderControl.Cursor = System.Windows.Forms.Cursors.Default; } } //TODO: remove, just testing renderToTexture: bool renderToTexture = false; // (System.Windows.Forms.Control.ModifierKeys == System.Windows.Forms.Keys.Shift); if (renderToTexture) { //this.Stage.Capture(); Endogine.BitmapHelpers.PixelDataProvider pdp = this.Stage.CreatePixelDataProvider(256, 256, 4); this.Stage.RenderTarget = pdp; } this._stage.Update(); if (renderToTexture) { this.Stage.RenderTarget = null; } }
private void CheckKeys() { if (this.keysSteering == null) { return; } EPoint pntMove = new EPoint(); if (keysSteering.GetKeyActive("up")) { pntMove.Y = -1; } else if (keysSteering.GetKeyActive("down")) { pntMove.Y = 1; } if (keysSteering.GetKeyActive("left")) { pntMove.X = -1; } else if (keysSteering.GetKeyActive("right")) { pntMove.X = 1; } if (pntMove.X != 0 || pntMove.Y != 0) { if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift) { pntMove *= 10; } if ((Control.ModifierKeys & Keys.Control) == Keys.Control) { pntMove *= 100; } if (KeyMoveEvent != null) { KeyMoveEvent(this, pntMove.ToEPointF()); } } }
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; } }
private void m_resizeCorner_MouseEvent(Sprite sender, System.Windows.Forms.MouseEventArgs e, MouseEventType t) { if (t==Sprite.MouseEventType.StillDown) { EPoint pntDiff = new EPoint(e.X-m_resizeCorner.MouseLastLoc.X, e.Y-m_resizeCorner.MouseLastLoc.Y); Rect = new ERectangleF(Rect.Location, Rect.Size+pntDiff.ToEPointF());//SizeF(Rect.Size.Width+pntDiff.X,Rect.Size.Height+pntDiff.Y)); } }