public void DoAddReference() { if (!CurrentDocumentControllerIsReady) { return; } if (addinModule.IsEditReference()) { DoEditReference(); return; } var currentDatabase = currentDocumentController.GetDatabase(); if (currentDatabase == null) { ShowNoDatabaseMessage(); return; } var addReferencesForm = new AddReferencesForm(); addReferencesForm.Reset(currentDatabase); var result = addReferencesForm.ShowDialog(); if (result == DialogResult.Cancel) { addReferencesForm.Dispose(); return; } // Keep a note of these as early as possible after closing dialog var isSequence = (Control.ModifierKeys & Keys.Control) != 0; var isLineSequence = isSequence && (Control.ModifierKeys & Keys.Shift) != 0; var entryAndPagePairs = addReferencesForm.GetSelectedReferences(); if (entryAndPagePairs.Count == 0) { return; } // Did the user change the database? if (addReferencesForm.Database != currentDatabase) { try { // Yes, so store it with the document currentDocumentController.SetDocumentDatabaseFilename(addReferencesForm.Database.Filename); } catch {} } addReferencesForm.Dispose(); currentDocumentController.DoInsertCitation(entryAndPagePairs, isSequence, isLineSequence); }