偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

C#編寫(xiě)自動(dòng)關(guān)機(jī)程序復(fù)習(xí)的知識(shí)

開(kāi)發(fā) 后端
上面我每隔半秒進(jìn)入中斷一次,判斷,如果已經(jīng)設(shè)置過(guò)定時(shí)關(guān)機(jī),就判斷是否到達(dá)關(guān)機(jī)時(shí)間,并顯示還剩多少秒關(guān)機(jī)。如果沒(méi)有設(shè)置定時(shí)關(guān)機(jī),就不顯示。

[[148264]]

首先一個(gè)程序***要素是logo

在設(shè)置里面可以設(shè)置程序圖標(biāo),在ICON里設(shè)置。

ICON圖標(biāo)可以在網(wǎng)上下載。

這些都是表面功夫

程序中涉及到Buton、Label、Timer、Notiflcon控件

Button按鈕控件,可以設(shè)計(jì)點(diǎn)擊事件

如下所示:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

private void button1_Click(object sender, EventArgs e)

        {

           // int shi, fen, miao;

            if (Flag_True == 0)

            {

                Flag_True = 1;

            }

            else

            {

                button1.Text = "確定";

                label6.Text = " ";

                label7.Text = " ";

                label5.Text = " ";

                //label1.Text = "定時(shí)關(guān)機(jī)設(shè)置";

                Flag_True = 0;

            }

            shi = (int)numericUpDown3.Value;

            fen = (int)numericUpDown2.Value;

            miao = (int)numericUpDown1.Value;

            time_set = shi * 3600 + fen * 60 + miao;

        }

 label控件操作簡(jiǎn)單

能夠顯示字符,并且其成員有text,可以隨時(shí)更改文本

timer控件相當(dāng)于嵌入式中的定時(shí)器,在屬性中行為一欄中設(shè)置ENABLE 并且設(shè)置interval時(shí)間間隔500就是半秒。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

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 = "取消";

                    label6.Text = "剩余關(guān)機(jī)時(shí)間";

                    label7.Text = "秒";

                    label5.Text = "0";

                    System.Diagnostics.Process.Start("shutdown","-s -t 0");//關(guān)機(jī)程序

                }//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 = "取消";

                        label6.Text = "剩余關(guān)機(jī)時(shí)間";

                        label7.Text = "秒";

                        //extra/3600

                        label5.Text = extra.ToString();

                    }

                    else

                    {

                        Flag_True = 0;

                    }

                         

                     

                }

            }

        }

 上面我每隔半秒進(jìn)入中斷一次,判斷,如果已經(jīng)設(shè)置過(guò)定時(shí)關(guān)機(jī),就判斷是否到達(dá)關(guān)機(jī)時(shí)間,并顯示還剩多少秒關(guān)機(jī)。如果沒(méi)有設(shè)置定時(shí)關(guān)機(jī),就不顯示。

其中button1和Label的text都可以隨時(shí)更改。

基本功能設(shè)置完成

接下來(lái)還有一個(gè)最小化到托盤(pán)的設(shè)置

用到Notiflcon控件

此控件設(shè)置最小化圖標(biāo),在設(shè)置里可以設(shè)置icon圖標(biāo)。

他帶有的事件有鼠標(biāo)單擊,鼠標(biāo)雙擊,單擊,雙擊。

1

2

3

4

5

6

private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)

        {

            this.Visible = true;

            this.WindowState = FormWindowState.Normal;

            this.notifyIcon1.Visible = false;

        }

 上述我設(shè)置了鼠標(biāo)單擊,代碼里是恢復(fù)可視化,正常窗口。

再之得設(shè)置程序最小化時(shí)隱藏在下邊

1

2

3

4

5

6

7

8

private void Form1_SizeChanged(object sender, EventArgs e)

        {

            if (this.WindowState == FormWindowState.Minimized)

            {

                this.Hide();

                this.notifyIcon1.Visible = true;

            }

        }

 上述就是一個(gè)關(guān)機(jī)程序,自己做著玩的。。

整體構(gòu)架如下圖所示。

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

namespace 關(guān)機(jī)任務(wù)管理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 button1_Click(object sender, EventArgs e)

        {

           // int shi, fen, miao;

            if (Flag_True == 0)

            {

                Flag_True = 1;

            }

            else

            {

                button1.Text = "確定";

                label6.Text = " ";

                label7.Text = " ";

                label5.Text = " ";

                //label1.Text = "定時(shí)關(guān)機(jī)設(shè)置";

                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 = "取消";

                    label6.Text = "剩余關(guān)機(jī)時(shí)間";

                    label7.Text = "秒";

                    label5.Text = "0";

                    System.Diagnostics.Process.Start("shutdown","-s -t 0");//關(guān)機(jī)程序

                }//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 = "取消";

                        label6.Text = "剩余關(guān)機(jī)時(shí)間";

                        label7.Text = "秒";

                        //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 notifyIcon1_MouseClick(object sender, MouseEventArgs e)

        {

            this.Visible = true;

            this.WindowState = FormWindowState.Normal;

            this.notifyIcon1.Visible = false;

        }

        //最小化代碼

        private void Form1_SizeChanged(object sender, EventArgs e)

        {

            if (this.WindowState == FormWindowState.Minimized)

            {

                this.Hide();

                this.notifyIcon1.Visible = true;

            }

        }

    }

}

 界面如下

[[148265]]

 
責(zé)任編輯:王雪燕 來(lái)源: 博客園
相關(guān)推薦

2009-08-06 10:28:11

Vmware虛擬機(jī)自動(dòng)

2019-10-18 10:30:14

Windows 10自動(dòng)關(guān)機(jī)Windows

2011-08-08 16:49:07

自動(dòng)關(guān)機(jī)SwitchOffWindows

2009-09-11 09:13:34

2017-06-08 11:11:03

Windows 8Windows自動(dòng)關(guān)機(jī)計(jì)劃

2017-03-20 20:10:04

Windows 7Windows定時(shí)關(guān)機(jī)

2011-07-28 22:41:04

投影機(jī)技巧

2010-12-21 09:58:37

Linux腳本自動(dòng)關(guān)機(jī)任務(wù)管理

2009-09-02 17:24:44

C#關(guān)機(jī)代碼

2022-01-11 09:59:23

Python關(guān)機(jī)程序文件

2009-09-02 17:12:06

C#關(guān)機(jī)代碼

2021-11-17 22:41:41

手機(jī)電池低溫

2020-07-15 14:51:39

代碼C+開(kāi)發(fā)

2011-04-29 10:02:35

投影機(jī)

2009-09-02 14:00:34

C#文件處理

2009-07-30 18:20:21

C#繼承

2009-08-12 18:04:44

編寫(xiě)C#多線程

2009-08-28 15:05:35

C#編寫(xiě)Calenda

2009-08-25 13:26:49

C#編寫(xiě)asp+

2009-08-06 16:58:40

C#編寫(xiě)ActiveX
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)