public Point getDrawingPoint(Point drawingOffset, PointDouble offset, double Zoom = 1.0) { double tX = this.X * Zoom; double tY = this.Y * Zoom; if (offset == null) { return new Point((int)Math.Round(tX), (int)Math.Round(tY)); } else { offset = offset.Mul(Zoom); Point result = new Point((int)Math.Round(tX), (int)Math.Round(tY)); result.X += drawingOffset.X + (int)Math.Round(offset.X); result.Y += drawingOffset.Y + (int)Math.Round(offset.Y); return result; } }
/// <summary> /// Wywoływana podczas każdego przemieszczenia myszy nad panelem przelicza przesunięcie /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void panelCanvas_MouseMove(object sender, MouseEventArgs e) { PKMap.SetCursorPos(new Point(e.Location.X - drawMiddle.X, e.Location.Y - drawMiddle.Y)); if(e.Button == MouseButtons.Right) { PointDouble change = new PointDouble(e.Location.X - mapPanStart.X, e.Location.Y - mapPanStart.Y); change = change.Mul(1.0/PKMap.Zoom); PKMap.Offset = PKMap.TempOffset.Add(change); } }