知识大全 用C#做ScreenSaver

Posted 文字

篇首语:没有理想,那些所谓的奋斗都是空话。本文由小常识网(cha138.com)小编为大家整理,主要介绍了知识大全 用C#做ScreenSaver相关的知识,希望对你有一定的参考价值。

用C#做ScreenSaver  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!

  /*    Program      :    A Simple Screen Saver*    File Name    :    ScreenSaver cs*    Author        :    Tran Khanh Hien*    Date        :    / / *    email        :    */

  namespace Screen_Saver    using System;    using System Drawing;    using System Collections;    using System ComponentModel;    using System WinForms;    using System Data;

  /// <summary>    ///    Summary description for Form     /// </summary>    public class ScreenSaver : System WinForms Form            /// <summary>        ///    Required designer variable         /// </summary>        private System ComponentModel Container ponents;        private System WinForms Timer timerSaver;        private System WinForms Label lblMarquee;

  private int  iSpeed = ;        private string strMarqueeText= C Sharp Screen Saver ;

  private System Drawing Font fontMarquee = new System Drawing Font ( Arial System Drawing FontStyle Bold);        private Color colorMarquee = System Drawing Color FromARGB( );

  private int iDistance;        private int ixStart= ;        private int iyStart= ;

  public ScreenSaver()                    InitializeComponent();

  lblMarquee Font=fontMarquee;            lblMarquee ForeColor=colorMarquee;            System Drawing Cursor Hide();       

  /// <summary>        ///    Clean up any resources being used         /// </summary>        public override void Dispose()                    base Dispose();            ponents Dispose();       

  /// <summary>        ///    Required method for Designer support do not modify        ///    the contents of this method with the code editor         /// </summary>        private void InitializeComponent()                    System Resources ResourceManager resources = new System Resources ResourceManager (typeof(ScreenSaver));            ponents = new System ComponentModel Container ();            this timerSaver = new System WinForms Timer (ponents);            this lblMarquee = new System WinForms Label ();            //@this TrayHeight = ;            //@this TrayLargeIcon = false;            //@this TrayAutoArrange = true;            //@timerSaver SetLocation (new System Drawing Point ( ));            timerSaver Interval = ;            timerSaver Enabled = true;            timerSaver Tick += new System EventHandler (this timerSaver_Tick);            lblMarquee Location = new System Drawing Point ( );            lblMarquee Size = new System Drawing Size ( );            lblMarquee ForeColor = System Drawing Color White;            lblMarquee TabIndex = ;            lblMarquee Visible = false;            this MaximizeBox = false;            this StartPosition = System WinForms FormStartPosition Manual;            this AutoScaleBaseSize = new System Drawing Size ( );            this BorderStyle = System WinForms FormBorderStyle None;            this KeyPreview = true;            this WindowState = System WinForms FormWindowState Maximized;            this ShowInTaskbar = false;            this Icon = (System Drawing Icon) resources GetObject ( $this Icon );            this ControlBox = false;            this MinimizeBox = false;            this BackColor = System Drawing Color Black;            this ClientSize = new System Drawing Size ( );            this KeyDown += new System WinForms KeyEventHandler (this Form _KeyDown);            this MouseDown += new System WinForms MouseEventHandler (this Form _MouseDown);            this MouseMove += new System WinForms MouseEventHandler (this Form _MouseMove);            this Controls Add (this lblMarquee);       

  protected void timerSaver_Tick (object sender System EventArgs e)                    lblMarquee Text=strMarqueeText;            lblMarquee Height=lblMarquee Font Height;            lblMarquee Width=lblMarquee Text Length*(int)lblMarquee Font Size;

  PlayScreenSaver();       

  private void PlayScreenSaver()                    //Get the working area of the the puter screen             System Drawing Rectangle ssWorkArea = System WinForms Screen GetWorkingArea(this);

  lblMarquee Location=new System Drawing Point(ssWorkArea Width iDistance                                         lblMarquee Location Y);

  //Make the label visible if it is not currently visible             lblMarquee Visible=true;

  // Increment the label distance based on the speed set by the user             iDistance += iSpeed;            // If the label is offscreen then we want to reposition it to the right             if (lblMarquee Location X <= (lblMarquee Width))                            //Reset the distance to                 iDistance = ;

  //If the label is at the top move it to the middle                 if (lblMarquee Location Y == )                    lblMarquee Location=new System Drawing Point(lblMarquee Location X (ssWorkArea Height / ));

  // If label is in the middle of the screen move it to the bottom                 else if(lblMarquee Location Y== ssWorkArea Height / )                    lblMarquee Location=new System Drawing Point(lblMarquee Location X ssWorkArea Height lblMarquee Height);                //Move the label back to the top                 else                    lblMarquee Location=new System Drawing Point(lblMarquee Location X );                   

  protected void Form _MouseDown (object sender System WinForms MouseEventArgs e)                    StopScreenSaver();       

  protected void Form _MouseMove (object sender System WinForms MouseEventArgs e)                    // Determine if the mouse cursor position has been stored previously             if (ixStart == && iyStart == )                            //Store the mouse cursor coordinates                 ixStart = e X;                iyStart = e Y;                return;                        // Has the mouse cursor moved since the screen saver was started?            else if (e X != ixStart || e Y != iyStart)                StopScreenSaver();

  

  private void StopScreenSaver()                    System Drawing Cursor Show();            timerSaver Enabled=false;            Application Exit();       

  protected void Form _KeyDown (object sender System WinForms KeyEventArgs e)                    StopScreenSaver();       

  /// <summary>        /// The main entry point for the application         /// </summary>        public static void Main(string[] args)                    if (args Length== )                            //Display the options dialog box                 if (args[ ] Substring( ) Equals( /c ))                                    MessageBox Show( Options are not available for this screen saver                                     C# Screen Saver                                     MessageBox IconInformation);                    Application Exit();                                //Start the screen saver normally                 else if (args[ ]== /s )                    Application Run(new ScreenSaver());

  //Diaplay the password dialog                else if (args[ ]== /a )                                    MessageBox Show( Passwords are not available for this screen saver                                     C# Screen Saver                                     MessageBox IconInformation);                    Application Exit();                                        //For any other args > start             else                Application Run(new ScreenSaver());       

cha138/Article/program/net/201311/13725

相关参考

知识大全 C#与NativeC++互相访问

C#与NativeC++互相访问  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  用C#做开发已经

知识大全 关于c#静态方法和实例方法的辨析和应用

  本文将围绕c#静态方法和实例方法讨论一下针对一些观点如静态方法是常驻内存还有静态方法比实例方法先装载做一个辨析同时讨论下何时用静态方法何时用实例方法  前几日在微软的好友发给我一个链接《静态方法和

知识大全 C#中COM操作(一)---实例化

C#中COM操作(一)---实例化  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  用C#做Win

知识大全 C#中COM操作(一)---实例化[1]

C#中COM操作(一)---实例化[1]  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  用C#做

知识大全 c#中使用多线程访问winform中控件

  我们在做winform应用的时候大部分情况下都会碰到使用多线程控制界面上控件信息的问题然而我们并不能用传统方法来做这个问题下面我将详细的介绍  首先来看传统方法  publicpartialcla

知识大全 用 C# 编程实现读写Binary

用C#编程实现读写Binary  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  本文给出一个用C#

知识大全 用C#实现飞信协议

用C#实现飞信协议  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  目前已经有C#版得飞信sdk功

知识大全 用C#编写ActiveX控件

用C#编写ActiveX控件  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!首先建立一个WinFor

知识大全 用C#写一个下载程序

用C#写一个下载程序  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!cha138/Arti

知识大全 用C#语言构造蜘蛛程序

用C#语言构造蜘蛛程序  以下文字资料是由(全榜网网www.cha138.com)小编为大家搜集整理后发布的内容,让我们赶快一起来看一下吧!  蜘蛛(Spider)是一种