37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Avalonia.Controls;
|
|
using KMeansBase;
|
|
using MvvmGen;
|
|
|
|
namespace KMeansGui
|
|
{
|
|
[ViewModel]
|
|
public partial class ShellViewModel
|
|
{
|
|
[Property] private int _countOfCentroids;
|
|
[Property] private List<Point> _points;
|
|
|
|
public async Task OpenCsvFileAsync(object parent)
|
|
{
|
|
if (parent is Window window)
|
|
{
|
|
var fileDialogFilter = new FileDialogFilter();
|
|
fileDialogFilter.Extensions.Add("csv");
|
|
fileDialogFilter.Name = "comma separated file";
|
|
var fileDialog = new OpenFileDialog();
|
|
fileDialog.AllowMultiple = false;
|
|
|
|
fileDialog.Filters.Add(fileDialogFilter);
|
|
fileDialog.Title = "Select a csv file.";
|
|
var result = await fileDialog.ShowAsync(window);
|
|
if (result?.Length == 1)
|
|
{
|
|
var path = result.First();
|
|
Points = Csv.Parse(path).ToList();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |