示例#1
0
        private void renameEntryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_activeClient == null || entryListView.SelectedItems.Count < 1)
                return;
            var entry = entryListView.SelectedItems[0].Tag as ClientEntry;
            if (entry == null)
                return;

            using (var aed = new AddEntryDialog(entry))
            {
                if (aed.ShowDialog() == DialogResult.OK)
                {
                    entry.Name = aed.ClientEntry.Name;  //just copy over the name
                    this.CurrentDatabase.CommitEntryChanges(new[] { entry });
                }
            }
        }
示例#2
0
        private void addEntryButton_Click(object sender, EventArgs e)
        {
            this.CurrentDatabase.RefreshTemplates();

            using (AddEntryDialog aed = new AddEntryDialog(this.CurrentDatabase.Templates))
            {
                if (aed.ShowDialog() == DialogResult.OK)
                {
                    _activeClient.AddEntry(aed.ClientEntry);
                    this.CurrentDatabase.CommitClient(_activeClient);

                    //find the listview item and select it immediately
                    var item = entryListView.Items
                        .Cast<ListViewItem>()
                        .FirstOrDefault(lvi => lvi.Tag == aed.ClientEntry);

                    if (!_editMode)
                        BeginEditMode();

                    if (item != null)
                    {
                        entryListView.SelectedItems.Clear();
                        item.Selected = true;
                        item.EnsureVisible();

                        if (fieldsDataGridView.Rows.Count > 0)
                        {
                            fieldsDataGridView.CurrentCell = fieldsDataGridView[1, 0];
                            fieldsDataGridView.BeginEdit(true);
                        }
                    }
                }
            }
        }