/******************************************************************************
 * InfoForm.cs 
 * 
 * <Copyright and License> 
 * 
 * This file is part of GODS, a package for annotating medical images. 
 * 
 * Copyright (C) 2004 
 * Xuedong Chen 
 * Heri Mariwa 
 * Kimmy (Hsiang-ling) Lin 
 * Rui Yu 
 * 
 * This program is free software; you can redistribute it and/or 
 * modify it under the terms of the GNU General Public License 
 * as published by the Free Software Foundation; either version 2 
 * of the License, or (at your option) any later version. 
 * 
 * This program is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
 * GNU General Public License for more details. 
 * 
 * You should have received a copy of the GNU General Public License 
 * along with this program; if not, write to the Free Software 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
 *  
 * For further questions about this file, please send email to 
 * gods@cs.umb.edu or visit us at http://gods.sourceforge.net.  
 ******************************************************************************/

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

namespace GODS
{
	/// <summary>
	/// Summary description for InfoForm.
	/// </summary>
	public class InfoForm : System.Windows.Forms.Form
	{
		private bool result;
		private System.Windows.Forms.Label lblMRN;
		private System.Windows.Forms.TextBox txtBxMRN;
		private System.Windows.Forms.Button btnOK;
		private System.Windows.Forms.Button btnCancel;
		private System.Windows.Forms.Label lblDate;
		private System.Windows.Forms.DateTimePicker dateTimePicker1;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public InfoForm()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			this.Activated += new EventHandler(this.focusTextBox);
		}

		public string MRN 
		{
			get 
			{
				return this.txtBxMRN.Text.Trim();
			}
		}

		public DateTime ImageDate
		{
			get
			{
				return this.dateTimePicker1.Value;
			}
		}

		public bool Result
		{
			get
			{
				return this.result;
			}
		}

		public void cleanup()
		{
			this.txtBxMRN.Text = "";
		}

		/// <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()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(InfoForm));
			this.lblMRN = new System.Windows.Forms.Label();
			this.lblDate = new System.Windows.Forms.Label();
			this.txtBxMRN = new System.Windows.Forms.TextBox();
			this.btnOK = new System.Windows.Forms.Button();
			this.btnCancel = new System.Windows.Forms.Button();
			this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker();
			this.SuspendLayout();
			// 
			// lblMRN
			// 
			this.lblMRN.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.lblMRN.Location = new System.Drawing.Point(16, 24);
			this.lblMRN.Name = "lblMRN";
			this.lblMRN.Size = new System.Drawing.Size(64, 16);
			this.lblMRN.TabIndex = 0;
			this.lblMRN.Text = "MRN";
			// 
			// lblDate
			// 
			this.lblDate.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.lblDate.Location = new System.Drawing.Point(16, 56);
			this.lblDate.Name = "lblDate";
			this.lblDate.Size = new System.Drawing.Size(64, 16);
			this.lblDate.TabIndex = 1;
			this.lblDate.Text = "Image Date";
			// 
			// txtBxMRN
			// 
			this.txtBxMRN.Location = new System.Drawing.Point(96, 19);
			this.txtBxMRN.Name = "txtBxMRN";
			this.txtBxMRN.Size = new System.Drawing.Size(184, 20);
			this.txtBxMRN.TabIndex = 2;
			this.txtBxMRN.Text = "";
			// 
			// btnOK
			// 
			this.btnOK.Location = new System.Drawing.Point(96, 128);
			this.btnOK.Name = "btnOK";
			this.btnOK.TabIndex = 4;
			this.btnOK.Text = "OK";
			this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
			// 
			// btnCancel
			// 
			this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnCancel.Location = new System.Drawing.Point(184, 128);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.TabIndex = 5;
			this.btnCancel.Text = "Cancel";
			this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
			// 
			// dateTimePicker1
			// 
			this.dateTimePicker1.Location = new System.Drawing.Point(96, 56);
			this.dateTimePicker1.Name = "dateTimePicker1";
			this.dateTimePicker1.Size = new System.Drawing.Size(184, 20);
			this.dateTimePicker1.TabIndex = 7;
			// 
			// InfoForm
			// 
			this.AcceptButton = this.btnOK;
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(338, 176);
			this.ControlBox = false;
			this.Controls.Add(this.dateTimePicker1);
			this.Controls.Add(this.btnCancel);
			this.Controls.Add(this.btnOK);
			this.Controls.Add(this.txtBxMRN);
			this.Controls.Add(this.lblDate);
			this.Controls.Add(this.lblMRN);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "InfoForm";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "Patient Information";
			this.ResumeLayout(false);

		}
		#endregion

		private void btnOK_Click(object sender, System.EventArgs e)
		{
			if (this.txtBxMRN.Text == null || this.txtBxMRN.Text.Trim().Equals(""))
				MessageBox.Show(this, "MRN field cannot be empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
			else 
			{
				this.result = true;
				this.Close();
			}
		}

		private void btnCancel_Click(object sender, System.EventArgs e)
		{
			this.result = false;
			this.Close();
		}


		private void focusTextBox(object sender, System.EventArgs e)
		{
			this.ActiveControl = this.txtBxMRN;
		}
	}
}
