Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
        private void AddRuleButton_Click(object sender, EventArgs e)
        {
            using (var addRuleForm = new AddRule())
            {
                var result = addRuleForm.ShowDialog();
                if (result == DialogResult.OK)
                {
                    string rule = addRuleForm.ReturnRuleString;

                    TextViewBox.AppendText(Environment.NewLine + rule);
                }
            }
        }
Ejemplo n.º 3
0
        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);
            }
        }