Removed dialogs for editing equipment and points, and their related resources

This commit is contained in:
retr0volkov
2025-07-30 09:08:22 +03:00 Unverified
parent edae732fac
commit 08eaa30209
77 changed files with 1498 additions and 1543 deletions
+34 -14
View File
@@ -1,31 +1,49 @@
using System.IO;
using System;
using System.IO;
using System.Threading.Tasks;
using Avalonia.Media.Imaging;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using GazpromApp.Messages;
using GazpromApp.Models;
namespace GazpromApp.ViewModels;
public partial class ImageViewModel : ViewModelBase
{
public ViewModelBase? Parent;
private Image Image { get; }
[ObservableProperty]
private byte[]? _bytes;
[ObservableProperty] private byte[]? _bytes;
[ObservableProperty] private DateTime _creationDate;
// EF stuff
[ObservableProperty]
private Point? _point;
[ObservableProperty]
private Equipment? _equipment;
[ObservableProperty]
private Bitmap? _fileName;
[ObservableProperty] private Point? _point;
[ObservableProperty] private Equipment? _equipment;
[ObservableProperty] private Bitmap? _fileName;
[RelayCommand]
private async Task ViewImage() => _ = await WeakReferenceMessenger.Default.Send(new ViewImageMessage(this));
[RelayCommand]
private void DeleteImage() => _ = Parent switch
{
PointViewModel pmv => pmv.Images.Remove(this),
EquipmentViewModel emv => emv.Images.Remove(this),
EditPointViewModel editPointViewModel => editPointViewModel.Images.Remove(this),
EditEquipmentViewModel editEquipmentViewModel => editEquipmentViewModel.Images.Remove(this),
_ => false
};
public ImageViewModel(Image image)
{
Bytes = image.Bytes;
CreationDate = image.CreationDate;
Equipment = image.Equipment;
Point = image.Point;
FileName = image.Bytes is { Length: > 0 } ? new Bitmap(new MemoryStream(image.Bytes)) : null;
@@ -35,6 +53,7 @@ public partial class ImageViewModel : ViewModelBase
public ImageViewModel()
{
Bytes = null;
CreationDate = DateTime.Now;
Equipment = null;
Point = null;
Image = new Image();
@@ -45,6 +64,7 @@ public partial class ImageViewModel : ViewModelBase
var ms = new MemoryStream();
FileName?.Save(ms);
Image.Bytes = ms.ToArray();
Image.CreationDate = CreationDate;
Image.Equipment = Equipment;
Image.Point = Point;
return Image;