Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (!add)
            {
                add    = true;
                delete = false;
                load   = false;

                MTitleField.Enabled = true;
                FTitleField.Enabled = true;
                EntryField.Enabled  = false;

                return;
            }

            string fTitle   = FTitleField.Text;
            string mTitle   = MTitleField.Text;
            string titleRow = DBCUtil.formatEntry(fTitle, mTitle);

            DBCUtil.addTitle(titleRow);
            DBCUtil.csvToDbc();

            if (titleList != null)
            {
                titleList.addOption(DBCUtil.formatDBCRow(titleRow));
            }

            updateAddStatus();
            load = false;
        }
Example #2
0
        private void DeleteTitle_Click(object sender, EventArgs e)
        {
            if (!delete && !load)
            {
                delete = true;
                add    = false;
                MTitleField.Enabled = false;
                FTitleField.Enabled = false;
                EntryField.Enabled  = true;
                return;
            }

            string data = getLine();

            if (data == null)
            {
                return;
            }

            string        tempFile    = Path.GetTempFileName();
            List <string> linesToKeep = File.ReadLines("CharTitles.dbc.csv").Where(line => line != data).ToList();

            File.WriteAllLines(tempFile, linesToKeep);
            File.Delete("CharTitles.dbc.csv");
            File.Move(tempFile, "CharTitles.dbc.csv");

            DBCUtil.csvToDbc();

            if (titleList != null)
            {
                titleList.removeOption(DBCUtil.formatDBCRow(data));
            }

            updateDeleteStatus();
        }