Advertisement
Fhernd

Principal.js

Mar 4th, 2018
1,268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.15 KB | None | 0 0
  1. using System;
  2. using System.Drawing;
  3. using System.Windows.Forms;
  4. using Timer = System.Timers.Timer;
  5.  
  6. namespace R716IconoAnimadoBandejaSistema
  7. {
  8.     public partial class Principal : Form
  9.     {
  10.         private Icon[] imagenes;
  11.         private Timer temporizador;
  12.         private int contadorImagenes;
  13.  
  14.         public Principal()
  15.         {
  16.             InitializeComponent();
  17.  
  18.             imagenes = new Icon[8];
  19.             temporizador = new Timer();
  20.             temporizador.Enabled = true;
  21.             temporizador.Interval = 1000D;
  22.             temporizador.SynchronizingObject = this;
  23.             temporizador.Elapsed += new System.Timers.ElapsedEventHandler(temporizador_Elapsed);
  24.  
  25.             inicializarIconNotificacion();
  26.         }
  27.  
  28.         private void inicializarIconNotificacion()
  29.         {
  30.             // Creación menú contextual:
  31.             ContextMenuStrip cmsMenuContextual = new ContextMenuStrip();
  32.             cmsMenuContextual.Items.AddRange(new ToolStripItem[]
  33.             {
  34.                 new ToolStripMenuItem("Más info"),
  35.                 new ToolStripSeparator(),
  36.                 new ToolStripMenuItem("Salir")
  37.             });
  38.  
  39.             nicBandejaSistema.ContextMenuStrip = cmsMenuContextual;
  40.         }
  41.  
  42.         protected override void OnLoad(EventArgs e)
  43.         {
  44.             base.OnLoad(e);
  45.  
  46.             imagenes[0] = new Icon("Resources/MOON01.ICO");
  47.             imagenes[1] = new Icon("Resources/MOON02.ICO");
  48.             imagenes[2] = new Icon("Resources/MOON03.ICO");
  49.             imagenes[3] = new Icon("Resources/MOON04.ICO");
  50.             imagenes[4] = new Icon("Resources/MOON05.ICO");
  51.             imagenes[5] = new Icon("Resources/MOON06.ICO");
  52.             imagenes[6] = new Icon("Resources/MOON07.ICO");
  53.             imagenes[7] = new Icon("Resources/MOON08.ICO");
  54.         }
  55.  
  56.         private void temporizador_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
  57.         {
  58.             nicBandejaSistema.Icon = imagenes[contadorImagenes];
  59.             ++contadorImagenes;
  60.             if (contadorImagenes > 7)
  61.             {
  62.                 contadorImagenes = 0;
  63.             }
  64.         }
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement