From 783a50a9847c8697fba0c7938b2f27850afa0c20 Mon Sep 17 00:00:00 2001 From: chn Date: Sun, 11 Sep 2022 23:19:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=91=E4=B9=9F=E5=BF=98=E4=BA=86=E6=94=B9?= =?UTF-8?q?=E4=BA=86=E4=BB=80=E4=B9=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Form1.Designer.vb | 19 +++++++-- Form1.vb | 49 ++++++++++++++++------ My Project/Settings.Designer.vb | 73 +++++++++++++++++++++++++++++++++ My Project/Settings.settings | 6 +++ 幸运抽奖.vbproj | 14 +++++++ 5 files changed, 145 insertions(+), 16 deletions(-) create mode 100644 My Project/Settings.Designer.vb create mode 100644 My Project/Settings.settings diff --git a/Form1.Designer.vb b/Form1.Designer.vb index 7e476a7..88b521f 100644 --- a/Form1.Designer.vb +++ b/Form1.Designer.vb @@ -39,12 +39,13 @@ Partial Class Form1 Me.Timer1 = New System.Windows.Forms.Timer(Me.components) Me.Timer2 = New System.Windows.Forms.Timer(Me.components) Me.Label5 = New System.Windows.Forms.Label() + Me.Button6 = New System.Windows.Forms.Button() Me.SuspendLayout() ' 'Button1 ' Me.Button1.Font = New System.Drawing.Font("Microsoft YaHei UI", 26.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point) - Me.Button1.Location = New System.Drawing.Point(227, 336) + Me.Button1.Location = New System.Drawing.Point(231, 316) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(170, 72) Me.Button1.TabIndex = 0 @@ -150,7 +151,6 @@ Partial Class Form1 'TextBox4 ' Me.TextBox4.BackColor = System.Drawing.SystemColors.HighlightText - Me.TextBox4.Enabled = False Me.TextBox4.Font = New System.Drawing.Font("Microsoft YaHei UI", 26.25!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point) Me.TextBox4.Location = New System.Drawing.Point(217, 240) Me.TextBox4.Name = "TextBox4" @@ -182,6 +182,7 @@ Partial Class Form1 ' 'Timer1 ' + Me.Timer1.Interval = 50 ' 'Timer2 ' @@ -195,15 +196,25 @@ Partial Class Form1 Me.Label5.Name = "Label5" Me.Label5.Size = New System.Drawing.Size(385, 68) Me.Label5.TabIndex = 13 - Me.Label5.Text = "code by 陈浩南@第一小组" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "最后修改于2022年4月18日,基于2021年10月5日统计的组成员信息" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "如果不是最新版,双击此处或手动访问kkmeetin" & + 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.TextAlign = System.Drawing.ContentAlignment.TopRight ' + 'Button6 + ' + Me.Button6.Location = New System.Drawing.Point(12, 447) + Me.Button6.Name = "Button6" + Me.Button6.Size = New System.Drawing.Size(75, 23) + Me.Button6.TabIndex = 14 + Me.Button6.Text = "导出数据" + Me.Button6.UseVisualStyleBackColor = True + ' '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.Controls.Add(Me.Button6) Me.Controls.Add(Me.Label5) Me.Controls.Add(Me.TextBox4) Me.Controls.Add(Me.Label4) @@ -219,6 +230,7 @@ Partial Class Form1 Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.Button1) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D + Me.ImeMode = System.Windows.Forms.ImeMode.Disable Me.MaximizeBox = False Me.Name = "Form1" Me.Text = "KK集团大组会抽奖" @@ -243,4 +255,5 @@ Partial Class Form1 Friend WithEvents Timer1 As Timer Friend WithEvents Timer2 As Timer Friend WithEvents Label5 As Label + Friend WithEvents Button6 As Button End Class diff --git a/Form1.vb b/Form1.vb index d2b5118..0dbe17f 100644 --- a/Form1.vb +++ b/Form1.vb @@ -14,12 +14,15 @@ }, New List(Of String) From { - "曾鑫龙", "常青", "陈晨", "陈铭禹", "陈子龙", "范洋涛", "费煜晨", "高扬钧", "胡玮琳", "黄飞鸿", "黄家新", - "蓝进肾", "李光容", "李锦安", "李迎秋", "林建平", "刘海洋", "刘兴宜", "柳梦宇", "莫炳杰", "聂思晴", "平坦", - "曲善直", "檀鹏", "唐唯卿", "万景", "吴建峰", "吴启鹏", "吴维", "吴雪峰", "徐聪卉", "徐望舒", "杨成彪", "叶晓芳", - "张爱忠", "张腾", "张耀宗", "张裕祥", "张宗南", "周小龙" + "曾鑫龙", "常青", "陈铭禹", "陈子龙", "范洋涛", "费煜晨", "高扬钧", "胡玮琳", "黄飞鸿", + "蓝进肾", "李光容", "李锦安", "李迎秋", "林建平", "刘海洋", "柳梦宇", "莫炳杰", "聂思晴", + "曲善直", "唐唯卿", "万景", "吴启鹏", "吴维", "吴雪峰", "徐望舒", "杨成彪", "叶晓芳", + "张腾", "张裕祥", "张宗南", "周小龙" }, - New List(Of String) From {"赵三", "赵四", "赵五"} + New List(Of String) From + { + "陈晨", "黄家新", "黄昱祺", "刘兴宜", "平坦", "檀鹏", "吴建峰", "徐聪卉", "张爱忠", "张耀宗" + } } Private TextBox_(3) As TextBox @@ -31,6 +34,7 @@ ' 在 InitializeComponent() 调用之后添加任何初始化。 TextBox_ = {TextBox1, TextBox2, TextBox3, TextBox4} ButtonRegenerate_ = {Button2, Button3, Button4, Button5} + OfficeOpenXml.ExcelPackage.LicenseContext = OfficeOpenXml.LicenseContext.NonCommercial End Sub Private Sub set_select_name(i As Integer) @@ -44,8 +48,7 @@ Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick - 'For i As Integer = 0 To 3 - For i As Integer = 0 To 2 + For i As Integer = 0 To 3 set_select_name(i) Next End Sub @@ -54,23 +57,20 @@ If (Timer1.Enabled) Then Timer1.Enabled = False Button1.Text = "再来一次" - 'For i As Integer = 0 To 3 - For i As Integer = 0 To 2 + For i As Integer = 0 To 3 ButtonRegenerate_(i).Visible = True Next Else Timer1.Enabled = True Button1.Text = "停!" - 'For i As Integer = 0 To 3 - For i As Integer = 0 To 2 + For i As Integer = 0 To 3 ButtonRegenerate_(i).Visible = False Next End If End Sub Private Sub ButtonRefresh_Click(sender As Object, e As EventArgs) Handles Button2.Click, Button3.Click, Button4.Click, Button5.Click - 'For i As Integer = 0 To 3 - For i As Integer = 0 To 2 + For i As Integer = 0 To 3 If sender Is ButtonRegenerate_(i) Then set_select_name(i) End If @@ -96,4 +96,27 @@ 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 = "成员名单"} + Dim result = dialog.ShowDialog() + If result = DialogResult.OK Then + Try + If FileIO.FileSystem.FileExists(dialog.FileName) Then FileIO.FileSystem.DeleteFile(dialog.FileName) + Dim file As New OfficeOpenXml.ExcelPackage(dialog.FileName) + Dim sheet = file.Workbook.Worksheets.Add("分组名单") + For i As Integer = 0 To 3 + Dim c = Chr(Asc("A"c) + i) + sheet.Cells(c + "1").Value = "第" + Convert.ToString(i + 1) + "小组" + For j As Integer = 0 To Students_(i).Count - 1 + sheet.Cells(c + Convert.ToString(j + 2)).Value = Students_(i)(j) + Next + Next + file.Save() + MsgBox("保存成功") + Catch ex As Exception + MsgBox("保存失败") + End Try + End If + End Sub End Class diff --git a/My Project/Settings.Designer.vb b/My Project/Settings.Designer.vb new file mode 100644 index 0000000..9f68023 --- /dev/null +++ b/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' 此代码由工具生成。 +' 运行时版本:4.0.30319.42000 +' +' 对此文件的更改可能会导致不正确的行为,并且如果 +' 重新生成代码,这些更改将会丢失。 +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) + +#Region "My.Settings 自动保存功能" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.幸运抽奖.My.MySettings + Get + Return Global.幸运抽奖.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/My Project/Settings.settings b/My Project/Settings.settings new file mode 100644 index 0000000..392df0a --- /dev/null +++ b/My Project/Settings.settings @@ -0,0 +1,6 @@ + + + + + + diff --git a/幸运抽奖.vbproj b/幸运抽奖.vbproj index 63a35a0..927a980 100644 --- a/幸运抽奖.vbproj +++ b/幸运抽奖.vbproj @@ -24,6 +24,10 @@ + + + + True @@ -35,6 +39,11 @@ True Resources.resx + + True + True + Settings.settings + @@ -50,6 +59,11 @@ MyApplicationCodeGenerator Application.Designer.vb + + My + SettingsSingleFileGenerator + Settings.Designer.vb + \ No newline at end of file