Bloom.CollectionTab.LibraryModel.AttemptMissingImageReplacements C# (CSharp) Method

AttemptMissingImageReplacements() public method

public AttemptMissingImageReplacements ( string pathToFolderOfReplacementImages = null ) : void
pathToFolderOfReplacementImages string
return void
        public void AttemptMissingImageReplacements(string pathToFolderOfReplacementImages=null)
        {
            using (var dlg = new ProgressDialogBackground())
            {
                dlg.ShowAndDoWork((progress, args) => DoChecksOfAllBooksBackgroundWork(dlg, pathToFolderOfReplacementImages));
                if (dlg.Progress.ErrorEncountered || dlg.Progress.WarningsEncountered)
                {
                    MessageBox.Show("There were some problems. Bloom will now open a log of the attempt to replace missing images.");
                }
                else
                {
                    MessageBox.Show("There are no more missing images. Bloom will now open a log of what it did.");
                }

                var path = Path.GetTempFileName() + ".txt";
                RobustFile.WriteAllText(path, dlg.ProgressString.Text);
                try
                {
                    PathUtilities.OpenFileInApplication(path);
                }
                catch (System.OutOfMemoryException)
                {
                    // This has happened at least once.  See https://silbloom.myjetbrains.com/youtrack/issue/BL-3431.
                    MessageBox.Show("Bloom ran out of memory trying to open the log.  You should quit and restart the program.  (Your books should all be okay.)");
                }
            }
        }

Usage Example

 private void _rescueMissingImagesToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (var dlg = new FolderBrowserDialog())
     {
         dlg.ShowNewFolderButton = false;
         dlg.Description         = "Select the folder where replacement images can be found";
         if (DialogResult.OK == dlg.ShowDialog())
         {
             _model.AttemptMissingImageReplacements(dlg.SelectedPath);
         }
     }
 }