/// <summary> /// Handle logic if user wants to load from a folder /// </summary> /// <param name="folder"></param> internal static async Task PicFolder(string folder) { // TODO add new function that can go to next/prev folder ChangeFolder(true); // If searching subdirectories, it might freeze UI, so wrap it in task await Task.Run(() => { Pics = FileList(folder); }).ConfigureAwait(true); if (Pics.Count > 0) { await LoadPicAt(0).ConfigureAwait(true); } else { Reload(true); } GetQuickSettingsMenu.GoToPic.GoToPicBox.Text = (FolderIndex + 1).ToString(CultureInfo.CurrentCulture); // Load new gallery values, if changing folder if (GetPicGallery != null && Properties.Settings.Default.FullscreenGallery) { if (GetPicGallery.Container.Children.Count == 0) { await GalleryLoad.Load().ConfigureAwait(false); } } }
/// <summary> /// Handle logic if user wants to load from a folder /// </summary> /// <param name="folder"></param> internal static async void PicFolder(string folder) { ChangeFolder(true); // If searching subdirectories, it might freeze UI, so wrap it in task await System.Threading.Tasks.Task.Run(() => { Pics = FileList(folder); }).ConfigureAwait(true); if (Pics.Count > 0) { Pic(0); } else { Reload(true); } GetQuickSettingsMenu.GoToPic.GoToPicBox.Text = (FolderIndex + 1).ToString(CultureInfo.CurrentCulture); // Load new gallery values, if changing folder if (GetPicGallery != null && Properties.Settings.Default.PicGallery == 2) { if (GetPicGallery.Container.Children.Count == 0) { await GalleryLoad.Load().ConfigureAwait(false); } } }
/// <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 SetLoadingString(); // Handle if from web if (!File.Exists(path)) { if (Uri.IsWellFormedUriString(path, UriKind.Absolute)) { LoadFromWeb.PicWeb(path); return; } else if (Directory.Exists(path)) { ChangeFolder(true); await GetValues(path).ConfigureAwait(true); } 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 old values and get new ChangeFolder(true); await GetValues(path).ConfigureAwait(true); } FolderIndex = Pics.IndexOf(path); // Fix large archive extraction error if (FolderIndex == -1) { var recovery = await RecoverFailedArchiveAsync().ConfigureAwait(true); if (!recovery) { Reload(true); return; } else { LoadWindows.GetMainWindow.TitleText.Text = Application.Current.Resources["Unzipping"] as string; LoadWindows.GetMainWindow.TitleText.ToolTip = LoadWindows.GetMainWindow.TitleText.Text; FolderIndex = 0; } LoadWindows.GetMainWindow.Focus(); } if (!FreshStartup) { Preloader.Clear(); } #if DEBUG if (FreshStartup) { Trace.WriteLine("Pic(string path) entering Pic(int x)"); } #endif // Navigate to picture using obtained index Pic(FolderIndex); // Load new gallery values, if changing folder if (GetPicGallery != null && Properties.Settings.Default.PicGallery == 2 && !GalleryFunctions.IsLoading) { await GalleryLoad.Load().ConfigureAwait(false); } }
/// <summary> /// Loads a picture from a given file path and does extra error checking /// </summary> /// <param name="path"></param> internal static async Task LoadPiFrom(string path) { // Set Loading SetLoadingString(); // Handle if from web if (!File.Exists(path)) { if (Uri.IsWellFormedUriString(path, UriKind.Absolute)) { LoadFromWeb.PicWeb(path); return; } else if (Directory.Exists(path)) { ChangeFolder(true); await GetValues(path).ConfigureAwait(true); } 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 old values and get new ChangeFolder(true); await GetValues(path).ConfigureAwait(true); } FolderIndex = Pics.IndexOf(path); if (!FreshStartup) { Preloader.Clear(); } if (FolderIndex != -1) // if it is -1, it means it being extracted and need to wait for it instead { // Navigate to picture using obtained index await LoadPicAt(FolderIndex).ConfigureAwait(false); } await ConfigureWindows.GetMainWindow.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, (Action)(async() => { // Load new gallery values, if changing folder if (GetPicGallery != null && Properties.Settings.Default.FullscreenGallery) { if (GetPicGallery.Container.Children.Count == 0) { await GalleryLoad.Load().ConfigureAwait(false); } } })); }
/// <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 SetLoadingString(); // Handle if from web if (!File.Exists(path)) { if (Uri.IsWellFormedUriString(path, UriKind.Absolute)) { LoadFromWeb.PicWeb(path); return; } else if (Directory.Exists(path)) { ChangeFolder(true); await GetValues(path).ConfigureAwait(true); } 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 old values and get new ChangeFolder(true); await GetValues(path).ConfigureAwait(true); } FolderIndex = Pics.IndexOf(path); if (!FreshStartup) { Preloader.Clear(); } #if DEBUG if (FreshStartup) { Trace.WriteLine("Pic(string path) entering Pic(int x)"); } #endif // Navigate to picture using obtained index Pic(FolderIndex == -1 ? 0 : FolderIndex); // Load new gallery values, if changing folder if (GetPicGallery != null && Properties.Settings.Default.PicGallery == 2) { if (GetPicGallery.Container.Children.Count == 0) { await GalleryLoad.Load().ConfigureAwait(false); } } }