Beispiel #1
0
        private void btnEditField_Click(object sender, EventArgs e)
        {
            if (stringTable.SelectedItems.Count == 0)
            {
                MessageBox.Show("You must select a field to edit", "Nope", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            ListViewItem lvi = stringTable.SelectedItems[0];

            KeyValuePair <string, string> res = AddEditDialog.EditExistingPair(new KeyValuePair <string, string>(lvi.SubItems[0].Text, lvi.SubItems[1].Text));

            if (cPack.Table.ContainsKey(res.Key) && lvi.SubItems[0].Text != res.Key)
            {
                MessageBox.Show("You cannot rename to an existing field", "Nope", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else if (lvi.SubItems[0].Text != res.Key)
            {
                stringTable.Items[lvi.Index].SubItems[0].Text = res.Key;
                stringTable.Items[lvi.Index].SubItems[1].Text = res.Value;
                cPack.Table.Remove(lvi.SubItems[0].Text);
                cPack.Table.Add(res.Key, res.Value);
            }
            else
            {
                stringTable.Items[lvi.Index].SubItems[0].Text = res.Key;
                stringTable.Items[lvi.Index].SubItems[1].Text = res.Value;
                cPack.Table[res.Key] = res.Value;
            }
            packChanges = true;
        }
Beispiel #2
0
        public static KeyValuePair <String, String> AddPair()
        {
            AddEditDialog aed = new AddEditDialog();

            if (aed.ShowDialog() == DialogResult.Cancel)
            {
                return(new KeyValuePair <string, string>("", ""));
            }

            return(new KeyValuePair <string, string>(aed.txtName.Text, aed.txtTrans.Text));
        }
Beispiel #3
0
        public static KeyValuePair <String, String> EditExistingPair(KeyValuePair <String, String> cur)
        {
            AddEditDialog aed = new AddEditDialog();

            aed.txtName.Text  = cur.Key;
            aed.txtTrans.Text = cur.Value;

            if (aed.ShowDialog() == DialogResult.Cancel)
            {
                return(cur);
            }

            return(new KeyValuePair <string, string>(aed.txtName.Text, aed.txtTrans.Text));
        }
Beispiel #4
0
        private void btnAddField_Click(object sender, EventArgs e)
        {
            KeyValuePair <string, string> res = AddEditDialog.AddPair();

            if (res.Key == "" && res.Value == "")
            {
                return;
            }

            if (cPack.Table.ContainsKey(res.Key.ToLower()))
            {
                MessageBox.Show("A translation already exists with that name!", "Duplicate Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            cPack.Table.Add(res.Key.ToLower(), res.Value);

            stringTable.Items.Add(new ListViewItem(new string[] { res.Key.ToLower(), res.Value }));
            packChanges = true;
        }