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

namespace Truffles
{
    public partial class DeleteColumn : Form
    {
        frmMain mainfrm;
        public DeleteColumn(frmMain main)
        {
            this.mainfrm = main;
            InitializeComponent();
        }

        public void init()
        {
            if (mainfrm.file.table == null) return;
            for (int i = 0; i < mainfrm.file.table.Columns.Count; i++)
            {
                txtList.Text += mainfrm.file.table.Columns[i].ColumnName + "\r\n";
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                List<string> lines = new List<string>();
                foreach (var line in mainfrm.file.ColumnNames)
                {
                    lines.Add(line);
                }
                foreach (var line in txtList.Lines)
                {
                    lines.Remove(line);
                }
                foreach (var line in lines)
                {
                    mainfrm.file.DeleteColumn(line);
                }
            }
            catch { }

            this.Close();
        }
    }
}