using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AnimatedGif
{
    public partial class frm88AnimatedGif : Form
    {
        public frm88AnimatedGif()
        {
            InitializeComponent();
        }

        // The image properties.
        private Bitmap[] Images =
        {
            Properties.Resources.piston,
            Properties.Resources.atom,
            Properties.Resources.arms,
        };

        // The file names.
        private string [] Filenames =
        {
            "piston.gif",
            "atom.gif",
            "arms.gif",
        };

        private int buttonIndex = 0;
        private void gifButton_Click(object sender, EventArgs e)
        {
            buttonIndex = (buttonIndex + 1) % 3;
            gifButton.Image = Images[buttonIndex];
        }

        private int labelIndex = 1;
        private void gifLabel_Click(object sender, EventArgs e)
        {
            labelIndex = (labelIndex + 1) % 3;
            gifLabel.Image = new Bitmap(Filenames[labelIndex]);
        }

        private int pictureBoxIndex = 2;
        private void gifPictureBox_Click(object sender, EventArgs e)
        {
            pictureBoxIndex = (pictureBoxIndex + 1) % 3;
            gifPictureBox.Image = Image.FromFile(Filenames[pictureBoxIndex]);
        }


        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.gifLabel = new System.Windows.Forms.Label();
            this.gifPictureBox = new System.Windows.Forms.PictureBox();
            this.gifButton = new System.Windows.Forms.Button();
            this.label1 = new System.Windows.Forms.Label();
            ((System.ComponentModel.ISupportInitialize)(this.gifPictureBox)).BeginInit();
            this.SuspendLayout();
            // 
            // gifLabel
            // 
            this.gifLabel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.gifLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
            this.gifLabel.Image = global::AnimatedGif.Properties.Resources.atom;
            this.gifLabel.ImageAlign = System.Drawing.ContentAlignment.TopCenter;
            this.gifLabel.Location = new System.Drawing.Point(148, 12);
            this.gifLabel.Name = "gifLabel";
            this.gifLabel.Size = new System.Drawing.Size(130, 130);
            this.gifLabel.TabIndex = 5;
            this.gifLabel.Text = "Label";
            this.gifLabel.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
            this.gifLabel.Click += new System.EventHandler(this.gifLabel_Click);
            // 
            // gifPictureBox
            // 
            this.gifPictureBox.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.gifPictureBox.Image = global::AnimatedGif.Properties.Resources.arms;
            this.gifPictureBox.Location = new System.Drawing.Point(284, 12);
            this.gifPictureBox.Name = "gifPictureBox";
            this.gifPictureBox.Size = new System.Drawing.Size(90, 90);
            this.gifPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
            this.gifPictureBox.TabIndex = 4;
            this.gifPictureBox.TabStop = false;
            this.gifPictureBox.Click += new System.EventHandler(this.gifPictureBox_Click);
            // 
            // gifButton
            // 
            this.gifButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
            this.gifButton.Image = global::AnimatedGif.Properties.Resources.piston;
            this.gifButton.ImageAlign = System.Drawing.ContentAlignment.TopCenter;
            this.gifButton.Location = new System.Drawing.Point(12, 12);
            this.gifButton.Name = "gifButton";
            this.gifButton.Size = new System.Drawing.Size(130, 130);
            this.gifButton.TabIndex = 3;
            this.gifButton.Text = "Button";
            this.gifButton.TextAlign = System.Drawing.ContentAlignment.BottomCenter;
            this.gifButton.UseVisualStyleBackColor = true;
            this.gifButton.Click += new System.EventHandler(this.gifButton_Click);
            // 
            // label1
            // 
            this.label1.Location = new System.Drawing.Point(284, 105);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(90, 21);
            this.label1.TabIndex = 6;
            this.label1.Text = "PictureBox";
            this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            // 
            // frm88AnimatedGif
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(427, 155);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.gifLabel);
            this.Controls.Add(this.gifPictureBox);
            this.Controls.Add(this.gifButton);
            this.Name = "frm88AnimatedGif";
            this.Text = "AnimatedGif";
            ((System.ComponentModel.ISupportInitialize)(this.gifPictureBox)).EndInit();
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.Label gifLabel;
        private System.Windows.Forms.PictureBox gifPictureBox;
        private System.Windows.Forms.Button gifButton;
        private System.Windows.Forms.Label label1;
    }
}