日期:2014-05-17  浏览次数:21208 次

给自己写的定时关机程序
效果图

连接:http://http://bbs.csdn.net/topics/new?forum_id=CSharp
------最佳解决方案--------------------
功能很简单啊
代码写得怎么样呢?


------其他解决方案--------------------
提几点意见:

1.  左图中时间设定处,时、分、秒之间缺少:分隔。

2.  个人认为,时、分、秒设定,用+-比用下拉框更人性化。

3.  这里的几个数字右对齐会美观一些
------其他解决方案--------------------
还要输入精确到秒,我计算不够好怎么办
------其他解决方案--------------------
几秒后关机很多余
------其他解决方案--------------------
额,多了http
http://bbs.csdn.net/topics/new?forum_id=CSharp
------其他解决方案--------------------
凌乱了
http://download.csdn.net/detail/wltica/4803757
------其他解决方案--------------------
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AotuShutdownPC
{
    public partial class Shutdown : Form
    {
        public Shutdown()
        {
            InitializeComponent();
        }
        int Delay;
        private void button1_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
            myProcess.StartInfo.FileName = "cmd.exe";
            myProcess.StartInfo.UseShellExecute = false;
            myProcess.StartInfo.RedirectStandardInput = true;
            myProcess.StartInfo.RedirectStandardOutput = true;
            myProcess.StartInfo.RedirectStandardError = true;
            myProcess.StartInfo.CreateNoWindow = true;
            myProcess.Start();
            if (tabControl1.SelectedIndex == 0)
            {
                DateTime From = System.DateTime.Now.Date;
                DateTime To = dateTimePicker1.Value.Date;
                TimeSpan ts =To.Subtract(From);
                Delay = ts.Days * 24 * 3600-System.DateTime.Now.Hour * 3600 - System.DateTime.Now.Minute * 60 - System.DateTime.Now.Se