Adding equipment works
This commit is contained in:
+2
@@ -4,9 +4,11 @@
|
|||||||
<option name="projectPerEditor">
|
<option name="projectPerEditor">
|
||||||
<map>
|
<map>
|
||||||
<entry key="App.axaml" value="GazpromApp.csproj" />
|
<entry key="App.axaml" value="GazpromApp.csproj" />
|
||||||
|
<entry key="Views/EditEquipmentDialog.axaml" value="GazpromApp.csproj" />
|
||||||
<entry key="Views/EditPointDialog.axaml" value="GazpromApp.csproj" />
|
<entry key="Views/EditPointDialog.axaml" value="GazpromApp.csproj" />
|
||||||
<entry key="Views/ImageView.axaml" value="GazpromApp.csproj" />
|
<entry key="Views/ImageView.axaml" value="GazpromApp.csproj" />
|
||||||
<entry key="Views/MainWindow.axaml" value="GazpromApp.csproj" />
|
<entry key="Views/MainWindow.axaml" value="GazpromApp.csproj" />
|
||||||
|
<entry key="Views/NewEquipmentDialog.axaml" value="GazpromApp.csproj" />
|
||||||
<entry key="Views/NewPointDialog.axaml" value="GazpromApp.csproj" />
|
<entry key="Views/NewPointDialog.axaml" value="GazpromApp.csproj" />
|
||||||
<entry key="Views/NewPointView.axaml" value="GazpromApp.csproj" />
|
<entry key="Views/NewPointView.axaml" value="GazpromApp.csproj" />
|
||||||
</map>
|
</map>
|
||||||
|
|||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||||
|
<data-source source="LOCAL" name="identifier.sqlite" uuid="c1eec8a6-76a3-4765-bdc3-25bf9abb59b1">
|
||||||
|
<driver-ref>sqlite.xerial</driver-ref>
|
||||||
|
<synchronize>true</synchronize>
|
||||||
|
<configured-by-url>true</configured-by-url>
|
||||||
|
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
|
||||||
|
<jdbc-url>jdbc:sqlite:identifier.sqlite</jdbc-url>
|
||||||
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
|
</data-source>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using GazpromApp.ViewModels;
|
||||||
|
|
||||||
|
namespace GazpromApp.Messages;
|
||||||
|
|
||||||
|
public class EditEquipmentDone(EquipmentViewModel equipment)
|
||||||
|
{
|
||||||
|
public EquipmentViewModel Equipment { get; } = equipment;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using CommunityToolkit.Mvvm.Messaging.Messages;
|
||||||
|
using GazpromApp.ViewModels;
|
||||||
|
|
||||||
|
namespace GazpromApp.Messages;
|
||||||
|
|
||||||
|
public class EditEquipmentMessage(EquipmentViewModel equipment) : AsyncRequestMessage<EquipmentViewModel?>
|
||||||
|
{
|
||||||
|
public EquipmentViewModel Equipment { get; } = equipment;
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using GazpromApp.ViewModels;
|
||||||
|
|
||||||
|
namespace GazpromApp.Messages;
|
||||||
|
|
||||||
|
public class NewEquipmentDone(EquipmentViewModel equipment)
|
||||||
|
{
|
||||||
|
public EquipmentViewModel Equipment { get; } = equipment;
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
using CommunityToolkit.Mvvm.Messaging.Messages;
|
||||||
|
using GazpromApp.ViewModels;
|
||||||
|
|
||||||
|
namespace GazpromApp.Messages;
|
||||||
|
|
||||||
|
public class NewEquipmentMessage : AsyncRequestMessage<EquipmentViewModel?>;
|
||||||
+4
-2
@@ -10,15 +10,17 @@ public class Equipment
|
|||||||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public string Name { get; set; } = string.Empty;
|
public string? Name { get; set; } = string.Empty;
|
||||||
[Required]
|
[Required]
|
||||||
public string Description { get; set; } = string.Empty;
|
public string? Description { get; set; } = string.Empty;
|
||||||
[Required]
|
[Required]
|
||||||
public int PointId { get; set; }
|
public int PointId { get; set; }
|
||||||
public int ImageId { get; set; }
|
public int ImageId { get; set; }
|
||||||
|
public List<int> InspectionIds { get; set; } = [];
|
||||||
|
|
||||||
// EF stuff
|
// EF stuff
|
||||||
public Image? Image { get; set; }
|
public Image? Image { get; set; }
|
||||||
public Models.Point? Point { get; set; }
|
public Models.Point? Point { get; set; }
|
||||||
public List<Property> Properties { get; } = [];
|
public List<Property> Properties { get; } = [];
|
||||||
|
public List<Inspection> Inspections { get; } = [];
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace GazpromApp.Models;
|
||||||
|
|
||||||
|
public class Inspection
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
[Required]
|
||||||
|
public DateTime InspectionDate { get; set; }
|
||||||
|
public int EquipmentId { get; set; }
|
||||||
|
|
||||||
|
// EF stuff
|
||||||
|
public Equipment? Equipment { get; set; }
|
||||||
|
}
|
||||||
+1
-1
@@ -20,5 +20,5 @@ public class Point
|
|||||||
// EF stuff
|
// EF stuff
|
||||||
public List<Image> Images { get; set; } = [];
|
public List<Image> Images { get; set; } = [];
|
||||||
public List<Equipment> Equipment { get; set; } = [];
|
public List<Equipment> Equipment { get; set; } = [];
|
||||||
public List<Property> Properties { get; } = [];
|
public List<Property> Properties { get; set; } = [];
|
||||||
}
|
}
|
||||||
@@ -43,5 +43,9 @@ public class AppDbContext : DbContext
|
|||||||
.HasOne(e => e.Point)
|
.HasOne(e => e.Point)
|
||||||
.WithMany(e => e.Equipment)
|
.WithMany(e => e.Equipment)
|
||||||
.HasForeignKey(e => e.PointId);
|
.HasForeignKey(e => e.PointId);
|
||||||
|
modelBuilder.Entity<Equipment>()
|
||||||
|
.HasMany(e => e.Inspections)
|
||||||
|
.WithOne(e => e.Equipment)
|
||||||
|
.HasForeignKey(e => e.EquipmentId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using Avalonia.Media.Imaging;
|
||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using GazpromApp.Models;
|
||||||
|
|
||||||
|
namespace GazpromApp.ViewModels;
|
||||||
|
|
||||||
|
public partial class EquipmentViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
[ObservableProperty]
|
||||||
|
private string? _name;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private string? _description;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private ImageViewModel? _image;
|
||||||
|
|
||||||
|
public ObservableCollection<PropertyViewModel> Properties { get; set; }
|
||||||
|
|
||||||
|
public ObservableCollection<InspectionViewModel> Inspections { get; set; }
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private string _nearestInspection;
|
||||||
|
|
||||||
|
public EquipmentViewModel()
|
||||||
|
{
|
||||||
|
Name = string.Empty;
|
||||||
|
Description = string.Empty;
|
||||||
|
Image = null;
|
||||||
|
Properties = [];
|
||||||
|
Inspections = [];
|
||||||
|
NearestInspection = DateTime.Now.ToLongDateString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public EquipmentViewModel(Equipment equipment)
|
||||||
|
{
|
||||||
|
Name = equipment.Name;
|
||||||
|
Description = equipment.Description;
|
||||||
|
Image = new ImageViewModel(equipment.Image ?? new Image());
|
||||||
|
Properties = new ObservableCollection<PropertyViewModel>(equipment.Properties.Select(e => new PropertyViewModel(e)));
|
||||||
|
Inspections = new ObservableCollection<InspectionViewModel>(equipment.Inspections.Select(e => new InspectionViewModel(e)));
|
||||||
|
NearestInspection = DateTime.Now.ToLongDateString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Equipment GetEquipment()
|
||||||
|
{
|
||||||
|
return new Equipment()
|
||||||
|
{
|
||||||
|
Name = Name,
|
||||||
|
Description = Description,
|
||||||
|
Image = Image?.GetImage(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using GazpromApp.Models;
|
||||||
|
|
||||||
|
namespace GazpromApp.ViewModels;
|
||||||
|
|
||||||
|
public partial class InspectionViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
public InspectionViewModel()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public InspectionViewModel(Inspection inspection)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,6 +17,7 @@ public partial class PointViewModel : ViewModelBase
|
|||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private double? _longitude;
|
private double? _longitude;
|
||||||
|
|
||||||
// EF stuff
|
// EF stuff
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private List<Image>? _images;
|
private List<Image>? _images;
|
||||||
@@ -41,7 +42,9 @@ public partial class PointViewModel : ViewModelBase
|
|||||||
return new Models.Point()
|
return new Models.Point()
|
||||||
{
|
{
|
||||||
Name = this.Name,
|
Name = this.Name,
|
||||||
Description = this.Description
|
Description = this.Description,
|
||||||
|
Equipment = this.Equipment ?? [],
|
||||||
|
Properties = this.Properties ?? [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using GazpromApp.Models;
|
||||||
|
|
||||||
|
namespace GazpromApp.ViewModels;
|
||||||
|
|
||||||
|
public partial class PropertyViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
[ObservableProperty]
|
||||||
|
private string _name;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private string _value;
|
||||||
|
|
||||||
|
public ObservableCollection<PropertyViewModel> Properties { get; set; } = [];
|
||||||
|
|
||||||
|
public PropertyViewModel()
|
||||||
|
{
|
||||||
|
Name = string.Empty;
|
||||||
|
Value = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PropertyViewModel(Property property)
|
||||||
|
{
|
||||||
|
Name = property.Name;
|
||||||
|
Value = property.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace GazpromApp.ViewModels;
|
||||||
|
|
||||||
|
public class EditEquipmentDialogViewModel
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ using CommunityToolkit.Mvvm.Input;
|
|||||||
using CommunityToolkit.Mvvm.Messaging;
|
using CommunityToolkit.Mvvm.Messaging;
|
||||||
using GazpromApp.Messages;
|
using GazpromApp.Messages;
|
||||||
using GazpromApp.Models;
|
using GazpromApp.Models;
|
||||||
|
using GazpromApp.Views;
|
||||||
using Image = GazpromApp.Models.Image;
|
using Image = GazpromApp.Models.Image;
|
||||||
|
|
||||||
namespace GazpromApp.ViewModels;
|
namespace GazpromApp.ViewModels;
|
||||||
@@ -76,6 +77,34 @@ public partial class EditPointDialogViewModel : ViewModelBase
|
|||||||
_ = await WeakReferenceMessenger.Default.Send(new ViewImageMessage(image));
|
_ = await WeakReferenceMessenger.Default.Send(new ViewImageMessage(image));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ObservableCollection<EquipmentViewModel> Equipment { get; set; }
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
private async Task AddEquipment()
|
||||||
|
{
|
||||||
|
EquipmentViewModel? equipment = await WeakReferenceMessenger.Default.Send(new NewEquipmentMessage());
|
||||||
|
|
||||||
|
if (equipment != null)
|
||||||
|
Equipment.Add(equipment);
|
||||||
|
|
||||||
|
IsEquipmentEmpty = Equipment.Count == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
private async Task EditEquipment(EquipmentViewModel equipment)
|
||||||
|
{
|
||||||
|
EquipmentViewModel e = await WeakReferenceMessenger.Default.Send(new EditEquipmentMessage(equipment)) ?? equipment;
|
||||||
|
Equipment[Equipment.IndexOf(equipment)] = e;
|
||||||
|
}
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
private void DeleteEquipment(EquipmentViewModel equipment)
|
||||||
|
{
|
||||||
|
Equipment.Remove(equipment);
|
||||||
|
|
||||||
|
IsEquipmentEmpty = Equipment.Count == 0;
|
||||||
|
}
|
||||||
|
|
||||||
private bool CanCompleteEdit() => !string.IsNullOrWhiteSpace(Name);
|
private bool CanCompleteEdit() => !string.IsNullOrWhiteSpace(Name);
|
||||||
|
|
||||||
[RelayCommand(CanExecute = nameof(CanCompleteEdit))]
|
[RelayCommand(CanExecute = nameof(CanCompleteEdit))]
|
||||||
@@ -86,7 +115,8 @@ public partial class EditPointDialogViewModel : ViewModelBase
|
|||||||
{
|
{
|
||||||
Name = Name,
|
Name = Name,
|
||||||
Description = Description,
|
Description = Description,
|
||||||
Images = Images.Select(e => e.GetImage()).ToList()
|
Images = Images.Select(e => e.GetImage()).ToList(),
|
||||||
|
Equipment = Equipment.Select(e => e.GetEquipment()).ToList()
|
||||||
};
|
};
|
||||||
WeakReferenceMessenger.Default.Send(new EditPointDone(new PointViewModel(point)));
|
WeakReferenceMessenger.Default.Send(new EditPointDone(new PointViewModel(point)));
|
||||||
}
|
}
|
||||||
@@ -104,7 +134,7 @@ public partial class EditPointDialogViewModel : ViewModelBase
|
|||||||
private bool _isImagesEmpty;
|
private bool _isImagesEmpty;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool _isEquipmentEmpty = true;
|
private bool _isEquipmentEmpty;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool _isClosed;
|
private bool _isClosed;
|
||||||
@@ -116,7 +146,21 @@ public partial class EditPointDialogViewModel : ViewModelBase
|
|||||||
Name = "";
|
Name = "";
|
||||||
Description = "";
|
Description = "";
|
||||||
Images = [];
|
Images = [];
|
||||||
|
Equipment = [
|
||||||
|
new EquipmentViewModel
|
||||||
|
{
|
||||||
|
Name = "Equipment Name Very Long",
|
||||||
|
Description = "Really big description for the equipment to show the long textReally big description for the equipment to show the long textReally big description for the equipment to show the long textReally big description for the equipment to show the long text", Image = null
|
||||||
|
},
|
||||||
|
new EquipmentViewModel
|
||||||
|
{
|
||||||
|
Name = "Equipment Name Very Long",
|
||||||
|
Description = "Really big description for the equipment to show the long textReally big description for the equipment to show the long textReally big description for the equipment to show the long textReally big description for the equipment to show the long text", Image = null
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
IsImagesEmpty = true;
|
IsImagesEmpty = true;
|
||||||
|
IsEquipmentEmpty = true;
|
||||||
|
|
||||||
_point = new PointViewModel(new Point());
|
_point = new PointViewModel(new Point());
|
||||||
}
|
}
|
||||||
@@ -126,11 +170,10 @@ public partial class EditPointDialogViewModel : ViewModelBase
|
|||||||
Name = point.Name;
|
Name = point.Name;
|
||||||
Description = point.Description;
|
Description = point.Description;
|
||||||
Images = new ObservableCollection<ImageViewModel>((point.Images ?? []).Select(e => new ImageViewModel(e)));
|
Images = new ObservableCollection<ImageViewModel>((point.Images ?? []).Select(e => new ImageViewModel(e)));
|
||||||
foreach (ImageViewModel imageViewModel in Images)
|
Equipment = new ObservableCollection<EquipmentViewModel>((point.Equipment ?? []).Select(e => new EquipmentViewModel(e)));
|
||||||
{
|
|
||||||
Debug.WriteLine(imageViewModel.FileName);
|
|
||||||
}
|
|
||||||
IsImagesEmpty = Images.Count == 0;
|
IsImagesEmpty = Images.Count == 0;
|
||||||
|
IsEquipmentEmpty = Equipment.Count == 0;
|
||||||
|
|
||||||
_point = point;
|
_point = point;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public partial class MainWindowViewModel : ViewModelBase
|
|||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
private async Task AddPoint()
|
private async Task AddPoint()
|
||||||
{
|
{
|
||||||
var point = await WeakReferenceMessenger.Default.Send(new NewPointMessage());
|
PointViewModel? point = await WeakReferenceMessenger.Default.Send(new NewPointMessage());
|
||||||
|
|
||||||
if (point != null)
|
if (point != null)
|
||||||
Points.Add(point);
|
Points.Add(point);
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Web;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Media.Imaging;
|
||||||
|
using Avalonia.Platform.Storage;
|
||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
using CommunityToolkit.Mvvm.Input;
|
||||||
|
using CommunityToolkit.Mvvm.Messaging;
|
||||||
|
using GazpromApp.Messages;
|
||||||
|
using GazpromApp.Models;
|
||||||
|
|
||||||
|
namespace GazpromApp.ViewModels;
|
||||||
|
|
||||||
|
public partial class NewEquipmentDialogViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
[ObservableProperty]
|
||||||
|
[NotifyCanExecuteChangedFor(nameof(EnterEquipmentCommand))]
|
||||||
|
private string? _name;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
[NotifyCanExecuteChangedFor(nameof(EnterEquipmentCommand))]
|
||||||
|
private string? _description;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private ImageViewModel? _image;
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
private async Task AddImage(Window w)
|
||||||
|
{
|
||||||
|
IReadOnlyList<IStorageFile> files = await w.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions()
|
||||||
|
{
|
||||||
|
AllowMultiple = false,
|
||||||
|
Title = "Выберите картинку",
|
||||||
|
FileTypeFilter = [FilePickerFileTypes.ImageAll],
|
||||||
|
});
|
||||||
|
|
||||||
|
IsImageSelected = files.Count > 0;
|
||||||
|
|
||||||
|
Image = IsImageSelected ? new ImageViewModel(new Models.Image()) { FileName = new Bitmap(HttpUtility.UrlDecode(files[0].Path.AbsolutePath)) } : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
private void DeleteImage()
|
||||||
|
{
|
||||||
|
Image = null;
|
||||||
|
IsImageSelected = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool CanEnterEquipment() => !string.IsNullOrEmpty(Name);
|
||||||
|
|
||||||
|
[RelayCommand (CanExecute = nameof(CanEnterEquipment))]
|
||||||
|
private void EnterEquipment()
|
||||||
|
{
|
||||||
|
Equipment equipment = new Equipment()
|
||||||
|
{
|
||||||
|
Name = Name,
|
||||||
|
Description = Description ?? string.Empty,
|
||||||
|
Image = (Image ?? new ImageViewModel()).GetImage()
|
||||||
|
|
||||||
|
};
|
||||||
|
WeakReferenceMessenger.Default.Send(new NewEquipmentDone(new EquipmentViewModel(equipment)));
|
||||||
|
}
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
private static void CancelEnterEquipment(Window w)
|
||||||
|
{
|
||||||
|
w.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Visual and other stuff
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private bool _isImageSelected;
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
x:Class="GazpromApp.Views.EditEquipmentDialog"
|
||||||
|
Title="EditEquipmentDialog">
|
||||||
|
Welcome to Avalonia!
|
||||||
|
</Window>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
|
namespace GazpromApp.Views;
|
||||||
|
|
||||||
|
public partial class EditEquipmentDialog : Window
|
||||||
|
{
|
||||||
|
public EditEquipmentDialog()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -87,7 +87,54 @@
|
|||||||
<TabItem Header="Оборудование">
|
<TabItem Header="Оборудование">
|
||||||
<ScrollViewer>
|
<ScrollViewer>
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
|
<ItemsRepeater
|
||||||
|
IsVisible="{Binding !IsEquipmentEmpty}"
|
||||||
|
ItemsSource="{Binding Equipment}">
|
||||||
|
<ItemsRepeater.Layout>
|
||||||
|
<NonVirtualizingStackLayout Orientation="Vertical"/>
|
||||||
|
</ItemsRepeater.Layout>
|
||||||
|
<ItemsRepeater.ItemTemplate>
|
||||||
|
<DataTemplate DataType="vm:EquipmentViewModel">
|
||||||
|
<Expander HorizontalAlignment="Stretch" Margin="0,4,0,4">
|
||||||
|
<Expander.Header>
|
||||||
|
<Grid Height="54" HorizontalAlignment="Left"
|
||||||
|
ColumnDefinitions="52, 300, *, Auto">
|
||||||
|
<Image Height="50" Width="50" Margin="0,2,2,2" HorizontalAlignment="Center" Stretch="Uniform"
|
||||||
|
Source="{Binding Image.FileName, FallbackValue=null}"/>
|
||||||
|
<TextBlock Grid.Column="1" FontSize="20" VerticalAlignment="Center" Margin="4,0,0,0"
|
||||||
|
Text="{Binding Name}"/>
|
||||||
|
<TextBlock Grid.Column="2" FontSize="15" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Stretch"
|
||||||
|
Text="{Binding Description}"/>
|
||||||
|
</Grid>
|
||||||
|
</Expander.Header>
|
||||||
|
<Grid ColumnDefinitions="Auto, *, Auto, Auto">
|
||||||
|
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
|
||||||
|
<TextBlock FontSize="18" Text="Ближайший ТО: "/>
|
||||||
|
<TextBlock FontSize="18" Text="{Binding NearestInspection}"/>
|
||||||
|
<TextBlock FontSize="18" Text="Свойств: " Margin="18, 0,0,0"/>
|
||||||
|
<TextBlock FontSize="18" Text="{Binding Properties.Count}"/>
|
||||||
|
</StackPanel>
|
||||||
|
<Button Grid.Column="2"
|
||||||
|
Command="{Binding #Root.((vm:EditPointDialogViewModel)DataContext).EditEquipmentCommand}"
|
||||||
|
CommandParameter="{Binding .}"
|
||||||
|
Margin="4,0,4,0">
|
||||||
|
<Image Source="avares://GazpromApp/Assets/ic_fluent_edit_24_filled (Custom).png"/>
|
||||||
|
</Button>
|
||||||
|
<Button Grid.Column="3"
|
||||||
|
Command="{Binding #Root.((vm:EditPointDialogViewModel)DataContext).DeleteEquipmentCommand}"
|
||||||
|
CommandParameter="{Binding .}"
|
||||||
|
Margin="4,0,4,0">
|
||||||
|
<Image Source="avares://GazpromApp/Assets/ic_fluent_delete_24_filled (Custom).png"/>
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
|
</Expander>
|
||||||
|
</DataTemplate>
|
||||||
|
</ItemsRepeater.ItemTemplate>
|
||||||
|
</ItemsRepeater>
|
||||||
|
<Button Height="30" Width="30" HorizontalAlignment="Center" Margin="0,20,0,0"
|
||||||
|
Command="{Binding AddEquipmentCommand}">
|
||||||
|
<Image Height="24" Width="24" Source="avares://GazpromApp/Assets/ic_fluent_add_24_filled (Custom).png"/>
|
||||||
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|||||||
@@ -28,6 +28,31 @@ public partial class EditPointDialog : Window
|
|||||||
m.Reply(dialog.ShowDialog<ImageViewModel?>(w));
|
m.Reply(dialog.ShowDialog<ImageViewModel?>(w));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// new equipment
|
||||||
|
WeakReferenceMessenger.Default.Register<EditPointDialog, NewEquipmentMessage>(this, static (w, m) =>
|
||||||
|
{
|
||||||
|
NewEquipmentDialog dialog = new NewEquipmentDialog()
|
||||||
|
{
|
||||||
|
DataContext = new NewEquipmentDialogViewModel()
|
||||||
|
};
|
||||||
|
m.Reply(dialog.ShowDialog<EquipmentViewModel?>(w));
|
||||||
|
});
|
||||||
|
|
||||||
|
// edit equipment
|
||||||
|
WeakReferenceMessenger.Default.Register<EditPointDialog, EditEquipmentMessage>(this, static (w, m) =>
|
||||||
|
{
|
||||||
|
EditEquipmentDialog dialog = new EditEquipmentDialog()
|
||||||
|
{
|
||||||
|
DataContext = m.Equipment
|
||||||
|
};
|
||||||
|
m.Reply(dialog.ShowDialog<EquipmentViewModel?>(w));
|
||||||
|
});
|
||||||
|
|
||||||
|
// new property
|
||||||
|
|
||||||
|
// edit property
|
||||||
|
|
||||||
|
// complete editing point
|
||||||
WeakReferenceMessenger.Default.Register<EditPointDialog, EditPointDone>(this, static (w, m) =>
|
WeakReferenceMessenger.Default.Register<EditPointDialog, EditPointDone>(this, static (w, m) =>
|
||||||
{
|
{
|
||||||
w.Close(m.Point);
|
w.Close(m.Point);
|
||||||
@@ -43,5 +68,10 @@ public partial class EditPointDialog : Window
|
|||||||
private void Window_OnClosed(object? sender, EventArgs e)
|
private void Window_OnClosed(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
WeakReferenceMessenger.Default.Unregister<ViewImageMessage>(this);
|
WeakReferenceMessenger.Default.Unregister<ViewImageMessage>(this);
|
||||||
|
WeakReferenceMessenger.Default.Unregister<NewEquipmentMessage>(this);
|
||||||
|
WeakReferenceMessenger.Default.Unregister<EditEquipmentMessage>(this);
|
||||||
|
// new prop
|
||||||
|
// edit prop
|
||||||
|
WeakReferenceMessenger.Default.Unregister<EditPointDone>(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,8 @@
|
|||||||
x:DataType="vm:MainWindowViewModel"
|
x:DataType="vm:MainWindowViewModel"
|
||||||
Icon="/Assets/avalonia-logo.ico"
|
Icon="/Assets/avalonia-logo.ico"
|
||||||
Title="GazpromApp"
|
Title="GazpromApp"
|
||||||
WindowStartupLocation="CenterScreen">
|
WindowStartupLocation="CenterScreen"
|
||||||
|
>
|
||||||
|
|
||||||
<Design.DataContext>
|
<Design.DataContext>
|
||||||
<!-- This only sets the DataContext for the previewer in an IDE,
|
<!-- This only sets the DataContext for the previewer in an IDE,
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:vm="using:GazpromApp.ViewModels"
|
||||||
|
x:Name="Window"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="500" d:DesignHeight="500"
|
||||||
|
Width="500" Height="500"
|
||||||
|
x:Class="GazpromApp.Views.NewEquipmentDialog"
|
||||||
|
x:DataType="vm:NewEquipmentDialogViewModel"
|
||||||
|
Title="Создание нового оборудования"
|
||||||
|
WindowStartupLocation="CenterOwner"
|
||||||
|
Closed="Window_OnClosed">
|
||||||
|
<Design.DataContext>
|
||||||
|
<vm:NewEquipmentDialogViewModel/>
|
||||||
|
</Design.DataContext>
|
||||||
|
<Grid x:Name="Root">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition MaxWidth="120"/>
|
||||||
|
<ColumnDefinition MinWidth="300"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition MaxHeight="50"/>
|
||||||
|
<RowDefinition MaxHeight="100"/>
|
||||||
|
<RowDefinition MinHeight="200" Height="*"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<TextBlock Grid.Column="0" Grid.Row="0" Margin="8" Text="Название: "/>
|
||||||
|
<TextBlock Grid.Column="0" Grid.Row="1" Margin="8" Text="Описание: "/>
|
||||||
|
<TextBlock Grid.Column="0" Grid.Row="2" Margin="8" Text="Изображение: "/>
|
||||||
|
<TextBox Grid.Column="1" Grid.Row="0" Margin="8"
|
||||||
|
Text="{Binding Name}"/>
|
||||||
|
<TextBox Grid.Column="1" Grid.Row="1" Margin="8"
|
||||||
|
Text="{Binding Description}"/>
|
||||||
|
|
||||||
|
<Grid Grid.Column="1" Grid.Row="2" Margin="2"
|
||||||
|
ColumnDefinitions="*,20,8,20,8" RowDefinitions="8,20,*"
|
||||||
|
IsVisible="True">
|
||||||
|
<Image Stretch="Uniform" Grid.RowSpan="3" Grid.ColumnSpan="3"
|
||||||
|
Source="{Binding Image.FileName, FallbackValue=null}"/>
|
||||||
|
<Button Grid.Row="1" Grid.Column="1" Width="20" Height="20"
|
||||||
|
IsVisible="{Binding IsImageSelected}"
|
||||||
|
Command="{Binding AddImageCommand}"
|
||||||
|
CommandParameter="{Binding #Window}">
|
||||||
|
<Image Width="16" Height="16" Source="avares://GazpromApp/Assets/ic_fluent_edit_24_filled (Custom) 16.png"/>
|
||||||
|
</Button>
|
||||||
|
<Button Grid.Row="1" Grid.Column="3" Width="20" Height="20"
|
||||||
|
IsVisible="{Binding IsImageSelected}"
|
||||||
|
Command="{Binding DeleteImageCommand}">
|
||||||
|
<Image Width="16" Height="16" Source="avares://GazpromApp/Assets/ic_fluent_delete_24_filled (Custom) 16.png"/>
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
|
<Button Grid.Row="2" Grid.Column="1" HorizontalAlignment="Center"
|
||||||
|
IsVisible="{Binding !IsImageSelected}"
|
||||||
|
Command="{Binding AddImageCommand}"
|
||||||
|
CommandParameter="{Binding #Window}">
|
||||||
|
<Image Width="24" Source="avares://GazpromApp/Assets/ic_fluent_camera_add_24_filled (Custom).png"/>
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<Button Grid.Column="0" Grid.Row="3" Margin="8" Content="Отменить"
|
||||||
|
Command="{Binding CancelEnterEquipmentCommand}"
|
||||||
|
CommandParameter="{Binding #Window}"/>
|
||||||
|
<Button Grid.Column="1" Grid.Row="3" Margin="8" Content="Добавить" HorizontalAlignment="Right"
|
||||||
|
Command="{Binding EnterEquipmentCommand}"/>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using CommunityToolkit.Mvvm.Messaging;
|
||||||
|
using GazpromApp.Messages;
|
||||||
|
|
||||||
|
namespace GazpromApp.Views;
|
||||||
|
|
||||||
|
public partial class NewEquipmentDialog : Window
|
||||||
|
{
|
||||||
|
public NewEquipmentDialog()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
WeakReferenceMessenger.Default.Register<NewEquipmentDialog, NewEquipmentDone>(this, static (w, m) =>
|
||||||
|
{
|
||||||
|
w.Close(m.Equipment);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Window_OnClosed(object? sender, EventArgs e)
|
||||||
|
{
|
||||||
|
WeakReferenceMessenger.Default.Unregister<NewEquipmentDone>(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -44,7 +44,8 @@
|
|||||||
<Border Margin="4" CornerRadius="4" Background="LightGray">
|
<Border Margin="4" CornerRadius="4" Background="LightGray">
|
||||||
<Grid Margin="2" Width="200" Height="200" Background="LightGray"
|
<Grid Margin="2" Width="200" Height="200" Background="LightGray"
|
||||||
ColumnDefinitions="*,20,8" RowDefinitions="8,20,*">
|
ColumnDefinitions="*,20,8" RowDefinitions="8,20,*">
|
||||||
<Image Stretch="Uniform" Width="200" Height="200" Grid.RowSpan="3" Grid.ColumnSpan="3" Source="{Binding FileName}" />
|
<Image Stretch="Uniform" Width="200" Height="200" Grid.RowSpan="3" Grid.ColumnSpan="3"
|
||||||
|
Source="{Binding FileName}" />
|
||||||
<Button Grid.Row="1" Grid.Column="1" Width="20" Height="20"
|
<Button Grid.Row="1" Grid.Column="1" Width="20" Height="20"
|
||||||
Command="{Binding #Root.((vm:NewPointDialogViewModel)DataContext).DeleteImageCommand}"
|
Command="{Binding #Root.((vm:NewPointDialogViewModel)DataContext).DeleteImageCommand}"
|
||||||
CommandParameter="{Binding .}">
|
CommandParameter="{Binding .}">
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
288757c38000c6b91b144251be635a8c5a7164190b6b87d309783f2ccc53212a
|
41a928e641efcd3e89b584959a8b8be084763735298d1e3a4ead534f873c57ec
|
||||||
|
|||||||
Binary file not shown.
@@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("GazpromApp")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("GazpromApp")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+044372eada717f33e07ad756f7ace116ab7fb9a3")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+812a13e5bb0a09295ee40845a12a0c855bb7376f")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("GazpromApp")]
|
[assembly: System.Reflection.AssemblyProductAttribute("GazpromApp")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("GazpromApp")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("GazpromApp")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
b6d09973f42f27742b27a1ce04303c8022bca7cb68cd245879c5b37de41be396
|
9e16bd1a0b8f6b51c35ae0e4fe20412558f0d499fbae32e7c62ee506cbe91b95
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
17514594140227201
|
17514599119483488
|
||||||
Reference in New Issue
Block a user