Error handling system added
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
@@ -9,7 +11,9 @@ using Avalonia.Platform.Storage;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using GazpromApp.Enums;
|
||||
using GazpromApp.Messages;
|
||||
using GazpromApp.Models;
|
||||
using Image = GazpromApp.Models.Image;
|
||||
using Point = GazpromApp.Models.Point;
|
||||
|
||||
@@ -37,7 +41,22 @@ public partial class NewPointDialogViewModel : ViewModelBase
|
||||
FileTypeFilter = [FilePickerFileTypes.ImageAll],
|
||||
});
|
||||
foreach (var file in files)
|
||||
Images.Add(new ImageViewModel(new Image()) { FileName = new Bitmap(HttpUtility.UrlDecode(file.Path.AbsolutePath)) });
|
||||
{
|
||||
try
|
||||
{
|
||||
Images.Add(new ImageViewModel(new Image()) { FileName = new Bitmap(HttpUtility.UrlDecode(file.Path.AbsolutePath)) });
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
Error error = new Error()
|
||||
{
|
||||
Title = "Ошибка обработки картинки",
|
||||
Message = $"Картинка не была добавлена: \"{HttpUtility.UrlDecode(file.Name)}\"",
|
||||
Severity = ErrorSeverity.Error,
|
||||
};
|
||||
_ = await WeakReferenceMessenger.Default.Send(new ErrorMessage(new ErrorViewModel(error)));
|
||||
}
|
||||
}
|
||||
|
||||
IsImagesEmpty = Images.Count == 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user