Ejemplo n.º 1
0
        private void buttonFieldAdd_Click(object sender, EventArgs e)
        {
            using (KeeFieldForm kff = new KeeFieldForm(null, null, null, FormFieldType.FFTtext, 1, PlaceholderHandling.Default))
            {
                if (kff.ShowDialog() == DialogResult.OK)
                {
                    FormField ff = new FormField(kff.Name, kff.Name, kff.Value, kff.Type, kff.Id, kff.Page, kff.PlaceholderHandling);

                    string type = Utilities.FormFieldTypeToDisplay(kff.Type, false);
                    int    page = kff.Page;

                    // We know any new passwords are not the main Entry password
                    // Also know that the display name can be same as main name
                    string displayValue = kff.Value;
                    if (kff.Type == FormFieldType.FFTpassword)
                    {
                        displayValue = "********";
                    }
                    if (kff.Type == FormFieldType.FFTcheckbox)
                    {
                        displayValue = kff.Value == "KEEFOX_CHECKED_FLAG_TRUE" ? "Enabled" : "Disabled";
                    }

                    ListViewItem lvi = new ListViewItem(new string[]
                    {
                        kff.Name, displayValue, kff.Id, type, page.ToString()
                    });
                    lvi.Tag = ff;
                    AddFieldListItem(lvi);
                    UpdateFieldStrings();
                }
            }
        }
Ejemplo n.º 2
0
        private void buttonFieldEdit_Click(object sender, EventArgs e)
        {
            ListView.SelectedListViewItemCollection lvsicSel = listView2.SelectedItems;

            FormField tag = (FormField)lvsicSel[0].Tag;

            using (KeeFieldForm kff = FormFieldForEditing(lvsicSel, tag))
            {
                if (kff.ShowDialog() == DialogResult.OK)
                {
                    string displayValue = kff.Value;
                    if (kff.Type == FormFieldType.FFTpassword)
                    {
                        displayValue = "********";
                    }

                    string displayName = kff.Name;
                    if (kff.Value == "{PASSWORD}")
                    {
                        displayName  = "KeePass password";
                        displayValue = "KeePass password";
                    }
                    else if (kff.Value == "{USERNAME}")
                    {
                        displayName  = "KeePass username";
                        displayValue = "KeePass username";
                    }

                    if (kff.Type == FormFieldType.FFTcheckbox)
                    {
                        displayValue = kff.Value == "KEEFOX_CHECKED_FLAG_TRUE" ? "Enabled" : "Disabled";
                    }

                    string type = Utilities.FormFieldTypeToDisplay(kff.Type, false);
                    int    page = kff.Page;

                    ListViewItem lvi = new ListViewItem(new string[] { kff.Name, displayValue, kff.Id, type, page.ToString() });
                    lvi.Tag = new FormField(kff.Name, displayName, kff.Value, kff.Type, kff.Id, page, kff.PlaceholderHandling);
                    RemoveFieldListItem(lvsicSel[0]);
                    AddFieldListItem(lvi);
                    UpdateFieldStrings();
                }
            }
        }