// Update the Quickpaste XML in the ImageSetTable and refresh the Quickpaste window to reflect the current contents private void QuickPasteRefreshWindowAndXML() { this.DataHandler.FileDatabase.ImageSet.QuickPasteXML = QuickPasteOperations.QuickPasteEntriesToXML(this.quickPasteEntries); this.DataHandler.FileDatabase.UpdateSyncImageSetToDatabase(); if (this.quickPasteWindow != null) { this.quickPasteWindow.Refresh(this.quickPasteEntries); } }
// Create a quickpaste entry from the current data controls, // add it to the quickpaste entries, and update the display and the ImageSetTable database as needed private void QuickPasteEntryNew() { string title = "QuickPaste #" + (this.quickPasteEntries.Count + 1).ToString(); QuickPasteEntry quickPasteEntry = QuickPasteOperations.TryGetQuickPasteItemFromDataFields(this.DataHandler.FileDatabase, this.DataHandler.ImageCache.CurrentRow, title); if (quickPasteEntry == null) { return; } // Make sure the quickPasteWindow is not topmost, as it may otherwise occlude part of the QuickPaste Editor if (this.quickPasteWindow.IsLoaded) { this.quickPasteWindow.Topmost = false; } QuickPasteEditor quickPasteEditor = new QuickPasteEditor(quickPasteEntry, this.DataHandler.FileDatabase, this.DataEntryControls) { Owner = this }; if (quickPasteEditor.ShowDialog() == true) { quickPasteEntry = quickPasteEditor.QuickPasteEntry; if (this.quickPasteEntries == null) { // This shouldn't be necessary, but just in case... this.quickPasteEntries = new List <QuickPasteEntry>(); } this.quickPasteEntries.Add(quickPasteEntry); this.QuickPasteRefreshWindowAndXML(); } // Restore the quickPaste window back to its topmost state if (this.quickPasteWindow.IsLoaded) { this.quickPasteWindow.Topmost = true; } }
/// Import QuickPaste Items from a .ddb file private void MenuItemQuickPasteImportFromDB_Click(object sender, RoutedEventArgs e) { if (Dialogs.TryGetFileFromUserUsingOpenFileDialog("Import QuickPaste entries by selecting the Timelapse database (.ddb) file from the image folder where you had used them.", Path.Combine(this.DataHandler.FileDatabase.FolderPath, Constant.File.DefaultFileDatabaseFileName), String.Format("Database files (*{0})|*{0}", Constant.File.FileDatabaseFileExtension), Constant.File.FileDatabaseFileExtension, out string ddbFile) == true) { List <QuickPasteEntry> qpe = QuickPasteOperations.QuickPasteImportFromDB(this.DataHandler.FileDatabase, ddbFile); if (qpe.Count == 0) { Dialogs.MenuEditCouldNotImportQuickPasteEntriesDialog(this); return; } else { this.quickPasteEntries = qpe; this.DataHandler.FileDatabase.UpdateSyncImageSetToDatabase(); this.QuickPasteRefreshWindowAndXML(); this.QuickPasteWindowShow(); } } }
/// <summary> /// When folder loading has completed add callbacks, prepare the UI, set up the image set, and show the image. /// </summary> private async Task OnFolderLoadingCompleteAsync(bool filesJustAdded) { this.ShowSortFeedback(true); // Show the image, hide the load button, and make the feedback panels visible this.ImageSetPane.IsActive = true; this.FileNavigatorSlider_EnableOrDisableValueChangedCallback(false); this.MarkableCanvas.Focus(); // We start with this having the focus so it can interpret keyboard shortcuts if needed. // Adjust the visibility of the CopyPreviousValuesButton. Copyable controls will preview/highlight as one enters the CopyPreviousValuesButton this.CopyPreviousValuesButton.Visibility = Visibility.Visible; this.DataEntryControlPanel.IsVisible = true; // Show the File Player this.FilePlayer.Visibility = Visibility.Visible; // Set whether detections actually exist at this point. GlobalReferences.DetectionsExists = this.State.UseDetections && this.DataHandler.FileDatabase.DetectionsExists(); // Sets the default bounding box threshold, either by using a default or reading it from the detection database table (if it exists) this.State.BoundingBoxDisplayThresholdResetToValueInDataBase(); // Get the QuickPasteXML from the database and populate the QuickPaste datastructure with it string xml = this.DataHandler.FileDatabase.ImageSet.QuickPasteXML; this.quickPasteEntries = QuickPasteOperations.QuickPasteEntriesFromXML(this.DataHandler.FileDatabase, xml); // if this is completion of an existing .ddb open, set the current selection and the image index to the ones from the previous session with the image set // also if this is completion of import to a new .ddb long mostRecentFileID = this.DataHandler.FileDatabase.ImageSet.MostRecentFileID; FileSelectionEnum fileSelection = this.DataHandler.FileDatabase.ImageSet.FileSelection; if (fileSelection == FileSelectionEnum.Folders) { // Compose a custom search term for the relative path // which sets and only usse the relative path as a search term this.DataHandler.FileDatabase.CustomSelection.ClearCustomSearchUses(); this.DataHandler.FileDatabase.CustomSelection.SetAndUseRelativePathSearchTerm(this.DataHandler.FileDatabase.ImageSet.SelectedFolder); } if (filesJustAdded && (this.DataHandler.ImageCache.CurrentRow != Constant.DatabaseValues.InvalidRow && this.DataHandler.ImageCache.CurrentRow != Constant.DatabaseValues.InvalidRow)) { // if this is completion of an add to an existing image set stay on the image, ideally, shown before the import if (this.DataHandler.ImageCache.Current != null) { mostRecentFileID = this.DataHandler.ImageCache.Current.ID; } // This is heavier weight than desirable, but it's a one off. this.DataHandler.ImageCache.TryInvalidate(mostRecentFileID); } // PERFORMANCE - Initial but necessary Selection done in OnFolderLoadingComplete invoking this.FilesSelectAndShow to display selected image set // PROGRESSBAR - Display a progress bar on this (and all other) calls to FilesSelectAndShow after a delay of (say) .5 seconds. await this.FilesSelectAndShowAsync(mostRecentFileID, fileSelection).ConfigureAwait(true); // match UX availability to file availability this.EnableOrDisableMenusAndControls(); // Reset the folder list used to construct the Select Folders menu this.MenuItemSelectByFolder_ResetFolderList(); // Trigger updates to the datagrid pane, if its visible to the user. if (this.DataGridPane.IsVisible) { this.DataGridPane_IsActiveChanged(null, null); } // We have to do this again, to ensure that we have switched to the ImageSetPane this.ImageSetPane.IsActive = true; }
// Delete the quickPaste Entry from the quickPasteEntries private void QuickPasteEntryDelete(QuickPasteEntry quickPasteEntry) { this.quickPasteEntries = QuickPasteOperations.DeleteQuickPasteEntry(this.quickPasteEntries, quickPasteEntry); this.QuickPasteRefreshWindowAndXML(); }