private void LoadPreview() { if (PathAndFileHelper.IsPathValid(DataObject.ResourcesDir)) { // Preview. UIHelper.LoadPreviewImage(DataObject.ResourcesDir, DataObject.ThumbnailName, _previewImage, _previewName); // Images. _imagesListView.ItemsSource = ImagePreview.LoadImages(DataObject.ResourcesDir); // Files. DirectoriesTreeView.ItemsSource = ItemProvider.GetItems(DataObject.ResourcesDir); } }
/// <summary> /// Loads an image into a preview controll. /// </summary> /// <param name="resourcesDir">A directory containing an image. Can be empty or null.</param> /// <param name="fileName">The image file name. Can be empty or null.</param> /// <param name="previewDisplay">The preview controll. Can be null.</param> /// <param name="previewDescription">The preview description controll. Can be null.</param> public static void LoadPreviewImage(string resourcesDir, string fileName, Image previewDisplay, Label previewDescription) { if (String.IsNullOrWhiteSpace(resourcesDir)) { resourcesDir = App.DataDirectoryPath; } var imageName = String.IsNullOrWhiteSpace(fileName) ? "Thumbnail.jpg" : fileName; var imgagePath = Path.Combine(resourcesDir, imageName); if (previewDisplay != null) { previewDisplay.Source = File.Exists(imgagePath) ? ImagePreview.LoadImage(imgagePath) : new BitmapImage(); } if (previewDescription != null) { previewDescription.Content = "<Documents>\\" + imageName; } }