public async void RefreshView() { try { // Show nothing if fileindex is outside what should be possible if (model.FileIndex < 0 || model.FileIndex > model.LoadedFiles.Count) { view.window.imgMainContent = null; return; } view.window.RefreshFolderList(); StorageFile storageFile = model.LoadedFiles[model.FileIndex].file; // Prefix with = await SetFileIsSorted(storageFile); view.window.SetTitle("ReFiler - (" + (model.FileIndex + 1) + "/" + model.LoadedFiles.Count + ") - " + storageFile.Name); if (FilerModel.IsImageExtension(storageFile.Name)) { // Image var bitmapImage = new BitmapImage(); bitmapImage.SetSource(await storageFile.OpenAsync(FileAccessMode.Read)); bitmapImage.DecodePixelHeight = (int)view.window.ContentGrid.ActualHeight; // Set the image on the main page to the dropped image view.window.imgMainContent.Source = bitmapImage; } else { // Thumbnail StorageItemThumbnail thumb = await storageFile.GetScaledImageAsThumbnailAsync(ThumbnailMode.SingleItem); if (thumb != null) { BitmapImage img = new BitmapImage(); await img.SetSourceAsync(thumb); view.window.imgMainContent.Source = img; } } UpdateInfobar(); } catch (Exception e) { view.window.imgMainContent.Source = null; Debug.WriteLine("Error loading file\n" + e); } }
public async void UpdateInfobar() { try { StorageFile file = model.LoadedFiles[model.FileIndex].file; string info = "(" + (model.FileIndex + 1) + "/" + model.LoadedFiles.Count + ")"; BasicProperties basicProperties = await file.GetBasicPropertiesAsync(); info += " - " + FilerModel.BytesToString((long)basicProperties.Size); view.window.Infobar.FontStyle = FontStyle.Normal; view.window.Infobar.Foreground = new SolidColorBrush(Colors.White); if (FilerModel.IsImageExtension(file.Name) && file.FileType.ToLower() != ".gif") { BitmapImage dimensions = (BitmapImage)view.window.imgMainContent.Source; int height = dimensions.PixelHeight; int width = dimensions.PixelWidth; info += " - ( " + width + " x " + height + " )"; if (height < 1000) { view.window.Infobar.FontStyle = FontStyle.Italic; view.window.Infobar.Foreground = new SolidColorBrush(Colors.Coral); } } string location = file.Path.Replace(model.RootFolder.folder.Path, model.RootFolder.folder.Name); view.window.SetInfobar(info + "\n" + location); } catch (Exception e) { Console.WriteLine(e); } }