namespace SHNDecrypt
{
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class columnBulkEdit : Form
    {
        private Button button1;
        private CheckBox checkBox1;
        private ComboBox comboBox1;
        private IContainer components;
        private frmMain frmColBulkEdit;
        private Label label1;
        private Label label2;
        private TextBox txtBulk;

        public columnBulkEdit(frmMain form)
        {
            this.frmColBulkEdit = form;
            this.InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int num = this.frmColBulkEdit.file.getColIndex(this.comboBox1.Items[this.comboBox1.SelectedIndex].ToString());
            if (num >= 0)
            {
                if (!this.checkBox1.Checked)
                {
                    for (int i = 0; i < this.frmColBulkEdit.file.table.Rows.Count; i++)
                    {
                        try
                        {
                            this.frmColBulkEdit.file.table.Rows[i][num] = this.txtBulk.Text;
                        }
                        catch (Exception exception)
                        {
                            MessageBox.Show(exception.Message);
                            break;
                        }
                    }
                }
                else if (this.frmColBulkEdit.dataGrid.SelectedRows.Count != 0)
                {
                    foreach (DataGridViewRow row in this.frmColBulkEdit.dataGrid.SelectedRows)
                    {
                        try
                        {
                            this.frmColBulkEdit.file.table.Rows[row.Index][num] = this.txtBulk.Text;
                        }
                        catch (Exception exception2)
                        {
                            MessageBox.Show(exception2.Message);
                            break;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Please select the appropriate rows to modify.");
                    this.frmColBulkEdit.SQLStatus.Text = "Please select the appropriate rows to modify.";
                }
                this.frmColBulkEdit.SQLStatus.Text = this.comboBox1.SelectedItem.ToString() + " column values have been set to \"" + this.txtBulk.Text + "\".";
            }
        }

        private void ColMultiplier_Load(object sender, EventArgs e)
        {
            if (this.frmColBulkEdit.file == null)
            {
                base.Close();
            }
            else
            {
                this.init();
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        public void init()
        {
            if (this.frmColBulkEdit.file.table != null)
            {
                this.comboBox1.Items.Clear();
                for (int i = 0; i < this.frmColBulkEdit.file.table.Columns.Count; i++)
                {
                    this.comboBox1.Items.Add(this.frmColBulkEdit.file.table.Columns[i].ColumnName);
                }
                this.comboBox1.SelectedIndex = 0;
            }
        }

        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(columnBulkEdit));
            this.comboBox1 = new ComboBox();
            this.button1 = new Button();
            this.txtBulk = new TextBox();
            this.label2 = new Label();
            this.label1 = new Label();
            this.checkBox1 = new CheckBox();
            base.SuspendLayout();
            this.comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
            this.comboBox1.FormattingEnabled = true;
            this.comboBox1.Location = new Point(0x3f, 12);
            this.comboBox1.Name = "comboBox1";
            this.comboBox1.Size = new Size(0xd7, 0x15);
            this.comboBox1.TabIndex = 0;
            this.button1.Location = new Point(0x3f, 0x41);
            this.button1.Name = "button1";
            this.button1.Size = new Size(0xd7, 30);
            this.button1.TabIndex = 7;
            this.button1.Text = "Edit";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new EventHandler(this.button1_Click);
            this.txtBulk.Location = new Point(0x3f, 0x27);
            this.txtBulk.Name = "txtBulk";
            this.txtBulk.Size = new Size(0xd7, 20);
            this.txtBulk.TabIndex = 1;
            this.label2.AutoSize = true;
            this.label2.Location = new Point(20, 0x2a);
            this.label2.Name = "label2";
            this.label2.Size = new Size(0x25, 13);
            this.label2.TabIndex = 0;
            this.label2.Text = "Value:";
            this.label1.AutoSize = true;
            this.label1.Location = new Point(12, 15);
            this.label1.Name = "label1";
            this.label1.Size = new Size(0x2d, 13);
            this.label1.TabIndex = 8;
            this.label1.Text = "Column:";
            this.checkBox1.AutoSize = true;
            this.checkBox1.Location = new Point(0x3f, 0x65);
            this.checkBox1.Name = "checkBox1";
            this.checkBox1.Size = new Size(0x52, 0x11);
            this.checkBox1.TabIndex = 9;
            this.checkBox1.Text = "In Selection";
            this.checkBox1.UseVisualStyleBackColor = true;
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x121, 0x7f);
            base.Controls.Add(this.checkBox1);
            base.Controls.Add(this.label1);
            base.Controls.Add(this.txtBulk);
            base.Controls.Add(this.label2);
            base.Controls.Add(this.button1);
            base.Controls.Add(this.comboBox1);
            base.FormBorderStyle = FormBorderStyle.FixedSingle;
            base.Icon = (Icon) manager.GetObject("$this.Icon");
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "columnBulkEdit";
            base.StartPosition = FormStartPosition.CenterParent;
            this.Text = "Column Bulk Editor";
            base.Load += new EventHandler(this.ColMultiplier_Load);
            base.ResumeLayout(false);
            base.PerformLayout();
        }
    }
}

