基本信息
源码名称:C#定时关机工具源码(亲测好用!)
源码大小:0.12M
文件格式:.rar
开发语言:C#
更新时间:2018-12-11
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Diagnostics;

namespace 定时关机工具
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            timer1.Start();
            numericUpDown1.Enabled = false;
            numericUpDown2.Enabled = false;
            numericUpDown3.Enabled = false;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            label1.Text = DateTime.Now.ToString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (checkBox1.Checked)
            {
                if (MessageBox.Show("将要设定计划关机,是否确认操作?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    decimal decl = numericUpDown1.Value * 3600   numericUpDown2.Value * 60   numericUpDown3.Value;
                    string str = decl.ToString();
                    Process.Start("shutdown.exe", "-s -t "   str);
                }
            }
            else
            {
                if (MessageBox.Show("是否确认关机?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    Process.Start("shutdown.exe", "-s");
                    //Process.Start("shutdown.exe", "-s -t xx");
                }
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("是否确认重启?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                Process.Start("shutdown.exe", "-r");
                Process.Start("shutdown.exe", "-r -t 10");
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("是否确认注销?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
                Process.Start("shutdown.exe", "-l");
        }

        private void 当前时间TToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (groupBox2.Visible) { groupBox2.Visible = false; 当前时间TToolStripMenuItem.Checked = false; }
            else { groupBox2.Visible = true; 当前时间TToolStripMenuItem.Checked = true; }
        }

        private void 背景色BToolStripMenuItem_Click(object sender, EventArgs e)
        {
            colorDialog1.AllowFullOpen = true;
            colorDialog1.AnyColor = true;
            colorDialog1.Color = this.BackColor;
            if (colorDialog1.ShowDialog() == DialogResult.OK)
            {
                this.BackColor = colorDialog1.Color;
                原色QToolStripMenuItem.Checked = false;
            }
        }

        private void 原色QToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.BackColor = SystemColors.Control;
            原色QToolStripMenuItem.Checked = true;
        }

        private void 关于AToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form2 form2 = new Form2(); form2.Show();
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBox1.Checked)
            {
                numericUpDown1.Enabled = true; numericUpDown2.Enabled = true;
                numericUpDown3.Enabled = true; button1.Text = "计划关机";
            }
            else
            {
                numericUpDown1.Enabled = false; numericUpDown2.Enabled = false;
                numericUpDown3.Enabled = false; button1.Text = "关机";
            }
        }
    }
}