成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

C#屏幕保護程序步驟

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

Visual C#是微軟公司推出的新一代程序開發語言,是微軟.Net框架中的一個重要組成部分。屏幕保護程序是以scr為擴展名的標準Windows可執行程序。C#屏幕保護程序不僅可以延長顯示器的使用壽命,還可以保護私人信息。本文向大家介紹一個.Net平臺上用C#編寫的一個動態文本及圖形的C#屏幕保護程序。

具體實現步驟:

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

2.現在我們來設計程序的主界面:

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

3.現在我們開始編寫完整C#屏幕保護程序代碼部分:

  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="福建南紡股份公司計算機中心";  
  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://計時器控件  
  35.  
  36. privateSystem.Windows.Forms.PictureBoxpicture1;file://圖形控件  
  37.  
  38. privateSystem.Windows.Forms.Labelword;file://文本顯示控件  
  39.  
  40. ///  
  41. ///必需的設計器變量。  
  42. ///  
  43.  
  44. publicscreen()  
  45. {  
  46. file://  
  47. //Windows窗體設計器支持所必需的  
  48.  
  49. file://  
  50.  
  51. InitializeComponent();  
  52. word.Font=TextStringFont;  
  53. word.ForeColor=TextStringcolor;  
  54. System.Windows.Forms.Cursor.Hide();file://隱藏光標  
  55.  
  56. file://  
  57. //TODO:在InitializeComponent調用后添加任何構造函數代碼  
  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. ///設計器支持所需的方法-不要使用代碼編輯器修改  
  77. ///此方法的內容。  
  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. //設置文本顯示控件(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. //設置計時器控件(timerSaver)屬性  
  98.  
  99. this.timerSaver.Enabled=true;  
  100. this.timerSaver.Interval=5;  
  101. this.timerSaver.Tick+=newSystem.EventHandler(this.timerSaver_Tick);  
  102. //  
  103. //設置圖片控件(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. //設置窗體(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://鍵盤按下響應事件  
  129.  
  130. this.KeyDown+=newSystem.Windows.Forms.KeyEventHandler(this.screen_KeyDown);  
  131. file://鼠標按下響應事件  
  132.  
  133. this.MouseDown+=newSystem.Windows.Forms.MouseEventHandler(this.screen_MouseDown);  
  134. file://窗體啟動調用事件  
  135.  
  136. this.Load+=newSystem.EventHandler(this.Form1_Load);  
  137. file://鼠標移動響應事件  
  138.  
  139. this.MouseMove+=newSystem.Windows.Forms.MouseEventHandler(this.screen_MouseMove);  
  140. this.ResumeLayout(false);  

【編輯推薦】

  1. C#反射方法學習總結
  2. 淺談C#測量cpu性能
  3. C#遠程計算機的一些理論知識
  4. 淺析C# Static修飾
  5. C#轉換農歷的簡單方法
責任編輯:佚名 來源: IT168
相關推薦

2009-08-06 17:31:46

C#制作屏幕保護

2011-03-30 13:28:26

2009-08-13 17:04:09

C#語言C#程序

2009-08-25 17:13:57

C#串口編程

2009-08-18 13:24:01

C#安裝程序

2009-08-24 13:04:44

操作步驟C#字符串

2009-08-11 15:46:15

C#日歷控件

2009-08-12 10:29:31

C#實現全局鉤子

2009-08-19 17:11:49

C#程序集

2019-10-23 16:00:28

Windows 10屏幕保護灰色

2021-04-22 09:00:50

蘋果macOS屏幕保護

2009-08-20 17:49:53

學習C#程序

2009-08-27 16:24:36

C#屏幕取詞

2009-09-03 14:49:49

C#實現網絡點對點

2009-09-24 15:10:54

C#調用COM組件

2009-08-07 17:32:17

C#編譯程序

2023-07-13 12:18:24

2009-07-31 16:48:44

C#位運算

2009-08-11 13:27:09

C#動態圖像按鈕

2009-08-12 17:44:30

C# Web Serv
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 国产精品日韩在线观看一区二区 | 日韩欧美国产一区二区 | 亚洲视频一区在线 | 久草中文在线 | 欧美中文字幕在线 | 成人欧美一区二区三区在线观看 | 欧美13videosex性极品 | 2019天天操| 国产精品一区二区三区在线 | 日韩福利 | av网站免费观看 | 国产精品av久久久久久久久久 | 黄视频免费观看 | 欧美a级成人淫片免费看 | 日本a在线 | 完全免费在线视频 | 免费在线观看av | 青青草视频网站 | 在线不卡视频 | 欧美二区三区 | 亚洲成人精品在线 | 成人福利网 | 亚洲精品久久久久久国产精华液 | 亚洲精品乱码久久久久久蜜桃91 | 国产精品久久久久久久久久久久 | 在线欧美 | 国产黄色大片 | 午夜一级黄色片 | 国产一区久久 | 噜噜噜噜狠狠狠7777视频 | 午夜激情免费视频 | 日韩一区二区在线播放 | 干干干日日日 | 国内自拍视频在线观看 | 久久精品亚洲 | 国产一区二区三区四区五区加勒比 | 91天堂网 | 亚洲人成人一区二区在线观看 | 网色| 亚洲一二三区在线观看 | 久久综合影院 |