Mouse [vb.net] 주어진 비율을 유지하면서 마우스로 사각형을 그립니다
페이지 정보
본문
Dim mRect As Rectangle
Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
mRect = New Rectangle(e.X, e.Y, 0, 0)
Me.Invalidate()
End Sub
Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
If e.Button = Windows.Forms.MouseButtons.Left Then
mRect = New Rectangle(mRect.Left, mRect.Top, e.X - mRect.Left, e.Y - mRect.Top)
'Replace 1.5 with the scale you want to use
Dim hgt As Integer = Convert.ToInt32(mRect.Height / 1.5)
Dim wdth As Integer = Convert.ToInt32(mRect.Width / 1.5)
mRect.Size = New Size(wdth * 1.5, hgt * 1.5)
Me.Invalidate()
End If
End Sub
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
Using pen As New Pen(Color.Red, 3)
e.Graphics.DrawRectangle(pen, mRect)
End Using
End Sub
- 이전글[vb.net] JSON 기본 정리 21.02.08
- 다음글[vb.net] Boolean(True/False) 의 값과 연산 결과값 21.01.30
댓글목록
등록된 댓글이 없습니다.