using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Babebi4
{
	public partial class Form__WordConcatenatedComponent__Delete : Form
	{
		private MainForm mainForm;

		private BabebiDataSet.WordDataTable							table__Word							{ get { return this.mainForm.DataSet.Word; } }
		private BabebiDataSet.Word_LanguageDataTable				table__Word_Language				{ get { return this.mainForm.DataSet.Word_Language; } }
		private BabebiDataSet.WordConcatenatedDataTable				table__WordConcatenated				{ get { return this.mainForm.DataSet.WordConcatenated; } }
		private BabebiDataSet.WordConcatenatedComponentDataTable	table__WordConcatenatedComponent	{ get { return this.mainForm.DataSet.WordConcatenatedComponent; } }

		private BabebiDataSet.WordRow						current__Word
		{
			get
			{
				return this.mainForm.Current__Word;
			}
		}
		private BabebiDataSet.Word_LanguageRow				current__Word_Language
		{
			get
			{
				return this.mainForm.Current__Word_Language;
			}
		}
		private BabebiDataSet.WordConcatenatedRow			current__WordConcatenated
		{
			get
			{
				return this.mainForm.Current__WordConcatenated;
			}
			set
			{
				this.mainForm.Current__WordConcatenated = value;
			}
		}
		private BabebiDataSet.WordConcatenatedComponentRow	current__WordConcatenatedComponent
		{
			get
			{
				return this.mainForm.Current__WordConcatenatedComponent;
			}
			set
			{
				this.mainForm.Current__WordConcatenatedComponent = null;
			}
		}
		private BabebiDataSet.WordRow						current__Word__of__ConcatenatedComponent
		{
			get
			{
				return this.mainForm.Current__Word__of__WordConcatenatedComponent;
			}
			set
			{
				this.mainForm.Current__Word__of__WordConcatenatedComponent = value;
			}
		}
		private BabebiDataSet.Word_LanguageRow				current__Word_Language__of__ConcatenatedComponent
		{
			get
			{
				return this.mainForm.Current__Word_Language__of__WordConcatenatedComponent;
			}
			set
			{
				this.mainForm.Current__Word_Language__of__WordConcatenatedComponent = value;
			}
		}

		#region		ctors

		public Form__WordConcatenatedComponent__Delete(MainForm mainForm) : this()
		{
			this.mainForm = mainForm;

			this.textBox__Word__String.Text									= this.current__Word.UniqueKeyString;
			this.textBox__Word__Meaning.Text								= this.current__Word_Language.Meaning;
			this.textBox__WordConcatenatedComponent__Rank.Text				= this.current__WordConcatenatedComponent.Rank.ToString();
			this.textBox__WordConcatenatedComponent__String.Text			= this.current__Word__of__ConcatenatedComponent.UniqueKeyString;
			this.textBox__WordConcatenatedComponent__Meaning.Text			= this.current__Word_Language__of__ConcatenatedComponent.Meaning;

			WordConcatenated.Read_SubString_Index_and_Length_from_DataRow
				(
					this.current__WordConcatenatedComponent, 
				out int index, 
				out int length
				);

			SubStringInformation subStringInformation = new SubStringInformation(index, length);

			this.textBox__WordConcatenatedComponent__SubStringIndex.Text	= subStringInformation.IndexSelectedItem;
			this.textBox__WordConcatenatedComponent__SubStringLength.Text	= subStringInformation.LengthSelectedItem;
		}

		public Form__WordConcatenatedComponent__Delete()
		{
			InitializeComponent();
		}

		#endregion	ctors

		private void button__Delete__Click(object sender, EventArgs e)
		{
			short rank = Convert.ToInt16( this.textBox__WordConcatenatedComponent__Rank.Text );

			this.table__WordConcatenatedComponent.RemoveWordConcatenatedComponentRow(this.current__WordConcatenatedComponent);

			this.mainForm.Compute__ConcatenatedString();

			this.DialogResult = DialogResult.OK;

			this.Close();
		}
	}
}
