Vb.net 如何在面板中维护picturebox的位置

Vb.net 如何在面板中维护picturebox的位置,vb.net,zooming,coordinates,trackbar,Vb.net,Zooming,Coordinates,Trackbar,我想保持picturebox2在面板内的位置。在我的例子中,图像如下所示。。(有一个map/picturebox1/,绿色定位器或指针是另一个picturebox/picturebox2/) 是否可以在不丢失正确坐标的情况下放大和缩小图像?因为我想保持定位器(picturebox2)在地图(picturebox1)中的位置 到目前为止,我现在可以使用轨迹栏在可滚动面板中放大和缩小图像。但我唯一的问题是,picturebox2(picturebox1上方的另一幅图像)需要在picturebox1缩

我想保持picturebox2在面板内的位置。在我的例子中,图像如下所示。。(有一个map/picturebox1/,绿色定位器或指针是另一个picturebox/picturebox2/)

是否可以在不丢失正确坐标的情况下放大和缩小图像?因为我想保持定位器(picturebox2)在地图(picturebox1)中的位置

到目前为止,我现在可以使用轨迹栏在可滚动面板中放大和缩小图像。但我唯一的问题是,picturebox2(picturebox1上方的另一幅图像)需要在picturebox1缩放时移动其位置

Public ClassForm1
Private img original As Image
Private m_PanStartPoint As New Point
Private n_PanStartPoint As New Point

Private Sub Form1_Load(ByVal sender AsSystem.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load
imgoriginal = Image.FromFile("C:\New Folder\picture1.jpg")
        PictureBox1.BackgroundImageLayout = ImageLayout.Stretch
zoomSlider.Minimum = 1
zoomSlider.Maximum = 5
zoomSlider.SmallChange = 1
zoomSlider.LargeChange = 1
zoomSlider.UseWaitCursor = False
Me.DoubleBuffered = True
        Panel1.AutoScroll = True
        PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize
        PictureBox1.Parent = PictureBox1
        PictureBox2.Parent = PictureBox1
        PictureBox1.BackColor = Color.Transparent
Dim mstream As NewSystem.IO.MemoryStream()
    PictureBox1.Image = Image.FromStream(mstream)
    PictureBox2.Location = NewSystem.Drawing.Point(100, 100)
End Sub

Public Function pictureboxzoom(ByValimgAsImage, ByVal size AsSize) AsImage
Dim bm As Bitmap = New Bitmap(img, Convert.ToInt32(img.Width * size.Width),     Convert.ToInt32(img.Height * size.Height))
Dim grap As Graphics = Graphics.FromImage(bm)
grap.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
Return bm
    End Function

Private Sub zoomSlider_Scroll(ByVal sender AsSystem.Object, ByVal e     AsSystem.EventArgs) Handles zoomSlider.Scroll
If zoomSlider.Value> 0 Then
            PictureBox1.Image = Nothing
            PictureBox1.Image = pictureboxzoom(imgoriginal, New     Size(zoomSlider.Value, zoomSlider.Value))
End If
End Sub

Private Sub PictureBox1_MouseDown(ByVal sender AsObject, ByVal e AsSystem.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
m_PanStartPoint = NewPoint(e.X, e.Y)
End Sub

Private Sub PictureBox1_MouseMove(ByVal sender AsObject, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If e.Button = Windows.Forms.MouseButtons.Left Then

Dim DeltaX As Integer = (m_PanStartPoint.X - e.X)
Dim DeltaY As Integer = (m_PanStartPoint.Y - e.Y)
Panel1.AutoScrollPosition = _
New Drawing.Point((DeltaX - Panel1.AutoScrollPosition.X), _
                    (DeltaY - Panel1.AutoScrollPosition.Y))
            Button1.Location = New System.Drawing.Point(0, 0)
End If
End Sub
End Class

不。还是一样的。:)我已经解释了我是如何使用这些图像的。我只是再次添加链接以进行解释。@JustinRyan我已经编辑了这个问题,所以没有人会感到困惑