Added some extra UI logging

This commit is contained in:
Terry MacDonald 2021-11-06 12:05:58 +13:00
parent ed07d84750
commit 712f0333f5

View File

@ -14,6 +14,7 @@ namespace DisplayMagician.UIForms
public partial class ChooseImageForm : Form public partial class ChooseImageForm : Form
{ {
private ShortcutBitmap _selectedImage = new ShortcutBitmap(); private ShortcutBitmap _selectedImage = new ShortcutBitmap();
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
public ChooseImageForm() public ChooseImageForm()
{ {
@ -116,6 +117,7 @@ namespace DisplayMagician.UIForms
List<ShortcutBitmap> newImages = ImageUtils.GetMeAllBitmapsFromFile(dialog_open.FileName); List<ShortcutBitmap> newImages = ImageUtils.GetMeAllBitmapsFromFile(dialog_open.FileName);
if (newImages.Count == 0) if (newImages.Count == 0)
{ {
logger.Trace($"No new images found when parsing {dialog_open.FileName} for images. Are you sure it's a valid image format?");
MessageBox.Show( MessageBox.Show(
$"No new images found when parsing {dialog_open.FileName} for images. Are you sure it's a valid image format?", $"No new images found when parsing {dialog_open.FileName} for images. Are you sure it's a valid image format?",
"Add images to icon", "Add images to icon",
@ -126,6 +128,7 @@ namespace DisplayMagician.UIForms
{ {
AvailableImages.AddRange(ImageUtils.GetMeAllBitmapsFromFile(dialog_open.FileName)); AvailableImages.AddRange(ImageUtils.GetMeAllBitmapsFromFile(dialog_open.FileName));
UpdateImageListBox(); UpdateImageListBox();
logger.Trace($"ChooseImageForm/btn_add_Click: Added {newImages.Count} image(s) from {dialog_open.FileName} to the end of this image list.");
MessageBox.Show( MessageBox.Show(
$"Added {newImages.Count} image(s) from {dialog_open.FileName} to the end of this image list.", $"Added {newImages.Count} image(s) from {dialog_open.FileName} to the end of this image list.",
"Add images to icon", "Add images to icon",
@ -137,6 +140,7 @@ namespace DisplayMagician.UIForms
} }
catch(Exception ex) catch(Exception ex)
{ {
logger.Warn(ex, $"ChooseImageForm/btn_add_Click: Exception - unable to parse {dialog_open.FileName} for images. Are you sure it's a valid image format?");
MessageBox.Show( MessageBox.Show(
$"Unable to parse {dialog_open.FileName} for images. Are you sure it's a valid image format?", $"Unable to parse {dialog_open.FileName} for images. Are you sure it's a valid image format?",
"Add images to icon", "Add images to icon",
@ -147,6 +151,7 @@ namespace DisplayMagician.UIForms
} }
else else
{ {
logger.Warn($"ChooseImageForm/btn_add_Click: Unable to open {dialog_open.FileName} to parse it for images. Are you sure you have the right file permissions?");
MessageBox.Show( MessageBox.Show(
$"Unable to open {dialog_open.FileName} to parse it for images. Are you sure you have the right file permissions?", $"Unable to open {dialog_open.FileName} to parse it for images. Are you sure you have the right file permissions?",
"Add images to icon", "Add images to icon",