namespace myImageRotator
{
    using System;
    using System.Drawing;
    using System.ComponentModel;
    using System.Windows.Forms;    public class Form1 : System.Windows.Forms.Form
    {
        protected Container components;
        protected ListBox listBox1;
        protected Label label2;
        protected Label label3;
        protected Label label5;
        protected PictureBox pictureBox1;
        protected Button button1;
        protected Button button2;
        protected Button button3;
        protected Button button4;
        protected Panel panel1;
        protected ImageList imageList1;
        protected Graphics myGraphics;
        protected OpenFileDialog openFileDialog1;        private int currentImage = 0;        public Form1()
        {
            InitializeComponent();
            imageList1 = new ImageList () ;
            // The default image size is 16 x 16, which sets up a larger
            // image size. 
            imageList1.ImageSize = new Size(255,255);
            imageList1.TransparentColor = Color.White;
            // Assigns the graphics object to use in the draw options.
            myGraphics = Graphics.FromHwnd(panel1.Handle);
        }       protected override void Dispose( bool disposing )
       {
           if( disposing )
           {
               if (components != null) 
               {
                   components.Dispose();
               }
           }
           base.Dispose( disposing );
       }        private void InitializeComponent()
        {
            // Initializations for listBox1, label2, pictureBox1,
            // button2, button3, panel1, openFileDialog1, button4, label1, 
            // button1, and imageList1.
        }        protected void button1_Click (object sender, System.EventArgs e)
        {
            displayNextImage();
        }        protected void button2_Click (object sender, System.EventArgs e)
        {
            imageList1.Images.RemoveAt(listBox1.SelectedIndex);
            listBox1.Items.Remove(listBox1.SelectedIndex);
        }        protected void button3_Click (object sender, System.EventArgs e)
        {
            imageList1.Images.Clear();
        }        protected void button4_Click (object sender, System.EventArgs e)
        {
            openFileDialog1.Multiselect = true ;
            if(openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                if (openFileDialog1.FileNames != null)
                {
                    for(int i =0 ; i < openFileDialog1.FileNames.Length ; i++ )
                    {
                        addImage(openFileDialog1.FileNames[i]);
                    }
                }
                else
                    addImage(openFileDialog1.FileName);
            }
        }        private void addImage(string imageToLoad)
        {
            if (imageToLoad != "")
            {
                imageList1.Images.Add(Image.FromFile(imageToLoad));
                listBox1.BeginUpdate();
                listBox1.Items.Add(imageToLoad);
                listBox1.EndUpdate();
            }
        }        void displayNextImage()
        {
            if(imageList1.Images.Empty != true)
            {
                if(imageList1.Images.Count-1 < currentImage)
                {
                    currentImage++;
                }
                else
                    currentImage=0;
                panel1.Refresh();
                imageList1.Draw(myGraphics,10,10,currentImage);
                pictureBox1.Image = imageList1.Images[currentImage];
                label3.Text = "Current image is " + currentImage ;
                listBox1.SelectedIndex = currentImage;
                label5.Text = "Image is " + listBox1.Text ;
            }            
        }        public static void Main(string[] args) 
        {
            Application.Run(new Form1());
        }
    }
}