Created
March 5, 2018 03:25
-
-
Save Fhernd/de605f3eab2fa9f5b5f480caf49be316 to your computer and use it in GitHub Desktop.
OrtizOL. Animación ícono bandeja del sistema. C#.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Drawing; | |
using System.Windows.Forms; | |
using Timer = System.Timers.Timer; | |
namespace R716IconoAnimadoBandejaSistema | |
{ | |
public partial class Principal : Form | |
{ | |
private Icon[] imagenes; | |
private Timer temporizador; | |
private int contadorImagenes; | |
public Principal() | |
{ | |
InitializeComponent(); | |
imagenes = new Icon[8]; | |
temporizador = new Timer(); | |
temporizador.Enabled = true; | |
temporizador.Interval = 1000D; | |
temporizador.SynchronizingObject = this; | |
temporizador.Elapsed += new System.Timers.ElapsedEventHandler(temporizador_Elapsed); | |
inicializarIconNotificacion(); | |
} | |
private void inicializarIconNotificacion() | |
{ | |
// Creación menú contextual: | |
ContextMenuStrip cmsMenuContextual = new ContextMenuStrip(); | |
cmsMenuContextual.Items.AddRange(new ToolStripItem[] | |
{ | |
new ToolStripMenuItem("Más info"), | |
new ToolStripSeparator(), | |
new ToolStripMenuItem("Salir") | |
}); | |
nicBandejaSistema.ContextMenuStrip = cmsMenuContextual; | |
} | |
protected override void OnLoad(EventArgs e) | |
{ | |
base.OnLoad(e); | |
imagenes[0] = new Icon("Resources/MOON01.ICO"); | |
imagenes[1] = new Icon("Resources/MOON02.ICO"); | |
imagenes[2] = new Icon("Resources/MOON03.ICO"); | |
imagenes[3] = new Icon("Resources/MOON04.ICO"); | |
imagenes[4] = new Icon("Resources/MOON05.ICO"); | |
imagenes[5] = new Icon("Resources/MOON06.ICO"); | |
imagenes[6] = new Icon("Resources/MOON07.ICO"); | |
imagenes[7] = new Icon("Resources/MOON08.ICO"); | |
} | |
private void temporizador_Elapsed(object sender, System.Timers.ElapsedEventArgs e) | |
{ | |
nicBandejaSistema.Icon = imagenes[contadorImagenes]; | |
++contadorImagenes; | |
if (contadorImagenes > 7) | |
{ | |
contadorImagenes = 0; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment