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

namespace HISClinic
{
	/// <summary>
	/// frmSetInterval 的摘要说明。
	/// </summary>
	public class frmSetInterval : System.Windows.Forms.Form
	{
		private System.Windows.Forms.TextBox txtInterval;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Button btnSetInterval;
		private System.Windows.Forms.Button btnCancel;
		private System.Windows.Forms.Label lblTitle;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.PictureBox pictureBox1;
		private System.Windows.Forms.PictureBox pictureBox2;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmSetInterval()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}
		public frmSetInterval(int Interval)
		{
			InitializeComponent();
			txtInterval.Text=Interval.ToString();
			interval=Interval;
		}


		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗体设计器生成的代码
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmSetInterval));
			this.txtInterval = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.btnSetInterval = new System.Windows.Forms.Button();
			this.btnCancel = new System.Windows.Forms.Button();
			this.lblTitle = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.pictureBox1 = new System.Windows.Forms.PictureBox();
			this.pictureBox2 = new System.Windows.Forms.PictureBox();
			this.SuspendLayout();
			// 
			// txtInterval
			// 
			this.txtInterval.Location = new System.Drawing.Point(115, 86);
			this.txtInterval.Name = "txtInterval";
			this.txtInterval.Size = new System.Drawing.Size(87, 21);
			this.txtInterval.TabIndex = 0;
			this.txtInterval.Text = "120";
			// 
			// label1
			// 
			this.label1.AutoSize = true;
			this.label1.Location = new System.Drawing.Point(29, 88);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(66, 17);
			this.label1.TabIndex = 1;
			this.label1.Text = "更新间隔：";
			this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// btnSetInterval
			// 
			this.btnSetInterval.BackColor = System.Drawing.SystemColors.InactiveBorder;
			this.btnSetInterval.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnSetInterval.BackgroundImage")));
			this.btnSetInterval.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnSetInterval.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.btnSetInterval.Location = new System.Drawing.Point(80, 128);
			this.btnSetInterval.Name = "btnSetInterval";
			this.btnSetInterval.Size = new System.Drawing.Size(56, 23);
			this.btnSetInterval.TabIndex = 2;
			this.btnSetInterval.Text = "确 定";
			this.btnSetInterval.Click += new System.EventHandler(this.btnSetInterval_Click);
			// 
			// btnCancel
			// 
			this.btnCancel.BackColor = System.Drawing.SystemColors.InactiveBorder;
			this.btnCancel.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("btnCancel.BackgroundImage")));
			this.btnCancel.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnCancel.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.btnCancel.Location = new System.Drawing.Point(160, 128);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.Size = new System.Drawing.Size(56, 23);
			this.btnCancel.TabIndex = 4;
			this.btnCancel.Text = "取 消";
			this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
			// 
			// lblTitle
			// 
			this.lblTitle.Anchor = System.Windows.Forms.AnchorStyles.None;
			this.lblTitle.Location = new System.Drawing.Point(0, 48);
			this.lblTitle.Name = "lblTitle";
			this.lblTitle.Size = new System.Drawing.Size(312, 16);
			this.lblTitle.TabIndex = 5;
			this.lblTitle.Text = "请选择自动更新的频率，时间间隔不得小于60秒";
			this.lblTitle.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// label2
			// 
			this.label2.AutoSize = true;
			this.label2.Location = new System.Drawing.Point(221, 88);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(66, 17);
			this.label2.TabIndex = 3;
			this.label2.Text = "单位（秒）";
			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// pictureBox1
			// 
			this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
			this.pictureBox1.Location = new System.Drawing.Point(0, 0);
			this.pictureBox1.Name = "pictureBox1";
			this.pictureBox1.Size = new System.Drawing.Size(320, 34);
			this.pictureBox1.TabIndex = 6;
			this.pictureBox1.TabStop = false;
			// 
			// pictureBox2
			// 
			this.pictureBox2.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox2.Image")));
			this.pictureBox2.Location = new System.Drawing.Point(0, 34);
			this.pictureBox2.Name = "pictureBox2";
			this.pictureBox2.Size = new System.Drawing.Size(320, 6);
			this.pictureBox2.TabIndex = 7;
			this.pictureBox2.TabStop = false;
			// 
			// frmSetInterval
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackColor = System.Drawing.SystemColors.InactiveCaptionText;
			this.ClientSize = new System.Drawing.Size(310, 165);
			this.Controls.Add(this.pictureBox2);
			this.Controls.Add(this.pictureBox1);
			this.Controls.Add(this.lblTitle);
			this.Controls.Add(this.btnCancel);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.txtInterval);
			this.Controls.Add(this.btnSetInterval);
			this.ForeColor = System.Drawing.SystemColors.Desktop;
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "frmSetInterval";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
			this.Text = "调整更新频率";
			this.Load += new System.EventHandler(this.frmSetInterval_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void frmSetInterval_Load(object sender, System.EventArgs e)
		{
		
		}
		private int interval;

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

		private void btnSetInterval_Click(object sender, System.EventArgs e)
		{
			try{
				int i=Convert.ToInt32(txtInterval.Text);
				if(i<60)
					throw new ApplicationException("更新间隔必须大于60秒！");
				interval=i;
				this.DialogResult=DialogResult.OK;
			}
			catch(Exception ex){
				txtInterval.SelectAll();
				txtInterval.Focus();
				MessageBox.Show("请输入大于60的数字!","",MessageBoxButtons.OK,MessageBoxIcon.Warning);
			}
		}
		public int UpdateInterval{
			get{
				return interval;
			}
			set{
				interval=value;
				txtInterval.Text=value.ToString();
			}
		}
	}
}
