public void AssignFrom(TabViewModel opt) { this.MasterServer = opt.MasterServer; this.InitialGameID = opt.InitialGameID; this.FilterMod = opt.FilterMod; this.FilterMap = opt.FilterMap; this.TagsIncludeServer = opt.TagsIncludeServer; this.TagsExcludeServer = opt.TagsExcludeServer; this.GetEmptyServers = opt.GetEmptyServers; this.GetFullServers = opt.GetFullServers; this.MasterServerQueryLimit = opt.MasterServerQueryLimit; this.Source = opt.Source; this.serverSource = opt.serverSource; this.Servers = new List <ServerRow>(opt.Servers); this.gameExtension = opt.gameExtension; this.GridFilter = opt.GridFilter; this.MinPlayers = opt.MinPlayers; this.MinPlayersInclBots = opt.MinPlayersInclBots; this.MaxPing = opt.MaxPing; this.TagsIncludeClient = opt.TagsIncludeClient; this.TagsExcludeClient = opt.TagsExcludeClient; this.ServerGridLayout = opt.ServerGridLayout; this.VersionMatch = opt.VersionMatch; this.CustomDetailColumns.AddRange(opt.CustomDetailColumns); this.CustomRuleColumns.AddRange(opt.CustomRuleColumns); this.HideColumns.AddRange(opt.HideColumns); }
private void LoadViewModelsFromIniFile(IniFile ini) { bool hasFavTab = false; if (ini != null) { int i = 0; foreach (var section in ini.Sections) { if (System.Text.RegularExpressions.Regex.IsMatch(section.Name, "^Tab[0-9]+$")) { var vm = new TabViewModel(); vm.LoadFromIni(ini, section, this.extenders); var page = new XtraTabPage(); page.Text = section.GetString("TabName") ?? this.GetGameCaption((Game) vm.InitialGameID); page.Tag = vm; page.ImageIndex = vm.ImageIndex; this.tabControl.TabPages.Insert(i++, page); hasFavTab |= vm.Source == TabViewModel.SourceType.Favorites; } } } else { // migrate favorite games from v1.16 int i = 0; foreach (var gameId in Settings.Default.FavGameIDs.Split(',')) { if (string.IsNullOrEmpty(gameId)) continue; var vm = new TabViewModel(); vm.AssignFrom(Settings.Default); vm.InitialGameID = int.Parse(gameId); var page = new XtraTabPage(); page.Text = this.GetGameCaption((Game)vm.InitialGameID); page.Tag = vm; this.tabControl.TabPages.Insert(i++, page); } } if (hasFavTab) { this.tabControl.TabPages.Remove(this.tabFavorites); this.tabFavorites.Dispose(); } if (this.tabControl.TabPages.Count > 2) this.tabControl.TabPages.Remove(this.tabGame); else this.tabGame.Tag = new TabViewModel(); }
public ServerBrowserForm() { InitializeComponent(); this.InitGameInfoExtenders(); this.queryLogic = new ServerQueryLogic(this.extenders); if (LicenseManager.UsageMode == LicenseUsageMode.Designtime) return; base.Text += " " + Version; this.iniFile = Path.Combine(Application.LocalUserAppDataPath, "ServerBrowser.ini"); this.queryLogic.UpdateStatus += (s, e) => this.BeginInvoke((Action)(() => queryLogic_SetStatusMessage(s, e))); this.queryLogic.ServerListReceived += (s, e) => this.BeginInvoke((Action) queryLogic_ServerListReceived); this.queryLogic.ReloadServerListComplete += (s, e) => this.BeginInvoke((Action)(() => { queryLogic_ReloadServerListComplete(e.Rows); })); this.queryLogic.RefreshSingleServerComplete += (s, e) => this.BeginInvoke((Action)(() => { queryLogic_RefreshSingleServerComplete(e); })); // make the server list panel fill the remaining space (this can't be done in the Forms Designer) this.panelServerList.Parent.Controls.Remove(this.panelServerList); this.panelServerList.Dock = DockingStyle.Fill; this.Controls.Add(this.panelServerList); this.panelStaticList.Height = this.panelQuery.Height; UserLookAndFeel.Default.StyleChanged += LookAndFeel_StyleChanged; var vm = new TabViewModel(); vm.Source = TabViewModel.SourceType.Favorites; this.tabFavorites.Tag = vm; }
private void CloneTab(XtraTabPage source) { var page = new XtraTabPage(); page.Text = source.Text + " #2"; page.ShowCloseButton = DefaultBoolean.True; var vm = new TabViewModel(); vm.AssignFrom(this.viewModel); page.Tag = vm; page.ImageIndex = vm.ImageIndex; var idx = this.tabControl.TabPages.IndexOf(source); this.tabControl.TabPages.Insert(idx + 1, page); this.tabControl.SelectedTabPage = page; }
private void AddNewTab(string name, TabViewModel.SourceType sourceType) { var vm = new TabViewModel(); vm.Source = sourceType; vm.servers = new List<ServerRow>(); vm.gameExtension = unknownGame; var page = new XtraTabPage(); page.Text = name; page.Tag = vm; page.ImageIndex = vm.ImageIndex; this.tabControl.TabPages.Insert(this.tabControl.TabPages.Count - 1, page); this.tabControl.SelectedTabPage = page; }
private void SetViewModel(TabViewModel vm) { this.viewModel = vm; if (vm.Source == TabViewModel.SourceType.Favorites) { vm.servers = new List<ServerRow>(); foreach (var fav in this.favServers) { var row = new ServerRow(fav.Key, this.extenders.Get(0)); row.CachedName = fav.Value; vm.servers.Add(row); } } var info = vm.MasterServer; if (string.IsNullOrEmpty(info)) info = "hl2master.steampowered.com:27011"; this.comboMasterServer.Text = info; this.SetSteamAppId(vm.InitialGameID); this.txtTagInclude.Text = vm.TagsInclude; this.txtTagExclude.Text = vm.TagsExclude; this.txtMod.Text = vm.FilterMod; this.txtMap.Text = vm.FilterMap; 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; }
private void miCreateSnapshot_ItemClick(object sender, ItemClickEventArgs e) { var srcPage = this.tabControl.SelectedTabPage; var vm = new TabViewModel(); vm.AssignFrom(this.viewModel); vm.Source = TabViewModel.SourceType.CustomList; vm.GridFilter = null; var page = new XtraTabPage(); page.Text = srcPage.Text + " #2"; page.ShowCloseButton = DefaultBoolean.True; page.Tag = vm; page.ImageIndex = vm.ImageIndex; vm.servers = new List<ServerRow>(); for(int i=0, c= this.gvServers.RowCount; i<c; i++) vm.servers.Add((ServerRow)this.gvServers.GetRow(i)); this.tabControl.TabPages.Insert(this.tabControl.TabPages.Count - 1, page); this.tabControl.SelectedTabPage = page; }