private void openToolStripMenuItem_Click(object sender, EventArgs e) { openFileDialog.FilterIndex = 1; openFileDialog.InitialDirectory = Path.GetDirectoryName(filePath); openFileDialog.FileName = Path.GetFileName(filePath).Replace(".xml", ".lng"); if (openFileDialog.ShowDialog() == DialogResult.OK) { // Clean lngDataGridView.DataSource = null; lngDataGridView.Rows.Clear(); lngDataGridView.Columns.Clear(); filePath = openFileDialog.FileName; openFileDialog.Dispose(); Stream s = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read); try { lngFile = new LngFile(s); } catch (Exception ex) { MessageBox.Show("Conversion Failed!" + Environment.NewLine + ex.Message, "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } lngDataGridView.DataSource = lngFile.GetDataTable(); this.Text = "Ego Language Editor - " + filePath; } }
public Form1(string[] args) { InitializeComponent(); this.Icon = Properties.Resources.Ryder25; LNG = new DataSet("language"); fRF = new FindAndReplaceForm(this.lngDataGridView); filePath = openFileDialog.FileName; lngDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; lngDataGridView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCells; lngDataGridView.DefaultCellStyle.WrapMode = DataGridViewTriState.True; lngDataGridView.AllowUserToAddRows = false; lngDataGridView.AlternatingRowsDefaultCellStyle.BackColor = System.Drawing.ColorTranslator.FromHtml("#E8EDFF"); DgvFilterManager dgvfm = new DgvFilterManager(lngDataGridView); // Open With if (args.Length > 0) { if (File.Exists(args[0]) == true) { filePath = args[0]; Stream s = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read); lngFile = new LngFile(s); lngDataGridView.DataSource = lngFile.GetDataTable(); this.Text = "Ego Language Editor - " + filePath; } } }