首先祝大家新年快乐.
先上效果图.
这里主要是增加了,框选放大效果.这其中就用到了WIN32的API 实现的橡皮线功能.
部分代码如下:
Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
MyBase.OnMouseDown(e)
Dim g As Graphics = Me.CreateGraphics()
Dim hdc As IntPtr = g.GetHdc()
m_Step += 1
SetROP2(hdc, 10)
If m_Step = 1 Then
m_StartX = e.X
m_Start_Y = e.Y
m_EndX = e.X
m_EndY = e.Y
ElseIf m_Step = 2 Then
If Math.Abs(m_StartX - m_EndX) > Math.Abs(m_Start_Y - m_EndY) Then
scale = Me.Width / Math.Abs(m_StartX - m_EndX)
Else
scale = Me.Height / Math.Abs(m_Start_Y - m_EndY)
End If
gMap = Me.CreateGraphics()
gMap.Clear(Color.Black)
gMap.ScaleTransform(scal * scale, scal * scale)
scal = scal * scale
Dim weiyi_x = m_StartX
Dim weiyi_y = m_Start_Y
gMap.TranslateTransform(distance - weiyi_x, distance_y - weiyi_y)
distance = distance - m_StartX
distance_y = distance_y - m_Start_Y
Call Form1.draw_feature2()
Call Form1.draw_profile()
m_Step = 0
End If
g.ReleaseHdc(hdc)
End Sub
Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
MyBase.OnMouseMove(e)
Dim g As Graphics = Me.CreateGraphics()
Dim prex, prey As Integer
If m_Step = 1 Then
Dim hdc As IntPtr = g.GetHdc()
prex = m_EndX
prey = m_EndY
SetROP2(hdc, 10)
Rectangle(hdc, m_StartX, m_Start_Y, prex, prey)
Rectangle(hdc, m_StartX, m_Start_Y, e.X, e.Y)
m_EndX = e.X
m_EndY = e.Y
g.ReleaseHdc(hdc)
End If
End Sub
来源:CSDN
作者:Kevin_Lai_1987
链接:https://blog.csdn.net/Kevin_Lai_1987/article/details/103818189