Error handling for corrupt images.

This commit is contained in:
Joe Tretter
2021-07-27 08:16:29 -05:00
parent 3794b54ee6
commit 3916cd94a1

View File

@@ -40,13 +40,21 @@ namespace WPicView
dPos = allDirs.Length - 1;
allFiles = System.IO.Directory.GetFiles(allDirs[dPos], searchPattern);
fPos = allFiles.Length-1;
this.Title = allFiles[fPos];
IMG1.Source = new BitmapImage(new Uri(allFiles[fPos]));
showFile(allFiles[fPos]);
group.Children.Add(st);
group.Children.Add(tt);
}
private void showFile(String fileName) {
this.Title = allFiles[fPos];
try {
IMG1.Source = new BitmapImage(new Uri(fileName));
} catch (Exception ex) {
this.Title = "ERRROR LOADING FILE " + this.Title;
}
}
private void OnKeyDownHandler(object sender, KeyEventArgs e)
{
// Directory Navigation
@@ -102,8 +110,7 @@ namespace WPicView
// Display file
if (allFiles.Length > 0)
{
this.Title = allFiles[fPos];
IMG1.Source = new BitmapImage(new Uri(allFiles[fPos]));
showFile(allFiles[fPos]);
}
// zoom - TODO