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
[1] [2] [3] 下一頁