From 6aa3c687ce49fb39447768b5c32f23921693ce57 Mon Sep 17 00:00:00 2001 From: Darkstack <1835601+darkstack@users.noreply.github.com> Date: Sat, 1 Jun 2019 00:23:14 +0200 Subject: [PATCH] Small fixes --- .../ViewModels/TournamentResultViewModel.cs | 16 ++++++++++------ .../LaDOSE.DesktopApp/Views/ShellView.xaml | 6 +++--- .../Views/TournamentResultView.xaml | 19 +++++++++++-------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/TournamentResultViewModel.cs b/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/TournamentResultViewModel.cs index 46e892a..e23910e 100644 --- a/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/TournamentResultViewModel.cs +++ b/LaDOSE.Src/LaDOSE.DesktopApp/ViewModels/TournamentResultViewModel.cs @@ -211,8 +211,9 @@ namespace LaDOSE.DesktopApp.ViewModels StringBuilder sb = new StringBuilder(); DataTable grid = new DataTable(); + var games = Results.Games.Distinct().OrderBy(e=>e.Order).ToList(); grid.Columns.Add("Players"); - Results.Games.ForEach(e => grid.Columns.Add(e.Name.Replace('.',' '))); + games.ForEach(e => grid.Columns.Add(e.Name.Replace('.',' '))); grid.Columns.Add("Total").DataType = typeof(Int32); @@ -222,10 +223,10 @@ namespace LaDOSE.DesktopApp.ViewModels var resultsParticipent = resultsParticipents[i]; int total = 0; dataRow["Players"] = resultsParticipent.Name; - var gameDtos = Results.Games.Distinct().ToList(); + - for (int j = 0; j < gameDtos.Count; j++) + for (int j = 0; j < games.Count; j++) { var resultsGame = Results.Games[j]; var dictionary = computed[resultsParticipent.Name]; @@ -258,22 +259,25 @@ namespace LaDOSE.DesktopApp.ViewModels private void ExportToCSV() { + + if (this.GridDataTable != null) { - + var dataTable = this.GridDataTable.DefaultView.ToTable(); SaveFileDialog sfDialog = new SaveFileDialog() { + Filter = "Text Files (*.csv)|*.csv|All Files (*.*)|*.*", AddExtension = true }; if (sfDialog.ShowDialog() == true) { StringBuilder sb = new StringBuilder(); - IEnumerable columnNames = this.GridDataTable.Columns.Cast() + IEnumerable columnNames = dataTable.Columns.Cast() .Select(column => column.ColumnName); sb.AppendLine(string.Join(";", columnNames)); - foreach (DataRow row in this.GridDataTable.Rows) + foreach (DataRow row in dataTable.Rows) { //EXCEL IS A BITCH IEnumerable fields = row.ItemArray.Select(field => diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/Views/ShellView.xaml b/LaDOSE.Src/LaDOSE.DesktopApp/Views/ShellView.xaml index 0ac4764..40609ba 100644 --- a/LaDOSE.Src/LaDOSE.DesktopApp/Views/ShellView.xaml +++ b/LaDOSE.Src/LaDOSE.DesktopApp/Views/ShellView.xaml @@ -39,7 +39,7 @@ - + @@ -50,8 +50,8 @@ - - + + diff --git a/LaDOSE.Src/LaDOSE.DesktopApp/Views/TournamentResultView.xaml b/LaDOSE.Src/LaDOSE.DesktopApp/Views/TournamentResultView.xaml index 4ad5480..8dce216 100644 --- a/LaDOSE.Src/LaDOSE.DesktopApp/Views/TournamentResultView.xaml +++ b/LaDOSE.Src/LaDOSE.DesktopApp/Views/TournamentResultView.xaml @@ -21,10 +21,10 @@ - + - - + +