vb.net实现简单的眼睛保护系统计算机二级考试
文章作者 100test 发表时间 2009:04:09 23:38:25
来源 100Test.Com百考试题网
1.前言:由于许多人使用电脑好长时间都不知道休息,我就是其中之一。我自从买了电脑之后,视力在不停的下降,身体也没有原来好了。对此我十分担心,为此我想到了自己做一个强制限制使用电脑时间,保护眼睛的小软件。我是用vb.net实现的!
2.基本原理:
百考试题提示是通过两个Timer控件控制工作和休息时间,当工作时间过了之后。调用新窗口,新窗口是一个没有边框的全屏form并且不能关闭!只有你休息的时间过了窗体自动关闭,在过一段你工作的时间之后,电脑又将锁定,强制保护你的眼睛,休息时间和工作时间可以自己设定!但是我建议工作50分钟后,休息10分钟!
3.部分代码: Public Class Form1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Me.Label5.Text = "系统当前时间:" &. Now
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Me.MaskedTextBox1.Text <.>. "" And Me.MaskedTextBox2.Text <.>. "" Then
Me.Timer2.Enabled = True
Me.Timer2.Interval = CInt(Me.MaskedTextBox1.Text) * 1000 * 60
Me.Hide()
Else
MsgBox("请你输入时间!")
End If
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
Dim peng As New Form2()
Me.Timer2.Enabled = False
Me.Visible = False
peng.Show()
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Me.Hide()
e.Cancel = True
End Sub
Private Sub NotifyIcon1_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseDoubleClick
Me.Show()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.MaskedTextBox1.Text = 50
Me.MaskedTextBox2.Text = 10
End Sub
End Class
Public Class Form2
Dim i As Long = 0
Dim flag As Boolean = True
Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
If flag Then
e.Cancel = True
End If
End Sub
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Timer1.Interval = CLng(Form1.MaskedTextBox2.Text) * 1000 * 60
Me.ProgressBar1.Minimum = 0
Me.ProgressBar1.Maximum = CLng(Form1.MaskedTextBox2.Text) * 60
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Form1.Timer2.Enabled = True
Me.Close()
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
If i <.= CInt(Form1.MaskedTextBox2.Text) * 60 Then
Me.Focus()
Me.TopMost = True
If i = CInt(Form1.MaskedTextBox2.Text) * 60 - 10 Then
flag = False
End If
Me.WindowState = FormWindowState.Maximized
i = i 1
Me.ProgressBar1.Value = i
End If
End Sub
End Class
4.小结:这个软件基本上实现了保护眼睛和身体的作用,可以阻止疯狂的使用电脑而不休息。对于保护好自己的眼睛和身体有重要的作用!特色:打开后不能关闭。除非在任务管理器中结束进程!需要.NET Framework支持。强制保护你的身体!有好的身体才有好的明天!建议用1分钟测试!