Thursday, September 23, 2010

Animating SystemTray Notification Icons in C#



This does as the title suggests. In the SystemTray in order to animate the icon, you have to load the icon from resources from within the Project.  This piece of code in the Timer event will change the image every given interval. I used this snippet in my S Cubed program, see screenshot above.


 int x = 0;
        private void timer2_Tick(object sender, EventArgs e)
        {
            Icon ico = Properties.Resources.workstation_locked_Vista;
            Icon ico2 = Properties.Resources.workstation_locked_Vista_on;
            Image log1 = Properties.Resources.puter1;
            Image log2 = Properties.Resources.puter2;


            if (x==1)
            {
                ntyS3.Icon = ico;
                imgS3.Image = log1;
                x = 0;
            }
            else
            {
                ntyS3.Icon = ico2;
                imgS3.Image = log2;
                x = 1;
            }
        }

No comments:

Post a Comment

Generating "Always On Top" NSWindow in macOS across all detected displays

Also: Using UIKit & Cocoa Frameworks using Objective-C In m acOS or OS X , written in either Objective-C or Swift  Langues, you m...