using System; using System.Collections.ObjectModel; using System.ComponentModel; using CommunityToolkit.Mvvm.ComponentModel; using DelauneyTriangulation.Models; namespace DelauneyTriangulation.ViewModels; public partial class MainWindowViewModel : ViewModelBase { private int _pointCount = 20; [ObservableProperty] private double _panX; [ObservableProperty] private double _panY; [ObservableProperty] private double _zoom = 1.0; public double Width { get; set; } = 1280; public double Height { get; set; } = 720; public int PointCount { get => _pointCount; set { _pointCount = value; OnPropertyChanged(nameof(PointCount)); GenerateRandomPoints(value); } } public ObservableCollection Points { get; } = new(); public ObservableCollection Edges { get; } = new(); public ObservableCollection Circles { get; } = new(); void GenerateRandomPoints(int count) { Points.Clear(); var rand = new Random(); for (var i = 0; i < PointCount; i++) { var x = rand.NextDouble() * Width; var y = rand.NextDouble() * Height; Points.Add(new Geometries.Point(x, y)); } } public MainWindowViewModel() { GenerateRandomPoints(_pointCount); } }