看起来这个功能不错

This commit is contained in:
陈浩南 2022-09-12 00:12:56 +08:00
parent 783a50a984
commit 6d7103b807
2 changed files with 99 additions and 17 deletions

66
Form1.Designer.vb generated
View File

@ -40,6 +40,10 @@ Partial Class Form1
Me.Timer2 = New System.Windows.Forms.Timer(Me.components)
Me.Label5 = New System.Windows.Forms.Label()
Me.Button6 = New System.Windows.Forms.Button()
Me.CheckBox1 = New System.Windows.Forms.CheckBox()
Me.Button7 = New System.Windows.Forms.Button()
Me.Button8 = New System.Windows.Forms.Button()
Me.Label6 = New System.Windows.Forms.Label()
Me.SuspendLayout()
'
'Button1
@ -192,28 +196,70 @@ Partial Class Form1
'Label5
'
Me.Label5.AutoSize = True
Me.Label5.Location = New System.Drawing.Point(243, 411)
Me.Label5.Location = New System.Drawing.Point(333, 500)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(385, 68)
Me.Label5.Size = New System.Drawing.Size(244, 17)
Me.Label5.TabIndex = 13
Me.Label5.Text = "code by 陈浩南@第一小组" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "最后修改于2022年4月20日基于2021年10月5日统计的组成员信息" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "如果不是最新版双击此处或手动访问kkmeetin" &
"g.chn.moe下载最新版" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "您也可以访问我的Github获取源代码"
Me.Label5.Text = "code by 陈浩南@第一小组 2022年9月11日"
Me.Label5.TextAlign = System.Drawing.ContentAlignment.TopRight
'
'Button6
'
Me.Button6.Location = New System.Drawing.Point(12, 447)
Me.Button6.Location = New System.Drawing.Point(160, 500)
Me.Button6.Name = "Button6"
Me.Button6.Size = New System.Drawing.Size(75, 23)
Me.Button6.Size = New System.Drawing.Size(107, 23)
Me.Button6.TabIndex = 14
Me.Button6.Text = "导出数据"
Me.Button6.Text = "导出名单到excel"
Me.Button6.UseVisualStyleBackColor = True
'
'CheckBox1
'
Me.CheckBox1.AutoSize = True
Me.CheckBox1.Checked = True
Me.CheckBox1.CheckState = System.Windows.Forms.CheckState.Checked
Me.CheckBox1.Location = New System.Drawing.Point(73, 411)
Me.CheckBox1.Name = "CheckBox1"
Me.CheckBox1.Size = New System.Drawing.Size(471, 38)
Me.CheckBox1.TabIndex = 15
Me.CheckBox1.Text = "尽量避免重复" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "(已经抽到过的人将不再被抽到,除非程序被重启或那个小组的人都轮换了一遍。)" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10)
Me.CheckBox1.UseVisualStyleBackColor = True
'
'Button7
'
Me.Button7.Location = New System.Drawing.Point(63, 468)
Me.Button7.Name = "Button7"
Me.Button7.Size = New System.Drawing.Size(81, 23)
Me.Button7.TabIndex = 16
Me.Button7.Text = "下载最新版"
Me.Button7.UseVisualStyleBackColor = True
'
'Button8
'
Me.Button8.Location = New System.Drawing.Point(63, 500)
Me.Button8.Name = "Button8"
Me.Button8.Size = New System.Drawing.Size(81, 23)
Me.Button8.TabIndex = 17
Me.Button8.Text = "获取源代码"
Me.Button8.UseVisualStyleBackColor = True
'
'Label6
'
Me.Label6.AutoSize = True
Me.Label6.Location = New System.Drawing.Point(150, 471)
Me.Label6.Name = "Label6"
Me.Label6.Size = New System.Drawing.Size(181, 17)
Me.Label6.TabIndex = 18
Me.Label6.Text = "或手动访问kkmeeting.chn.moe"
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(7.0!, 17.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(640, 482)
Me.ClientSize = New System.Drawing.Size(603, 537)
Me.Controls.Add(Me.Label6)
Me.Controls.Add(Me.Button8)
Me.Controls.Add(Me.Button7)
Me.Controls.Add(Me.CheckBox1)
Me.Controls.Add(Me.Button6)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.TextBox4)
@ -256,4 +302,8 @@ Partial Class Form1
Friend WithEvents Timer2 As Timer
Friend WithEvents Label5 As Label
Friend WithEvents Button6 As Button
Friend WithEvents CheckBox1 As CheckBox
Friend WithEvents Button7 As Button
Friend WithEvents Button8 As Button
Friend WithEvents Label6 As Label
End Class

View File

@ -1,5 +1,5 @@
Public Class Form1
Private Students_() As List(Of String) =
Private Students_ As New List(Of List(Of String)) From
{
New List(Of String) From
{
@ -24,6 +24,7 @@
"陈晨", "黄家新", "黄昱祺", "刘兴宜", "平坦", "檀鹏", "吴建峰", "徐聪卉", "张爱忠", "张耀宗"
}
}
Private StudentsUsed_ As New List(Of List(Of String)) From {New List(Of String), New List(Of String), New List(Of String), New List(Of String)}
Private TextBox_(3) As TextBox
Private ButtonRegenerate_(3) As Button
@ -40,12 +41,23 @@
Private Sub set_select_name(i As Integer)
Dim rand As New Random
Dim current_text = TextBox_(i).Text
While current_text = TextBox_(i).Text
While TextBox_(i).Text = current_text And (Students_(i).Count > 1 Or TextBox_(i).Text <> Students_(i)(0))
TextBox_(i).Text = Students_(i)(rand.Next(0, Students_(i).Count))
End While
TextBox_(i).Refresh()
End Sub
Private Sub move_to_used(i As Integer, name As String)
If CheckBox1.Checked And Students_(i).Contains(name) Then
If Students_(i).Count > 1 Then
Students_(i).Remove(name)
StudentsUsed_(i).Add(name)
Else
Students_(i).AddRange(StudentsUsed_(i))
StudentsUsed_(i).Clear()
End If
End If
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
For i As Integer = 0 To 3
@ -56,6 +68,9 @@
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If (Timer1.Enabled) Then
Timer1.Enabled = False
For i As Integer = 0 To 3
move_to_used(i, TextBox_(i).Text)
Next
Button1.Text = "再来一次"
For i As Integer = 0 To 3
ButtonRegenerate_(i).Visible = True
@ -73,6 +88,7 @@
For i As Integer = 0 To 3
If sender Is ButtonRegenerate_(i) Then
set_select_name(i)
move_to_used(i, TextBox_(i).Text)
End If
Next
End Sub
@ -89,13 +105,6 @@
' End If
End Sub
Private Sub Label5_DoubleClick(sender As Object, e As EventArgs) Handles Label5.DoubleClick
Try
Process.Start(New ProcessStartInfo("https://kkmeeting.chn.moe") With {.UseShellExecute = True})
Catch ex As Exception
MsgBox("调用浏览器失败请手动使用浏览器访问kkmeeting.chn.moe。")
End Try
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Dim dialog As New SaveFileDialog With {.Filter = "Excel 工作簿|*.xlsx", .Title = "保存为excel", .FileName = "成员名单"}
@ -119,4 +128,27 @@
End Try
End If
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
Try
Process.Start(New ProcessStartInfo("https://kkmeeting.chn.moe") With {.UseShellExecute = True})
Catch ex As Exception
MsgBox("调用浏览器失败请手动使用浏览器访问kkmeeting.chn.moe。")
End Try
End Sub
Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
Try
Process.Start(New ProcessStartInfo("https://github.com/CHN-beta/group-meeting-lottery") With {.UseShellExecute = True})
Catch ex As Exception
MsgBox("调用浏览器失败请手动使用浏览器访问kkmeeting.chn.moe。")
End Try
End Sub
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
For i As Integer = 0 To 3
Students_(i).AddRange(StudentsUsed_(i))
StudentsUsed_(i).Clear()
Next
End Sub
End Class