VB.net to realize simple eye protection system

Source: Internet
Author: User
Tags current time

1. I am one of the many people who do not know how to rest for a long time with a computer. Since I bought a computer, my eyesight keeps dropping and my body is not as good as it used to be. I am very worried about this, so I think of myself to make a mandatory limit the use of computer time, protect the eyes of small software. I realized it with vb.net!

2. Basic principles:

I control my work and rest time through two timer controls, after working hours. Call a new window, the new window is a full-screen form without a border and cannot be closed! Only you have time to rest. Forms are automatically closed, after a period of time you work, the computer will be locked, mandatory protection of your eyes, rest time and working hours can be set themselves! But I suggest that after 50 minutes of work, rest for 10 minutes!

3. Part of the code:Public Class Form1
Private Sub Timer1_Tick (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles Timer1.tick
Me.Label5.Text = "System Current Time:" & 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 ("Please enter your time!") ")
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.fo Rmclosing
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.fo Rmclosing
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) * 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. Summary: This software basically realizes protects the eye and the body the function, may prevent the crazy to use the computer without the rest. For the protection of their eyes and the body has an important role! Features: cannot be closed after opening. Unless you end the process in Task Manager! Requires. NET Framework support. Force you to protect your body! Have a good body to have a good tomorrow! Recommended 1-minute test!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.