DB integration added, multiple images for equipment
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using Avalonia.Media.Imaging;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using GazpromApp.Models;
|
||||
@@ -8,13 +7,19 @@ namespace GazpromApp.ViewModels;
|
||||
|
||||
public partial class ImageViewModel : ViewModelBase
|
||||
{
|
||||
private Image Image { get; }
|
||||
|
||||
[ObservableProperty]
|
||||
private byte[]? _bytes;
|
||||
|
||||
// EF stuff
|
||||
|
||||
[ObservableProperty]
|
||||
private List<Point>? _points;
|
||||
private Point? _point;
|
||||
|
||||
[ObservableProperty]
|
||||
private List<Equipment>? _equipment;
|
||||
private Equipment? _equipment;
|
||||
|
||||
[ObservableProperty]
|
||||
private Bitmap? _fileName;
|
||||
|
||||
@@ -22,26 +27,26 @@ public partial class ImageViewModel : ViewModelBase
|
||||
{
|
||||
Bytes = image.Bytes;
|
||||
Equipment = image.Equipment;
|
||||
Points = image.Points;
|
||||
Point = image.Point;
|
||||
FileName = image.Bytes is { Length: > 0 } ? new Bitmap(new MemoryStream(image.Bytes)) : null;
|
||||
Image = image;
|
||||
}
|
||||
|
||||
public ImageViewModel()
|
||||
{
|
||||
Bytes = null;
|
||||
Equipment = null;
|
||||
Points = null;
|
||||
Point = null;
|
||||
Image = new Image();
|
||||
}
|
||||
|
||||
public Image GetImage()
|
||||
{
|
||||
var ms = new MemoryStream();
|
||||
FileName?.Save(ms);
|
||||
return new Image
|
||||
{
|
||||
Bytes = ms.ToArray(),
|
||||
Equipment = Equipment ?? [],
|
||||
Points = Points ?? []
|
||||
};
|
||||
Image.Bytes = ms.ToArray();
|
||||
Image.Equipment = Equipment;
|
||||
Image.Point = Point;
|
||||
return Image;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user