高考倒计时(vb.net,持续更新版本)

发布于:2025-06-12 ⋅ 阅读:(24) ⋅ 点赞:(0)

引言

在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.Click
        Localization.Read()
        LayerEdit.Read()
h3:     ScreenSize = Screen.PrimaryScreen.Bounds.Size
        bmp = New Bitmap(ScreenSize.Width, ScreenSize.Height)
        g = Graphics.FromImage(bmp)
        Button9_Click(Nothing, Nothing)
        Dim d = Date.Now
        Dim y As Integer
        Dim dg As Date
        Dim textpath As String
        If d.Date.Month = 6 And d.Date.Day >= 10 Or d.Date.Month > 6 Then
            y = d.Date.Year + 1
            dg = New Date(y, 6, 7)
        Else
            y = d.Date.Year
            dg = New Date(y, 6, 7)
        End If

        ' bp1.Close()
        If ComboBox1.SelectedIndex = 4 Then

            GoTo H1
        Else

        End If

        g.FillRectangle(New SolidBrush(Pic1.BackColor), Screen.PrimaryScreen.Bounds)
        '''背景层绘制
        For Each i In LayerEdit.Layers.BackLayer
            g.DrawImage(ZoomBmp(New Bitmap(i.strPath), i.ZoomScale), i.Location)
        Next

        Dim bmp1 As Bitmap
        If mode = 1 Then
            GoTo H1
        ElseIf mode = 2 Then
            textpath = TextBox1.Text
            Try
                bmp1 = New Bitmap(textpath)
            Catch ex As Exception
                'MsgBox("文件不存在!")
                RadioButton1.Checked = True
                mode = 1
                GoTo h3
                'Exit Sub
            End Try

        ElseIf mode = 3 Then
            Try
                Dim interr = 0
H2:             Dim list As ObjectModel.ReadOnlyCollection(Of String) '定义该路径下文件名的集合
                list = My.Computer.FileSystem.GetFiles(TextBox2.Text)
                Dim max = list.Count
                bmpindex += 1
                If bmpindex = max Then
                    bmpindex = 0

                End If
                textpath = list(bmpindex)
                Try
                    bmp1 = New Bitmap(textpath)

                Catch ex As Exception
                    interr += 1
                    If interr = max Then
                        ' MsgBox("文件夹下没有图片")
                        RadioButton1.Checked = True
                        mode = 1
                        GoTo h3
                        'Exit Sub
                    End If
                    GoTo H2

                End Try
            Catch ex As Exception
                'MsgBox("文件夹不存在!")
                RadioButton1.Checked = True
                mode = 1
                GoTo h3
                'Exit Sub
            End Try


        End If


        Select Case ComboBox1.SelectedIndex
            Case 0
                g.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 Then
                    Dim k As Single = ScreenSize.Height / bmp1.Height
                    Dim newh = ScreenSize.Height
                    Dim neww = bmp1.Width * k
                    g.DrawImage(bmp1, New Rectangle((ScreenSize.Width - neww) / 2, 0, neww, newh), New Rectangle(0, 0, bmp1.Width, bmp1.Height), GraphicsUnit.Pixel)
                Else
                    Dim k As Single = ScreenSize.Width / bmp1.Width
                    Dim newh = bmp1.Height * k
                    Dim neww = ScreenSize.Width
                    g.DrawImage(bmp1, New Rectangle(0, (ScreenSize.Height - newh) / 2, neww, newh), New Rectangle(0, 0, bmp1.Width, bmp1.Height), GraphicsUnit.Pixel)
                End If

            Case 2
                g.DrawImage(bmp1, New Rectangle(New Point(0, 0), ScreenSize), New Rectangle(0, 0, bmp1.Width, bmp1.Height), GraphicsUnit.Pixel)
            Case 3
                If bmp1.Width / bmp1.Height > ScreenSize.Width / ScreenSize.Height Then
                    Dim k As Single = ScreenSize.Height / bmp1.Height
                    Dim newh = ScreenSize.Height
                    Dim neww = bmp1.Width * k
                    g.DrawImage(bmp1, New Rectangle((ScreenSize.Width - neww) / 2, 0, neww, newh), New Rectangle(0, 0, bmp1.Width, bmp1.Height), GraphicsUnit.Pixel)
                Else
                    Dim k As Single = ScreenSize.Width / bmp1.Width
                    Dim newh = bmp1.Height * k
                    Dim neww = ScreenSize.Width
                    g.DrawImage(bmp1, New Rectangle(0, (ScreenSize.Height - newh) / 2, neww, newh), New Rectangle(0, 0, bmp1.Width, bmp1.Height), GraphicsUnit.Pixel)
                End If
        End Select
        '''背景2层
        For Each i In LayerEdit.Layers.ImageLayer
            g.DrawImage(ZoomBmp(New Bitmap(i.strPath), i.ZoomScale), i.Location)
        Next

H1:

        g.SmoothingMode = SmoothingMode.AntiAlias
        g.InterpolationMode = InterpolationMode.HighQualityBicubic
        g.CompositingQuality = CompositingQuality.HighQuality
        If ComboBox1.SelectedIndex = 4 Then
            g.TextRenderingHint = Drawing.Text.TextRenderingHint.SingleBitPerPixelGridFit
        Else

            g.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
        End If
        g.PageUnit = GraphicsUnit.Pixel
        'g.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit
        'g.InterpolationMode = InterpolationMode.NearestNeighbor
        If ComboBox1.SelectedIndex = 4 Then
            For Each i In LayerEdit.Layers.BackLayer
                g.DrawImage(ZoomBmp(New Bitmap(i.strPath), i.ZoomScale), i.Location)
            Next
            For Each i In LayerEdit.Layers.ImageLayer
                g.DrawImage(ZoomBmp(New Bitmap(i.strPath), i.ZoomScale), i.Location)
            Next
        End If
        '''距离高考还有
        Dim NITD = Localization.BackGroundSetting.NormalInformTextData
        Dim BEF = Localization.BackGroundSetting.BeforeNumberData
        Dim AFT = Localization.BackGroundSetting.AfterNumberData
        Dim ZeroDay = BEF & " 0 " & AFT
        If d.Date.Month = 6 And (d.Date.Day = 7 Or d.Date.Day = 8 Or d.Date.Day = 9) Then


            Dim p1 = New Point((ScreenSize.Width - GetStringSize(NITD, f1, New StringFormat(1)).Width) / 2, ScreenSize.Height / 2 - 100)
            '0 tian
            Dim 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)
        Else
            Dim days As Integer = Decimal.Ceiling((dg - d).TotalDays)
            Dim stitle, sdays As String
            Dim stk As Date
            Dim stk1 As Date
            For i = 1 To 31
                stk = New Date(d.Year, 12, i)
                If stk.DayOfWeek = DayOfWeek.Saturday Then
                    Label6.Text = "省统考系统生成的时间为:" & stk.ToString & "   " & Format(stk, "ddd")
                    stk1 = stk.AddDays(OffsetDays.Value)
                    Label7.Text = "省统考自定义的时间为:" & stk1.ToString & "   " & Format(stk, "ddd")
                    Exit For
                End If
            Next
            If 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 Then
                stitle = Localization.BackGroundSetting.SpecialInformTextData '省统考
                sdays = Decimal.Ceiling(BEF & " " & (stk1 - d).TotalDays) & " / " & days & " " & AFT
                If Decimal.Ceiling((stk1 - d).TotalDays) < 0 Or isonstk = False Then
                    GoTo Err0
                End If
            Else
Err0:           stitle = NITD
                sdays = BEF & " " & days & " " & AFT
                OffsetDays.Value = 0
                'Button9_Click(Nothing, Nothing)
            End If

            Dim 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 If

        Dim DF = Localization.BackGroundSetting.DateFormatData
        Dim 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) / 2
        Dim y4 = p3.Y - GetStringSize(GetNongLi, f1, New StringFormat(1)).Height
        Dim 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 = "配置请查看系统托盘!" & ver
        Dim 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 Then
        For Each i In LayerEdit.Layers.TopLayer
            g.DrawImage(ZoomBmp(New Bitmap(i.strPath), i.ZoomScale), i.Location)
        Next
        ' End If
        '''顶层

        Dim ar As New Arrangement
        ar.LoadArrangement()
        For i = 0 To ar.ar.AllList.Count - 1
            g.DrawImage(Arrangement.DrawArrangement(ar.ar, i), ar.ar.AllList(i).Position)
        Next


        If formInTran = False Then
            If LastSelect < 4 Then
                BackPlayer.Pic.Image = bmp
            Else
                BackPlayer1.Close()
                RefreshBack()
                BackPlayer.Pic.Image = bmp
                BackPlayer.Show()
                u.SetAnimeBackground(BackPlayer.Handle)
            End If
        Else
            If LastSelect = 4 Then
                BackPlayer1.Pic.Image = bmp
            Else
                BackPlayer.Close()
                RefreshBack()
                BackPlayer1.Pic.Image = bmp
                BackPlayer1.Show()
                u.SetAnimeBackground(BackPlayer1.Handle)
            End If

        End If
        LastSelect = ComboBox1.SelectedIndex
        GC.Collect()
    End Sub

 任务栏系统托盘:快速配置

使用可以快速在任务栏托盘里面创建一个图标,属性里面设置一个即可,有必要可以加气球通知

发布:本内容完全开源免费

【免费】高考倒计时(跨平台版本+美术省统考)源代码.zip资源-CSDN文库