﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Custom_Tag
{
	static class TableColumn
	{
		static private void NameFile(List<DataGridViewTextBoxColumn> buff)
		{
			buff.Add(new DataGridViewTextBoxColumn());
			buff.Last().AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCellsExceptHeader;
			buff.Last().HeaderText = "Имя файла";
			buff.Last().MaxInputLength = 99;
			buff.Last().MinimumWidth = 100;
			buff.Last().Name = "NameFile";
			buff.Last().ToolTipText = "%fname";
		}
		static private void Ext(List<DataGridViewTextBoxColumn> buff)
		{
			buff.Add(new DataGridViewTextBoxColumn());
			buff.Last().AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCellsExceptHeader;
			buff.Last().HeaderText = "Ext";
			buff.Last().MaxInputLength = 10;
			buff.Last().MinimumWidth = 30;
			buff.Last().Name = "Ext";
			buff.Last().ReadOnly = true;
			buff.Last().Width = 30;
		}

		static public void vNewColum(DataGridView Table)
		{
			Table.Columns.Clear();
			List<DataGridViewTextBoxColumn> lColumn = new List<DataGridViewTextBoxColumn>();
			NameFile(lColumn);

			Ext(lColumn);

			CreateColumn(lColumn, Table);
		}

		static public void mNewColum(DataGridView Table)
		{
			Table.Columns.Clear();
			List<DataGridViewTextBoxColumn> lColumn = new List<DataGridViewTextBoxColumn>();
			NameFile(lColumn);

			lColumn.Add(new DataGridViewTextBoxColumn());
			lColumn.Last().AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCellsExceptHeader;
			lColumn.Last().HeaderText = "№";
			lColumn.Last().MaxInputLength = 10;
			lColumn.Last().MinimumWidth = 30;
			lColumn.Last().Name = "Track";
			lColumn.Last().ToolTipText = "%track";
			lColumn.Last().Width = 30;
			lColumn.Last().ValueType = typeof(uint);

			lColumn.Add(new DataGridViewTextBoxColumn());
			lColumn.Last().AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCellsExceptHeader;
			lColumn.Last().HeaderText = "Название";
			lColumn.Last().MaxInputLength = 99;
			lColumn.Last().MinimumWidth = 100;
			lColumn.Last().Name = "Title";
			lColumn.Last().ToolTipText = "%title";

			lColumn.Add(new DataGridViewTextBoxColumn());
			lColumn.Last().AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			lColumn.Last().HeaderText = "Комментарий";
			lColumn.Last().MaxInputLength = 99;
			lColumn.Last().MinimumWidth = 40;
			lColumn.Last().Name = "Comment";
			lColumn.Last().Width = 85;

			lColumn.Add(new DataGridViewTextBoxColumn());
			lColumn.Last().AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCellsExceptHeader;
			lColumn.Last().HeaderText = "Исполнитель";
			lColumn.Last().MaxInputLength = 99;
			lColumn.Last().MinimumWidth = 100;
			lColumn.Last().Name = "Performer";
			lColumn.Last().ToolTipText = "%perf";

			lColumn.Add(new DataGridViewTextBoxColumn());
			lColumn.Last().AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCellsExceptHeader;
			lColumn.Last().HeaderText = "Исполнитель альбома";
			lColumn.Last().MaxInputLength = 99;
			lColumn.Last().MinimumWidth = 100;
			lColumn.Last().Name = "AlbumArtist";
			lColumn.Last().ToolTipText = "%aperf";

			lColumn.Add(new DataGridViewTextBoxColumn());
			lColumn.Last().AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCellsExceptHeader;
			lColumn.Last().HeaderText = "Альбом";
			lColumn.Last().MaxInputLength = 99;
			lColumn.Last().MinimumWidth = 100;
			lColumn.Last().Name = "Album";
			lColumn.Last().ToolTipText = "%album";

			lColumn.Add(new DataGridViewTextBoxColumn());
			lColumn.Last().AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCellsExceptHeader;
			lColumn.Last().HeaderText = "Год";
			lColumn.Last().MaxInputLength = 4;
			lColumn.Last().MinimumWidth = 40;
			lColumn.Last().Name = "Year";
			lColumn.Last().ToolTipText = "%year";
			lColumn.Last().Width = 40;
			lColumn.Last().ValueType = typeof(uint);

			lColumn.Add(new DataGridViewTextBoxColumn());
			lColumn.Last().AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCellsExceptHeader;
			lColumn.Last().HeaderText = "Жанр";
			lColumn.Last().MaxInputLength = 99;
			lColumn.Last().MinimumWidth = 60;
			lColumn.Last().Name = "Genre";
			lColumn.Last().ToolTipText = "%genre";
			lColumn.Last().Width = 60;

			Ext(lColumn);

			CreateColumn(lColumn, Table);
		}

		static private void CreateColumn(List<DataGridViewTextBoxColumn> buff, DataGridView Table)
		{
			foreach (DataGridViewTextBoxColumn buffer in buff)
			{

				buffer.SortMode = DataGridViewColumnSortMode.NotSortable;
				Table.Columns.Add(buffer);
			}
		}
	}
}
