From 11468cf4af56b8baf53652c3c22f92783738493e Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 31 Dec 2016 10:06:58 +1100 Subject: [PATCH] Syle: Less LINQ --- GUI/Window.cs | 16 +++++++++++----- GUI/app.config | 6 ++++++ 2 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 GUI/app.config diff --git a/GUI/Window.cs b/GUI/Window.cs index 798bfe951..8c54d7b4f 100644 --- a/GUI/Window.cs +++ b/GUI/Window.cs @@ -19,7 +19,6 @@ using System; using System.Collections.Generic; using System.Drawing; using System.IO; -using System.Linq; using System.Threading; using System.Windows.Forms; @@ -230,9 +229,13 @@ namespace MCGalaxy.Gui { main_Maps.DataSource = lc; // Try to keep the same selection on update - string selected = null; + List selected = null; if (lc.Count > 0 && main_Maps.SelectedRows.Count > 0) { - selected = (from DataGridViewRow row in main_Maps.Rows where row.Selected select lc[row.Index]).First().name; + selected = new List(); + foreach (DataGridViewRow row in main_Maps.SelectedRows) { + string lvlName = (string)row.Cells[0].Value; + selected.Add(lvlName); + } } // Update the data source and control @@ -261,10 +264,13 @@ namespace MCGalaxy.Gui { //dgvPlayers.Invalidate(); main_Maps.DataSource = null; main_Maps.DataSource = lc; + // Reselect map if (selected != null) { - foreach (DataGridViewRow row in Server.levels.SelectMany(l => main_Maps.Rows.Cast().Where(row => (string)row.Cells[0].Value == selected))) - row.Selected = true; + foreach (DataGridViewRow row in main_Maps.Rows) { + string lvlName = (string)row.Cells[0].Value; + if (selected.Contains(lvlName)) row.Selected = true; + } } main_Maps.Refresh(); diff --git a/GUI/app.config b/GUI/app.config new file mode 100644 index 000000000..88f2be5e2 --- /dev/null +++ b/GUI/app.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file