using System;

using System.Drawing;

using System.Collections;

using System.Windows.Forms;

using System.Data;

using System.Net;

 

namespace BayAreaTraffic

{

    /// <summary>

    /// Summary description for Form2.

    /// </summary>

    public class Form2 : System.Windows.Forms.Form

    {

        private PictureBox pictureBox1;

        private MenuItem menuItem1;

        private MenuItem menuItem2;

        private System.Windows.Forms.MainMenu mainMenu1;

 

        public Form2()

        {

            InitializeComponent();

            LoadPictureBox();

        }

 

        #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.mainMenu1 = new System.Windows.Forms.MainMenu();

            this.menuItem1 = new System.Windows.Forms.MenuItem();

            this.pictureBox1 = new System.Windows.Forms.PictureBox();

            this.menuItem2 = new System.Windows.Forms.MenuItem();

//

// mainMenu1

//

            this.mainMenu1.MenuItems.Add(this.menuItem1);

            this.mainMenu1.MenuItems.Add(this.menuItem2);

//

// menuItem1

//

            this.menuItem1.Text = "Done";

            this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);

//

// pictureBox1

//

            this.pictureBox1.Location = new System.Drawing.Point(0, -67);

            this.pictureBox1.Size = new System.Drawing.Size(210, 247);

            this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;

//

// menuItem2

//

            this.menuItem2.Text = "Fit";

            this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);

//

// Form2

//

            this.ClientSize = new System.Drawing.Size(176, 180);

            this.Controls.Add(this.pictureBox1);

            this.Menu = this.mainMenu1;

            this.Text = "System Map";

 

        }

 

        #endregion

 

        /// <summary>

        /// Clean up any resources being used.

        /// </summary>

        protected override void Dispose(bool disposing)

        {

            base.Dispose(disposing);

        }

        private void LoadPictureBox()

        {

            Cursor.Current = Cursors.WaitCursor;

 

            // Get HTTP stream to icon (image) from URL

            HttpWebRequest req = (HttpWebRequest)

                                 WebRequest.Create(@"http://traffic.511.org/homepage.gif");

            HttpWebResponse resp = (HttpWebResponse)req.GetResponse();

            // Put in picture control

            pictureBox1.Image = new System.Drawing.Bitmap(resp.GetResponseStream());

 

            Cursor.Current = Cursors.Default;

        }

 

        private void menuItem1_Click(object sender, EventArgs e)

        {

            this.Close();

        }

 

        private void menuItem2_Click(object sender, EventArgs e)

        {

            if (pictureBox1.SizeMode == System.Windows.Forms.PictureBoxSizeMode.StretchImage)

            {

                pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;

                menuItem2.Text = "Fit";

            }

            else

            {

                pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;

                menuItem2.Text = "Center";

            }

            pictureBox1.Refresh();

        }

    }

}