using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace InternetSimulator
{
	/// <summary>
	/// Summary description for LatencyForm.
	/// </summary>
	public class LatencyForm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Button btnOk;
		private System.Windows.Forms.Button btnCancel;
		private System.Windows.Forms.NumericUpDown nudMinLatency;
		private System.Windows.Forms.NumericUpDown nudMaxLatency;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public LatencyForm()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(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.groupBox1 = new System.Windows.Forms.GroupBox();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.btnOk = new System.Windows.Forms.Button();
			this.btnCancel = new System.Windows.Forms.Button();
			this.nudMinLatency = new System.Windows.Forms.NumericUpDown();
			this.nudMaxLatency = new System.Windows.Forms.NumericUpDown();
			this.groupBox1.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.nudMinLatency)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.nudMaxLatency)).BeginInit();
			this.SuspendLayout();
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.AddRange(new System.Windows.Forms.Control[] {
																					this.nudMaxLatency,
																					this.nudMinLatency,
																					this.label2,
																					this.label1});
			this.groupBox1.Location = new System.Drawing.Point(8, 8);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(216, 104);
			this.groupBox1.TabIndex = 2;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Latency";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(16, 24);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(88, 23);
			this.label1.TabIndex = 2;
			this.label1.Text = "Min latency(ms)";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(16, 64);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(88, 23);
			this.label2.TabIndex = 3;
			this.label2.Text = "Max latency(ms)";
			// 
			// btnOk
			// 
			this.btnOk.Location = new System.Drawing.Point(56, 120);
			this.btnOk.Name = "btnOk";
			this.btnOk.TabIndex = 3;
			this.btnOk.Text = "&Ok";
			this.btnOk.Click += new System.EventHandler(this.btnOk_Click);
			// 
			// btnCancel
			// 
			this.btnCancel.Location = new System.Drawing.Point(144, 120);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.TabIndex = 4;
			this.btnCancel.Text = "&Cancel";
			this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
			// 
			// nudMinLatency
			// 
			this.nudMinLatency.Location = new System.Drawing.Point(104, 24);
			this.nudMinLatency.Maximum = new System.Decimal(new int[] {
																		  1000,
																		  0,
																		  0,
																		  0});
			this.nudMinLatency.Name = "nudMinLatency";
			this.nudMinLatency.Size = new System.Drawing.Size(104, 20);
			this.nudMinLatency.TabIndex = 4;
			// 
			// nudMaxLatency
			// 
			this.nudMaxLatency.Location = new System.Drawing.Point(104, 64);
			this.nudMaxLatency.Maximum = new System.Decimal(new int[] {
																		  1000,
																		  0,
																		  0,
																		  0});
			this.nudMaxLatency.Name = "nudMaxLatency";
			this.nudMaxLatency.Size = new System.Drawing.Size(104, 20);
			this.nudMaxLatency.TabIndex = 5;
			// 
			// LatencyForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(232, 149);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.btnCancel,
																		  this.btnOk,
																		  this.groupBox1});
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.Name = "LatencyForm";
			this.Text = "LatencyForm";
			this.groupBox1.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.nudMinLatency)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.nudMaxLatency)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void btnCancel_Click(object sender, System.EventArgs e)
		{
			DialogResult=DialogResult.Cancel;
		}

		private void btnOk_Click(object sender, System.EventArgs e)
		{
			DialogResult=DialogResult.OK;
		}

		private int Text2Property(String str)
		{
			try 
			{
				return Convert.ToInt32(str);
			}
			catch(FormatException )
			{
				return 0;
			}
		}

		
		public int minLatency
		{
			get
			{
				return (int)nudMinLatency.Value;
			}
			set
			{
				nudMinLatency.Value=value;
			}
		}

		public int maxLatency
		{
			get
			{
				return (int)nudMaxLatency.Value;
			}
			set
			{
				nudMaxLatency.Value=value;
			}
		}
	}
}
