当前位置: 首页 > news >正文

怎么查网站的关键词/今日军事新闻头条

怎么查网站的关键词,今日军事新闻头条,网站建设合同技术开发合同,在溧水做新店推广那家网站好C# 关机长老2.0(最好用的定时关机程序源代码) 如有转载,请注明出处:http://www.cnblogs.com/flydoos/archive/2011/08/20/2146472.htmlC# 关机长老2.0(最好用的定时关机程序源代码) 今天把以前写的一个关机…

C# 关机长老2.0(最好用的定时关机程序+源代码)


如有转载,请注明出处:http://www.cnblogs.com/flydoos/archive/2011/08/20/2146472.html


C# 关机长老2.0(最好用的定时关机程序+源代码) 


今天把以前写的一个关机程序代码贴出来,写得不好,而且控件名字也都懒得命名,别见怪哟, 呵呵。觉得好的请支持下吧。


 【背景介绍】

深夜看电影、熬夜玩游戏等等,想必大家总会忘记关机吧?呵呵,如果被父母看见了可就又要挨骂了……针对这种情况,飞度软件工作室特意制作"关机长老"程序,给大家提供一丝方便,如果有什么地方需要改进的,请在下方评论并及时向我们反馈,谢谢!
【功能介绍】
01.支持定时关机、延时关机两种方式
02.可以设置密码,防止被意外关闭
03.支持托盘控制:可更新、显示、隐藏、退出
04.用于定时操作 关机、注销、重启

 

【更新历史】
关机长老2.0   2011-02-03
重新采用C#编写,修复时间日期不存在等问题,改善剩余时间显示格式为“剩余 X天 X时 X分 X秒”,进一步优化算法,减少内存开销;
关机长老1.1   2010-10-21
由于易语言误报非常严重,杀软会把易语言写的所有程序一律当做病毒给干掉了,本人无语,所以采用VB重新编写关机长老,1.1版本就此诞生,此版本开始,不再存在误报问题;
关机长老1.0   2010-07-31

首次采用易语言开发关机长老,1.0版本就此诞生; 



 

 Form1.cs 代码:

复制代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
    
public partial class Form1 : Form
    {
        
string cmdState="nothing";
        
int goTime = 0;
        
int countTime;

        
public Form1()
        {
            InitializeComponent();
        }

        
private void Form1_Load(object sender, EventArgs e)
        {
            notifyIcon1.Icon 
= this.Icon;
            textBox1.Text 
= DateTime.Now.ToString();
            numericUpDown1.Maximum 
= 23;
            numericUpDown2.Maximum 
= 59;
            numericUpDown3.Maximum 
= 59;
            numericUpDown4.Maximum 
= 23;
            numericUpDown5.Maximum 
= 59;
            numericUpDown6.Maximum 
= 59;
            comboBox1.Text 
= DateTime.Now.Month.ToString();
            comboBox2.Text 
= DateTime.Now.Day.ToString();
            numericUpDown1.Value 
= DateTime.Now.Hour;
            numericUpDown2.Value 
= DateTime.Now.Minute;
            numericUpDown3.Value 
= DateTime.Now.Second;
            numericUpDown4.Enabled 
= false;
            numericUpDown5.Enabled 
= false;
            numericUpDown6.Enabled 
= false;
            timer1.Interval 
= 1000;
            timer1.Enabled 
= true;
            
//timer2.Interval = 500;
            
//timer2.Enabled = true;
            textBox2.Enabled = false;
            
for (int i = 1; i < 13; i++)
            {
                comboBox1.Items.Add(i);
            }
            
for (int i = 1; i < 32; i++)
            {
                comboBox2.Items.Add(i);
            }
        }

        
private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            
if (radioButton1.Checked == true)
            {
                numericUpDown4.Enabled 
= false;
                numericUpDown5.Enabled 
= false;
                numericUpDown6.Enabled 
= false;
                comboBox1.Enabled 
= true;
                comboBox2.Enabled 
= true;
                numericUpDown1.Enabled 
= true;
                numericUpDown2.Enabled 
= true;
                numericUpDown3.Enabled 
= true;
                numericUpDown1.Focus();
            }
        }

        
private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            
if (radioButton2.Checked==true
            {
                numericUpDown4.Enabled 
= true;
                numericUpDown5.Enabled 
= true;
                numericUpDown6.Enabled 
= true;
                numericUpDown1.Enabled 
= true;
                comboBox1.Enabled 
= false;
                comboBox2.Enabled 
= false;
                numericUpDown1.Enabled 
= false;
                numericUpDown2.Enabled 
= false;
                numericUpDown3.Enabled 
= false;
                numericUpDown4.Focus();
            }
        }

        
private void notifyShow() //显示托盘
        {
            
this.Show();
            
this.ShowInTaskbar = true;
            
this.WindowState = FormWindowState.Normal;
        }

        
private void notifyHide() //隐藏托盘
        {
            
this.Hide();
            
this.ShowInTaskbar = false;
            notifyIcon1.Visible 
= true;
        }

        
private void Form1_Resize(object sender, EventArgs e)
        {
            
if (this.WindowState == FormWindowState.Minimized)
                notifyHide();
        }

        
public void cancelPlan()
        {
            button1.Enabled 
= true;
            button2.Enabled 
= true;
            button3.Enabled 
= true;
            cmdState 
= "nothing";
            goTime 
= 0;
            textBox3.Text 
= "0";
            MessageBox.Show(
"恭喜!任务已被取消!","取消任务",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
        }

        
string f_getValue() //获取txt2的值,因为C#无法直接传递
        {
            
return textBox2.Text;
        }

        
private void button4_Click(object sender, EventArgs e)
        {
            
if (button1.Enabled == false)
            {
                
if (checkBox1.Enabled == false)
                {
                    Form2 f2 
= new Form2();
                    f2.getvalue 
+= new Form2.getvalueHandler(f_getValue);
                    f2.ShowDialog();
                    System.Diagnostics.Debug.Print(f2.boolPwd.ToString());
                    
if (f2.boolPwd.ToString() == "1")
                    {
                        textBox2.Enabled 
= true;
                        checkBox1.Enabled 
= true;
                        cancelPlan();
                    }
                    f2.Close();
                    f2.Dispose();
                }
                
else
                {
                    cancelPlan();
                }
            }
            
else
            {
                MessageBox.Show(
"注意!请新建任务后再执行取消操作!""新建任务", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }

        
private void timer1_Tick(object sender, EventArgs e)
        {
            textBox1.Text 
= DateTime.Now.ToString();
            
if (cmdState != "nothing")
            {
                goTime 
+= 1;
                
if (countTime - goTime + 1 < 0)
                {
                    textBox3.Text 
= "0";
                    cmdState 
= "nothing";
                }
                
else
                {
                    textBox3.Text 
= (countTime - goTime + 1/ 86400 + "天 " + (countTime - goTime + 1% 86400 / 3600 + "时 " + (countTime - goTime + 1)  % 3600 / 60 + "分 " + (countTime - goTime + 1% 60 + "";
                    
if (countTime - goTime + 1 == 0)
                    {
                        System.Diagnostics.ProcessStartInfo p1 
= new System.Diagnostics.ProcessStartInfo("shutdown.exe", cmdState);
                        p1.WindowStyle 
= System.Diagnostics.ProcessWindowStyle.Hidden;   //隐藏窗口
                        System.Diagnostics.Process.Start(p1);
                        Application.ExitThread();
                        Application.Exit();
                    }
                }
            }
        }

        
private void timeControl()
        {
            
if (radioButton1.Checked == true)
            {
                DateTime startTime 
=Convert.ToDateTime (DateTime.Now.Year.ToString() + "/" + comboBox1.Text + "/" + comboBox2.Text + " " + numericUpDown1.Value + ":" + numericUpDown2.Value + ":" + numericUpDown3.Value);
                TimeSpan endTime 
= startTime-DateTime.Now; //旧的时间减去新的时间
                countTime =endTime.Days*86400+ endTime.Hours * 3600 + endTime.Minutes * 60 + endTime.Seconds; //转为秒

            }
            
else
            {
                countTime 
= decimal.ToInt32(numericUpDown4.Value) * 3600 + decimal.ToInt32(numericUpDown5.Value) * 60 + decimal.ToInt32(numericUpDown6.Value);
            }
            
if(countTime<0)
            {
                MessageBox.Show(
"抱歉!您输入的时间已经过期,请重新输入!""时间有误", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            
else
            {
                
if(checkBox1.Checked=true && textBox2.Text != "")
                {
                    textBox2.Enabled
=false;
                    checkBox1.Enabled
=false;
                }
                goTime
=0;
                button1.Enabled
=false;
                button2.Enabled
=false;
                button3.Enabled
=false;
            }
        }

        
private void comboBox1_TextChanged(object sender, EventArgs e)
        {
            
try
            {
                
int n = int.Parse(comboBox1.Text);
                
if (n < 1 || n > 12)
                    comboBox1.Text 
= DateTime.Now.Month.ToString();
            }
            
catch (Exception)
            {
                comboBox1.Text 
= DateTime.Now.Month.ToString();
            }
        }

        
private void comboBox2_TextChanged(object sender, EventArgs e)
        {
            
try
            {
                
int n = int.Parse(comboBox2.Text);
                
if (n < 1 || n > 31)
                {
                    comboBox2.Text 
= DateTime.Now.Day.ToString();
                }
                
else
                {
                    
if (comboBox1.Text == "2")
                    {
                        
if (DateTime.IsLeapYear(DateTime.Now.Year) == true//如果是闰年二月
                        {
                            
if (Convert.ToInt32(comboBox2.Text) > 28)
                                comboBox2.Text 
= "28";
                        }
                        
else
                        {
                            
if (Convert.ToInt32(comboBox2.Text) > 29)
                                comboBox2.Text 
= "29";
                        }
                    }
                    
else if (comboBox1.Text == "4" || comboBox1.Text == "6" || comboBox1.Text == "9" || comboBox1.Text == "11")
                    {
                        
if (Convert.ToInt32(comboBox2.Text) > 30)
                            comboBox2.Text 
= "30";
                    }
                }
            }
            
catch (Exception)
            {
                comboBox2.Text 
= DateTime.Now.Day.ToString();
            }
        }

        
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            
this.notifyIcon1.Icon = null;
            
this.notifyIcon1.Visible = false;
            Application.Exit();
        }

        
private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            
if (checkBox1.Checked == true)
            {
                textBox2.Enabled 
= true;
                textBox2.Focus();
            }
            
else
            {
                textBox2.Enabled
=false;
            }
        }

        
private void button1_Click(object sender, EventArgs e)
        {
            timeControl();
            cmdState 
= "-s -f -t 0"//关机
            label4.Text = "剩余关机时间";
        }

        
private void button2_Click(object sender, EventArgs e)
        {
            timeControl();
            cmdState 
= "-l"//注销
            label4.Text = "剩余注销时间";
        }

        
private void button3_Click(object sender, EventArgs e)
        {
            timeControl();
            cmdState 
= "-r -f -t 0"// 重启
            label4.Text = "剩余重启时间";
        }

        
private void notifyIcon1_DoubleClick(object sender, EventArgs e)
        {
            notifyShow();
        }

        
private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            notifyShow();
        }

        
private void toolStripMenuItem2_Click(object sender, EventArgs e)
        {
            notifyHide();
        }

        
private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start(
"http://hi.baidu.com/flydoos/blog/item/a670c17ee0369b1b28388ab1.html");
        }

        
private void toolStripMenuItem4_Click(object sender, EventArgs e)
        {
            notifyHide();
            Application.Exit();
        }

        
private void timer2_Tick(object sender, EventArgs e)
        {
            
//System.Diagnostics.Process.GetCurrentProcess().MinWorkingSet = new System.IntPtr(5);
            
//System.Diagnostics.Process.GetCurrentProcess().MinWorkingSet = new System.IntPtr(5);
        }

        
private void toolStripMenuItem5_Click(object sender, EventArgs e)
        {
            MessageBox.Show(
"关机长老 2.0\n\n更新于2011-03-01""关于");
        }

    }

}  

复制代码


 Form2.cs代码:

复制代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
    
public partial class Form2 : Form
    {
        
public delegate string getvalueHandler();
        
public event getvalueHandler getvalue;

        
public Form2()
        {
            InitializeComponent();
        }

        
public int boolPwd //判断密码是否正确
        {
            
get
            {
            Form1 f1 
= new Form1();
            
if (this.textBox1.Text == getvalue())
                
return 1;
            
else
                
return 0;
            }
        }
        
private void button1_Click(object sender, EventArgs e)
        {
            
if (boolPwd.ToString() == "1")
                
this.Hide();
            
else
                MessageBox.Show(
"抱歉!您输入的密码有误,请重新输入!""取消任务", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            
this.textBox1.Focus();
        }

        
private void button2_Click(object sender, EventArgs e)
        {
            
this.Close();
            
this.Dispose();
        }

        
private void Form2_Load(object sender, EventArgs e)
        {
            Form1 f1 
= new Form1();
            
this.Icon = f1.Icon;
        }
    }

}  

复制代码


 

文件下载:

程序下载1:http://www.ctdisk.com/file/3719700 

程序下载2:http://www.newhua.com/soft/107138.htm

 

代码下载1:http://www.ctdisk.com/file/3719719 

代码下载2:http://download.csdn.net/source/3516050 

http://www.jmfq.cn/news/4894489.html

相关文章:

  • 武汉网站制作公司排名/班级优化大师下载安装
  • 各大电商购物网站转化率报表/优化网站内容
  • 服装企业营销网站建设/免费的十大免费货源网站
  • 物联网软件开发/汕头seo计费管理
  • 外贸英语怎么自学/惠州seo代理商
  • 做外贸比较好的网站/seo关键词优化技术
  • 网站备案的是空间还是域名/业务推广方式有哪些
  • 企业做网站要/百度seo排名点击器app
  • 网站模板文章资讯/海南快速seo排名优化
  • 电商网站建设思路/深圳seo公司助力网络营销飞跃
  • 网站测试方案/企业网站推广方案设计毕业设计
  • 苏州网站排名方案/模板建站的网站
  • 小企业做网站怎么做/手机怎么制作网页
  • 滨州网站建设公司电话/seo关键词排名优化销售
  • 找人做app网站吗/宁波谷歌seo
  • 泸州网站建设/网络推广服务外包公司
  • 手机端网站优化/百度网站排名
  • 网站设计第一步怎么做/做网站seo推广公司
  • 网站正在建设中 自拍/重庆百度小额贷款有限公司
  • 网站做端口是什么情况/如何制作百度网页
  • 广州有什么好玩的/浙江网站seo
  • 网上接单 网站建设/新品怎么刷关键词
  • 凤岗网站建设公司/青岛疫情最新情况
  • 西楚房产网宿迁房产网/站长工具之家seo查询
  • 建设网站要注意什么问题/注册网站平台
  • 做酒店网站的公司/互联网广告推广好做吗
  • 公司网站建设的好处/在线网站建设平台
  • 石家庄做网站建设的公司/百度客服在线咨询电话
  • 软件公司招聘/枣庄网站seo
  • 有教做鱼骨图的网站吗/高端网站设计