📄 form1.vb
字号:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.BackColor = Color.LightGray
cboShape.SelectedIndex = 0
cboShape.DropDownStyle = ComboBoxStyle.DropDownList
End Sub
Dim insetX, insetY, shapeWidth, shapeHeight As Integer
Dim shape As String
Dim pen As New Pen(System.Drawing.Color.Black)
Dim brush As New SolidBrush(System.Drawing.Color.Blue)
Dim polyPoints(4) As Point
Private Sub setVars()
shape = cboShape.Text
shapeWidth = nupWidth.Value
shapeHeight = nupHeight.Value
insetX = nupX.Value
insetY = nupy.Value
End Sub
'Private Sub drawPolygonExample(ByVal e As PaintEventArgs)
' Dim bluePen As New Pen(Color.Blue)
' e.Graphics.DrawPolygon(bluePen, polyPoints)
'End Sub
Private Sub pbDrawingSurface_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles pbDrawingSurface.Paint
If (shape = "Line Rectangle") Then
e.Graphics.Clear(Color.LightBlue)
e.Graphics.DrawRectangle(pen, insetX, insetY, shapeWidth, shapeHeight)
ElseIf (shape = "Solid Rectangle") Then
e.Graphics.FillRectangle(brush, insetX, insetY, shapeWidth, shapeHeight)
ElseIf (shape = "Line Ellipse") Then
e.Graphics.DrawEllipse(pen, insetX, insetY, shapeWidth, shapeHeight)
ElseIf (shape = "Solid Ellipse") Then
e.Graphics.FillEllipse(brush, insetX, insetY, shapeWidth, shapeHeight)
ElseIf (shape = "Polygon") Then
polyPoints(0).X = 1
polyPoints(0).Y = 1
polyPoints(1).X = 1
polyPoints(1).Y = 25
polyPoints(3).X = 25
polyPoints(3).Y = 25
polyPoints(2).X = 75
polyPoints(2).Y = 75
polyPoints(4).X = 1
polyPoints(4).Y = 75
e.Graphics.DrawPolygon(pen, polyPoints)
ElseIf (shape = "String") Then
Dim exampleString As String = "Here is an example String!"
'Dim blackBrush As New SolidBrush(Color.Black)
Dim drawFont As New Font("Arial", 18)
e.Graphics.DrawString(exampleString, drawFont, brush, insetX, insetY)
End If
End Sub
Private Sub cmbDraw_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbDraw.Click
setVars()
pbDrawingSurface.Refresh()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -