private void AboutPage_Loaded(object sender, RoutedEventArgs e) { EnterAnimation.Begin(); }
private async Task Initialize() { try { ExitLocker = new ManualResetEvent(false); Cancellation = new CancellationTokenSource(); LoadQueue = new Queue <int>(); Behavior.Attach(Flip); if (await FileSystemStorageItemBase.OpenAsync(Path.GetDirectoryName(SelectedPhotoFile.Path)) is FileSystemStorageFolder Item) { FileSystemStorageFile[] PictureFileList = (await Item.GetChildItemsAsync(SettingControl.IsDisplayHiddenItem, SettingControl.IsDisplayProtectedSystemItems, Filter: ItemFilters.File, AdvanceFilter: (Name) => { string Extension = Path.GetExtension(Name); return(Extension.Equals(".png", StringComparison.OrdinalIgnoreCase) || Extension.Equals(".jpg", StringComparison.OrdinalIgnoreCase) || Extension.Equals(".bmp", StringComparison.OrdinalIgnoreCase)); })).Cast <FileSystemStorageFile>().ToArray(); if (PictureFileList.Length == 0) { QueueContentDialog Dialog = new QueueContentDialog { Title = Globalization.GetString("Common_Dialog_ErrorTitle"), Content = Globalization.GetString("Queue_Dialog_ImageReadError_Content"), CloseButtonText = Globalization.GetString("Common_Dialog_GoBack") }; _ = await Dialog.ShowAsync(); Frame.GoBack(); } else { int LastSelectIndex = Array.FindIndex(PictureFileList, (Photo) => Photo.Path.Equals(SelectedPhotoFile.Path, StringComparison.OrdinalIgnoreCase)); if (LastSelectIndex < 0 || LastSelectIndex >= PictureFileList.Length) { LastSelectIndex = 0; } PhotoCollection = new ObservableCollection <PhotoDisplaySupport>(PictureFileList.Select((Item) => new PhotoDisplaySupport(Item))); Flip.ItemsSource = PhotoCollection; if (!await PhotoCollection[LastSelectIndex].ReplaceThumbnailBitmapAsync()) { CouldnotLoadTip.Visibility = Visibility.Visible; } for (int i = LastSelectIndex - 5 > 0 ? LastSelectIndex - 5 : 0; i <= (LastSelectIndex + 5 < PhotoCollection.Count - 1 ? LastSelectIndex + 5 : PhotoCollection.Count - 1) && !Cancellation.IsCancellationRequested; i++) { await PhotoCollection[i].GenerateThumbnailAsync(); } if (!Cancellation.IsCancellationRequested) { Flip.SelectedIndex = LastSelectIndex; Flip.SelectionChanged += Flip_SelectionChanged; Flip.SelectionChanged += Flip_SelectionChanged1; EnterAnimation.Begin(); } } } else { throw new FileNotFoundException(); } } catch (Exception ex) { CouldnotLoadTip.Visibility = Visibility.Visible; LogTracer.Log(ex, "An error was threw when initialize PhotoViewer"); } finally { ExitLocker.Set(); } }