namespace SHNDecrypt
{
    using Microsoft.Win32;
    using SHNDecrypt.Help;
    using SHNDecrypt.Search;
    using SHNDecrypt.Tools;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Diagnostics;
    using System.Drawing;
    using System.IO;
    using System.IO.Compression;
    using System.Linq;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;

    public class frmMain : Form
    {
        private ToolStripMenuItem aboutToolStripMenuItem;
        private Button button1;
        private Button button2;
        private CheckBox chkDrop;
        private ToolStripMenuItem closeToolStripMenuItem;
        private ToolStripMenuItem columnBulkEditToolStripMenuItem;
        private ToolStripMenuItem columnBulkMultiplyToolStripMenuItem;
        private ToolStripMenuItem columnDivideToolStripMenuItem;
        private ToolStripMenuItem columnToolStripMenuItem;
        private IContainer components;
        private ToolStripMenuItem copySelectedRowToolStripMenuItem;
        private ToolStripMenuItem createToolStripMenuItem;
        private ToolStripMenuItem createToolStripMenuItem1;
        private ToolStripMenuItem creditsToolStripMenuItem;
        private ToolStripMenuItem cSVToolStripMenuItem;
        public bool dataGridError;
        private ToolStripMenuItem debugToolStripMenuItem;
        private ToolStripMenuItem deleteRowsToolStripMenuItem;
        private ToolStripMenuItem deleteToolStripMenuItem;
        private ToolStripMenuItem deleteToolStripMenuItem1;
        private ToolStripMenuItem editToolStripMenuItem;
        private ToolStripMenuItem encodingToolStripMenuItem;
        private ToolStripMenuItem exitToolStripMenuItem;
        private ToolStripMenuItem exportToolStripMenuItem1;
        private ToolStripMenuItem expRateEditorToolStripMenuItem;
        private ToolStripMenuItem fileAssociationToolStripMenuItem;
        private TabControl FileTabs;
        private ToolStripMenuItem fileTreeToolStripMenuItem;
        private searchFilter filterFrm;
        private ToolStripMenuItem findModernToolStripMenuItem;
        private ToolStripMenuItem fromSHRToolStripMenuItem;
        private ToolStripMenuItem goToToolStripMenuItem;
        private GroupBox groupMysql;
        private GroupBox groupTree;
        private ToolStripMenuItem headerInfoToolStripMenuItem;
        private ToolStripMenuItem itemEditorToolStripMenuItem;
        private MenuStrip menuStrip1;
        private MRUManager mruManager;
        private ToolStripMenuItem newToolStripMenuItem;
        private ToolStripMenuItem oDTEditorToolStripMenuItem;
        private ToolStripMenuItem openFileToolStripMenuItem;
        private ToolStripMenuItem openToolStripMenuItem;
        private ToolStripMenuItem optionsToolStripMenuItem;
        private ToolStripMenuItem pasteRowToolStripMenuItem;
        private ToolStripMenuItem pasteToolStripMenuItem;
        private ToolStripMenuItem recentToolStripMenuItem;
        private ToolStripMenuItem renameToolStripMenuItem;
        private ToolStripMenuItem replaceToolStripMenuItem;
        private ToolStripMenuItem resetColumnSortToolStripMenuItem;
        private ToolStripMenuItem rowFilterToolStripMenuItem;
        private ToolStripMenuItem rowReplaceToolStripMenuItem;
        private ToolStripMenuItem rowSyncToolStripMenuItem;
        private ToolStripMenuItem rowToolStripMenuItem;
        private ToolStripMenuItem saveAsToolStripMenuItem;
        private ToolStripMenuItem saveToolStripMenuItem;
        private searchFindOld searchFrm;
        private ToolStripMenuItem searchToolStripMenuItem;
        private ToolStripMenuItem searchToolStripMenuItem1;
        private ToolStripMenuItem shopCreatorToolStripMenuItem;
        private ToolStripMenuItem sQLPanelToolStripMenuItem;
        private TextBox SQLScript;
        public ToolStripStatusLabel SQLStatus;
        private StatusStrip statusStrip1;
        private ToolStripMenuItem toCSVBetaToolStripMenuItem;
        private ToolStripMenuItem toolsToolStripMenuItem;
        private ToolStripMenuItem toolStripMenuItem1;
        private ToolStripSeparator toolStripSeparator1;
        private ToolStripSeparator toolStripSeparator2;
        private ToolStripSeparator toolStripSeparator3;
        private ToolStripSeparator toolStripSeparator4;
        private ToolStripSeparator toolStripSeparator5;
        private ToolStripSeparator toolStripSeparator6;
        private ToolStripSeparator toolStripSeparator8;
        private ToolStripMenuItem toSHRToolStripMenuItem;
        private ToolStripMenuItem translatorToolStripMenuItem;
        private ToolStripMenuItem transToolStripMenuItem;
        private TreeView treeView1;
        private ToolStripMenuItem updatesToolStripMenuItem;

        public frmMain()
        {
            this.InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                this.SQLStatus.Text = "Busy...";
                string output = "";
                this.file.CreateSQL(out output, this.chkDrop.Checked);
                this.SQLScript.Text = output;
                this.SQLStatus.Text = "Done generating query.";
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (this.SQLScript.Text.Length >= 5)
            {
                SaveFileDialog dialog = new SaveFileDialog {
                    Filter = "SQL Script(*.sql)|*.sql",
                    Title = "Save SQL Query"
                };
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    TextWriter writer = new StreamWriter(dialog.FileName);
                    writer.Write(this.SQLScript.Text);
                    writer.Close();
                }
                this.SQLStatus.Text = "File saved!";
            }
        }

        private void checkForParams()
        {
            string[] commandLineArgs = Environment.GetCommandLineArgs();
            if (commandLineArgs.Length != 1)
            {
                string filename = commandLineArgs[1];
                this.InitFile(filename, false);
            }
        }

        private void closeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                this.SQLScript.Text = string.Empty;
                this.file.Dispose();
                this.file = null;
                this.FileTabs.TabPages.Remove(this.FileTabs.SelectedTab);
                this.SQLStatus.Text = "Closed Tab.";
                this.Text = "SHN Editor - " + this.FileTabs.TabCount.ToString() + " file(s) open";
            }
        }

        private void columnAutosetToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                new rowReplace(this).ShowDialog();
            }
        }

        private void columnBulkMultiplyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                new columnMultiply(this).ShowDialog();
            }
        }

        private void columnDivideToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                new columnDivide(this).ShowDialog();
            }
        }

        private void columnMultiplierToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                new columnBulkEdit(this).ShowDialog();
            }
        }

        private void copySelectedRowToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                try
                {
                    if (this.dataGrid.Rows[this.dataGrid.NewRowIndex].Selected)
                    {
                        this.dataGrid.Rows[this.dataGrid.NewRowIndex].Selected = false;
                    }
                }
                catch (Exception)
                {
                }
                MemoryStream output = new MemoryStream();
                BinaryWriter writer = new BinaryWriter(output);
                new DataTable();
                this.file.table.Clone();
                IOrderedEnumerable<DataGridViewRow> enumerable = from row in this.dataGrid.SelectedRows.Cast<DataGridViewRow>()
                    orderby row.Index
                    select row;
                writer.Write(this.dataGrid.SelectedRows.Count);
                foreach (DataGridViewRow row in enumerable)
                {
                    try
                    {
                        object[] itemArray = (row.DataBoundItem as DataRowView).Row.ItemArray;
                        writer.Write(itemArray.Length);
                        for (int i = 0; i < itemArray.Length; i++)
                        {
                            writer.Write(this.file.table.Columns[i].ColumnName);
                            writer.Write(itemArray[i].ToString());
                        }
                        writer.Write((byte) 0);
                    }
                    catch (NullReferenceException exception)
                    {
                        MessageBox.Show("You have selected an invalid row: " + Environment.NewLine + exception.Message);
                    }
                    catch (Exception exception2)
                    {
                        MessageBox.Show("An unknown error has occured: " + Environment.NewLine + exception2.Message);
                    }
                }
                output.Position = 0L;
                byte[] buffer = new byte[output.Length];
                output.Read(buffer, 0, (int) output.Length);
                Clipboard.SetData("Bytes", buffer);
                writer.Close();
                this.SQLStatus.Text = "Copied to clipboard.";
            }
        }

        private void CreateAssociation()
        {
            string[] openWithList = new string[] { "notepad.exe", "wordpad.exe" };
            FileAssociation.AssociationCreation(".shn", "SHN Tool", "application/myfile", openWithList, true, "SHN Editor");
        }

        private void createToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                columnCreate create = new columnCreate(this);
                create.init();
                create.ShowDialog();
            }
        }

        private void createToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                new createRow(this).ShowDialog();
            }
        }

        private void creditsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            new helpAbout().ShowDialog();
        }

        private void dataGrid_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (this.dataGrid.SelectedRows.Count < 1)
                {
                    SHNColumn colByName = this.file.GetColByName(this.file.table.Columns[e.ColumnIndex].ColumnName);
                    string str = this.file.table.Columns[e.ColumnIndex].DataType.ToString();
                    this.SQLStatus.Text = string.Concat(new object[] { colByName.name, ": ", str, " || SHN type: ", colByName.Type, " len: ", colByName.Lenght });
                }
                else
                {
                    object[] objArray2 = new object[] { "Ready. Columns: ", this.dataGrid.Columns.Count.ToString(), " Row: ", this.dataGrid.CurrentCell.RowIndex, "/", (this.file.table.Rows.Count - 1).ToString() };
                    this.SQLStatus.Text = string.Concat(objArray2);
                }
            }
            catch (Exception exception)
            {
                this.SQLStatus.Text = "Ready. Error Occured: " + exception.Message;
            }
        }

        private void dataGrid_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            MessageBox.Show("Data Type: " + ((DataTable) this.dataGrid.DataSource).Columns[e.ColumnIndex].DataType.Name);
        }

        private void debugToolStripMenuItem_Click(object sender, EventArgs e)
        {
            new DebugFrm(this).ShowDialog();
        }

        private void deleteRowsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                foreach (DataGridViewRow row in this.dataGrid.SelectedRows)
                {
                    try
                    {
                        this.dataGrid.Rows.RemoveAt(row.Index);
                    }
                    catch
                    {
                        MessageBox.Show("You have selected to delete an invalid row.");
                    }
                }
            }
        }

        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                columnDeletion deletion = new columnDeletion(this);
                deletion.init();
                deletion.ShowDialog();
            }
        }

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

        private void encodingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            new toolSetEncoding(this).ShowDialog();
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void expRateEditorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                if (!this.file.Path.EndsWith("MobInfoServer.shn"))
                {
                    MessageBox.Show("Please open MobInfoServer.shn first!");
                }
                else
                {
                    new ExpEditor(this).ShowDialog();
                }
            }
        }

        private void FileTabs_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] data = (string[]) e.Data.GetData(DataFormats.FileDrop);
                foreach (string str in data)
                {
                    this.InitFile(str, false);
                }
            }
        }

        private void FileTabs_DragEnter(object sender, DragEventArgs e)
        {
            e.Effect = DragDropEffects.Move;
        }

        private void FileTabs_KeyDown(object sender, KeyEventArgs e)
        {
            if ((e.KeyCode == Keys.Escape) && (MessageBox.Show("Are you sure you want to exit SHN editor?", "SHN Editor", MessageBoxButtons.YesNo) == DialogResult.Yes))
            {
                e.SuppressKeyPress = true;
                Application.Exit();
            }
        }

        private void fileTreeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.groupTree.Visible)
            {
                this.groupTree.Visible = false;
            }
            else
            {
                this.groupTree.Visible = true;
            }
        }

        private void filterToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                if (this.filterFrm == null)
                {
                    this.filterFrm = new searchFilter(this);
                }
                this.filterFrm.Text = "Filter: " + this.FileTabs.SelectedTab.Text;
                this.filterFrm.Show();
            }
        }

        private void findOldToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                if (this.searchFrm == null)
                {
                    this.searchFrm = new searchFindOld(this);
                }
                this.searchFrm.Text = "Find: " + this.FileTabs.SelectedTab.Text;
                this.searchFrm.Show();
            }
        }

        private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            Application.Exit();
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
            bool flag = FileAssociation.AssociationCheck(".shn", "SHN Tool");
            this.fileAssociationToolStripMenuItem.Checked = flag;
            if (!flag && (MessageBox.Show("Do you want to associate this tool with SHN files?", "SHN", MessageBoxButtons.YesNo) == DialogResult.Yes))
            {
                this.CreateAssociation();
            }
            this.setRegistryInfo();
            this.mruManager = new MRUManager(this.recentToolStripMenuItem, Program.assemblyName, new Action<object, EventArgs>(this.myOwnRecentFileGotClicked_handler), null);
            this.Text = "SHN Editor - V" + Application.ProductVersion;
            this.showHideMySQLToolStripMenuItem_Click(null, null);
            this.fileTreeToolStripMenuItem_Click(null, null);
            this.checkForParams();
        }

        private void fromSHRToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                OpenFileDialog dialog = new OpenFileDialog {
                    Filter = "SHN Row File (*.shr)|*.shr",
                    Title = "Select SHN Row file"
                };
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    GZipStream input = new GZipStream(File.Open(dialog.FileName, FileMode.Open), CompressionMode.Decompress);
                    BinaryReader reader = new BinaryReader(input);
                    int num = reader.ReadInt32();
                    for (int i = 0; i < num; i++)
                    {
                        int num3 = reader.ReadInt32();
                        Dictionary<string, string> dictionary = new Dictionary<string, string>();
                        for (int j = 0; j < num3; j++)
                        {
                            string key = reader.ReadString();
                            string str2 = reader.ReadString();
                            dictionary.Add(key, str2);
                        }
                        if (reader.ReadByte() != 0)
                        {
                            return;
                        }
                        DataRow row = this.file.table.NewRow();
                        for (int k = 0; k < this.file.table.Columns.Count; k++)
                        {
                            string columnName = this.file.table.Columns[k].ColumnName;
                            if (dictionary.ContainsKey(columnName))
                            {
                                row[k] = dictionary[columnName];
                            }
                        }
                        this.file.table.Rows.Add(row);
                    }
                    input.Close();
                    this.SQLStatus.Text = "Imported " + num.ToString() + " rows.";
                }
            }
        }

        private void goToToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.file != null)
            {
                new searchGoTo(this).ShowDialog();
            }
        }

        private void grid_DataError(object sender, DataGridViewDataErrorEventArgs anError)
        {
            if (anError.Context == DataGridViewDataErrorContexts.Commit)
            {
                MessageBox.Show("Commit Error: " + anError.Exception.Message.ToString());
                this.dataGridError = true;
            }
            else if (anError.Exception is ConstraintException)
            {
                DataGridView view = (DataGridView) sender;
                view.Rows[anError.RowIndex].ErrorText = "an error";
                view.Rows[anError.RowIndex].Cells[anError.ColumnIndex].ErrorText = "an error";
                anError.ThrowException = false;
                this.dataGridError = true;
            }
            else
            {
                MessageBox.Show("An error occured: " + anError.Exception.Message.ToString());
                this.dataGridError = true;
            }
        }

        private void headerInfoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if ((this.file != null) && (this.dataGrid != null))
            {
                new editHeaderInfo(this).ShowDialog();
            }
        }

        private void InitFile(string Filename, bool NewFile = false)
        {
            Stopwatch stopwatch = Stopwatch.StartNew();
            stopwatch.Restart();
            if (!NewFile)
            {
                if (this.recentToolStripMenuItem.DropDownItems.Count == 7)
                {
                    this.mruManager.RemoveRecentFile(this.recentToolStripMenuItem.DropDown.Items[0].Text);
                    this.mruManager.AddRecentFile(Filename);
                }
                else
                {
                    this.mruManager.AddRecentFile(Filename);
                }
                if (!File.Exists(Filename))
                {
                    return;
                }
                if (Path.GetFileName(Filename) == "QuestData.shn")
                {
                    MessageBox.Show("Please use iQuest as this application cannot view this file.");
                    return;
                }
                if (!Filename.ToLower().EndsWith(".shn"))
                {
                    SHNFile file = new SHNFile();
                    file.LoadMe(Filename);
                    new OPToolEditor(this, file.data, Path.GetExtension(Filename)).ShowDialog();
                    return;
                }
            }
            try
            {
                TabPage page;
                SHNFile file2;
                if (NewFile)
                {
                    file2 = new SHNFile();
                    file2.CreateDefaultLayout();
                    page = new TabPage(Filename);
                }
                else
                {
                    page = new TabPage(Path.GetFileName(Filename));
                    file2 = new SHNFile(Filename);
                }
                this.FileTabs.TabPages.Add(page);
                this.FileTabs.SelectedTab = page;
                DataGridView dgv = new DataGridView();
                page.Tag = dgv;
                dgv.Tag = file2;
                dgv.DataSource = file2.table;
                dgv.AllowUserToDeleteRows = true;
                dgv.AllowUserToOrderColumns = true;
                dgv.AllowUserToResizeColumns = true;
                dgv.DoubleBuffered(true);
                dgv.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
                dgv.Location = new Point(6, 0x13);
                dgv.Name = "grid";
                dgv.Size = new Size(0x2ed, 470);
                dgv.ScrollBars = ScrollBars.Both;
                dgv.TabIndex = 1;
                dgv.Dock = DockStyle.Fill;
                dgv.DataError += new DataGridViewDataErrorEventHandler(this.grid_DataError);
                dgv.CellClick += new DataGridViewCellEventHandler(this.dataGrid_CellClick);
                page.Controls.Add(dgv);
                page.ToolTipText = Filename;
                this.Text = "SHN Editor - " + this.FileTabs.TabCount.ToString() + " file(s) open";
                stopwatch.Stop();
                this.SQLStatus.Text = string.Concat(new object[] { "Loaded ", this.file.table.Columns.Count, " column(s) and ", this.file.table.Rows.Count.ToString(), " row(s) in ", stopwatch.ElapsedMilliseconds, " milliseconds." });
            }
            catch (Exception exception)
            {
                this.SQLStatus.Text = exception.Message;
            }
        }

        private void InitializeComponent()
        {
            TreeNode node = new TreeNode("Node1");
            TreeNode node2 = new TreeNode("Node2");
            TreeNode node3 = new TreeNode("Node0", new TreeNode[] { node, node2 });
            ComponentResourceManager manager = new ComponentResourceManager(typeof(frmMain));
            this.menuStrip1 = new MenuStrip();
            this.openFileToolStripMenuItem = new ToolStripMenuItem();
            this.newToolStripMenuItem = new ToolStripMenuItem();
            this.openToolStripMenuItem = new ToolStripMenuItem();
            this.recentToolStripMenuItem = new ToolStripMenuItem();
            this.toolStripSeparator2 = new ToolStripSeparator();
            this.saveToolStripMenuItem = new ToolStripMenuItem();
            this.saveAsToolStripMenuItem = new ToolStripMenuItem();
            this.toolStripSeparator1 = new ToolStripSeparator();
            this.closeToolStripMenuItem = new ToolStripMenuItem();
            this.exitToolStripMenuItem = new ToolStripMenuItem();
            this.editToolStripMenuItem = new ToolStripMenuItem();
            this.copySelectedRowToolStripMenuItem = new ToolStripMenuItem();
            this.pasteToolStripMenuItem = new ToolStripMenuItem();
            this.deleteRowsToolStripMenuItem = new ToolStripMenuItem();
            this.toolStripSeparator8 = new ToolStripSeparator();
            this.pasteRowToolStripMenuItem = new ToolStripMenuItem();
            this.toolStripMenuItem1 = new ToolStripMenuItem();
            this.fromSHRToolStripMenuItem = new ToolStripMenuItem();
            this.cSVToolStripMenuItem = new ToolStripMenuItem();
            this.exportToolStripMenuItem1 = new ToolStripMenuItem();
            this.toSHRToolStripMenuItem = new ToolStripMenuItem();
            this.toCSVBetaToolStripMenuItem = new ToolStripMenuItem();
            this.toolStripSeparator3 = new ToolStripSeparator();
            this.headerInfoToolStripMenuItem = new ToolStripMenuItem();
            this.searchToolStripMenuItem = new ToolStripMenuItem();
            this.searchToolStripMenuItem1 = new ToolStripMenuItem();
            this.replaceToolStripMenuItem = new ToolStripMenuItem();
            this.goToToolStripMenuItem = new ToolStripMenuItem();
            this.columnToolStripMenuItem = new ToolStripMenuItem();
            this.createToolStripMenuItem = new ToolStripMenuItem();
            this.renameToolStripMenuItem = new ToolStripMenuItem();
            this.deleteToolStripMenuItem = new ToolStripMenuItem();
            this.toolStripSeparator4 = new ToolStripSeparator();
            this.columnBulkEditToolStripMenuItem = new ToolStripMenuItem();
            this.columnBulkMultiplyToolStripMenuItem = new ToolStripMenuItem();
            this.columnDivideToolStripMenuItem = new ToolStripMenuItem();
            this.rowToolStripMenuItem = new ToolStripMenuItem();
            this.createToolStripMenuItem1 = new ToolStripMenuItem();
            this.deleteToolStripMenuItem1 = new ToolStripMenuItem();
            this.toolStripSeparator5 = new ToolStripSeparator();
            this.rowSyncToolStripMenuItem = new ToolStripMenuItem();
            this.rowFilterToolStripMenuItem = new ToolStripMenuItem();
            this.rowReplaceToolStripMenuItem = new ToolStripMenuItem();
            this.toolsToolStripMenuItem = new ToolStripMenuItem();
            this.shopCreatorToolStripMenuItem = new ToolStripMenuItem();
            this.itemEditorToolStripMenuItem = new ToolStripMenuItem();
            this.translatorToolStripMenuItem = new ToolStripMenuItem();
            this.oDTEditorToolStripMenuItem = new ToolStripMenuItem();
            this.toolStripSeparator6 = new ToolStripSeparator();
            this.expRateEditorToolStripMenuItem = new ToolStripMenuItem();
            this.debugToolStripMenuItem = new ToolStripMenuItem();
            this.transToolStripMenuItem = new ToolStripMenuItem();
            this.optionsToolStripMenuItem = new ToolStripMenuItem();
            this.encodingToolStripMenuItem = new ToolStripMenuItem();
            this.sQLPanelToolStripMenuItem = new ToolStripMenuItem();
            this.fileTreeToolStripMenuItem = new ToolStripMenuItem();
            this.fileAssociationToolStripMenuItem = new ToolStripMenuItem();
            this.aboutToolStripMenuItem = new ToolStripMenuItem();
            this.updatesToolStripMenuItem = new ToolStripMenuItem();
            this.creditsToolStripMenuItem = new ToolStripMenuItem();
            this.groupMysql = new GroupBox();
            this.chkDrop = new CheckBox();
            this.button2 = new Button();
            this.button1 = new Button();
            this.SQLScript = new TextBox();
            this.statusStrip1 = new StatusStrip();
            this.SQLStatus = new ToolStripStatusLabel();
            this.FileTabs = new TabControl();
            this.treeView1 = new TreeView();
            this.resetColumnSortToolStripMenuItem = new ToolStripMenuItem();
            this.groupTree = new GroupBox();
            this.findModernToolStripMenuItem = new ToolStripMenuItem();
            this.menuStrip1.SuspendLayout();
            this.groupMysql.SuspendLayout();
            this.statusStrip1.SuspendLayout();
            this.groupTree.SuspendLayout();
            base.SuspendLayout();
            this.menuStrip1.Items.AddRange(new ToolStripItem[] { this.openFileToolStripMenuItem, this.editToolStripMenuItem, this.searchToolStripMenuItem, this.columnToolStripMenuItem, this.rowToolStripMenuItem, this.toolsToolStripMenuItem, this.optionsToolStripMenuItem, this.aboutToolStripMenuItem });
            this.menuStrip1.Location = new Point(0, 0);
            this.menuStrip1.Name = "menuStrip1";
            this.menuStrip1.Size = new Size(0x433, 0x18);
            this.menuStrip1.TabIndex = 1;
            this.menuStrip1.Text = "menuStrip1";
            this.openFileToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { this.newToolStripMenuItem, this.openToolStripMenuItem, this.recentToolStripMenuItem, this.toolStripSeparator2, this.saveToolStripMenuItem, this.saveAsToolStripMenuItem, this.toolStripSeparator1, this.closeToolStripMenuItem, this.exitToolStripMenuItem });
            this.openFileToolStripMenuItem.Name = "openFileToolStripMenuItem";
            this.openFileToolStripMenuItem.Size = new Size(0x25, 20);
            this.openFileToolStripMenuItem.Text = "File";
            this.newToolStripMenuItem.Name = "newToolStripMenuItem";
            this.newToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.N;
            this.newToolStripMenuItem.Size = new Size(0xb1, 0x16);
            this.newToolStripMenuItem.Text = "New";
            this.newToolStripMenuItem.Click += new EventHandler(this.newToolStripMenuItem_Click);
            this.openToolStripMenuItem.Name = "openToolStripMenuItem";
            this.openToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.O;
            this.openToolStripMenuItem.Size = new Size(0xb1, 0x16);
            this.openToolStripMenuItem.Text = "Open";
            this.openToolStripMenuItem.Click += new EventHandler(this.openToolStripMenuItem_Click);
            this.recentToolStripMenuItem.Name = "recentToolStripMenuItem";
            this.recentToolStripMenuItem.Size = new Size(0xb1, 0x16);
            this.recentToolStripMenuItem.Text = "Recent";
            this.toolStripSeparator2.Name = "toolStripSeparator2";
            this.toolStripSeparator2.Size = new Size(0xae, 6);
            this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
            this.saveToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.S;
            this.saveToolStripMenuItem.Size = new Size(0xb1, 0x16);
            this.saveToolStripMenuItem.Text = "Save";
            this.saveToolStripMenuItem.Click += new EventHandler(this.saveToolStripMenuItem_Click);
            this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem";
            this.saveAsToolStripMenuItem.ShortcutKeys = Keys.Alt | Keys.Control | Keys.S;
            this.saveAsToolStripMenuItem.Size = new Size(0xb1, 0x16);
            this.saveAsToolStripMenuItem.Text = "Save As";
            this.saveAsToolStripMenuItem.Click += new EventHandler(this.saveAsToolStripMenuItem_Click);
            this.toolStripSeparator1.Name = "toolStripSeparator1";
            this.toolStripSeparator1.Size = new Size(0xae, 6);
            this.closeToolStripMenuItem.Name = "closeToolStripMenuItem";
            this.closeToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.T;
            this.closeToolStripMenuItem.Size = new Size(0xb1, 0x16);
            this.closeToolStripMenuItem.Text = "Close Tab";
            this.closeToolStripMenuItem.Click += new EventHandler(this.closeToolStripMenuItem_Click);
            this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
            this.exitToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.E;
            this.exitToolStripMenuItem.Size = new Size(0xb1, 0x16);
            this.exitToolStripMenuItem.Text = "Exit";
            this.exitToolStripMenuItem.Click += new EventHandler(this.exitToolStripMenuItem_Click);
            this.editToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { this.copySelectedRowToolStripMenuItem, this.pasteToolStripMenuItem, this.deleteRowsToolStripMenuItem, this.toolStripSeparator8, this.pasteRowToolStripMenuItem, this.exportToolStripMenuItem1, this.toolStripSeparator3, this.headerInfoToolStripMenuItem });
            this.editToolStripMenuItem.Name = "editToolStripMenuItem";
            this.editToolStripMenuItem.Size = new Size(0x27, 20);
            this.editToolStripMenuItem.Text = "Edit";
            this.copySelectedRowToolStripMenuItem.Name = "copySelectedRowToolStripMenuItem";
            this.copySelectedRowToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.Shift | Keys.C;
            this.copySelectedRowToolStripMenuItem.Size = new Size(0xb3, 0x16);
            this.copySelectedRowToolStripMenuItem.Text = "Copy";
            this.copySelectedRowToolStripMenuItem.ToolTipText = "Copy selected rows";
            this.copySelectedRowToolStripMenuItem.Click += new EventHandler(this.copySelectedRowToolStripMenuItem_Click);
            this.pasteToolStripMenuItem.Name = "pasteToolStripMenuItem";
            this.pasteToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.Shift | Keys.V;
            this.pasteToolStripMenuItem.Size = new Size(0xb3, 0x16);
            this.pasteToolStripMenuItem.Text = "Paste";
            this.pasteToolStripMenuItem.Click += new EventHandler(this.toolStripMenuItem1_Click);
            this.deleteRowsToolStripMenuItem.Name = "deleteRowsToolStripMenuItem";
            this.deleteRowsToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.D;
            this.deleteRowsToolStripMenuItem.Size = new Size(0xb3, 0x16);
            this.deleteRowsToolStripMenuItem.Text = "Delete";
            this.deleteRowsToolStripMenuItem.ToolTipText = "Delete selected rows";
            this.deleteRowsToolStripMenuItem.Click += new EventHandler(this.deleteRowsToolStripMenuItem_Click);
            this.toolStripSeparator8.Name = "toolStripSeparator8";
            this.toolStripSeparator8.Size = new Size(0xb0, 6);
            this.pasteRowToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { this.toolStripMenuItem1, this.fromSHRToolStripMenuItem, this.cSVToolStripMenuItem });
            this.pasteRowToolStripMenuItem.Name = "pasteRowToolStripMenuItem";
            this.pasteRowToolStripMenuItem.Size = new Size(0xb3, 0x16);
            this.pasteRowToolStripMenuItem.Text = "Import";
            this.pasteRowToolStripMenuItem.ToolTipText = "Import rows from clipboard";
            this.toolStripMenuItem1.Name = "toolStripMenuItem1";
            this.toolStripMenuItem1.Size = new Size(0x9d, 0x16);
            this.toolStripMenuItem1.Text = "From Clipboard";
            this.toolStripMenuItem1.Click += new EventHandler(this.toolStripMenuItem1_Click);
            this.fromSHRToolStripMenuItem.Name = "fromSHRToolStripMenuItem";
            this.fromSHRToolStripMenuItem.Size = new Size(0x9d, 0x16);
            this.fromSHRToolStripMenuItem.Text = "From SHR";
            this.fromSHRToolStripMenuItem.Click += new EventHandler(this.fromSHRToolStripMenuItem_Click);
            this.cSVToolStripMenuItem.Name = "cSVToolStripMenuItem";
            this.cSVToolStripMenuItem.Size = new Size(0x9d, 0x16);
            this.cSVToolStripMenuItem.Text = "From CSV";
            this.exportToolStripMenuItem1.DropDownItems.AddRange(new ToolStripItem[] { this.toSHRToolStripMenuItem, this.toCSVBetaToolStripMenuItem });
            this.exportToolStripMenuItem1.Name = "exportToolStripMenuItem1";
            this.exportToolStripMenuItem1.Size = new Size(0xb3, 0x16);
            this.exportToolStripMenuItem1.Text = "Export";
            this.toSHRToolStripMenuItem.Name = "toSHRToolStripMenuItem";
            this.toSHRToolStripMenuItem.Size = new Size(0x71, 0x16);
            this.toSHRToolStripMenuItem.Text = "To SHR";
            this.toSHRToolStripMenuItem.ToolTipText = "This imports previously saved rows.";
            this.toSHRToolStripMenuItem.Click += new EventHandler(this.toSHRToolStripMenuItem_Click);
            this.toCSVBetaToolStripMenuItem.Name = "toCSVBetaToolStripMenuItem";
            this.toCSVBetaToolStripMenuItem.Size = new Size(0x71, 0x16);
            this.toCSVBetaToolStripMenuItem.Text = "To CSV";
            this.toCSVBetaToolStripMenuItem.ToolTipText = "This exports your file to CVS";
            this.toCSVBetaToolStripMenuItem.Click += new EventHandler(this.toCSVBetaToolStripMenuItem_Click);
            this.toolStripSeparator3.Name = "toolStripSeparator3";
            this.toolStripSeparator3.Size = new Size(0xb0, 6);
            this.headerInfoToolStripMenuItem.Name = "headerInfoToolStripMenuItem";
            this.headerInfoToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.H;
            this.headerInfoToolStripMenuItem.Size = new Size(0xb3, 0x16);
            this.headerInfoToolStripMenuItem.Text = "Header Info";
            this.headerInfoToolStripMenuItem.Click += new EventHandler(this.headerInfoToolStripMenuItem_Click);
            this.searchToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { this.searchToolStripMenuItem1, this.findModernToolStripMenuItem, this.replaceToolStripMenuItem, this.goToToolStripMenuItem });
            this.searchToolStripMenuItem.Name = "searchToolStripMenuItem";
            this.searchToolStripMenuItem.Size = new Size(0x36, 20);
            this.searchToolStripMenuItem.Text = "Search";
            this.searchToolStripMenuItem1.Name = "searchToolStripMenuItem1";
            this.searchToolStripMenuItem1.ShortcutKeyDisplayString = "";
            this.searchToolStripMenuItem1.ShortcutKeys = Keys.Control | Keys.F;
            this.searchToolStripMenuItem1.Size = new Size(0xac, 0x16);
            this.searchToolStripMenuItem1.Text = "Find";
            this.searchToolStripMenuItem1.Click += new EventHandler(this.findOldToolStripMenuItem_Click);
            this.replaceToolStripMenuItem.Name = "replaceToolStripMenuItem";
            this.replaceToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.R;
            this.replaceToolStripMenuItem.Size = new Size(0xac, 0x16);
            this.replaceToolStripMenuItem.Text = "Replace";
            this.replaceToolStripMenuItem.Click += new EventHandler(this.replaceToolStripMenuItem_Click);
            this.goToToolStripMenuItem.Name = "goToToolStripMenuItem";
            this.goToToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.G;
            this.goToToolStripMenuItem.Size = new Size(0xac, 0x16);
            this.goToToolStripMenuItem.Text = "Go To";
            this.goToToolStripMenuItem.Click += new EventHandler(this.goToToolStripMenuItem_Click);
            this.columnToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { this.createToolStripMenuItem, this.renameToolStripMenuItem, this.deleteToolStripMenuItem, this.resetColumnSortToolStripMenuItem, this.toolStripSeparator4, this.columnBulkEditToolStripMenuItem, this.columnBulkMultiplyToolStripMenuItem, this.columnDivideToolStripMenuItem });
            this.columnToolStripMenuItem.Name = "columnToolStripMenuItem";
            this.columnToolStripMenuItem.Size = new Size(0x3e, 20);
            this.columnToolStripMenuItem.Text = "Column";
            this.createToolStripMenuItem.Name = "createToolStripMenuItem";
            this.createToolStripMenuItem.Size = new Size(0xa6, 0x16);
            this.createToolStripMenuItem.Text = "Create";
            this.createToolStripMenuItem.Click += new EventHandler(this.createToolStripMenuItem_Click);
            this.renameToolStripMenuItem.Name = "renameToolStripMenuItem";
            this.renameToolStripMenuItem.Size = new Size(0xa6, 0x16);
            this.renameToolStripMenuItem.Text = "Rename";
            this.renameToolStripMenuItem.Click += new EventHandler(this.renameToolStripMenuItem_Click);
            this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
            this.deleteToolStripMenuItem.Size = new Size(0xa6, 0x16);
            this.deleteToolStripMenuItem.Text = "Delete";
            this.deleteToolStripMenuItem.Click += new EventHandler(this.deleteToolStripMenuItem_Click);
            this.toolStripSeparator4.Name = "toolStripSeparator4";
            this.toolStripSeparator4.Size = new Size(0xa3, 6);
            this.columnBulkEditToolStripMenuItem.Name = "columnBulkEditToolStripMenuItem";
            this.columnBulkEditToolStripMenuItem.Size = new Size(0xa6, 0x16);
            this.columnBulkEditToolStripMenuItem.Text = "Column Bulk Edit";
            this.columnBulkEditToolStripMenuItem.Click += new EventHandler(this.columnMultiplierToolStripMenuItem_Click);
            this.columnBulkMultiplyToolStripMenuItem.Name = "columnBulkMultiplyToolStripMenuItem";
            this.columnBulkMultiplyToolStripMenuItem.Size = new Size(0xa6, 0x16);
            this.columnBulkMultiplyToolStripMenuItem.Text = "Column Multiply";
            this.columnBulkMultiplyToolStripMenuItem.Click += new EventHandler(this.columnBulkMultiplyToolStripMenuItem_Click);
            this.columnDivideToolStripMenuItem.Name = "columnDivideToolStripMenuItem";
            this.columnDivideToolStripMenuItem.Size = new Size(0xa6, 0x16);
            this.columnDivideToolStripMenuItem.Text = "Column Divide";
            this.columnDivideToolStripMenuItem.Click += new EventHandler(this.columnDivideToolStripMenuItem_Click);
            this.rowToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { this.createToolStripMenuItem1, this.deleteToolStripMenuItem1, this.toolStripSeparator5, this.rowSyncToolStripMenuItem, this.rowFilterToolStripMenuItem, this.rowReplaceToolStripMenuItem });
            this.rowToolStripMenuItem.Name = "rowToolStripMenuItem";
            this.rowToolStripMenuItem.Size = new Size(0x2a, 20);
            this.rowToolStripMenuItem.Text = "Row";
            this.createToolStripMenuItem1.Name = "createToolStripMenuItem1";
            this.createToolStripMenuItem1.Size = new Size(0x8d, 0x16);
            this.createToolStripMenuItem1.Text = "Create";
            this.createToolStripMenuItem1.Click += new EventHandler(this.createToolStripMenuItem1_Click);
            this.deleteToolStripMenuItem1.Name = "deleteToolStripMenuItem1";
            this.deleteToolStripMenuItem1.ShortcutKeyDisplayString = "";
            this.deleteToolStripMenuItem1.Size = new Size(0x8d, 0x16);
            this.deleteToolStripMenuItem1.Tag = "";
            this.deleteToolStripMenuItem1.Text = "Delete";
            this.deleteToolStripMenuItem1.Click += new EventHandler(this.deleteRowsToolStripMenuItem_Click);
            this.toolStripSeparator5.Name = "toolStripSeparator5";
            this.toolStripSeparator5.Size = new Size(0x8a, 6);
            this.rowSyncToolStripMenuItem.Name = "rowSyncToolStripMenuItem";
            this.rowSyncToolStripMenuItem.Size = new Size(0x8d, 0x16);
            this.rowSyncToolStripMenuItem.Text = "Row Tally";
            this.rowSyncToolStripMenuItem.Click += new EventHandler(this.rowRecountToolStripMenuItem_Click);
            this.rowFilterToolStripMenuItem.Name = "rowFilterToolStripMenuItem";
            this.rowFilterToolStripMenuItem.Size = new Size(0x8d, 0x16);
            this.rowFilterToolStripMenuItem.Text = "Row Filter";
            this.rowFilterToolStripMenuItem.Click += new EventHandler(this.specOutputToolStripMenuItem_Click);
            this.rowReplaceToolStripMenuItem.Name = "rowReplaceToolStripMenuItem";
            this.rowReplaceToolStripMenuItem.Size = new Size(0x8d, 0x16);
            this.rowReplaceToolStripMenuItem.Text = "Row Replace";
            this.rowReplaceToolStripMenuItem.Click += new EventHandler(this.columnAutosetToolStripMenuItem_Click);
            this.toolsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { this.shopCreatorToolStripMenuItem, this.itemEditorToolStripMenuItem, this.translatorToolStripMenuItem, this.oDTEditorToolStripMenuItem, this.toolStripSeparator6, this.expRateEditorToolStripMenuItem, this.debugToolStripMenuItem, this.transToolStripMenuItem });
            this.toolsToolStripMenuItem.Name = "toolsToolStripMenuItem";
            this.toolsToolStripMenuItem.Size = new Size(0x30, 20);
            this.toolsToolStripMenuItem.Text = "Tools";
            this.shopCreatorToolStripMenuItem.Name = "shopCreatorToolStripMenuItem";
            this.shopCreatorToolStripMenuItem.Size = new Size(0x9b, 0x16);
            this.shopCreatorToolStripMenuItem.Text = "Shop Creator";
            this.shopCreatorToolStripMenuItem.Click += new EventHandler(this.shopCreatorToolStripMenuItem_Click);
            this.itemEditorToolStripMenuItem.Name = "itemEditorToolStripMenuItem";
            this.itemEditorToolStripMenuItem.Size = new Size(0x9b, 0x16);
            this.itemEditorToolStripMenuItem.Text = "Item Editor";
            this.itemEditorToolStripMenuItem.Click += new EventHandler(this.itemEditorToolStripMenuItem_Click);
            this.translatorToolStripMenuItem.Name = "translatorToolStripMenuItem";
            this.translatorToolStripMenuItem.Size = new Size(0x9b, 0x16);
            this.translatorToolStripMenuItem.Text = "Translator";
            this.translatorToolStripMenuItem.ToolTipText = "Translate columns using other version files.";
            this.translatorToolStripMenuItem.Click += new EventHandler(this.translatorToolStripMenuItem_Click);
            this.oDTEditorToolStripMenuItem.Name = "oDTEditorToolStripMenuItem";
            this.oDTEditorToolStripMenuItem.Size = new Size(0x9b, 0x16);
            this.oDTEditorToolStripMenuItem.Text = "ODT Editor";
            this.oDTEditorToolStripMenuItem.ToolTipText = "Edit OPTool setting files";
            this.oDTEditorToolStripMenuItem.Click += new EventHandler(this.oDTEditorToolStripMenuItem_Click);
            this.toolStripSeparator6.Name = "toolStripSeparator6";
            this.toolStripSeparator6.Size = new Size(0x98, 6);
            this.toolStripSeparator6.Visible = false;
            this.expRateEditorToolStripMenuItem.Name = "expRateEditorToolStripMenuItem";
            this.expRateEditorToolStripMenuItem.Size = new Size(0x9b, 0x16);
            this.expRateEditorToolStripMenuItem.Text = "Exp Rate Editor";
            this.expRateEditorToolStripMenuItem.ToolTipText = "Edit EXP rate on MobInfoServer.shn";
            this.expRateEditorToolStripMenuItem.Visible = false;
            this.expRateEditorToolStripMenuItem.Click += new EventHandler(this.expRateEditorToolStripMenuItem_Click);
            this.debugToolStripMenuItem.Name = "debugToolStripMenuItem";
            this.debugToolStripMenuItem.Size = new Size(0x9b, 0x16);
            this.debugToolStripMenuItem.Text = "GM List Output";
            this.debugToolStripMenuItem.ToolTipText = "Create an easy to read output";
            this.debugToolStripMenuItem.Visible = false;
            this.debugToolStripMenuItem.Click += new EventHandler(this.debugToolStripMenuItem_Click);
            this.transToolStripMenuItem.Name = "transToolStripMenuItem";
            this.transToolStripMenuItem.Size = new Size(0x9b, 0x16);
            this.transToolStripMenuItem.Text = "TransByList";
            this.transToolStripMenuItem.Visible = false;
            this.transToolStripMenuItem.Click += new EventHandler(this.transToolStripMenuItem_Click);
            this.optionsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { this.encodingToolStripMenuItem, this.sQLPanelToolStripMenuItem, this.fileTreeToolStripMenuItem, this.fileAssociationToolStripMenuItem });
            this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
            this.optionsToolStripMenuItem.Size = new Size(0x3d, 20);
            this.optionsToolStripMenuItem.Text = "Options";
            this.encodingToolStripMenuItem.Name = "encodingToolStripMenuItem";
            this.encodingToolStripMenuItem.Size = new Size(0x9c, 0x16);
            this.encodingToolStripMenuItem.Text = "Encoding";
            this.encodingToolStripMenuItem.Click += new EventHandler(this.encodingToolStripMenuItem_Click);
            this.sQLPanelToolStripMenuItem.CheckOnClick = true;
            this.sQLPanelToolStripMenuItem.Name = "sQLPanelToolStripMenuItem";
            this.sQLPanelToolStripMenuItem.Size = new Size(0x9c, 0x16);
            this.sQLPanelToolStripMenuItem.Text = "SQL Panel";
            this.sQLPanelToolStripMenuItem.Click += new EventHandler(this.showHideMySQLToolStripMenuItem_Click);
            this.fileTreeToolStripMenuItem.CheckOnClick = true;
            this.fileTreeToolStripMenuItem.Name = "fileTreeToolStripMenuItem";
            this.fileTreeToolStripMenuItem.Size = new Size(0x9c, 0x16);
            this.fileTreeToolStripMenuItem.Text = "File Tree Panel";
            this.fileTreeToolStripMenuItem.Click += new EventHandler(this.fileTreeToolStripMenuItem_Click);
            this.fileAssociationToolStripMenuItem.CheckOnClick = true;
            this.fileAssociationToolStripMenuItem.Name = "fileAssociationToolStripMenuItem";
            this.fileAssociationToolStripMenuItem.Size = new Size(0x9c, 0x16);
            this.fileAssociationToolStripMenuItem.Text = "File Association";
            this.fileAssociationToolStripMenuItem.Click += new EventHandler(this.removeFileAsoToolStripMenuItem_Click);
            this.aboutToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { this.updatesToolStripMenuItem, this.creditsToolStripMenuItem });
            this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
            this.aboutToolStripMenuItem.Size = new Size(0x2c, 20);
            this.aboutToolStripMenuItem.Text = "Help";
            this.updatesToolStripMenuItem.Name = "updatesToolStripMenuItem";
            this.updatesToolStripMenuItem.Size = new Size(0x75, 0x16);
            this.updatesToolStripMenuItem.Text = "Updates";
            this.updatesToolStripMenuItem.Click += new EventHandler(this.updatesToolStripMenuItem_Click);
            this.creditsToolStripMenuItem.Name = "creditsToolStripMenuItem";
            this.creditsToolStripMenuItem.Size = new Size(0x75, 0x16);
            this.creditsToolStripMenuItem.Text = "About";
            this.creditsToolStripMenuItem.Click += new EventHandler(this.creditsToolStripMenuItem_Click);
            this.groupMysql.Controls.Add(this.chkDrop);
            this.groupMysql.Controls.Add(this.button2);
            this.groupMysql.Controls.Add(this.button1);
            this.groupMysql.Controls.Add(this.SQLScript);
            this.groupMysql.Dock = DockStyle.Right;
            this.groupMysql.Location = new Point(0x317, 0x18);
            this.groupMysql.Name = "groupMysql";
            this.groupMysql.Size = new Size(0x11c, 0x22d);
            this.groupMysql.TabIndex = 4;
            this.groupMysql.TabStop = false;
            this.groupMysql.Text = "SQL Panel";
            this.chkDrop.AutoSize = true;
            this.chkDrop.Checked = true;
            this.chkDrop.CheckState = CheckState.Checked;
            this.chkDrop.Location = new Point(6, 0x217);
            this.chkDrop.Name = "chkDrop";
            this.chkDrop.Size = new Size(0x4b, 0x11);
            this.chkDrop.TabIndex = 6;
            this.chkDrop.Text = "Drop table";
            this.chkDrop.UseVisualStyleBackColor = true;
            this.button2.Location = new Point(0x8e, 0x1ec);
            this.button2.Name = "button2";
            this.button2.Size = new Size(0x86, 0x25);
            this.button2.TabIndex = 5;
            this.button2.Text = "Save SQL File";
            this.button2.UseVisualStyleBackColor = true;
            this.button2.Click += new EventHandler(this.button2_Click);
            this.button2.KeyDown += new KeyEventHandler(this.FileTabs_KeyDown);
            this.button1.Location = new Point(6, 0x1ec);
            this.button1.Name = "button1";
            this.button1.Size = new Size(0x86, 0x25);
            this.button1.TabIndex = 4;
            this.button1.Text = "Create SQL Queries";
            this.button1.UseVisualStyleBackColor = true;
            this.button1.Click += new EventHandler(this.button1_Click);
            this.button1.KeyDown += new KeyEventHandler(this.FileTabs_KeyDown);
            this.SQLScript.Location = new Point(6, 0x13);
            this.SQLScript.Multiline = true;
            this.SQLScript.Name = "SQLScript";
            this.SQLScript.ScrollBars = ScrollBars.Both;
            this.SQLScript.Size = new Size(0x110, 0x1d3);
            this.SQLScript.TabIndex = 3;
            this.SQLScript.KeyDown += new KeyEventHandler(this.FileTabs_KeyDown);
            this.statusStrip1.Items.AddRange(new ToolStripItem[] { this.SQLStatus });
            this.statusStrip1.Location = new Point(0, 0x22f);
            this.statusStrip1.Name = "statusStrip1";
            this.statusStrip1.Size = new Size(0x317, 0x16);
            this.statusStrip1.TabIndex = 8;
            this.statusStrip1.Text = "statusStrip1";
            this.SQLStatus.Name = "SQLStatus";
            this.SQLStatus.Size = new Size(0x2a, 0x11);
            this.SQLStatus.Text = "Ready.";
            this.FileTabs.AllowDrop = true;
            this.FileTabs.Dock = DockStyle.Fill;
            this.FileTabs.Location = new Point(200, 0x18);
            this.FileTabs.Name = "FileTabs";
            this.FileTabs.SelectedIndex = 0;
            this.FileTabs.Size = new Size(0x24f, 0x217);
            this.FileTabs.TabIndex = 10;
            this.FileTabs.DragDrop += new DragEventHandler(this.FileTabs_DragDrop);
            this.FileTabs.DragEnter += new DragEventHandler(this.FileTabs_DragEnter);
            this.FileTabs.KeyDown += new KeyEventHandler(this.FileTabs_KeyDown);
            this.treeView1.Dock = DockStyle.Fill;
            this.treeView1.Location = new Point(3, 0x10);
            this.treeView1.Name = "treeView1";
            node.Name = "Node1";
            node.Text = "Node1";
            node2.Name = "Node2";
            node2.Text = "Node2";
            node3.Name = "Node0";
            node3.Text = "Node0";
            this.treeView1.Nodes.AddRange(new TreeNode[] { node3 });
            this.treeView1.Size = new Size(0xc2, 0x204);
            this.treeView1.TabIndex = 0;
            this.resetColumnSortToolStripMenuItem.Name = "resetColumnSortToolStripMenuItem";
            this.resetColumnSortToolStripMenuItem.Size = new Size(0xa6, 0x16);
            this.resetColumnSortToolStripMenuItem.Text = "Reset Sort";
            this.resetColumnSortToolStripMenuItem.Click += new EventHandler(this.resetColumnSortToolStripMenuItem_Click);
            this.groupTree.Controls.Add(this.treeView1);
            this.groupTree.Dock = DockStyle.Left;
            this.groupTree.Location = new Point(0, 0x18);
            this.groupTree.Name = "groupTree";
            this.groupTree.Size = new Size(200, 0x217);
            this.groupTree.TabIndex = 11;
            this.groupTree.TabStop = false;
            this.groupTree.Text = "File Tree";
            this.findModernToolStripMenuItem.Name = "findModernToolStripMenuItem";
            this.findModernToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.Shift | Keys.F;
            this.findModernToolStripMenuItem.Size = new Size(0xac, 0x16);
            this.findModernToolStripMenuItem.Text = "Filter";
            this.findModernToolStripMenuItem.Click += new EventHandler(this.filterToolStripMenuItem_Click);
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x433, 0x245);
            base.Controls.Add(this.FileTabs);
            base.Controls.Add(this.groupTree);
            base.Controls.Add(this.statusStrip1);
            base.Controls.Add(this.groupMysql);
            base.Controls.Add(this.menuStrip1);
            this.DoubleBuffered = true;
            base.Icon = (Icon) manager.GetObject("$this.Icon");
            base.MainMenuStrip = this.menuStrip1;
            this.MinimumSize = new Size(200, 200);
            base.Name = "frmMain";
            base.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "SHN Editor";
            base.FormClosing += new FormClosingEventHandler(this.frmMain_FormClosing);
            base.Load += new EventHandler(this.frmMain_Load);
            base.KeyDown += new KeyEventHandler(this.FileTabs_KeyDown);
            this.menuStrip1.ResumeLayout(false);
            this.menuStrip1.PerformLayout();
            this.groupMysql.ResumeLayout(false);
            this.groupMysql.PerformLayout();
            this.statusStrip1.ResumeLayout(false);
            this.statusStrip1.PerformLayout();
            this.groupTree.ResumeLayout(false);
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        private void itemEditorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                if (this.FileTabs.SelectedTab.Text.ToString() != "ItemInfo.shn")
                {
                    MessageBox.Show("Please open ItemInfo.shn first.");
                }
                else
                {
                    new ItemEditor(this).ShowDialog();
                }
            }
        }

        private void myOwnRecentFileGotClicked_handler(object obj, EventArgs evt)
        {
            string text = (obj as ToolStripItem).Text;
            if (!File.Exists(text))
            {
                if (MessageBox.Show($"{text} doesn't exist. Remove item?", "File not found", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    this.mruManager.RemoveRecentFile(text);
                }
            }
            else
            {
                this.InitFile(text, false);
            }
        }

        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.InitFile("New File.shn", true);
        }

        private void oDTEditorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            new OPToolEditor(this, new byte[1], ".dat").ShowDialog();
        }

        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog {
                Filter = "SHN File (*.shn)|*.shn|OTD File (*.otd)|*.otd|Other File(*.*)|*.*",
                Title = "Select File"
            };
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                this.InitFile(dialog.FileName, false);
            }
        }

        private void removeFileAsoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (!this.fileAssociationToolStripMenuItem.Checked)
                {
                    FileAssociation.AssociationDeletion(".shn", "SHN Tool");
                    this.SQLStatus.Text = "File Association Deleted!";
                }
                else
                {
                    this.CreateAssociation();
                    this.SQLStatus.Text = "File Association Created!";
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("An error occured: " + exception.Message);
            }
        }

        private void renameToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                columnRename rename = new columnRename(this);
                rename.init();
                rename.ShowDialog();
            }
        }

        private void replaceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                new searchReplace(this).Show();
            }
        }

        private void resetColumnSortToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ((DataTable) this.dataGrid.DataSource).DefaultView.Sort = string.Empty;
        }

        private void rowRecountToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                new rowTally(this).ShowDialog();
            }
        }

        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                SaveFileDialog dialog = new SaveFileDialog {
                    Filter = "SHN File (*.shn)|*.shn"
                };
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    this.SaveTo(dialog.FileName);
                }
            }
        }

        private void SaveTo(string FileName)
        {
            for (int i = 0; i < this.dataGrid.Columns.Count; i++)
            {
                this.file.displayToReal.Add(this.dataGrid.Columns[i].DisplayIndex, i);
            }
            bool flag = this.file.Save(FileName);
            this.file.displayToReal.Clear();
            if (!flag)
            {
                this.SQLStatus.Text = "Could not save file.";
            }
            else
            {
                this.SQLStatus.Text = "File saved!";
            }
            this.file.displayToReal.Clear();
        }

        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                this.SaveTo(this.file.Path);
            }
        }

        private void searchToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                new searchFind(this) { Text = "Find: " + this.FileTabs.SelectedTab.Text }.ShowDialog();
            }
        }

        private void setRegistryInfo()
        {
            try
            {
                Program.eT = Registry.CurrentUser.OpenSubKey(@"Software\" + Program.assemblyName + @"\Encoding").GetValue("0").ToString();
            }
            catch (NullReferenceException)
            {
                Program.rK.SetValue("0", "ISO-8859-1");
                Program.eT = Registry.CurrentUser.OpenSubKey(@"Software\" + Program.assemblyName + @"\Encoding").GetValue("0").ToString();
            }
            catch (Exception exception)
            {
                MessageBox.Show("An error occurred trying to get encoding type: " + exception.Message);
            }
        }

        private void shopCreatorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            new createShop(this).ShowDialog();
        }

        private void showHideMySQLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.groupMysql.Visible)
            {
                this.groupMysql.Visible = false;
            }
            else
            {
                this.groupMysql.Visible = true;
            }
        }

        private void specOutputToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                new rowFilter(this).ShowDialog();
            }
        }

        private void toCSVBetaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                SaveFileDialog dialog = new SaveFileDialog {
                    Title = "Export to CSV",
                    Filter = "Comma Separated File (*.csv)|*.csv"
                };
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    this.file.exportCVS(dialog.FileName);
                    this.SQLStatus.Text = "File saved!";
                }
            }
        }

        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                try
                {
                    if (this.dataGrid.Rows[this.dataGrid.NewRowIndex].Selected)
                    {
                        this.dataGrid.Rows[this.dataGrid.NewRowIndex].Selected = false;
                        this.dataGrid.CurrentCell = this.dataGrid.Rows[this.dataGrid.NewRowIndex - 1].Cells[0];
                        this.dataGrid.Rows[this.dataGrid.NewRowIndex - 1].Selected = true;
                    }
                    this.dataGrid.CurrentCell = this.dataGrid.Rows[this.dataGrid.NewRowIndex - 1].Cells[0];
                    this.dataGrid.Rows[this.dataGrid.NewRowIndex].Selected = false;
                }
                catch (Exception)
                {
                }
                bool flag = false;
                if (Clipboard.ContainsData("Bytes"))
                {
                    byte[] data = (byte[]) Clipboard.GetData("Bytes");
                    BinaryReader reader = new BinaryReader(new MemoryStream(data));
                    int num = reader.ReadInt32();
                    for (int i = 0; i < num; i++)
                    {
                        int num3 = reader.ReadInt32();
                        Dictionary<string, string> dictionary = new Dictionary<string, string>();
                        for (int j = 0; j < num3; j++)
                        {
                            string key = reader.ReadString();
                            string str2 = reader.ReadString();
                            dictionary.Add(key, str2);
                        }
                        if (reader.ReadByte() != 0)
                        {
                            return;
                        }
                        DataRow row = this.file.table.NewRow();
                        for (int k = 0; k < this.file.table.Columns.Count; k++)
                        {
                            string columnName = this.file.table.Columns[k].ColumnName;
                            try
                            {
                                if ((dictionary[columnName].Length > 0) && dictionary.ContainsKey(columnName))
                                {
                                    row[k] = dictionary[columnName];
                                }
                            }
                            catch (Exception exception)
                            {
                                if (!flag)
                                {
                                    MessageBox.Show("Program encountered an error while trying to import data: " + exception.Message);
                                    this.SQLStatus.Text = exception.Message;
                                    flag = true;
                                }
                            }
                        }
                        this.file.table.Rows.Add(row);
                    }
                    reader.Close();
                    if (this.file.table.DefaultView.Sort == string.Empty)
                    {
                        this.dataGrid.CurrentCell = this.dataGrid.Rows[this.dataGrid.NewRowIndex - 1].Cells[0];
                        this.dataGrid.Rows[this.dataGrid.NewRowIndex - 1].Selected = true;
                    }
                    this.SQLStatus.Text = "Imported " + num.ToString() + " rows.";
                }
                else
                {
                    this.SQLStatus.Text = "Clipboard has wrong type of data.";
                }
                flag = false;
            }
        }

        private void toSHRToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                SaveFileDialog dialog = new SaveFileDialog {
                    Filter = "SHN Row File (*.shr)|*.shr",
                    Title = "Save to SHR"
                };
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    FileStream stream = new FileStream(dialog.FileName, FileMode.Create);
                    GZipStream output = new GZipStream(stream, CompressionMode.Compress);
                    BinaryWriter writer = new BinaryWriter(output);
                    new DataTable();
                    this.file.table.Clone();
                    writer.Write(this.dataGrid.SelectedRows.Count);
                    foreach (DataGridViewRow row in this.dataGrid.SelectedRows)
                    {
                        object[] itemArray = (row.DataBoundItem as DataRowView).Row.ItemArray;
                        writer.Write(itemArray.Length);
                        for (int i = 0; i < itemArray.Length; i++)
                        {
                            writer.Write(this.file.table.Columns[i].ColumnName);
                            writer.Write(itemArray[i].ToString());
                        }
                        writer.Write((byte) 0);
                    }
                    output.Close();
                    stream.Close();
                    this.SQLStatus.Text = "Rows exported successfully!";
                }
            }
        }

        private void translatorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.FileTabs.TabPages.Count >= 1)
            {
                new Translator(this).ShowDialog();
            }
        }

        private void transToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Option disabled by creator");
        }

        private void updatesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            new helpUpdates(this).ShowDialog();
        }

        public DataGridView dataGrid
        {
            get
            {
                try
                {
                    return (DataGridView) this.FileTabs.SelectedTab.Tag;
                }
                catch
                {
                    return null;
                }
            }
            set
            {
                this.FileTabs.SelectedTab.Tag = value;
            }
        }

        public SHNFile file
        {
            get
            {
                try
                {
                    return (SHNFile) this.dataGrid.Tag;
                }
                catch
                {
                    return null;
                }
            }
            set
            {
                try
                {
                    this.dataGrid.Tag = value;
                }
                catch
                {
                }
            }
        }

        public TabControl FileTab =>
            this.FileTabs
    }
}

