Hello,
I trying to implement a Zoomable and panable image But in
<winforms>without the scrollbars value proprety,
with the zooming everything fine,
the problem is
but when I try to calculate the x and y for panning everything goes wrong ,image goes off borders and acts strangely ,
heres my code with the scroll bar values and here it working fine :
mousemove event
if (m_drawing && CurrentZoomRate >1)
{
int DeltaX = (m_StartingPoint.X - e.X);
int DeltaY = (m_StartingPoint.Y - e.Y);
this.pbImage.x = DeltaX;
this.pbImage.y = DeltaY;
pbimage.AutoScrollPosition= new System.Drawing.Point(Math.Abs(DeltaX - AutoScrollPosition.X), Math.Abs(DeltaY - AutoScrollPosition.Y));
and here when i trying to do it without out the scroll bars(that my goal without them)
and everything goes wrong
int DeltaX = (m_StartingPoint.X - e.X);
int DeltaY = (m_StartingPoint.Y - e.Y);
this.pbImage.x = DeltaX;
this.pbImage.y = DeltaY;
this.pbImage.Refresh();
and here is my paintevent (taken from bobpowell.net)
Matrix mx = new Matrix(_zoom, 0, 0, _zoom, 0, 0);
mx.Translate(this.x / _zoom, this.y / _zoom);
e.Graphics.Transform = mx;
e.Graphics.InterpolationMode = _interpolationMode;
e.Graphics.DrawImage(_image, new Rectangle(0, 0, this._image.Width, this._image.Height), 0, 0, _image.Width, _image.Height, GraphicsUnit.Pixel);
base.OnPaint(e);
can anyone have idea how to preform this calculations ?
I also trying to make the invisible but the ccalculation of this
"
this.AutoScrollMinSize=new Size(
(int)(this._image.Width*_zoom+0.5f),
(int)(this._image.Height*_zoom+0.5f)
always turn the invisible to true , trying to set it of in the paint event jst get my endless flickering .