private void NewToolStripMenuItem_Click(object sender, EventArgs e) { TIDEntryBox.Clear(); PackNameBox.Clear(); TextViewBox.Clear(); AddRuleButton.Enabled = false; SetDefinition.Enabled = true; TIDEntryBox.Enabled = true; PackNameBox.Enabled = true; }
private void OpenRulesToolStripMenuItem_Click(object sender, EventArgs e) { try { OpenFileDialog openFile = new OpenFileDialog() { Filter = "rules.txt|*.txt", Title = "Open GraphicPack rules.txt" }; if (openFile.ShowDialog() == DialogResult.OK) { TextViewBox.Clear(); TIDEntryBox.Clear(); PackNameBox.Clear(); AddRuleButton.Enabled = true; SetDefinition.Enabled = false; TIDEntryBox.Enabled = false; PackNameBox.Enabled = false; StreamReader sr = new StreamReader(openFile.FileName); TextViewBox.Text = sr.ReadToEnd(); string titleIDs = "titleIds"; string packName = "name"; StreamReader sr2 = new StreamReader(openFile.FileName); IList <string> result = new List <string>(); using (var reader = sr2) { string currentLine; while ((currentLine = reader.ReadLine()) != null) { if (currentLine.Contains(titleIDs)) { var input = (currentLine); var output = input.Replace("titleIds = ", ""); TIDEntryBox.Text = (output); } if (currentLine.Contains(packName)) { var input = (currentLine); var output = input.Replace("name = ", ""); string s = output; var finalOutput = s = s.Replace("\"", ""); PackNameBox.Text = (finalOutput); break; } } } sr.Close(); sr2.Close(); } } catch (Exception ex) { MessageBox.Show("Could not open file. Details: \n" + "\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }