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

namespace QCGM.Forms
{
	/// <summary>
	/// Summary description for GenericConfirmForm.
	/// </summary>
	public class GenericConfirmForm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label label1;
		public System.Windows.Forms.Button buttonOK;
		public System.Windows.Forms.Button buttonCancel;
		private System.Windows.Forms.Label label3;

		public string Title = "";
		public string LabelText = "";
		public string HeaderText = "";
		public ButtonTypes ButtonType = GenericConfirmForm.ButtonTypes.OKAndCancel;
		public System.Windows.Forms.MessageBoxIcon FormIcon = MessageBoxIcon.None;

		public enum ButtonTypes { OK, Cancel, OKAndCancel, YesAndNo, Close };
		public enum DefaultButton { button1, button2 };

//		public bool response;

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

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

		/// <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(GenericConfirmForm));
			this.label1 = new System.Windows.Forms.Label();
			this.buttonOK = new System.Windows.Forms.Button();
			this.buttonCancel = new System.Windows.Forms.Button();
			this.label3 = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// label1
			// 
			this.label1.BackColor = System.Drawing.Color.Transparent;
			this.label1.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label1.Location = new System.Drawing.Point(16, 48);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(352, 48);
			this.label1.TabIndex = 1;
			this.label1.Text = "Are you sure you want to clear all crud?";
			// 
			// buttonOK
			// 
			this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
			this.buttonOK.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.buttonOK.Location = new System.Drawing.Point(288, 104);
			this.buttonOK.Name = "buttonOK";
			this.buttonOK.Size = new System.Drawing.Size(80, 24);
			this.buttonOK.TabIndex = 2;
			this.buttonOK.Text = "OK";
			this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
			// 
			// buttonCancel
			// 
			this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.buttonCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.buttonCancel.Location = new System.Drawing.Point(192, 104);
			this.buttonCancel.Name = "buttonCancel";
			this.buttonCancel.TabIndex = 3;
			this.buttonCancel.Text = "Cancel";
			this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
			// 
			// label3
			// 
			this.label3.Dock = System.Windows.Forms.DockStyle.Top;
			this.label3.Font = new System.Drawing.Font("Verdana", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.label3.Image = ((System.Drawing.Image)(resources.GetObject("label3.Image")));
			this.label3.ImageAlign = System.Drawing.ContentAlignment.BottomCenter;
			this.label3.Location = new System.Drawing.Point(0, 0);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(384, 40);
			this.label3.TabIndex = 11;
			this.label3.Text = "Confirmation";
			this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// GenericConfirmForm
			// 
			this.AcceptButton = this.buttonOK;
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.BackColor = System.Drawing.SystemColors.Window;
			this.CancelButton = this.buttonCancel;
			this.ClientSize = new System.Drawing.Size(384, 142);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.buttonCancel);
			this.Controls.Add(this.buttonOK);
			this.Controls.Add(this.label1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "GenericConfirmForm";
			this.ShowInTaskbar = false;
			this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "GenericConfirmDialog";
			this.TopMost = true;
			this.ResumeLayout(false);

		}
		#endregion

		private void buttonOK_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void buttonCancel_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		public void Set()
		{
			this.Text = this.Title;
			this.label1.Text = this.LabelText;
			this.label3.Text = this.HeaderText;

			switch (this.ButtonType)
			{
				case GenericConfirmForm.ButtonTypes.OK:
					this.buttonCancel.Hide();
					this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
					break;
				case GenericConfirmForm.ButtonTypes.Cancel:
					this.buttonOK.Hide();
					break;
				case GenericConfirmForm.ButtonTypes.Close:
					this.buttonCancel.Hide();
					this.buttonOK.Text = "Close";
					this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
					break;
				case GenericConfirmForm.ButtonTypes.YesAndNo:
					this.buttonCancel.Text = "No";
					this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.No;
					this.buttonOK.Text = "Yes";
					this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.Yes;
					break;
				default:
					break;
			}

			//this.pictureBox1.Image = (Image)this.FormIcon;
			//System.Windows.Forms.MessageBoxIcon.Exclamation. Icon
		}
	}
}
