diff --git a/ServerBrowser/Properties/Settings.Designer.cs b/ServerBrowser/Properties/Settings.Designer.cs index 9e6d167..d974eb7 100644 --- a/ServerBrowser/Properties/Settings.Designer.cs +++ b/ServerBrowser/Properties/Settings.Designer.cs @@ -299,5 +299,17 @@ public int TabIndex { this["TabIndex"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("False")] + public bool ColumnLayoutPerTab { + get { + return ((bool)(this["ColumnLayoutPerTab"])); + } + set { + this["ColumnLayoutPerTab"] = value; + } + } } } diff --git a/ServerBrowser/Properties/Settings.settings b/ServerBrowser/Properties/Settings.settings index 21477bd..43eb574 100644 --- a/ServerBrowser/Properties/Settings.settings +++ b/ServerBrowser/Properties/Settings.settings @@ -71,5 +71,8 @@ 0 + + False + \ No newline at end of file diff --git a/ServerBrowser/ServerBrowserForm.Designer.cs b/ServerBrowser/ServerBrowserForm.Designer.cs index f8e2a0a..d50039c 100644 --- a/ServerBrowser/ServerBrowserForm.Designer.cs +++ b/ServerBrowser/ServerBrowserForm.Designer.cs @@ -150,6 +150,7 @@ private void InitializeComponent() this.linkFilter1 = new DevExpress.XtraEditors.HyperlinkLabelControl(); this.timerUpdateServerList = new System.Windows.Forms.Timer(this.components); this.panelOptions = new DevExpress.XtraEditors.PanelControl(); + this.cbRememberColumnLayout = new DevExpress.XtraEditors.CheckEdit(); this.rbUpdateStatusOnly = new DevExpress.XtraEditors.CheckEdit(); this.cbFavServersOnTop = new DevExpress.XtraEditors.CheckEdit(); this.rbAddressGamePort = new DevExpress.XtraEditors.CheckEdit(); @@ -222,6 +223,7 @@ private void InitializeComponent() this.tabControl.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.panelOptions)).BeginInit(); this.panelOptions.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.cbRememberColumnLayout.Properties)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.rbUpdateStatusOnly.Properties)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.cbFavServersOnTop.Properties)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.rbAddressGamePort.Properties)).BeginInit(); @@ -1511,7 +1513,7 @@ private void InitializeComponent() // cbRefreshSelectedServer // this.cbRefreshSelectedServer.EditValue = true; - this.cbRefreshSelectedServer.Location = new System.Drawing.Point(350, 71); + this.cbRefreshSelectedServer.Location = new System.Drawing.Point(350, 53); this.cbRefreshSelectedServer.Name = "cbRefreshSelectedServer"; this.cbRefreshSelectedServer.Properties.AutoWidth = true; this.cbRefreshSelectedServer.Properties.Caption = "Update status when selecting a server"; @@ -1626,6 +1628,8 @@ private void InitializeComponent() this.comboGames.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)}); this.comboGames.Properties.DropDownRows = 30; + this.comboGames.Properties.NullValuePrompt = "Select game or enter numeric Steam AppID"; + this.comboGames.Properties.NullValuePromptShowForEmptyValue = true; this.comboGames.Size = new System.Drawing.Size(268, 20); this.comboGames.TabIndex = 5; this.comboGames.SelectedIndexChanged += new System.EventHandler(this.comboGames_SelectedIndexChanged); @@ -1809,6 +1813,7 @@ private void InitializeComponent() // panelOptions // this.panelOptions.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder; + this.panelOptions.Controls.Add(this.cbRememberColumnLayout); this.panelOptions.Controls.Add(this.rbUpdateStatusOnly); this.panelOptions.Controls.Add(this.cbFavServersOnTop); this.panelOptions.Controls.Add(this.rbAddressGamePort); @@ -1830,6 +1835,16 @@ private void InitializeComponent() this.panelOptions.TabIndex = 1; this.panelOptions.Visible = false; // + // cbRememberColumnLayout + // + this.cbRememberColumnLayout.Location = new System.Drawing.Point(350, 71); + this.cbRememberColumnLayout.Name = "cbRememberColumnLayout"; + this.cbRememberColumnLayout.Properties.AutoWidth = true; + this.cbRememberColumnLayout.Properties.Caption = "Remember column layout for each tab"; + this.cbRememberColumnLayout.Size = new System.Drawing.Size(204, 19); + this.cbRememberColumnLayout.TabIndex = 18; + this.cbRememberColumnLayout.ToolTip = "When enabled, you can have different column widths in different tabs."; + // // rbUpdateStatusOnly // this.rbUpdateStatusOnly.Location = new System.Drawing.Point(136, 52); @@ -1844,7 +1859,7 @@ private void InitializeComponent() // // cbFavServersOnTop // - this.cbFavServersOnTop.Location = new System.Drawing.Point(350, 51); + this.cbFavServersOnTop.Location = new System.Drawing.Point(350, 33); this.cbFavServersOnTop.Name = "cbFavServersOnTop"; this.cbFavServersOnTop.Properties.AutoWidth = true; this.cbFavServersOnTop.Properties.Caption = "Keep my favorite servers on top"; @@ -2149,6 +2164,7 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.panelOptions)).EndInit(); this.panelOptions.ResumeLayout(false); this.panelOptions.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.cbRememberColumnLayout.Properties)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.rbUpdateStatusOnly.Properties)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.cbFavServersOnTop.Properties)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.rbAddressGamePort.Properties)).EndInit(); @@ -2319,5 +2335,6 @@ private void InitializeComponent() private DevExpress.XtraBars.BarSubItem mnuTabs; private DevExpress.XtraBars.BarSubItem mnuServer; private DevExpress.XtraBars.BarSubItem mnuUpdate; + protected CheckEdit cbRememberColumnLayout; } } diff --git a/ServerBrowser/ServerBrowserForm.cs b/ServerBrowser/ServerBrowserForm.cs index 5fe02e2..2c48092 100644 --- a/ServerBrowser/ServerBrowserForm.cs +++ b/ServerBrowser/ServerBrowserForm.cs @@ -286,7 +286,9 @@ private void SetViewModel(TabViewModel vm) this.cbGetEmpty.Checked = vm.GetEmptyServers; this.cbGetFull.Checked = vm.GetFullServers; this.comboQueryLimit.Text = vm.MasterServerQueryLimit.ToString(); + this.gvServers.ActiveFilterString = vm.GridFilter; + UpdatePanelVisibility(); this.miFindServers.Enabled = vm.Source == TabViewModel.SourceType.MasterServer; } @@ -324,6 +326,7 @@ protected virtual void ApplyAppSettings() this.rbUpdateListAndStatus.Checked = opt.AutoUpdateList; this.rbUpdateStatusOnly.Checked = opt.AutoUpdateInfo; this.cbFavServersOnTop.Checked = opt.KeepFavServersOnTop; + this.cbRememberColumnLayout.Checked = opt.ColumnLayoutPerTab; // load favorite servers this.favServers.Clear(); @@ -367,6 +370,7 @@ protected virtual void SaveAppSettings() opt.AutoUpdateInfo = this.rbUpdateStatusOnly.Checked; opt.Skin = UserLookAndFeel.Default.SkinName; opt.TabIndex = this.tabControl.SelectedTabPageIndex; + opt.ColumnLayoutPerTab = this.cbRememberColumnLayout.Checked; var sb = new StringBuilder(); foreach (var fav in this.favServers) @@ -423,7 +427,12 @@ protected virtual void UpdateViewModel() vm.MasterServerQueryLimit = Convert.ToInt32(this.comboQueryLimit.Text); vm.GridFilter = this.gvServers.ActiveFilterString; - + if (this.cbRememberColumnLayout.Checked) + { + var strm = new MemoryStream(); + this.gvServers.SaveLayoutToStream(strm); + vm.ServerGridLayout = strm; + } vm.serverSource = this.CreateServerSource(vm.MasterServer); vm.gameExtension = this.extenders.Get((Game)vm.InitialGameID); } @@ -470,8 +479,11 @@ private void SetSteamAppId(int appId) int index = this.gameIdForComboBoxIndex.IndexOf((Game)appId); if (index >= 0) this.comboGames.SelectedIndex = index; - else + else if (appId != 0) this.comboGames.Text = appId.ToString(); + else + this.comboGames.EditValue = null; + --this.ignoreUiEvents; } #endregion @@ -479,12 +491,22 @@ private void SetSteamAppId(int appId) #region InitGameExtension() private void InitGameExtension() { - this.viewModel.gameExtension = this.extenders.Get((Game)this.viewModel.InitialGameID); + var ext = this.extenders.Get((Game) this.viewModel.InitialGameID); + if (ext != this.viewModel.gameExtension) + { + this.viewModel.ServerGridLayout = null; + this.viewModel.gameExtension = ext; + } this.gvServers.BeginUpdate(); this.ResetGridColumns(this.gvServers); this.viewModel.gameExtension.CustomizeServerGridColumns(gvServers); this.gvServers.EndUpdate(); + if (viewModel.ServerGridLayout != null && this.cbRememberColumnLayout.Checked) + { + viewModel.ServerGridLayout.Seek(0, SeekOrigin.Begin); + this.gvServers.RestoreLayoutFromStream(viewModel.ServerGridLayout); + } this.gvPlayers.BeginUpdate(); this.ResetGridColumns(this.gvPlayers); @@ -1520,6 +1542,7 @@ private void tabControl_SelectedPageChanged(object sender, TabPageChangedEventAr if (this.ignoreUiEvents > 0) return; this.SetViewModel((TabViewModel)e.Page.Tag); this.UpdateViews(true); + if (this.viewModel.servers == null) this.ReloadServerList(); else if (this.viewModel.Source != TabViewModel.SourceType.MasterServer) diff --git a/ServerBrowser/TabViewModel.cs b/ServerBrowser/TabViewModel.cs index aaa83d3..ee73629 100644 --- a/ServerBrowser/TabViewModel.cs +++ b/ServerBrowser/TabViewModel.cs @@ -1,4 +1,6 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; +using System.IO; using System.Text; using ChanSort.Api; using QueryMaster; @@ -26,6 +28,7 @@ public enum SourceType { MasterServer, CustomList, Favorites } public int MasterServerQueryLimit { get; set; } public string GridFilter { get; set; } + public MemoryStream ServerGridLayout { get; set; } public SourceType Source { get; set; } public int ImageIndex => Source == SourceType.Favorites ? 3 : Source == SourceType.CustomList ? 12 : -1; @@ -58,6 +61,7 @@ public void AssignFrom(IViewModel opt) this.servers = vm.servers; this.gameExtension = vm.gameExtension; this.GridFilter = vm.GridFilter; + this.ServerGridLayout = vm.ServerGridLayout; } #endregion @@ -75,6 +79,11 @@ public void LoadFromIni(IniFile.Section ini, GameExtensionPool pool) this.GetFullServers = ini.GetBool("GetFullServers", true); this.MasterServerQueryLimit = ini.GetInt("MasterServerQueryLimit", 500); this.GridFilter = ini.GetString("GridFilter"); + + var layout = ini.GetString("GridLayout"); + if (!string.IsNullOrEmpty(layout)) + this.ServerGridLayout = new MemoryStream(Convert.FromBase64String(layout)); + this.gameExtension = pool.Get((Game) this.InitialGameID); if (this.Source == SourceType.CustomList) @@ -104,7 +113,8 @@ public void WriteToIni(StringBuilder ini) ini.Append("GetFullServers=").AppendLine(this.GetFullServers ? "1" : "0"); ini.Append("MasterServerQueryLimit=").Append(this.MasterServerQueryLimit).AppendLine(); ini.Append("GridFilter=").AppendLine(this.GridFilter); - + if (this.ServerGridLayout != null) + ini.Append("GridLayout=").AppendLine(Convert.ToBase64String(this.ServerGridLayout.GetBuffer(), 0, (int) this.ServerGridLayout.Length)); if (this.Source == SourceType.CustomList) { ini.Append("Servers="); diff --git a/ServerBrowser/app.config b/ServerBrowser/app.config index e999daf..6116d63 100644 --- a/ServerBrowser/app.config +++ b/ServerBrowser/app.config @@ -76,6 +76,9 @@ 0 + + False +