Properties added
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using GazpromApp.Models;
|
||||
|
||||
namespace GazpromApp.ViewModels;
|
||||
|
||||
|
||||
public partial class PropertyViewModel : ViewModelBase
|
||||
{
|
||||
[ObservableProperty]
|
||||
@@ -12,17 +15,50 @@ public partial class PropertyViewModel : ViewModelBase
|
||||
[ObservableProperty]
|
||||
private string _value;
|
||||
|
||||
public ObservableCollection<PropertyViewModel> Properties { get; set; } = [];
|
||||
public ObservableCollection<PropertyViewModel> Properties { get; set; }
|
||||
|
||||
// Visual and other properties
|
||||
|
||||
public PropertyViewModel? Parent { get; set; }
|
||||
|
||||
[ObservableProperty]
|
||||
private bool _isEditing;
|
||||
|
||||
public PropertyViewModel()
|
||||
public Property GetProperty(Property? parent = null)
|
||||
{
|
||||
Name = string.Empty;
|
||||
Value = string.Empty;
|
||||
Property p = new Property
|
||||
{
|
||||
Name = Name,
|
||||
Value = Value,
|
||||
Properties = [],
|
||||
Parent = parent
|
||||
};
|
||||
p.Properties = Properties.Select(e => e.GetProperty(p)).ToList();
|
||||
return p;
|
||||
}
|
||||
|
||||
public PropertyViewModel(Property property)
|
||||
public PropertyViewModel()
|
||||
{
|
||||
Name = "Имя свойства";
|
||||
Value = "Значение свойства";
|
||||
Properties = [];
|
||||
Parent = null;
|
||||
}
|
||||
|
||||
public PropertyViewModel(Property property, PropertyViewModel? parent = null)
|
||||
{
|
||||
Name = property.Name;
|
||||
Value = property.Value;
|
||||
Properties = new ObservableCollection<PropertyViewModel>(
|
||||
property.Properties.Select(e => new PropertyViewModel(e, this)));
|
||||
Parent = property.Parent is null ? null : parent;
|
||||
}
|
||||
|
||||
public PropertyViewModel(PropertyViewModel property)
|
||||
{
|
||||
Name = "Имя свойства";
|
||||
Value = "Значение свойства";
|
||||
Properties = [];
|
||||
Parent = property;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user