| .NET DotNet Forum Index » General Discussion » Pan WinForm PictureBox... |
|
Page 1 of 1 |
|
| Author |
Message |
| Jon... |
Posted: Fri Oct 30, 2009 1:40 am |
|
|
|
Guest
|
Hello all.
I have an ImagePanel that contains and ImageBox. It allows zooming and
has a couple of Scroll Bars that at the moment are the only way to
move about. A link to the code is here: http://www.codeproject.com/KB/miscctrl/zoompancontrol.aspx
I'd like to add in the functionality where a user could 'grab' the
image to pan it around. Can anyone please help?
Jon |
|
|
| Back to top |
|
|
|
| Jon... |
Posted: Fri Oct 30, 2009 5:54 am |
|
|
|
Guest
|
On 30 Oct, 14:11, John Bundy <jmbu... at (no spam) gmail.com(remove)> wrote:
Quote: This worked for me on a fairly small image. I added a sensitivity that I
through into the calculation to adjust the speed of movement as desired.
Public Class Form1
Dim x1, y1 As Double
Dim scrollSensitivity As Double
Dim md As Boolean
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
md = True
x1 = Me.Panel1.HorizontalScroll.Value
y1 = Me.Panel1.VerticalScroll.Value
End Sub
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
scrollSensitivity = 4
If md = True Then
Try
Me.Panel1.HorizontalScroll.Value = (e.X - x1) /
scrollSensitivity
Me.Panel1.VerticalScroll.Value = (e.Y - y1) /
scrollSensitivity
Catch ex As Exception
End Try
End If
End Sub
Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
md = False
End Sub
--
-Johnhttp://www.jmbundy.blogspot.com/
Please rate when your question is answered to help us and others know what
is helpful.
"Jon" wrote:
Hello all.
I have an ImagePanel that contains and ImageBox. It allows zooming and
has a couple of Scroll Bars that at the moment are the only way to
move about. A link to the code is here:http://www.codeproject.com/KB/miscctrl/zoompancontrol.aspx
I'd like to add in the functionality where a user could 'grab' the
image to pan it around. Can anyone please help?
Jon
.
Thanks John, I'll have a go. |
|
|
| Back to top |
|
|
|
| John Bundy... |
Posted: Fri Oct 30, 2009 8:11 am |
|
|
|
Guest
|
This worked for me on a fairly small image. I added a sensitivity that I
through into the calculation to adjust the speed of movement as desired.
Public Class Form1
Dim x1, y1 As Double
Dim scrollSensitivity As Double
Dim md As Boolean
Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
md = True
x1 = Me.Panel1.HorizontalScroll.Value
y1 = Me.Panel1.VerticalScroll.Value
End Sub
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
scrollSensitivity = 4
If md = True Then
Try
Me.Panel1.HorizontalScroll.Value = (e.X - x1) /
scrollSensitivity
Me.Panel1.VerticalScroll.Value = (e.Y - y1) /
scrollSensitivity
Catch ex As Exception
End Try
End If
End Sub
Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
md = False
End Sub
--
-John http://www.jmbundy.blogspot.com/
Please rate when your question is answered to help us and others know what
is helpful.
"Jon" wrote:
Quote: Hello all.
I have an ImagePanel that contains and ImageBox. It allows zooming and
has a couple of Scroll Bars that at the moment are the only way to
move about. A link to the code is here: http://www.codeproject.com/KB/miscctrl/zoompancontrol.aspx
I'd like to add in the functionality where a user could 'grab' the
image to pan it around. Can anyone please help?
Jon
.
|
|
|
| Back to top |
|
|
|
|