Modifying points works

This commit is contained in:
retr0volkov
2025-07-02 16:01:42 +03:00 Unverified
parent 7beee75d14
commit 044372eada
29 changed files with 427 additions and 79 deletions
+26 -19
View File
@@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Media.Imaging;
using Avalonia.Platform.Storage;
@@ -20,20 +17,14 @@ namespace GazpromApp.ViewModels;
public partial class NewPointDialogViewModel : ViewModelBase
{
[ObservableProperty]
[NotifyCanExecuteChangedFor(nameof(EnterPointCommand))]
private string? _name;
[ObservableProperty]
[NotifyCanExecuteChangedFor(nameof(EnterPointCommand))]
private string? _description;
public ObservableCollection<ImageViewModel> Images { get; } = new ObservableCollection<ImageViewModel>();
[RelayCommand]
public void DeleteImage(ImageViewModel image)
{
Images.Remove(image);
if (Images.Count == 0)
IsImagesEmpty = true;
}
public ObservableCollection<ImageViewModel> Images { get; } = [];
[RelayCommand]
private async Task AddImage(Window w)
@@ -46,16 +37,21 @@ public partial class NewPointDialogViewModel : ViewModelBase
});
foreach (var file in files)
Images.Add(new ImageViewModel(new Image()) { FileName = new Bitmap(file.Path.AbsolutePath) });
IsImagesEmpty = false;
IsImagesEmpty = Images.Count == 0;
}
[ObservableProperty]
private bool _isImagesEmpty = true;
[RelayCommand]
private void DeleteImage(ImageViewModel image)
{
Images.Remove(image);
IsImagesEmpty = Images.Count == 0;
}
private bool CanExecuteEnterPoint() => !string.IsNullOrEmpty(Name) || !string.IsNullOrEmpty(Description);
private bool CanEnterPoint() => !string.IsNullOrEmpty(Name);
[RelayCommand(CanExecute = nameof(CanExecuteEnterPoint))]
public void EnterPoint()
[RelayCommand (CanExecute = nameof(CanEnterPoint))]
private void EnterPoint()
{
Point point = new Point()
{
@@ -65,4 +61,15 @@ public partial class NewPointDialogViewModel : ViewModelBase
};
WeakReferenceMessenger.Default.Send(new NewPointDone(new PointViewModel(point)));
}
[RelayCommand]
private static void CancelEnterPoint(Window w)
{
w.Close();
}
// Visual properties
[ObservableProperty]
private bool _isImagesEmpty = true;
}