高考倒计时(vb.net,持续更新版本)
引言
在2025年6月10日,你肯定已经高考结束了,也希望所以和我一样的高三学生可以考出理想的成绩
不经历风雨,怎么见彩虹,没有人能随随便便成功……
好的我们直接步入正题,还记得我之前的1.4版本的高考倒计时吗,后来省统考倒计时变成负的了,于是连夜修改;而且加入了序列化存储信息的功能,省去了繁琐的文件存储和读取程序。
首先是内容
和上次对比可以发现,多了很多很多比如说导出图片、重新嵌入壁纸、安排表(持续更新)、层级表(背景层设置图片,持续更新),本地化
这一次我们是花了大力气搞到2.1.1版本的,预示着大家都靠211学校。关键不还是你的分数吗?
由于程序较复杂,我一天可能都讲不完,那么就讲讲核心技术吧
一、存储方面:使用了序列化存储用户的配置
这一用法其实我在上一个文章里面已经提及了,大家可以跳转
VB.net序列化和反序列化的使用方法和实用场景-CSDN博客
二、绘制的窗口嵌入桌面背景
1、这一用法在之前的一篇讲过,可以参考
桌面壁纸层嵌入窗口(wallpaper engine核心)原理讲解_wallpaper engine 原理-CSDN博客
2、背景分为纯色背景、图片背景、幻灯片背景、透明背景
三、操作性方面:目前还差点意思
注意的安排表了吗,他目前不支持复制和调换顺序,后续版本会推出更多自定义功能
然后是代码:内部逻辑
一、核心:应用时触发的代码(使用VB.net的最大好处就是代码可读性强,在阅读超复杂的代码时可以快速了解结构,当然,我们注重的是效率,而不是盲目追求C#,就是要做不同质化的内容)
快速了解结构,切勿盲目复制!
Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.ClickLocalization.Read()LayerEdit.Read()
h3: ScreenSize = Screen.PrimaryScreen.Bounds.Sizebmp = New Bitmap(ScreenSize.Width, ScreenSize.Height)g = Graphics.FromImage(bmp)Button9_Click(Nothing, Nothing)Dim d = Date.NowDim y As IntegerDim dg As DateDim textpath As StringIf d.Date.Month = 6 And d.Date.Day >= 10 Or d.Date.Month > 6 Theny = d.Date.Year + 1dg = New Date(y, 6, 7)Elsey = d.Date.Yeardg = New Date(y, 6, 7)End If' bp1.Close()If ComboBox1.SelectedIndex = 4 ThenGoTo H1ElseEnd Ifg.FillRectangle(New SolidBrush(Pic1.BackColor), Screen.PrimaryScreen.Bounds)'''背景层绘制For Each i In LayerEdit.Layers.BackLayerg.DrawImage(ZoomBmp(New Bitmap(i.strPath), i.ZoomScale), i.Location)NextDim bmp1 As BitmapIf mode = 1 ThenGoTo H1ElseIf mode = 2 Thentextpath = TextBox1.TextTrybmp1 = New Bitmap(textpath)Catch ex As Exception'MsgBox("文件不存在!")RadioButton1.Checked = Truemode = 1GoTo h3'Exit SubEnd TryElseIf mode = 3 ThenTryDim interr = 0
H2: Dim list As ObjectModel.ReadOnlyCollection(Of String) '定义该路径下文件名的集合list = My.Computer.FileSystem.GetFiles(TextBox2.Text)Dim max = list.Countbmpindex += 1If bmpindex = max Thenbmpindex = 0End Iftextpath = list(bmpindex)Trybmp1 = New Bitmap(textpath)Catch ex As Exceptioninterr += 1If interr = max Then' MsgBox("文件夹下没有图片")RadioButton1.Checked = Truemode = 1GoTo h3'Exit SubEnd IfGoTo H2End TryCatch ex As Exception'MsgBox("文件夹不存在!")RadioButton1.Checked = Truemode = 1GoTo h3'Exit SubEnd TryEnd IfSelect Case ComboBox1.SelectedIndexCase 0g.DrawImage(bmp1, New PointF(0, 0))Case 1' g.FillRectangle(New SolidBrush(Pic1.BackColor), Screen.PrimaryScreen.Bounds)If bmp1.Width / bmp1.Height < ScreenSize.Width / ScreenSize.Height ThenDim k As Single = ScreenSize.Height / bmp1.HeightDim newh = ScreenSize.HeightDim neww = bmp1.Width * kg.DrawImage(bmp1, New Rectangle((ScreenSize.Width - neww) / 2, 0, neww, newh), New Rectangle(0, 0, bmp1.Width, bmp1.Height), GraphicsUnit.Pixel)ElseDim k As Single = ScreenSize.Width / bmp1.WidthDim newh = bmp1.Height * kDim neww = ScreenSize.Widthg.DrawImage(bmp1, New Rectangle(0, (ScreenSize.Height - newh) / 2, neww, newh), New Rectangle(0, 0, bmp1.Width, bmp1.Height), GraphicsUnit.Pixel)End IfCase 2g.DrawImage(bmp1, New Rectangle(New Point(0, 0), ScreenSize), New Rectangle(0, 0, bmp1.Width, bmp1.Height), GraphicsUnit.Pixel)Case 3If bmp1.Width / bmp1.Height > ScreenSize.Width / ScreenSize.Height ThenDim k As Single = ScreenSize.Height / bmp1.HeightDim newh = ScreenSize.HeightDim neww = bmp1.Width * kg.DrawImage(bmp1, New Rectangle((ScreenSize.Width - neww) / 2, 0, neww, newh), New Rectangle(0, 0, bmp1.Width, bmp1.Height), GraphicsUnit.Pixel)ElseDim k As Single = ScreenSize.Width / bmp1.WidthDim newh = bmp1.Height * kDim neww = ScreenSize.Widthg.DrawImage(bmp1, New Rectangle(0, (ScreenSize.Height - newh) / 2, neww, newh), New Rectangle(0, 0, bmp1.Width, bmp1.Height), GraphicsUnit.Pixel)End IfEnd Select'''背景2层For Each i In LayerEdit.Layers.ImageLayerg.DrawImage(ZoomBmp(New Bitmap(i.strPath), i.ZoomScale), i.Location)NextH1:g.SmoothingMode = SmoothingMode.AntiAliasg.InterpolationMode = InterpolationMode.HighQualityBicubicg.CompositingQuality = CompositingQuality.HighQualityIf ComboBox1.SelectedIndex = 4 Theng.TextRenderingHint = Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFitElseg.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAliasEnd Ifg.PageUnit = GraphicsUnit.Pixel'g.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit'g.InterpolationMode = InterpolationMode.NearestNeighborIf ComboBox1.SelectedIndex = 4 ThenFor Each i In LayerEdit.Layers.BackLayerg.DrawImage(ZoomBmp(New Bitmap(i.strPath), i.ZoomScale), i.Location)NextFor Each i In LayerEdit.Layers.ImageLayerg.DrawImage(ZoomBmp(New Bitmap(i.strPath), i.ZoomScale), i.Location)NextEnd If'''距离高考还有Dim NITD = Localization.BackGroundSetting.NormalInformTextDataDim BEF = Localization.BackGroundSetting.BeforeNumberDataDim AFT = Localization.BackGroundSetting.AfterNumberDataDim ZeroDay = BEF & " 0 " & AFTIf d.Date.Month = 6 And (d.Date.Day = 7 Or d.Date.Day = 8 Or d.Date.Day = 9) ThenDim p1 = New Point((ScreenSize.Width - GetStringSize(NITD, f1, New StringFormat(1)).Width) / 2, ScreenSize.Height / 2 - 100)'0 tianDim p2 = New Point((ScreenSize.Width - GetStringSize(ZeroDay, f2, New StringFormat(1)).Width) / 2, p1.Y + GetStringSize(NITD, f1, New StringFormat(1)).Height)g.DrawString(NITD, f1, New SolidBrush(Pic2.BackColor), p1)g.DrawString(ZeroDay, f2, New SolidBrush(Pic3.BackColor), p2)ElseDim days As Integer = Decimal.Ceiling((dg - d).TotalDays)Dim stitle, sdays As StringDim stk As DateDim stk1 As DateFor i = 1 To 31stk = New Date(d.Year, 12, i)If stk.DayOfWeek = DayOfWeek.Saturday ThenLabel6.Text = "省统考系统生成的时间为:" & stk.ToString & " " & Format(stk, "ddd")stk1 = stk.AddDays(OffsetDays.Value)Label7.Text = "省统考自定义的时间为:" & stk1.ToString & " " & Format(stk, "ddd")Exit ForEnd IfNextIf d.Month = 6 And d.Day > 9 Or d.Month = stk1.Month And d.Day < stk1.Day Or d.Month < stk1.Month And d.Month > 6 Thenstitle = Localization.BackGroundSetting.SpecialInformTextData '省统考sdays = Decimal.Ceiling(BEF & " " & (stk1 - d).TotalDays) & " / " & days & " " & AFTIf Decimal.Ceiling((stk1 - d).TotalDays) < 0 Or isonstk = False ThenGoTo Err0End IfElse
Err0: stitle = NITDsdays = BEF & " " & days & " " & AFTOffsetDays.Value = 0'Button9_Click(Nothing, Nothing)End IfDim p1 = New Point((ScreenSize.Width - GetStringSize(stitle, f1, New StringFormat(1)).Width) / 2, ScreenSize.Height / 2 - 100)Dim p2 = New Point((ScreenSize.Width - GetStringSize(sdays, f2, New StringFormat(1)).Width) / 2, p1.Y + GetStringSize(NITD, f1, New StringFormat(1)).Height)g.DrawString(stitle, f1, New SolidBrush(Pic2.BackColor), p1)g.DrawString(sdays, f2, New SolidBrush(Pic3.BackColor), p2)End IfDim DF = Localization.BackGroundSetting.DateFormatDataDim p3 = New Point((ScreenSize.Width - GetStringSize(Format(d, DF), f1, New StringFormat(1)).Width) / 2, ScreenSize.Height / 2 - GetStringSize(Format(d, DF), f1, New StringFormat(1)).Height - 100)g.DrawString(Format(d, DF), f1, New SolidBrush(Pic2.BackColor), p3)Dim x4 = (ScreenSize.Width - GetStringSize(GetNongLi, f1, New StringFormat(1)).Width) / 2Dim y4 = p3.Y - GetStringSize(GetNongLi, f1, New StringFormat(1)).HeightDim p5 = New Point(x4, y4)g.DrawString(GetNongLi, f1, New SolidBrush(Pic2.BackColor), p5)' g.DrawLine(New Pen(Color.Red, 1), New Point(0, 0), New Point(ScreenSize.Width, 0))Dim tinfo = "配置请查看系统托盘!" & verDim tfont = New Font("楷体", 20, FontStyle.Regular)Dim p4 = New Point(ScreenSize.Width - GetStringSize(tinfo, tfont, New StringFormat(1)).Width, 0)g.DrawString(tinfo, tfont, New SolidBrush(Color.Red), p4)'bmp.Save(Application.StartupPath & "\1.bmp")'SystemParametersInfo(20, True, Application.StartupPath & "\1.bmp", 1)'If mode <> 4 ThenFor Each i In LayerEdit.Layers.TopLayerg.DrawImage(ZoomBmp(New Bitmap(i.strPath), i.ZoomScale), i.Location)Next' End If'''顶层Dim ar As New Arrangementar.LoadArrangement()For i = 0 To ar.ar.AllList.Count - 1g.DrawImage(Arrangement.DrawArrangement(ar.ar, i), ar.ar.AllList(i).Position)NextIf formInTran = False ThenIf LastSelect < 4 ThenBackPlayer.Pic.Image = bmpElseBackPlayer1.Close()RefreshBack()BackPlayer.Pic.Image = bmpBackPlayer.Show()u.SetAnimeBackground(BackPlayer.Handle)End IfElseIf LastSelect = 4 ThenBackPlayer1.Pic.Image = bmpElseBackPlayer.Close()RefreshBack()BackPlayer1.Pic.Image = bmpBackPlayer1.Show()u.SetAnimeBackground(BackPlayer1.Handle)End IfEnd IfLastSelect = ComboBox1.SelectedIndexGC.Collect()End Sub
任务栏系统托盘:快速配置
使用可以快速在任务栏托盘里面创建一个图标,属性里面设置一个
即可,有必要可以加气球通知
发布:本内容完全开源免费
【免费】高考倒计时(跨平台版本+美术省统考)源代码.zip资源-CSDN文库