From 17cb6d559655a02cc657aaed7f6d325a3173931b Mon Sep 17 00:00:00 2001 From: hbeham Date: Tue, 12 Jan 2016 19:02:14 +0100 Subject: [PATCH] - fixed error message popup at startup - fixed keeping rows at position when only updating single rows --- ServerBrowser/Games/QuakeLive.cs | 8 +++--- ServerBrowser/GeoIpClient.cs | 2 +- ServerBrowser/Program.cs | 1 + ServerBrowser/ServerBrowserForm.cs | 42 +++++++++++++++++++++--------- ServerBrowser/ServerQueryLogic.cs | 2 +- changelog.md | 5 ++++ 6 files changed, 43 insertions(+), 17 deletions(-) diff --git a/ServerBrowser/Games/QuakeLive.cs b/ServerBrowser/Games/QuakeLive.cs index 1b28f95..9b53bf3 100644 --- a/ServerBrowser/Games/QuakeLive.cs +++ b/ServerBrowser/Games/QuakeLive.cs @@ -213,13 +213,16 @@ private void LoadQlstatsPersonalRating() { var rating = ratings[i]; if (rating == null) continue; - text += $"\n{gametypes[i].ToUpper()}: {rating.r}­ ± {rating.rd} ({rating.games} games)"; + text += $"\n{gametypes[i].ToUpper()}: {rating.r} ± {rating.rd} ({rating.games} games)"; } if (gametypes.Length == 0) text = ""; } - this.colSkill.ToolTip = SkillTooltip + text; + this.colSkill.View.GridControl.BeginInvoke((Action) (() => + { + this.colSkill.ToolTip = SkillTooltip + text; + })); } } catch @@ -260,7 +263,6 @@ private void LoadQlstatsServerRatings() if (info != null) row.PlayerCount.Update(); } - view.RefreshData(); })); } } diff --git a/ServerBrowser/GeoIpClient.cs b/ServerBrowser/GeoIpClient.cs index 6fbd2c5..018c0dc 100644 --- a/ServerBrowser/GeoIpClient.cs +++ b/ServerBrowser/GeoIpClient.cs @@ -53,7 +53,7 @@ private void ProcessLoop() object o; Action callbacks; lock (cache) - callbacks = cache.TryGetValue(ipInt, out o) ? (Action)o : null; + callbacks = cache.TryGetValue(ipInt, out o) ? o as Action : null; var geoInfo = this.HandleResult(ipInt, result); if (callbacks != null) ThreadPool.QueueUserWorkItem(ctx => callbacks(geoInfo)); diff --git a/ServerBrowser/Program.cs b/ServerBrowser/Program.cs index e6ee6a6..bacf5ed 100644 --- a/ServerBrowser/Program.cs +++ b/ServerBrowser/Program.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.Drawing; using System.Threading; using System.Windows.Forms; diff --git a/ServerBrowser/ServerBrowserForm.cs b/ServerBrowser/ServerBrowserForm.cs index 4064bac..5a0a877 100644 --- a/ServerBrowser/ServerBrowserForm.cs +++ b/ServerBrowser/ServerBrowserForm.cs @@ -30,7 +30,7 @@ namespace ServerBrowser { public partial class ServerBrowserForm : XtraForm { - private const string Version = "2.25"; + private const string Version = "2.25.1"; private const string DevExpressVersion = "v15.1"; private const string CustomDetailColumnPrefix = "ServerInfo."; private const string CustomRuleColumnPrefix = "custRule."; @@ -55,6 +55,7 @@ public partial class ServerBrowserForm : XtraForm private readonly string iniPath; private readonly IniFile iniFile; private XtraTabPage dragPage; + private bool isSingleRowUpdate = true; private const int PredefinedTabCount = 2; #region ctor() @@ -784,6 +785,7 @@ protected void ReloadServerList() if (this.viewModel.InitialGameID == 0) // this would result in a truncated list of all games return; + this.isSingleRowUpdate = false; this.SetStatusMessage("Requesting server list from master server..."); this.miStopUpdate.Enabled = true; this.timerReloadServers.Stop(); @@ -810,6 +812,7 @@ private void RefreshServerInfo() { if (this.queryLogic.IsUpdating) return; + this.isSingleRowUpdate = false; this.miStopUpdate.Enabled = true; this.timerReloadServers.Stop(); this.SetStatusMessage("Updating status of " + this.viewModel.servers.Count + " servers..."); @@ -929,6 +932,14 @@ protected void UpdateViews(bool forceUpdateDetails = false) ++ignoreUiEvents; + // special logic for single-row updates to prevent reordering of rows + if (this.isSingleRowUpdate) + { + this.RefreshDataInSelectedRows(); + --ignoreUiEvents; + return; + } + var topRow = this.gvServers.TopRowIndex; this.gvServers.BeginDataUpdate(); @@ -971,6 +982,15 @@ protected void UpdateViews(bool forceUpdateDetails = false) } #endregion + #region RefreshDataInSelectedRows() + private void RefreshDataInSelectedRows() + { + var sel = this.gvServers.GetSelectedRows(); + foreach (var handle in sel) + this.gvServers.RefreshRow(handle); + } + #endregion + #region UpdateCachedServerNames() private void UpdateCachedServerNames() { @@ -1339,6 +1359,7 @@ protected virtual void queryLogic_ReloadServerListComplete(List rows) this.CheckAlertCondition(); if (this.spinRefreshInterval.Value > 0) this.timerReloadServers.Start(); + this.isSingleRowUpdate = true; } #endregion @@ -1347,15 +1368,10 @@ protected virtual void queryLogic_ReloadServerListComplete(List rows) protected virtual void queryLogic_RefreshSingleServerComplete(ServerEventArgs e) { this.UpdateBuddyCount(e.Server); - - if (this.gvServers.GetFocusedRow() == e.Server) - { - if (this.gvServers.SelectedRowsCount <= 1) - this.gvServers.RefreshRow(this.gvServers.FocusedRowHandle); - else - this.gvServers.RefreshData(); - this.UpdateGridDataSources(); - } + var idx = this.viewModel?.servers?.IndexOf(e.Server) ?? -1; + if (idx >= 0) + this.gvServers.RefreshRow(this.gvServers.GetRowHandle(idx)); + this.UpdateGridDataSources(); } #endregion @@ -1990,14 +2006,16 @@ private void miUpdateServerInfo_ItemClick(object sender, ItemClickEventArgs e) { this.RefreshGameExtensions(); if (this.gvServers.SelectedRowsCount == 1) + { this.queryLogic.RefreshSingleServer((ServerRow) this.gvServers.GetFocusedRow()); + } else { var list = new List(); foreach (var handle in this.gvServers.GetSelectedRows()) - list.Add((ServerRow)this.gvServers.GetRow(handle)); + list.Add((ServerRow) this.gvServers.GetRow(handle)); this.queryLogic.RefreshAllServers(list); - } + } } #endregion diff --git a/ServerBrowser/ServerQueryLogic.cs b/ServerBrowser/ServerQueryLogic.cs index 2035afd..4f6c32b 100644 --- a/ServerBrowser/ServerQueryLogic.cs +++ b/ServerBrowser/ServerQueryLogic.cs @@ -137,7 +137,7 @@ public void Cancel() this.currentRequest.IsCancelled = true; } #endregion - + // reload server list #region ReloadServerList() diff --git a/changelog.md b/changelog.md index b12f24d..c2c7553 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,8 @@ +2.25.1 +--- +- fixed error message popup at startup +- fixed keeping rows at position when only updating single rows + 2.25 --- - added control to turn ghost player filter on/off