/// <summary> /// Refresh the current list of pics and reload them if there is some missing or changes. /// </summary> internal static void Reload(bool fromBackup = false) { if (fromBackup && string.IsNullOrWhiteSpace(xPicPath)) { Unload(); return; } var x = fromBackup ? xPicPath : Pics[FolderIndex]; if (File.Exists(x)) { // Force reloading values by setting freshStartup to true freshStartup = true; // Clear Preloader, to avoid errors by FolderIndex changing location because of re-sorting Preloader.Clear(); // Need a sort method instead PicGalleryLogic.Clear(); PicGalleryLoad.Load(); Pic(x); // Reset if (isZoomed) { ResetZoom(); } if (Flipped) { Flip(); } if (Rotateint != 0) { Rotate(0); } } else { Unload(); ToolTipStyle("Unknown error occured"); } }
/// <summary> /// Loads a picture from a given file path and does extra error checking /// </summary> /// <param name="path"></param> internal static async void Pic(string path) { // Set Loading mainWindow.Title = mainWindow.Bar.Text = Loading; mainWindow.Bar.ToolTip = Loading; if (mainWindow.img.Source == null) { AjaxLoadingStart(); } // Handle if from web if (!File.Exists(path)) { if (Uri.IsWellFormedUriString(path, UriKind.Absolute)) { LoadFromWeb.PicWeb(path); } else { Unload(); } return; } // If count not correct or just started, get values if (Pics.Count <= FolderIndex || FolderIndex < 0 || freshStartup) { await GetValues(path).ConfigureAwait(true); } // If the file is in the same folder, navigate to it. If not, start manual loading procedure. else if (!string.IsNullOrWhiteSpace(Pics[FolderIndex]) && Path.GetDirectoryName(path) != Path.GetDirectoryName(Pics[FolderIndex])) { //// Reset zipped values //if (!string.IsNullOrWhiteSpace(TempZipPath)) //{ // DeleteTempFiles(); // TempZipPath = string.Empty; // RecentFiles.SetZipped(string.Empty, false); //} // Reset old values and get new ChangeFolder(true); await GetValues(path).ConfigureAwait(true); } // If no need to reset values, get index else if (Pics != null) { FolderIndex = Pics.IndexOf(path); } if (Pics != null) { // Fix large archive extraction error if (Pics.Count == 0) { var recovery = await RecoverFailedArchiveAsync().ConfigureAwait(true); if (!recovery) { if (sexyToolTip.Opacity == 0) { ToolTipStyle("Archive could not be processed"); } Reload(true); return; } mainWindow.Focus(); } } else { Reload(true); return; } if (File.Exists(Pics[FolderIndex])) { if (!freshStartup) { Preloader.Clear(); } // Navigate to picture using obtained index Pic(FolderIndex); } else { Reload(true); return; } // Load images for PicGallery if enabled if (Properties.Settings.Default.PicGallery > 0) { if (!PicGalleryLogic.IsLoading) { await PicGalleryLoad.Load().ConfigureAwait(true); } } prevPicResource = null; // Make sure to not waste memory }