add csv import
This commit is contained in:
@ -12,18 +12,18 @@
|
||||
<kMeansGui:ShellViewModel />
|
||||
</Window.DataContext>
|
||||
<Grid ColumnDefinitions="*,*">
|
||||
<StackPanel Grid.Row="0" Grid.Column="0" Spacing="10">
|
||||
<StackPanel Grid.Row="0" Grid.Column="0" Spacing="10" Margin="10">
|
||||
<Button HorizontalAlignment="Stretch" Command="{Binding OpenCsvFileAsync}"
|
||||
CommandParameter="{Binding ElementName=LayoutRoot}">
|
||||
CommandParameter="{Binding ElementName=LayoutRoot}" HorizontalContentAlignment="Center">
|
||||
Load CSV file
|
||||
</Button>
|
||||
<TextBox UseFloatingWatermark="True" Watermark="Hello" Text="{Binding CountOfCentroids}"></TextBox>
|
||||
<TextBox UseFloatingWatermark="True" Watermark="Count of centroids" Text="{Binding CountOfCentroids}" />
|
||||
</StackPanel>
|
||||
<avalonia:Plot Height="150" Grid.Column="1"
|
||||
<avalonia:Plot Grid.Column="1"
|
||||
PlotMargins="50 0 0 0"
|
||||
PlotAreaBorderColor="#999999">
|
||||
<avalonia:Plot.Series>
|
||||
<avalonia:ScatterSeries Items="{Binding Points}" />
|
||||
<avalonia:ScatterSeries Items="{Binding Points}" DataFieldX="X" DataFieldY="Y" />
|
||||
</avalonia:Plot.Series>
|
||||
</avalonia:Plot>
|
||||
</Grid>
|
||||
|
@ -1,6 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.Controls;
|
||||
using KMeansBase;
|
||||
using MvvmGen;
|
||||
|
||||
namespace KMeansGui
|
||||
@ -9,7 +11,7 @@ namespace KMeansGui
|
||||
public partial class ShellViewModel
|
||||
{
|
||||
[Property] private int _countOfCentroids;
|
||||
[Property] private List<KMeansBase.Point> _points;
|
||||
[Property] private List<Point> _points;
|
||||
|
||||
public async Task OpenCsvFileAsync(object parent)
|
||||
{
|
||||
@ -24,6 +26,11 @@ namespace KMeansGui
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user