// Populate a data field from metadata (example metadata displayed from the currently selected image) private async void MenuItemPopulateFieldFromMetadata_Click(object sender, RoutedEventArgs e) { // If we are not in the selection All view, or if its a corrupt image or deleted image, or if its a video that no longer exists, tell the person. Selecting ok will shift the selection. // We want to be on a valid image as otherwise the metadata of interest won't appear if (this.DataHandler.ImageCache.Current.IsDisplayable(this.FolderPath) == false) { // There are no displayable images, and thus no metadata to choose from, so abort Dialogs.MenuEditPopulateDataFieldWithMetadataDialog(this); return; } // Warn the user that they are currently in a selection displaying only a subset of files, and make sure they want to continue. if (Dialogs.MaybePromptToApplyOperationOnSelectionDialog(this, this.DataHandler.FileDatabase, this.State.SuppressSelectedPopulateFieldFromMetadataPrompt, "'Populate a data field with image metadata...'", (bool optOut) => { this.State.SuppressSelectedPopulateFieldFromMetadataPrompt = optOut; })) { using (PopulateFieldWithMetadata populateField = new PopulateFieldWithMetadata(this, this.DataHandler.FileDatabase, this.DataHandler.ImageCache.Current.GetFilePath(this.FolderPath))) { if (this.ShowDialogAndCheckIfChangesWereMade(populateField)) { await this.FilesSelectAndShowAsync().ConfigureAwait(true); } ; } } }
// Populate a data field from metadata (example metadata displayed from the currently selected image) private async void MenuEditPopulateFieldFromMetadata_Click(object sender, RoutedEventArgs e) { if (this.dataHandler.ImageCache.Current.IsDisplayable() == false) { int firstFileDisplayable = this.dataHandler.FileDatabase.GetCurrentOrNextDisplayableFile(this.dataHandler.ImageCache.CurrentRow); if (firstFileDisplayable == -1) { // There are no displayable files and thus no metadata to choose from, so abort MessageBox messageBox = new MessageBox("Can't populate a data field with image metadata.", this); messageBox.Message.Problem = "Metadata is not available as no file in the image set can be read." + Environment.NewLine; messageBox.Message.Reason += "Carnassial must have at least one valid file in order to get its metadata. All files are either corrupted or removed."; messageBox.Message.StatusImage = MessageBoxImage.Error; messageBox.ShowDialog(); return; } } PopulateFieldWithMetadata populateField = new PopulateFieldWithMetadata(this.dataHandler.FileDatabase, this.dataHandler.ImageCache.Current.GetFilePath(this.FolderPath), this); await this.ShowBulkFileEditDialogAsync(populateField); }