C # compile a review of the automatic shutdown Program

Source: Internet
Author: User

C # compile a review of the automatic shutdown Program

First, the first element of a program is that you can set the program ICON in the settings of the logo and set it in the ICON. The ICON can be downloaded from the Internet. These are the Button controls of the Buton, Label, Timer, and Notiflcon controls involved in the surface kung fu program. You can design the click events as follows:

Private void timereffectick (object sender, EventArgs e) {Int32 time_now; Int32 extra; if (Flag_True = 1) {if (DateTime. now. minute = fen & DateTime. now. hour = shi & DateTime. now. second = miao) {button1.Text = "cancel"; label6.Text = "remaining Shutdown Time"; label7.Text = "seconds"; label5.Text = "0"; System. diagnostics. process. start ("shutdown", "-s-t 0"); // shutdown program} // shutdown else {time_now = DateTime. now. second + DateTime. now. minute * 60 + DateTime. now. hour * 3600; extra = time_set-time_now; if (extra> 0) {button1.Text = "cancel"; label6.Text = "remaining Shutdown Time"; label7.Text = "second "; // extra/3600 label5.Text = extra. toString () ;}else {Flag_True = 0 ;}}}}

 

The x label control is easy to display characters, and its members include text. You can change the text timer control at any time, which is equivalent to an embedded timer, set ENABLE in the row of the attribute and set the interval of 500 to half a second.
Private void timereffectick (object sender, EventArgs e) {Int32 time_now; Int32 extra; if (Flag_True = 1) {if (DateTime. now. minute = fen & DateTime. now. hour = shi & DateTime. now. second = miao) {button1.Text = "cancel"; label6.Text = "remaining Shutdown Time"; label7.Text = "seconds"; label5.Text = "0"; System. diagnostics. process. start ("shutdown", "-s-t 0"); // shutdown program} // shutdown else {time_now = DateTime. now. second + DateTime. now. minute * 60 + DateTime. now. hour * 3600; extra = time_set-time_now; if (extra> 0) {button1.Text = "cancel"; label6.Text = "remaining Shutdown Time"; label7.Text = "second "; // extra/3600 label5.Text = extra. toString () ;}else {Flag_True = 0 ;}}}}

 

I interrupted every half second and determined whether the shutdown time has been reached and how many seconds are left to shut down. If no Timed Shutdown is set, it is not displayed. The text of button1 and Label can be changed at any time. After the basic function settings are complete, there is a minimal to tray setting that uses the Notiflcon control. This control sets the minimal icon. You can set the icon in the settings. You can click, double-click, or double-click an event.
private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)        {            this.Visible = true;            this.WindowState = FormWindowState.Normal;            this.notifyIcon1.Visible = false;        }

 

I have set the mouse click above, and the code is to restore the visualization, the normal window. You have to hide the program below when it is minimized.
private void Form1_SizeChanged(object sender, EventArgs e)        {            if (this.WindowState == FormWindowState.Minimized)            {                this.Hide();                this.notifyIcon1.Visible = true;            }        }

 

The above is a Shutdown program .. Shows the overall architecture.
Namespace shutdown Task Management V1. _ 0 {public partial class Form1: Form {int shi, fen, miao; Int32 time_set; int Flag_True = 0; public Form1 () {InitializeComponent ();} private void Form1_Load (object sender, EventArgs e) {} private void numericUpDown1_ValueChanged (object sender, EventArgs e) {if (numericUpDown1.Value =-1) numericUpDown1.Value = 60; else if (numericUpDown1.Value = 61) numericUpDown1.Value = 0;} private void numericUpDown2_ValueChanged (object sender, EventArgs e) {if (numericUpDown2.Value =-1) numericUpDown2.Value = 60; else if (numericUpDown2.Value = 61) numericUpDown2.Value = 0;} private void numericUpDown3_ValueChanged (object sender, EventArgs e) {if (numericUpDown3.Value = 25) numericUpDown3.Value = 0; else if (numericUpDown3.Value =-1) numericUpDown3.Value = 24;} private void button#click (object sender, EventArgs e) {// int shi, fen, miao; if (Flag_True = 0) {Flag_True = 1 ;}else {button1.Text = "OK"; label6.Text = ""; label7.Text = ""; label5.Text = ""; // label1.Text = "Timed Shutdown Settings"; Flag_True = 0 ;}shi = (int) numericUpDown3.Value; fen = (int) numericUpDown2.Value; miao = (int) numericUpDown1.Value; time_set = shi * 3600 + fen * 60 + miao;} private void timer1_Tick (object sender, EventArgs e) {Int32 time_now; Int32 extra; if (Flag_True = 1) {if (DateTime. now. minute = fen & DateTime. now. hour = shi & DateTime. now. second = miao) {button1.Text = "cancel"; label6.Text = "remaining Shutdown Time"; label7.Text = "seconds"; label5.Text = "0"; System. diagnostics. process. start ("shutdown", "-s-t 0"); // shutdown program} // shutdown else {time_now = DateTime. now. second + DateTime. now. minute * 60 + DateTime. now. hour * 3600; extra = time_set-time_now; if (extra> 0) {button1.Text = "cancel"; label6.Text = "remaining Shutdown Time"; label7.Text = "second "; // extra/3600 label5.Text = extra. toString () ;}else {Flag_True = 0 ;}}} private void label5_Click (object sender, EventArgs e) {} private void label4_Click (object sender, EventArgs e) {} private void label3_Click (object sender, EventArgs e) {} private void label6_Click (object sender, EventArgs e) {} private void policyicon#mouseclick (object sender, MouseEventArgs e) {this. visible = true; this. windowState = FormWindowState. normal; this. policyicon1.visible = false;} // minimize the code private void Form1_SizeChanged (object sender, EventArgs e) {if (this. windowState = FormWindowState. minimized) {this. hide (); this. policyicon1.visible = true ;}}

 

}

Related Article

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.