📄 sorttestpanel.vb
字号:
Public Class SortTestPanel
Inherits System.Windows.Forms.UserControl
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'UserControl 重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents picSort As System.Windows.Forms.PictureBox
Friend WithEvents lblEnd As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.picSort = New System.Windows.Forms.PictureBox
Me.lblEnd = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'picSort
'
Me.picSort.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.picSort.Location = New System.Drawing.Point(0, 16)
Me.picSort.Name = "picSort"
Me.picSort.Size = New System.Drawing.Size(100, 200)
Me.picSort.TabIndex = 0
Me.picSort.TabStop = False
'
'lblEnd
'
Me.lblEnd.Dock = System.Windows.Forms.DockStyle.Top
Me.lblEnd.ForeColor = System.Drawing.Color.Red
Me.lblEnd.Location = New System.Drawing.Point(0, 0)
Me.lblEnd.Name = "lblEnd"
Me.lblEnd.Size = New System.Drawing.Size(100, 16)
Me.lblEnd.TabIndex = 1
'
'SortTestPanel
'
Me.Controls.Add(Me.lblEnd)
Me.Controls.Add(Me.picSort)
Me.Name = "SortTestPanel"
Me.Size = New System.Drawing.Size(100, 216)
Me.ResumeLayout(False)
End Sub
#End Region
Private objSort As New SortTest
WithEvents objSortEvent As SortTest
Private Item(99) As Integer
Public Sub Init()
Dim i As Integer
For i = 0 To 99 Step 1
Item(i) = CInt(1000 * Rnd() + 1)
Next
objSortEvent = objSort
Me.picSort.Refresh()
Me.lblEnd.Text = "Wait..."
End Sub
Public Sub Begin(ByVal Sorttype As String)
Me.lblEnd.Text = "Begin..."
Me.Refresh()
Select Case Sorttype
Case "Bubble"
objSort.BubbleSort(Item, 0, 99)
Case "Select"
objSort.SelectSort(Item, 0, 99)
Case "Insert"
objSort.InsertSort(Item, 0, 99)
Case "Quick"
objSort.QuickSort(Item, 0, 99)
Case Else
objSort.QuickSort(Item, 0, 99)
End Select
Me.lblEnd.Text = "Finished!"
Me.Refresh()
End Sub
Private Sub picSort_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles picSort.Paint
Dim myPen As New Pen(Color.Black, 1)
Dim myGraphics As Graphics = e.Graphics
Dim i As Long
For i = 0 To 99
myGraphics.DrawLine(myPen, 0, 2 * i, CInt(CDbl(Item(i)) / 10), 2 * i)
Next
End Sub
Private Sub objSortEvent_ItemChanged() Handles objSortEvent.ItemChanged
Me.picSort.Refresh()
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -