/// <summary> /// Reset to default state /// </summary> internal static void Unload() { ConfigureWindows.GetMainWindow.TitleText.ToolTip = ConfigureWindows.GetMainWindow.TitleText.Text = Application.Current.Resources["NoImage"] as string; ConfigureWindows.GetMainWindow.Title = Application.Current.Resources["NoImage"] as string + " - " + UILogic.SetTitle.AppName; CanNavigate = false; ConfigureWindows.GetMainWindow.MainImage.Source = null; FreshStartup = true; if (Pics != null) { Pics.Clear(); } Preloader.Clear(); GalleryFunctions.Clear(); ConfigureWindows.GetMainWindow.MainImage.Width = ConfigureWindows.GetMainWindow.Scroller.Width = ConfigureWindows.GetMainWindow.Scroller.Height = ConfigureWindows.GetMainWindow.MainImage.Height = double.NaN; ScaleImage.xWidth = ScaleImage.xHeight = 0; if (!string.IsNullOrWhiteSpace(ArchiveExtraction.TempZipPath)) { DeleteTempFiles(); ArchiveExtraction.TempZipPath = string.Empty; } SystemIntegration.Taskbar.NoProgress(); }
/// <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(BackupPath)) { Unload(); return; } string s; if (Pics != null && Pics.Count > 0) { s = fromBackup ? BackupPath : Pics[FolderIndex]; } else { // TODO extract url from path or get alternative method s = Path.GetFileName(ConfigureWindows.GetMainWindow.TitleText.Text); } if (File.Exists(s)) { // 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 GalleryFunctions.Clear(); Pic(s); // Reset if (Flipped) { Flip(); } if (Rotateint != 0) { Rotate(0); } } else if (Clipboard.ContainsImage() || Base64.IsBase64String(s)) { return; } else if (Uri.IsWellFormedUriString(s, UriKind.Absolute)) // Check if from web { LoadFromWeb.PicWeb(s); } else { Unload(); ShowTooltipMessage(Application.Current.Resources["UnexpectedError"]); } }
/// <summary> /// Clears data, to free objects no longer necessary to store in memory and allow changing folder without error. /// </summary> internal static void ChangeFolder(bool backup = false) { if (Pics.Count > 0 && backup) { // Make a backup of xPicPath and FolderIndex if (!string.IsNullOrWhiteSpace(Pics[FolderIndex])) { BackupPath = Pics[FolderIndex]; } } Pics.Clear(); GalleryFunctions.Clear(); Preloader.Clear(); FreshStartup = true; DeleteTempFiles(); }