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

Home
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.LINQ
23.GUI Windows Forms
24.Windows Presentation Foundation
25.Windows Communication Foundation
26.Workflow
27.2D
28.Design Patterns
29.Windows
30.XML
31.XML LINQ
32.ADO.Net
33.Network
34.Directory Services
35.Security
36.unsafe
C# / C Sharp
C# / C Sharp by API
C# / CSharp Open Source
C# / CSharp Tutorial » GUI Windows Forms » NotifyIcon 
23.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);

    }
}
23.43.NotifyIcon
23.43.1.NotifyIcon Sample
23.43.2.Use Timer to update NotifyIconUse Timer to update NotifyIcon
23.43.3.Use Timer to update User interface: NotifyIconUse Timer to update User interface: NotifyIcon
23.43.4.Use NotifyIcon class to display an icon for an application in the notification area.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.