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

C#屏幕保護(hù)程序步驟

開發(fā) 后端
本文介紹編寫C#屏幕保護(hù)程序步驟,將 Timer控件的Name設(shè)置為timerSaver、Enabled 屬性設(shè)為true、Interval屬性設(shè)為5等。

Visual C#是微軟公司推出的新一代程序開發(fā)語(yǔ)言,是微軟.Net框架中的一個(gè)重要組成部分。屏幕保護(hù)程序是以scr為擴(kuò)展名的標(biāo)準(zhǔn)Windows可執(zhí)行程序。C#屏幕保護(hù)程序不僅可以延長(zhǎng)顯示器的使用壽命,還可以保護(hù)私人信息。本文向大家介紹一個(gè).Net平臺(tái)上用C#編寫的一個(gè)動(dòng)態(tài)文本及圖形的C#屏幕保護(hù)程序。

具體實(shí)現(xiàn)步驟:

1.在Visual Studio.Net下新建一個(gè)C#的Windows應(yīng)用程序工程,不妨命名為screen_saver。

2.現(xiàn)在我們來設(shè)計(jì)程序的主界面:

先將窗體的Name屬性設(shè)置為screen、Text屬性設(shè)置為空,BackColor屬性設(shè)置為Black、Size屬性設(shè)置為(800, 600)、 ControlBox、MaximizeBox、MinimizeBox、ShowInTaskbar屬性設(shè)置均為false、 FormBorderStyle屬性設(shè)置為None。再往窗體上添加Label控件、PictureBox控件、Timer控件各一個(gè)。將Label控件的Name設(shè)置為word、Text屬性設(shè)置為空;將PictureBox控件的Name設(shè)置為picture1、Image設(shè)置為一個(gè)預(yù)知圖片;將 Timer控件的Name設(shè)置為timerSaver、Enabled 屬性設(shè)為true、Interval屬性設(shè)為5。

3.現(xiàn)在我們開始編寫完整C#屏幕保護(hù)程序代碼部分:

  1. usingSystem;  
  2. usingSystem.Drawing;  
  3. usingSystem.Collections;  
  4. usingSystem.ComponentModel;  
  5. usingSystem.Windows.Forms;  
  6. usingSystem.Data;  
  7. file://  
  8.  
  9. namespacescreen_saver  
  10. {  
  11. ///  
  12. ///Form1的摘要說明。  
  13. ///  
  14.  
  15. publicclassscreen:System.Windows.Forms.Form  
  16. {  
  17. file://加入私有成員變量  
  18.  
  19. privateSystem.ComponentModel.IContainercomponents;  
  20. privateintiSpeed=2;  
  21. privatestringstr="福建南紡股份公司計(jì)算機(jī)中心";  
  22. file://定義文本字體及大小  
  23.  
  24. privateSystem.Drawing.FontTextStringFont=newSystem.Drawing.Font("宋體”,10,System.Drawing.FontStyle.Bold);  
  25.  
  26. privateColorTextStringcolor=System.Drawing.Color.Yellow;file://文本字體顏色  
  27.  
  28. privateintiDistance;  
  29. privateintixStart=0;  
  30. privateintiyStart=0;  
  31. privateintspeed;  
  32. privateintx1,y1;  
  33. intwidth1,height1;  
  34. privateSystem.Windows.Forms.TimertimerSaver;file://計(jì)時(shí)器控件  
  35.  
  36. privateSystem.Windows.Forms.PictureBoxpicture1;file://圖形控件  
  37.  
  38. privateSystem.Windows.Forms.Labelword;file://文本顯示控件  
  39.  
  40. ///  
  41. ///必需的設(shè)計(jì)器變量。  
  42. ///  
  43.  
  44. publicscreen()  
  45. {  
  46. file://  
  47. //Windows窗體設(shè)計(jì)器支持所必需的  
  48.  
  49. file://  
  50.  
  51. InitializeComponent();  
  52. word.Font=TextStringFont;  
  53. word.ForeColor=TextStringcolor;  
  54. System.Windows.Forms.Cursor.Hide();file://隱藏光標(biāo)  
  55.  
  56. file://  
  57. //TODO:在InitializeComponent調(diào)用后添加任何構(gòu)造函數(shù)代碼  
  58.  
  59. file://  
  60.  
  61. }  
  62.  
  63. protectedoverridevoidDispose(booldisposing)  
  64. {  
  65. if(disposing)  
  66. {  
  67. if(components!=null)  
  68. {  
  69. components.Dispose();  
  70. }  
  71. }  
  72. base.Dispose(disposing);  
  73. }  
  74. #regionWindowsFormDesignergeneratedcode  
  75. ///  
  76. ///設(shè)計(jì)器支持所需的方法-不要使用代碼編輯器修改  
  77. ///此方法的內(nèi)容。  
  78. privatevoidInitializeComponent()file://初始化程序中使用到的組件  
  79.  
  80. {  
  81. this.components=newSystem.ComponentModel.Container();  
  82. System.Resources.ResourceManagerresources=newsystem.Resources.ResourceManger(typeof(screen));  
  83. this.word=newSystem.Windows.Forms.Label();  
  84. this.timerSaver=newSystem.Windows.Forms.Timer(this.components);  
  85. this.picture1=newSystem.Windows.Forms.PictureBox();  
  86. this.SuspendLayout();  
  87. //  
  88. //設(shè)置文本顯示控件(word)屬性  
  89.  
  90. this.word.ForeColor=System.Drawing.Color.Yellow;  
  91. this.word.Location=newSystem.Drawing.Point(624,8);  
  92. this.word.Name="word";  
  93. this.word.Size=newSystem.Drawing.Size(168,16);  
  94. this.word.TabIndex=0;  
  95. this.word.Visible=false;  
  96. //  
  97. //設(shè)置計(jì)時(shí)器控件(timerSaver)屬性  
  98.  
  99. this.timerSaver.Enabled=true;  
  100. this.timerSaver.Interval=5;  
  101. this.timerSaver.Tick+=newSystem.EventHandler(this.timerSaver_Tick);  
  102. //  
  103. //設(shè)置圖片控件(picture1)屬性  
  104.  
  105. this.picture1.Image=((System.Drawing.Bitmap)(resources.GetObject("picture1.Image")));  
  106. this.picture1.Location=newSystem.Drawing.Point(800,600);  
  107. this.picture1.Name="picture1";  
  108. this.picture1.Size=newSystem.Drawing.Size(304,224);  
  109. this.picture1.SizeMode=System.Windows.Forms.PictureBoxSizeMode.StretchImage;  
  110. this.picture1.TabIndex=1;  
  111. this.picture1.TabStop=false;  
  112. //  
  113. //設(shè)置窗體(screen)屬性  
  114.  
  115. this.AutoScaleBaseSize=newSystem.Drawing.Size(6,14);  
  116. this.BackColor=System.Drawing.Color.Black;  
  117. this.ClientSize=newSystem.Drawing.Size(800,600);  
  118. this.ControlBox=false;  
  119. this.Controls.AddRange(newSystem.Windows.Forms.Control[]{this.picture1,this.word});  
  120. this.FormBorderStyle=System.Windows.Forms.FormBorderStyle.None;  
  121. this.KeyPreview=true;  
  122. this.MaximizeBox=false;  
  123. this.MinimizeBox=false;  
  124. this.Name="screen";  
  125. this.ShowInTaskbar=false;  
  126. this.StartPosition=System.Windows.Forms.FormStartPosition.Manual;  
  127. this.WindowState=System.Windows.Forms.FormWindowState.Maximized;  
  128. file://鍵盤按下響應(yīng)事件  
  129.  
  130. this.KeyDown+=newSystem.Windows.Forms.KeyEventHandler(this.screen_KeyDown);  
  131. file://鼠標(biāo)按下響應(yīng)事件  
  132.  
  133. this.MouseDown+=newSystem.Windows.Forms.MouseEventHandler(this.screen_MouseDown);  
  134. file://窗體啟動(dòng)調(diào)用事件  
  135.  
  136. this.Load+=newSystem.EventHandler(this.Form1_Load);  
  137. file://鼠標(biāo)移動(dòng)響應(yīng)事件  
  138.  
  139. this.MouseMove+=newSystem.Windows.Forms.MouseEventHandler(this.screen_MouseMove);  
  140. this.ResumeLayout(false);  

【編輯推薦】

  1. C#反射方法學(xué)習(xí)總結(jié)
  2. 淺談C#測(cè)量cpu性能
  3. C#遠(yuǎn)程計(jì)算機(jī)的一些理論知識(shí)
  4. 淺析C# Static修飾
  5. C#轉(zhuǎn)換農(nóng)歷的簡(jiǎn)單方法
責(zé)任編輯:佚名 來源: IT168
相關(guān)推薦

2009-08-06 17:31:46

C#制作屏幕保護(hù)

2011-03-30 13:28:26

2009-08-13 17:04:09

C#語(yǔ)言C#程序

2009-08-25 17:13:57

C#串口編程

2009-08-20 17:49:53

學(xué)習(xí)C#程序

2009-08-18 13:24:01

C#安裝程序

2019-10-23 16:00:28

Windows 10屏幕保護(hù)灰色

2021-04-22 09:00:50

蘋果macOS屏幕保護(hù)

2009-08-19 17:11:49

C#程序集

2009-08-24 13:04:44

操作步驟C#字符串

2009-08-12 10:29:31

C#實(shí)現(xiàn)全局鉤子

2009-08-11 15:46:15

C#日歷控件

2009-08-27 16:24:36

C#屏幕取詞

2009-07-31 16:48:44

C#位運(yùn)算

2009-08-11 13:27:09

C#動(dòng)態(tài)圖像按鈕

2009-08-12 17:44:30

C# Web Serv

2009-08-12 18:28:09

C#事件處理程序

2009-08-24 15:46:46

C# SmartPho

2009-08-20 10:48:05

C#做Screen C

2009-09-03 14:49:49

C#實(shí)現(xiàn)網(wǎng)絡(luò)點(diǎn)對(duì)點(diǎn)
點(diǎn)贊
收藏

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