Bug fix
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Media.Imaging;
|
||||
using Avalonia.Platform.Storage;
|
||||
@@ -17,8 +18,6 @@ namespace GazpromApp.ViewModels;
|
||||
|
||||
public partial class EditPointDialogViewModel : ViewModelBase
|
||||
{
|
||||
public ObservableCollection<ImageViewModel> Images { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
[NotifyCanExecuteChangedFor(nameof(CompleteEditCommand))]
|
||||
private string? _name;
|
||||
@@ -46,6 +45,8 @@ public partial class EditPointDialogViewModel : ViewModelBase
|
||||
IsDescriptionEditing = !IsDescriptionEditing;
|
||||
IsNameEditing = false;
|
||||
}
|
||||
|
||||
public ObservableCollection<ImageViewModel> Images { get; set; }
|
||||
|
||||
[RelayCommand]
|
||||
private async Task AddImage(Window w)
|
||||
@@ -57,7 +58,7 @@ public partial class EditPointDialogViewModel : ViewModelBase
|
||||
FileTypeFilter = [FilePickerFileTypes.ImageAll],
|
||||
});
|
||||
foreach (var file in files)
|
||||
Images.Add(new ImageViewModel(new Image()) { FileName = new Bitmap(file.Path.AbsolutePath) });
|
||||
Images.Add(new ImageViewModel(new Image()) { FileName = new Bitmap(HttpUtility.UrlDecode(file.Path.AbsolutePath) ) });
|
||||
|
||||
IsImagesEmpty = Images.Count == 0;
|
||||
}
|
||||
@@ -70,7 +71,7 @@ public partial class EditPointDialogViewModel : ViewModelBase
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private async Task ViewImage(ImageViewModel image)
|
||||
private static async Task ViewImage(ImageViewModel image)
|
||||
{
|
||||
_ = await WeakReferenceMessenger.Default.Send(new ViewImageMessage(image));
|
||||
}
|
||||
@@ -80,6 +81,7 @@ public partial class EditPointDialogViewModel : ViewModelBase
|
||||
[RelayCommand(CanExecute = nameof(CanCompleteEdit))]
|
||||
private void CompleteEdit()
|
||||
{
|
||||
IsClosed = true;
|
||||
Point point = new Point()
|
||||
{
|
||||
Name = Name,
|
||||
@@ -90,20 +92,33 @@ public partial class EditPointDialogViewModel : ViewModelBase
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private static void CancelEdit(Window w)
|
||||
private void CancelEdit(Window w)
|
||||
{
|
||||
w.Close();
|
||||
IsClosed = true;
|
||||
WeakReferenceMessenger.Default.Send(new EditPointDone(_point));
|
||||
}
|
||||
|
||||
// Visual and other properties
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _isImagesEmpty;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _isEquipmentEmpty = true;
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _isClosed;
|
||||
|
||||
private readonly PointViewModel _point;
|
||||
|
||||
public EditPointDialogViewModel()
|
||||
{
|
||||
Name = "";
|
||||
Description = "";
|
||||
Images = [];
|
||||
IsImagesEmpty = true;
|
||||
|
||||
_point = new PointViewModel(new Point());
|
||||
}
|
||||
|
||||
public EditPointDialogViewModel(PointViewModel point)
|
||||
@@ -116,5 +131,7 @@ public partial class EditPointDialogViewModel : ViewModelBase
|
||||
Debug.WriteLine(imageViewModel.FileName);
|
||||
}
|
||||
IsImagesEmpty = Images.Count == 0;
|
||||
|
||||
_point = point;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user