4f5530c87e
TODO: Generate Points distinct from eachother
50 lines
1.4 KiB
C#
50 lines
1.4 KiB
C#
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<Geometries.Point> Points { get; } = new();
|
|
public ObservableCollection<Geometries.Edge> Edges { get; } = new();
|
|
public ObservableCollection<Geometries.Circle> 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);
|
|
}
|
|
} |