Files
GazpromApp/ViewModels/MainWindowViewModel.cs
T
2025-06-30 20:13:36 +03:00

40 lines
1.0 KiB
C#

using CommunityToolkit.Mvvm.ComponentModel;
namespace GazpromApp.ViewModels;
using GazpromApp.Messages;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Threading.Tasks;
public partial class MainWindowViewModel : ViewModelBase
{
public ObservableCollection<PointViewModel> Points { get; } = new ObservableCollection<PointViewModel>();
[RelayCommand]
private async Task AddPoint()
{
var point = await WeakReferenceMessenger.Default.Send(new NewPointMessage());
if (point != null)
Points.Add(point);
IsLineVisible = true;
}
[RelayCommand]
private void RemovePoint(PointViewModel point)
{
Points.Remove(point);
if (Points.Count == 0)
IsLineVisible = false;
}
[RelayCommand]
private void EditPoint(PointViewModel point)
{
Debug.WriteLine(point.Name);
}
[ObservableProperty]
private bool _isLineVisible;
}