解读ODB++文件--续集

不打扰是莪最后的温柔 提交于 2020-01-04 00:16:29

首先祝大家新年快乐.
先上效果图.
在这里插入图片描述

这里主要是增加了,框选放大效果.这其中就用到了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
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!