Ejemplo n.º 1
0
 private void ActiveEntry_CustomFieldAdded(object sender, EntryFieldEventArgs e)
 {
     //create the entryfieldrow and add to view
     var cache = GetCurrentCachedEntryFieldRows();
     var row = new EntryFieldRow(_activeEntry, e.EntryField);
     cache.Add(e.EntryField, row);
     cache.ForceCommit = true;
     _activeFields.Add(row);
 }
Ejemplo n.º 2
0
        private void DisplaySelectedEntry()
        {
            if (_activeEntry != null)
            {
                _activeEntry.CustomFieldAdded -= ActiveEntry_CustomFieldAdded;
                _activeEntry.CustomFieldRemoved -= ActiveEntry_CustomFieldRemoved;
            }

            _activeFields.Clear();

            if (entryListView.SelectedItems.Count > 0)
            {
                _activeEntry = entryListView.SelectedItems[0].Tag as ClientEntry;

                _activeEntry.CustomFieldAdded += new EventHandler<EntryFieldEventArgs>(ActiveEntry_CustomFieldAdded);
                _activeEntry.CustomFieldRemoved += new EventHandler<EntryFieldEventArgs>(ActiveEntry_CustomFieldRemoved);

                entryGroupBox.Text = _activeEntry.Template == null ? _activeEntry.Name : String.Format("{0} ({1})", _activeEntry.Name, _activeEntry.Template.Name);

                EntryNotes notes;
                if (!_entryNotes.TryGetValue(_activeEntry, out notes))
                {
                    notes = new EntryNotes() { Notes = _activeEntry.Notes };
                    _entryNotes.Add(_activeEntry, notes);
                }

                entryNotesBindingSource.DataSource = notes;
                notesTextBox.Enabled = true;

                addCustomFieldLink.Enabled = _activeEntry.Template == null || _activeEntry.Template.AllowCustomFields;
                removeCustomFieldLink.Enabled = _activeEntry.Template == null || _activeEntry.Template.AllowCustomFields;

                //display fields by creating temporary Row objects, which last as long as the client stays selected
                //this allows the user to jump from entry to entry within a client without losing changes
                Dictionary<EntryField, EntryFieldRow> rowCache = GetCurrentCachedEntryFieldRows();

                foreach (var f in _activeEntry.AllFields)
                {
                    EntryFieldRow row;
                    if (!rowCache.TryGetValue(f, out row))
                    {
                        row = new EntryFieldRow(_activeEntry, f);
                        rowCache.Add(f, row);
                    }

                    _activeFields.Add(row);
                }

                deleteEntryToolStripMenuItem.Enabled = true;
                renameEntryToolStripMenuItem.Enabled = true;

                //record the log entry
                this.CurrentDatabase.AddLogEntry(_activeEntry, UserLogEntryType.Access);
            }
            else
            {
                _activeEntry = null;
                _activeFields.Clear();
                entryGroupBox.Text = "(no entry selected)";
                entryNotesBindingSource.DataSource = typeof(EntryNotes);
                notesTextBox.Enabled = false;
                deleteEntryToolStripMenuItem.Enabled = false;
                renameEntryToolStripMenuItem.Enabled = false;
                addCustomFieldLink.Enabled = false;
                removeCustomFieldLink.Enabled = false;
            }
        }