using System;
using System.Collections;
using System.Collections.Generic;
using System.Windows.Forms;

namespace CustomForms
{
	public partial class InputForm : Form
	{
		private readonly List<Control> CheckEnableContols = new List<Control>();
		private readonly Control MainWnd;
		private string PatternInput;
		private List<object> LinkedValueList;
		private TextBox LinkedValuesTBox;

		public InputForm(Control mainWnd)
		{
			InitializeComponent();
			MainWnd = mainWnd;
		}


		public bool Show(string Title, string Prompt, ref string Value)
		{
			Height = 195;
			Panel.Height = 90;
			OkBtn.Top = 115;
			CancelBtn.Top = 115;

			Text = Title;
			PromptLbl.Text = Prompt;
			TextBox Box = new TextBox {Left = PromptLbl.Left, Top = PromptLbl.Top + PromptLbl.Height};
			Box.Width = Panel.Width - Box.Left * 2;
			Box.Text = Value;
			Panel.Controls.Add(Box);
			ActiveControl = Box;
			DialogResult res = ShowDialog();
			if (res == DialogResult.OK)
				Value = Box.Text;

			Box.Dispose();

			return (res == DialogResult.OK);
		}

		public bool Show(string Title, string Prompt, ArrayList Values, ref int ValueIndex)
		{
			Height = 195;
			Panel.Height = 90;
			OkBtn.Top = 115;
			CancelBtn.Top = 115;

			Text = Title;
			PromptLbl.Text = Prompt;
			ComboBox Box = new ComboBox {Left = PromptLbl.Left, Top = PromptLbl.Top + PromptLbl.Height};
			Box.Width = Panel.Width - Box.Left * 2;
			Box.DropDownStyle = ComboBoxStyle.DropDownList;
			for (int i = 0; i < Values.Count; i++)
				Box.Items.Add(Values[i]);
			Box.SelectedIndex = ValueIndex;
			Panel.Controls.Add(Box);
			ActiveControl = Box;

			DialogResult res = ShowDialog();
			if (res == DialogResult.OK)
				ValueIndex = Box.SelectedIndex;

			Box.Dispose();

			return (res == DialogResult.OK);
		}

		public bool Show(string Title, string Prompt, ref string Value,
										 string Prompt2, ref string Value2)
		{
			Height = 260;
			Panel.Height = 150;
			OkBtn.Top = 180;
			CancelBtn.Top = 180;

			Text = Title;
			PromptLbl.Text = Prompt;
			TextBox Box = new TextBox {Left = PromptLbl.Left, Top = PromptLbl.Top + PromptLbl.Height};
			Box.Width = Panel.Width - Box.Left * 2;
			Box.Text = Value;
			Panel.Controls.Add(Box);

			Label Prompt2Lbl = new Label
			                   	{
			                   		Font = PromptLbl.Font,
			                   		Left = PromptLbl.Left,
			                   		Top = Box.Top + Box.Height + 20,
			                   		Text = Prompt2,
			                   		AutoSize = true
			                   	};
			Panel.Controls.Add(Prompt2Lbl);

			TextBox Box2 = new TextBox {Left = Prompt2Lbl.Left, Top = Prompt2Lbl.Top + Prompt2Lbl.Height + 10};
			Box2.Width = Panel.Width - Box2.Left * 2;
			Box2.Text = Value2;
			Panel.Controls.Add(Box2);
			Box.Focus();

			DialogResult res = ShowDialog();
			if (res == DialogResult.OK)
			{
				Value = Box.Text;
				Value2 = Box2.Text;
			}

			Box.Dispose();
			Box2.Dispose();
			Prompt2Lbl.Dispose();

			return (res == DialogResult.OK);
		}

		public bool Show(string Title, string Prompt, ref string Value,
										 string Prompt2, ref string Value2, string Pattern, int MaxLength)
		{
			Height = 260;
			Panel.Height = 150;
			OkBtn.Top = 180;
			CancelBtn.Top = 180;

			PatternInput = Pattern;
			Text = Title;
			PromptLbl.Text = Prompt;
			TextBox Box = new TextBox {Left = PromptLbl.Left, Top = PromptLbl.Top + PromptLbl.Height};
			Box.Width = Panel.Width - Box.Left * 2;
			Box.Text = Value;
			Box.MaxLength = MaxLength;
			Box.KeyPress += Box_KeyPress;
			Panel.Controls.Add(Box);

			Label Prompt2Lbl = new Label
			                   	{
			                   		Font = PromptLbl.Font,
			                   		Left = PromptLbl.Left,
			                   		Top = Box.Top + Box.Height + 20,
			                   		Text = Prompt2
			                   	};
			Panel.Controls.Add(Prompt2Lbl);

			TextBox Box2 = new TextBox {Left = Prompt2Lbl.Left, Top = Prompt2Lbl.Top + Prompt2Lbl.Height};
			Box2.Width = Panel.Width - Box2.Left * 2;
			Box2.Text = Value2;
			Box2.MaxLength = MaxLength;
			Box2.KeyPress += Box_KeyPress;
			Panel.Controls.Add(Box2);
			Box.Focus();

			DialogResult res = ShowDialog();
			if (res == DialogResult.OK)
			{
				Value = Box.Text;
				Value2 = Box2.Text;
			}

			Box.Dispose();
			Box2.Dispose();
			Prompt2Lbl.Dispose();

			return (res == DialogResult.OK);
		}

		public bool Show(string Title, string Prompt, ref string Value,
										 string Prompt2, ref string Value2, 
										string Prompt3, ref string Value3, 
										string Pattern, int MaxLength)
		{
			Height = 320;
			Panel.Height = 230;
			OkBtn.Top = 250;
			CancelBtn.Top = 250;

			PatternInput = Pattern;
			Text = Title;
			PromptLbl.Text = Prompt;
			TextBox Box = new TextBox {Left = PromptLbl.Left, Top = PromptLbl.Top + PromptLbl.Height};
			Box.Width = Panel.Width - Box.Left * 2;
			Box.Text = Value;
			Box.MaxLength = MaxLength;
			Box.KeyPress += Box_KeyPress;
			Panel.Controls.Add(Box);

			Label Prompt2Lbl = new Label
			                   	{
			                   		Font = PromptLbl.Font,
			                   		Left = PromptLbl.Left,
			                   		Top = Box.Top + Box.Height + 20,
			                   		Text = Prompt2
			                   	};
			Panel.Controls.Add(Prompt2Lbl);

			TextBox Box2 = new TextBox {Left = Prompt2Lbl.Left, Top = Prompt2Lbl.Top + Prompt2Lbl.Height};
			Box2.Width = Panel.Width - Box2.Left * 2;
			Box2.Text = Value2;
			Box2.MaxLength = MaxLength;
			Box2.KeyPress += Box_KeyPress;
			Panel.Controls.Add(Box2);

			Label Prompt3Lbl = new Label
			                   	{
			                   		Font = PromptLbl.Font,
			                   		Left = PromptLbl.Left,
			                   		Top = Box2.Top + Box.Height + 20,
			                   		Text = Prompt3
			                   	};
			Panel.Controls.Add(Prompt3Lbl);

			TextBox Box3 = new TextBox {Left = Prompt3Lbl.Left, Top = Prompt3Lbl.Top + Prompt3Lbl.Height};
			Box3.Width = Panel.Width - Box3.Left * 2;
			Box3.Text = Value3;
			Panel.Controls.Add(Box3);
			
			Box.Focus();

			DialogResult res = ShowDialog();
			if (res == DialogResult.OK)
			{
				Value = Box.Text;
				Value2 = Box2.Text;
				Value3 = Box3.Text;
			}

			Box.Dispose();
			Box2.Dispose();
			Box3.Dispose();
			Prompt2Lbl.Dispose();
			Prompt3Lbl.Dispose();
			return (res == DialogResult.OK);
		}

		public bool Show(string Title, string Prompt, ref string Value,
										 string Prompt2, ref string Value2,
										 string Prompt3, ref string Value3)
		{
			Height = 320;
			Panel.Height = 230;
			OkBtn.Top = 250;
			CancelBtn.Top = 250;

			Text = Title;
			PromptLbl.Text = Prompt;
			TextBox Box = new TextBox {Left = PromptLbl.Left, Top = PromptLbl.Top + PromptLbl.Height};
			Box.Width = Panel.Width - Box.Left * 2;
			Box.Text = Value;
			Panel.Controls.Add(Box);

			Label Prompt2Lbl = new Label
			                   	{
			                   		Font = PromptLbl.Font,
			                   		Left = PromptLbl.Left,
			                   		Top = Box.Top + Box.Height + 20,
			                   		Text = Prompt2
			                   	};
			Panel.Controls.Add(Prompt2Lbl);

			TextBox Box2 = new TextBox {Left = Prompt2Lbl.Left, Top = Prompt2Lbl.Top + Prompt2Lbl.Height};
			Box2.Width = Panel.Width - Box2.Left * 2;
			Box2.Text = Value2;
			Panel.Controls.Add(Box2);

			Label Prompt3Lbl = new Label
			                   	{
			                   		Font = PromptLbl.Font,
			                   		Left = PromptLbl.Left,
			                   		Top = Box2.Top + Box.Height + 20,
			                   		Text = Prompt3
			                   	};
			Panel.Controls.Add(Prompt3Lbl);

			TextBox Box3 = new TextBox {Left = Prompt3Lbl.Left, Top = Prompt3Lbl.Top + Prompt3Lbl.Height};
			Box3.Width = Panel.Width - Box3.Left * 2;
			Box3.Text = Value3;
			Panel.Controls.Add(Box3);

			DialogResult res = ShowDialog();
			if (res == DialogResult.OK)
			{
				Value = Box.Text;
				Value2 = Box2.Text;
				Value3 = Box3.Text;
			}

			Box.Dispose();
			Box2.Dispose();
			Box3.Dispose();
			Prompt2Lbl.Dispose();
			Prompt3Lbl.Dispose();

			return (res == DialogResult.OK);
		}

		public bool Show(string Title, string Prompt, ref string Value,
										 string Prompt2, ref string Value2,
										 string PromptChBox, ref bool Checked)
		{
			Height = 320;
			Panel.Height = 230;
			OkBtn.Top = 250;
			CancelBtn.Top = 250;

			Text = Title;
			PromptLbl.Text = Prompt;
			TextBox Box = new TextBox {Left = PromptLbl.Left, Top = PromptLbl.Top + PromptLbl.Height};
			Box.Width = Panel.Width - Box.Left * 2;
			Box.Text = Value;
			Panel.Controls.Add(Box);

			Label Prompt2Lbl = new Label
			                   	{
			                   		Font = PromptLbl.Font,
			                   		Left = PromptLbl.Left,
			                   		Top = Box.Top + Box.Height + 20,
			                   		Text = Prompt2
			                   	};
			Panel.Controls.Add(Prompt2Lbl);

			TextBox Box2 = new TextBox {Left = Prompt2Lbl.Left, Top = Prompt2Lbl.Top + Prompt2Lbl.Height};
			Box2.Width = Panel.Width - Box2.Left * 2;
			Box2.Text = Value2;
			Panel.Controls.Add(Box2);

			CheckBox ChBox = new CheckBox
			                 	{
			                 		Top = Box2.Top + Box2.Height + 10,
			                 		Font = PromptLbl.Font,
			                 		Height = Box2.Height,
			                 		Text = PromptChBox,
			                 		Width = Box2.Width,
			                 		Left = Box2.Left
			                 	};
			ChBox.CheckStateChanged += ChBox_CheckStateChanged;
			ChBox.Checked = Checked;
			Panel.Controls.Add(ChBox);


			DialogResult res = ShowDialog();
			if (res == DialogResult.OK)
			{
				Value = Box.Text;
				Value2 = Box2.Text;
				Checked = ChBox.Checked;
			}

			Box.Dispose();
			Box2.Dispose();
			ChBox.Dispose();
			Prompt2Lbl.Dispose();
			CheckEnableContols.Clear();

			return (res == DialogResult.OK);
		}

		public bool Show(string Title, string Prompt, ref string Value,
										 string Prompt2, ref string Value2,
										 string Prompt3, ref string Value3,
										 string PromptChBox, ref bool Checked)
		{
			Height = 320;
			Panel.Height = 230;
			OkBtn.Top = 250;
			CancelBtn.Top = 250;

			Text = Title;
			PromptLbl.Text = Prompt;
			TextBox Box = new TextBox {Left = PromptLbl.Left, Top = PromptLbl.Top + PromptLbl.Height};
			Box.Width = Panel.Width - Box.Left * 2;
			Box.Text = Value;
			Panel.Controls.Add(Box);

			Label Prompt2Lbl = new Label
			                   	{
			                   		Font = PromptLbl.Font,
			                   		Left = PromptLbl.Left,
			                   		Top = Box.Top + Box.Height + 20,
			                   		Text = Prompt2
			                   	};
			Panel.Controls.Add(Prompt2Lbl);

			TextBox Box2 = new TextBox {Left = Prompt2Lbl.Left, Top = Prompt2Lbl.Top + Prompt2Lbl.Height};
			Box2.Width = Panel.Width - Box2.Left * 2;
			Box2.Text = Value2;
			Panel.Controls.Add(Box2);

			Label Prompt3Lbl = new Label
			                   	{
			                   		Font = PromptLbl.Font,
			                   		Left = PromptLbl.Left,
			                   		Top = Box2.Top + Box.Height + 20,
			                   		Text = Prompt3
			                   	};
			Panel.Controls.Add(Prompt3Lbl);

			TextBox Box3 = new TextBox {Left = Prompt3Lbl.Left, Top = Prompt3Lbl.Top + Prompt3Lbl.Height};
			Box3.Width = Panel.Width - Box3.Left * 2;
			Box3.Text = Value3;
			Panel.Controls.Add(Box3);
			CheckEnableContols.Add(Box3);

			CheckBox ChBox = new CheckBox
			                 	{
			                 		Top = Box3.Top + Box3.Height + 10,
			                 		Font = PromptLbl.Font,
			                 		Height = Box3.Height,
			                 		Text = PromptChBox,
			                 		Width = Box3.Width,
			                 		Left = Box3.Left
			                 	};
			ChBox.CheckStateChanged += ChBox_CheckStateChanged;
			ChBox.Checked = Checked;
			Panel.Controls.Add(ChBox);


			DialogResult res = ShowDialog();
			if (res == DialogResult.OK)
			{
				Value = Box.Text;
				Value2 = Box2.Text;
				Value3 = Box3.Text;
				Checked = ChBox.Checked;
			}

			Box.Dispose();
			Box2.Dispose();
			Box3.Dispose();
			ChBox.Dispose();
			Prompt2Lbl.Dispose();
			Prompt3Lbl.Dispose();
			CheckEnableContols.Clear();

			return (res == DialogResult.OK);
		}

		public bool Show(string Title, string Prompt, List<object> Values, ref int ValueIndex,
										 string Prompt2, ref string Value2,
										 string Prompt3, ref string Value3,
										 string PromptChBox, ref bool Checked)
		{
			Height = 320;
			Panel.Height = 230;
			OkBtn.Top = 250;
			CancelBtn.Top = 250;

			Text = Title;
			PromptLbl.Text = Prompt;

			ComboBox Box = new ComboBox {Left = PromptLbl.Left, Top = PromptLbl.Top + PromptLbl.Height};
			Box.Width = Panel.Width - Box.Left * 2;
			Box.DropDownStyle = ComboBoxStyle.DropDownList;
			for (int i = 0; i < Values.Count; i++)
				Box.Items.Add(Values[i]);
			Box.SelectedIndex = ValueIndex;
			Panel.Controls.Add(Box);
			ActiveControl = Box;

			Label Prompt2Lbl = new Label
			                   	{
			                   		Font = PromptLbl.Font,
			                   		Left = PromptLbl.Left,
			                   		Top = Box.Top + Box.Height + 20,
			                   		Text = Prompt2,
			                   		Width = Box.Width
			                   	};
			Panel.Controls.Add(Prompt2Lbl);

			TextBox Box2 = new TextBox {Left = Prompt2Lbl.Left, Top = Prompt2Lbl.Top + Prompt2Lbl.Height};
			Box2.Width = Panel.Width - Box2.Left * 2;
			Box2.Text = Value2;
			Panel.Controls.Add(Box2);

			Label Prompt3Lbl = new Label
			                   	{
			                   		Font = PromptLbl.Font,
			                   		Left = PromptLbl.Left,
			                   		Top = Box2.Top + Box.Height + 20,
			                   		Text = Prompt3,
			                   		Width = Box.Width
			                   	};
			Panel.Controls.Add(Prompt3Lbl);

			TextBox Box3 = new TextBox {Left = Prompt3Lbl.Left, Top = Prompt3Lbl.Top + Prompt3Lbl.Height};
			Box3.Width = Panel.Width - Box3.Left * 2;
			Box3.Text = Value3;
			Panel.Controls.Add(Box3);
			CheckEnableContols.Add(Box3);

			CheckBox ChBox = new CheckBox
			                 	{
			                 		Top = Box3.Top + Box3.Height + 10,
			                 		Font = PromptLbl.Font,
			                 		Height = Box3.Height,
			                 		Text = PromptChBox,
			                 		Width = Box3.Width,
			                 		Left = Box3.Left
			                 	};
			ChBox.CheckStateChanged += ChBox_CheckStateChanged;
			ChBox.Checked = Checked;
			Panel.Controls.Add(ChBox);


			DialogResult res = ShowDialog();
			if (res == DialogResult.OK)
			{
				ValueIndex = Box.SelectedIndex;
				Value2 = Box2.Text;
				Value3 = Box3.Text;
				Checked = ChBox.Checked;
			}

			Box.Dispose();
			Box2.Dispose();
			Box3.Dispose();
			ChBox.Dispose();
			Prompt2Lbl.Dispose();
			Prompt3Lbl.Dispose();
			CheckEnableContols.Clear();

			return (res == DialogResult.OK);
		}

		public bool Show(string Title, string Prompt, List<object> Values, ref int ValueIndex,
										 string Prompt2, ref string Value2,
										 string Prompt3, ref string Value3)
		{
			Height = 320;
			Panel.Height = 230;
			OkBtn.Top = 250;
			CancelBtn.Top = 250;

			Text = Title;
			PromptLbl.Text = Prompt;

			ComboBox Box = new ComboBox {Left = PromptLbl.Left, Top = PromptLbl.Top + PromptLbl.Height};
			Box.Width = Panel.Width - Box.Left * 2;
			Box.DropDownStyle = ComboBoxStyle.DropDownList;
			for (int i = 0; i < Values.Count; i++)
				Box.Items.Add(Values[i]);
			Box.SelectedIndex = ValueIndex;
			Panel.Controls.Add(Box);
			ActiveControl = Box;

			Label Prompt2Lbl = new Label
			                   	{
			                   		Font = PromptLbl.Font,
			                   		Left = PromptLbl.Left,
			                   		Top = Box.Top + Box.Height + 20,
			                   		Text = Prompt2,
			                   		Width = Box.Width
			                   	};
			Panel.Controls.Add(Prompt2Lbl);

			TextBox Box2 = new TextBox {Left = Prompt2Lbl.Left, Top = Prompt2Lbl.Top + Prompt2Lbl.Height};
			Box2.Width = Panel.Width - Box2.Left * 2;
			Box2.Text = Value2;
			Panel.Controls.Add(Box2);

			Label Prompt3Lbl = new Label
			                   	{
			                   		Font = PromptLbl.Font,
			                   		Left = PromptLbl.Left,
			                   		Top = Box2.Top + Box.Height + 20,
			                   		Text = Prompt3,
			                   		Width = Box.Width
			                   	};
			Panel.Controls.Add(Prompt3Lbl);

			TextBox Box3 = new TextBox {Left = Prompt3Lbl.Left, Top = Prompt3Lbl.Top + Prompt3Lbl.Height};
			Box3.Width = Panel.Width - Box3.Left * 2;
			Box3.Text = Value3;
			Panel.Controls.Add(Box3);
			CheckEnableContols.Add(Box3);

			DialogResult res = ShowDialog();
			if (res == DialogResult.OK)
			{
				ValueIndex = Box.SelectedIndex;
				Value2 = Box2.Text;
				Value3 = Box3.Text;
			}

			Box.Dispose();
			Box2.Dispose();
			Box3.Dispose();
			Prompt2Lbl.Dispose();
			Prompt3Lbl.Dispose();
			CheckEnableContols.Clear();

			return (res == DialogResult.OK);
		}

		public bool Show(string Title, string Prompt, List<object> Values, ref int ValueIndex,
										 string Prompt2, ref string Value2)
		{
			Height = 260;
			Panel.Height = 150;
			OkBtn.Top = 180;
			CancelBtn.Top = 180;

			Text = Title;
			PromptLbl.Text = Prompt;

			ComboBox Box = new ComboBox {Left = PromptLbl.Left, Top = PromptLbl.Top + PromptLbl.Height};
			Box.Width = Panel.Width - Box.Left * 2;
			Box.DropDownStyle = ComboBoxStyle.DropDownList;
			for (int i = 0; i < Values.Count; i++)
				Box.Items.Add(Values[i]);
			Box.SelectedIndex = ValueIndex;
			Panel.Controls.Add(Box);
			ActiveControl = Box;

			Label Prompt2Lbl = new Label
			                   	{
			                   		Font = PromptLbl.Font,
			                   		Left = PromptLbl.Left,
			                   		Top = Box.Top + Box.Height + 20,
			                   		Text = Prompt2,
			                   		Width = Box.Width
			                   	};
			Panel.Controls.Add(Prompt2Lbl);

			TextBox Box2 = new TextBox {Left = Prompt2Lbl.Left, Top = Prompt2Lbl.Top + Prompt2Lbl.Height};
			Box2.Width = Panel.Width - Box2.Left * 2;
			Box2.Text = Value2;
			Panel.Controls.Add(Box2);

			DialogResult res = ShowDialog();
			if (res == DialogResult.OK)
			{
				ValueIndex = Box.SelectedIndex;
				Value2 = Box2.Text;
			}

			Box.Dispose();
			Box2.Dispose();
			Prompt2Lbl.Dispose();
			CheckEnableContols.Clear();

			return (res == DialogResult.OK);
		}

		public bool Show(string Title, string Prompt, List<object> Values, List<object> LinkedValues, ref int ValueIndex,
										 string Prompt2, ref string Value2)
		{
			Height = 260;
			Panel.Height = 150;
			OkBtn.Top = 180;
			CancelBtn.Top = 180;

			Text = Title;
			PromptLbl.Text = Prompt;
			LinkedValueList = LinkedValues;

			ComboBox Box = new ComboBox {Left = PromptLbl.Left, Top = PromptLbl.Top + PromptLbl.Height};
			Box.Width = Panel.Width - Box.Left * 2;
			Box.DropDownStyle = ComboBoxStyle.DropDownList;
			Box.SelectedIndexChanged += Box_SelectedIndexChanged;
			for (int i = 0; i < Values.Count; i++)
				Box.Items.Add(Values[i]);
			Box.SelectedIndex = ValueIndex;
			Panel.Controls.Add(Box);
			ActiveControl = Box;

			Label Prompt2Lbl = new Label
			                   	{
			                   		Font = PromptLbl.Font,
			                   		Left = PromptLbl.Left,
			                   		Top = Box.Top + Box.Height + 20,
			                   		Text = Prompt2,
			                   		Width = Box.Width
			                   	};
			Panel.Controls.Add(Prompt2Lbl);

			TextBox Box2 = new TextBox {Left = Prompt2Lbl.Left, Top = Prompt2Lbl.Top + Prompt2Lbl.Height};
			Box2.Width = Panel.Width - Box2.Left * 2;
			Box2.Text = Value2;
			Panel.Controls.Add(Box2);
			LinkedValuesTBox = Box2;

			DialogResult res = ShowDialog();
			if (res == DialogResult.OK)
			{
				ValueIndex = Box.SelectedIndex;
				Value2 = Box2.Text;
			}

			Box.Dispose();
			Box2.Dispose();
			Prompt2Lbl.Dispose();
			CheckEnableContols.Clear();

			return (res == DialogResult.OK);
		}

		void Box_SelectedIndexChanged(object sender, EventArgs e)
		{
			if(LinkedValueList != null && LinkedValuesTBox != null)
			{
				LinkedValuesTBox.Text = LinkedValueList[((ComboBox) sender).SelectedIndex].ToString();
			}
		}

		private void ChBox_CheckStateChanged(object sender, EventArgs e)
		{
			bool ch = ((CheckBox)sender).Checked;
			for (int i = 0; i < CheckEnableContols.Count; i++)
				CheckEnableContols[i].Enabled = !ch;
		}

		void Box_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (!string.IsNullOrEmpty(PatternInput))
			{
				if (PatternInput.IndexOf(e.KeyChar) == -1)
					e.Handled = true;
			}
		}

		private void InputForm_Shown(object sender, EventArgs e)
		{
		}

		private void InputForm_Load(object sender, EventArgs e)
		{
			if (MainWnd != null)
			{
				int X = MainWnd.Left + (MainWnd.Width / 2 - Width / 2);
				int Y = MainWnd.Top + (MainWnd.Height / 2 - Height / 2);
				Left = X;
				Top = Y;
			}
		}
	}
}