예제 #1
0
        private void EditSelected()
        {
            if (lvKeys.SelectedItems.Count <= 0 || lvKeys.SelectedItems[0] == null)
            {
                return;
            }

            Key k = m_Keys.FindLast(key => key.FileName.ToLower() == lvKeys.SelectedItems[0].Text.ToLower());

            if (k == null)
            {
                return;
            }

            EditKeyDlg Dlg = new EditKeyDlg();

            Dlg.Title("Edit");
            Dlg.Set(k);

            if (Dlg.ShowDialog() == DialogResult.OK)
            {
                Key res = Dlg.Get();
                int ind = m_Keys.IndexOf(k);
                m_Keys.Remove(k);
                m_Keys.Insert(ind, res);
            }
            ReloadItems();
            KeyDatabase.Save();
        }
예제 #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            EditKeyDlg Dlg = new EditKeyDlg();

            Dlg.Title("Add");
            if (Dlg.ShowDialog() == DialogResult.OK)
            {
                Key k = Dlg.Get();

                if (!m_Keys.Exists(k.FileName))
                {
                    m_Keys.Add(Dlg.Get());
                }
                else
                {
                    MessageBox.Show("A key already exists for this file!", "Error!");
                }

                ReloadItems();

                KeyDatabase.Save();
            }
        }