public void OnNotifyLoggedIn() { // Remove login control RemoveComaToolLoginControl(); List <string> communityList = _ticketManager.GetComaToolCommunityList(); AddTabControl(); _tabControl.Selected += new TabControlEventHandler(_tabControl_Selected); AddComaToolWebBrowserTab(); _tabPageWebBrowser.Controls.Add(_comaToolWebBrowserControl); _comaToolWebBrowserControl.LoadControl(new Uri("https://lobby.ogame.gameforge.com/en_GB/")); int count = 1; foreach (string community in communityList) { int communityId = Int32.Parse(community.Split('|')[0]); string communityName = community.Split('|')[1]; TabPage tab = new TabPage(communityName); tab.BackColor = System.Drawing.Color.Transparent; tab.UseVisualStyleBackColor = true; ComaToolSubControl subControl = new ComaToolSubControl(_gameManager, this, communityId, communityName); subControl.Dock = DockStyle.Fill; tab.Controls.Add(subControl); _tabControl.TabPages.Add(tab); if (count == 1) { _tabControl.SelectedTab = tab; subControl.SelectActiveCommunity(); } if (communityList.Count < 10) { //subControl.LoadControl(); } else if (count == 1) { //subControl.LoadControl(); } count++; } //if (communityList.Count == 1) //{ // int communityId = Int32.Parse(communityList[0].Split('|')[0]); // string communityName = communityList[0].Split('|')[1]; // AddComaToolSubControl(communityId, communityName); //} //else //{ // MessageBox.Show("Sorry, it seems you do not currently have access to the ticket tool.\r\rIf this is an error, please contact vodler", "Could not load tickets"); //} }
void _tabControl_Selected(object sender, TabControlEventArgs e) { try { ComaToolSubControl subControl = e?.TabPage?.Controls[0] as ComaToolSubControl ?? null; subControl?.SelectActiveCommunity(); } catch { } }