Use Timer to update User interface: NotifyIcon : NotifyIcon « GUI Windows Forms « C# / CSharp Tutorial

C# / CSharp Tutorial
1. Language Basics
2. Data Type
3. Operator
4. Statement
5. String
6. struct
7. Class
8. Operator Overload
9. delegate
10. Attribute
11. Data Structure
12. Assembly
13. Date Time
14. Development
15. File Directory Stream
16. Preprocessing Directives
17. Regular Expression
18. Generic
19. Reflection
20. Thread
21. I18N Internationalization
22. GUI Windows Forms
23. 2D
24. Design Patterns
25. Windows
26. XML
27. ADO.Net
28. Network
29. Directory Services
30. Security
31. unsafe
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
C# / CSharp Tutorial » GUI Windows Forms » NotifyIcon 
22. 43. 3. Use Timer to update User interface: NotifyIcon
Use Timer to update User interface: NotifyIcon
using System;
using System.Drawing;
using System.Windows.Forms;

public class NotifyIconTimerUpdate : Form
{
    private Icon[] images = new Icon[8];

    int index = 0;

    public NotifyIconTimerUpdate()
    {
        InitializeComponent();

        images[0new Icon("1.ico");
        images[1new Icon("2.ico");
        images[2new Icon("3.ico");
        images[3new Icon("4.ico");
        images[4new Icon("5.ico");
        images[5new Icon("1.ico");
        images[6new Icon("2.ico");
        images[7new Icon("3.ico");
    }

    private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
    {
        notifyIcon.Icon = images[index];
        index++;
        if (index > 7
           index = 0;
    }

    [STAThread]
    public static void Main(string[] args)
    {
        Application.Run(new NotifyIconTimerUpdate());
    }
    private System.Windows.Forms.NotifyIcon notifyIcon;
    private System.Timers.Timer timer;
    
    private System.ComponentModel.IContainer components = null;

    private void InitializeComponent()
    {
        this.components = new System.ComponentModel.Container();
        this.notifyIcon = new System.Windows.Forms.NotifyIcon(this.components);
        this.timer = new System.Timers.Timer();
        ((System.ComponentModel.ISupportInitialize)(this.timer)).BeginInit();
        this.SuspendLayout();
        // 
        // notifyIcon
        // 
        this.notifyIcon.Text = "notifyIcon1";
        this.notifyIcon.Visible = true;
        // 
        // timer
        // 
        this.timer.Enabled = true;
        this.timer.Interval = 1000;
        this.timer.SynchronizingObject = this;
        this.timer.Elapsed += new System.Timers.ElapsedEventHandler(this.timer_Elapsed);
        // 
        // NotifyIconTimerUpdate
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(340174);
        ((System.ComponentModel.ISupportInitialize)(this.timer)).EndInit();
        this.ResumeLayout(false);

    }
}
22. 43. NotifyIcon
22. 43. 1. NotifyIcon Sample
22. 43. 2. Use Timer to update NotifyIconUse Timer to update NotifyIcon
22. 43. 3. Use Timer to update User interface: NotifyIconUse Timer to update User interface: NotifyIcon
w___w__w_._j___a__v_a2_s__.__co___m_ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.