private void Connections_ConnectionAdded(PRoConClient item) { uscServerConnection uscNewConnectionPanel = null; uscNewConnectionPanel = new uscServerConnection(this.m_paProcon, item, this, this.m_frmManageAccounts); uscNewConnectionPanel.Dock = DockStyle.Fill; //uscNewConnectionPanel.SetLocalization(this.m_clocLanguage); //uscNewConnectionPanel.BFBC2Connection.Connect(); uscNewConnectionPanel.ManageAccountsRequest += new uscServerConnection.ManageAccountsRequestDelegate(uscServerConnection_ManageAccountsRequest); uscNewConnectionPanel.OnTabChange += new uscServerConnection.OnTabChangeDelegate(uscNewConnectionPanel_OnTabChange); this.pnlWindows.Controls.Add(uscNewConnectionPanel); this.m_dicPages.Add(item.HostNamePort, uscNewConnectionPanel); this.cboServerList.ComboBox.Items.Add(uscNewConnectionPanel); if (this.cboServerList.SelectedItem == null) { this.cboServerList.SelectedItem = uscNewConnectionPanel; } item.ConnectionClosed += new PRoConClient.EmptyParamterHandler(item_ConnectionClosed); item.ConnectionFailure += new PRoConClient.FailureHandler(item_ConnectionFailure); item.ConnectSuccess += new PRoConClient.EmptyParamterHandler(item_ConnectSuccess); item.Login += new PRoConClient.EmptyParamterHandler(item_Login); item.ConnectAttempt += new PRoConClient.EmptyParamterHandler(item_ConnectAttempt); item.GameTypeDiscovered += new PRoConClient.EmptyParamterHandler(item_GameTypeDiscovered); item.AutomaticallyConnectChanged += new PRoConClient.AutomaticallyConnectHandler(item_AutomaticallyConnectChanged); this.RefreshServerListing(); }
private void RefreshServerListing() { //this.cboServerList.BeginUpdate(); this.cboServerList_SelectedIndexChanged(null, null); Point cursor = this.PointToClient(Cursor.Position); //cursor.Y -= this.mnuMain.Height; if (this.cboServerList.SelectedItem != null && this.cboServerList.SelectedItem is uscServerConnection) { uscServerConnection selectedServer = (uscServerConnection)this.cboServerList.SelectedItem; object b = this.cboServerList.ComboBox.SelectedItem; if (selectedServer.Client.State == ConnectionState.Connecting || (selectedServer.Client.State == ConnectionState.Connected && selectedServer.Client.IsLoggedIn == false)) { if (this.btnConnectDisconnect.Bounds.Contains(cursor) == true) { this.btnConnectDisconnect_MouseEnter(null, null); } } } //this.cboServerList.Invalidate(); //this.cboServerList.EndUpdate(); }
private void btnConnectDisconnect_MouseLeave(object sender, EventArgs e) { if (this.cboServerList.SelectedItem != null && this.cboServerList.SelectedItem is uscServerConnection) { uscServerConnection selectedServer = (uscServerConnection)this.cboServerList.SelectedItem; this.btnConnectDisconnect.Enabled = true; if (selectedServer.Client.State == ConnectionState.Connected) { this.btnConnectDisconnect.Image = this.iglIcons.Images["plug-connect.png"]; if (this.m_clocLanguage != null) { this.btnConnectDisconnect.Text = this.m_clocLanguage.GetLocalized("fmrMain.tlsConnections.btnConnectDisconnect.Connect"); } } else { this.btnConnectDisconnect.Image = this.iglIcons.Images["plug-disconnect.png"]; if (this.m_clocLanguage != null) { this.btnConnectDisconnect.Text = this.m_clocLanguage.GetLocalized("fmrMain.tlsConnections.btnConnectDisconnect.Disconnect"); } } } }
public void Initialize(frmMain frmMainWindow, uscServerConnection uscConnectionPanel) { this.m_frmMain = frmMainWindow; this.SettingFail = frmMainWindow.picAjaxStyleFail.Image; this.SettingSuccess = frmMainWindow.picAjaxStyleSuccess.Image; this.SettingLoading = frmMainWindow.picAjaxStyleLoading.Image; this.btnAddMap.Image = frmMainWindow.iglIcons.Images["arrow-curve-000-left.png"]; this.btnRemoveMap.Image = frmMainWindow.iglIcons.Images["arrow-curve-180-left.png"]; }
public void Initialize(frmMain frmMainWindow, uscServerConnection uscConnectionPanel) { this.m_frmMain = frmMainWindow; this.SettingFail = frmMainWindow.picAjaxStyleFail.Image; this.SettingSuccess = frmMainWindow.picAjaxStyleSuccess.Image; this.SettingLoading = frmMainWindow.picAjaxStyleLoading.Image; this.btnAddMap.Image = frmMainWindow.iglIcons.Images["arrow-curve-000-left.png"]; this.btnRemoveMap.Image = frmMainWindow.iglIcons.Images["arrow-curve-180-left.png"]; this.btnMaplistRefresh.ImageList = this.m_frmMain.iglIcons; this.btnMaplistRefresh.ImageKey = "arrow_refresh.png"; this.btnMaplistClear.ImageList = this.m_frmMain.iglIcons; this.btnMaplistClear.ImageKey = "cross.png"; }
private void btnConnectDisconnect_Click(object sender, EventArgs e) { if (this.cboServerList.SelectedItem != null && this.cboServerList.SelectedItem is uscServerConnection) { uscServerConnection selectedServer = (uscServerConnection)this.cboServerList.SelectedItem; if (selectedServer.Client.State == ConnectionState.Connected) { selectedServer.Client.ForceDisconnect(); selectedServer.Client.AutomaticallyConnect = false; } else { selectedServer.Client.Connect(); } } }
private void m_frmConfirmation_ConfirmationSuccess() { if (this.cboServerList.SelectedItem != null) { uscServerConnection selectedServer = (uscServerConnection)this.cboServerList.SelectedItem; string strConfigFile = String.Format("{0}.cfg", selectedServer.Client.FileHostNamePort); selectedServer.Hide(); // Find another panel to show while we remove this server. foreach (KeyValuePair <string, uscPage> kvpPanel in this.m_dicPages) { if (kvpPanel.Value != selectedServer) { this.cboServerList.SelectedItem = kvpPanel.Value; break; } } //this.m_dicConnectionPages[strServerHostnamePort].BFBC2Connection.Destroying(); if (this.cboServerList.ComboBox.Items.Contains(selectedServer) == true) { this.cboServerList.ComboBox.Items.Remove(selectedServer); } this.m_paProcon.Connections.Remove(selectedServer.Client); selectedServer.Dispose(); this.m_dicPages.Remove(selectedServer.Client.HostNamePort); //this.uscServerPlayerTreeviewListing.OnServerDeleted(strServerHostnamePort); try { if (File.Exists(Path.Combine("Configs", strConfigFile)) == true) { File.Delete(Path.Combine("Configs", strConfigFile)); } } catch (Exception) { } } }
private void RefreshServerListing() { if (this.IsDisposed == false) { this.cboServerList_SelectedIndexChanged(null, null); Point cursor = this.PointToClient(Cursor.Position); uscServerConnection item = this.cboServerList.SelectedItem as uscServerConnection; if (item != null) { uscServerConnection selectedServer = item; if (selectedServer.Client.State == ConnectionState.Connecting || (selectedServer.Client.State == ConnectionState.Connected && selectedServer.Client.IsLoggedIn == false)) { if (this.btnConnectDisconnect.Bounds.Contains(cursor) == true) { this.btnConnectDisconnect_MouseEnter(null, null); } } } } }
private void ComboBox_DrawItem(object sender, DrawItemEventArgs e) { if (e.Index != -1) { e.DrawBackground(); e.DrawFocusRectangle(); if (this.cboServerList.ComboBox.Items[e.Index] is uscServerConnection) { uscServerConnection drawItem = ((uscServerConnection)this.cboServerList.ComboBox.Items[e.Index]); if (drawItem.Client.CurrentServerInfo != null) { if (drawItem.Client.State == ConnectionState.Connected && drawItem.Client.IsLoggedIn == true) { e.Graphics.DrawImage(this.iglIcons.Images["tick-button.png"], e.Bounds.Left + 57, e.Bounds.Top + 1, this.iglIcons.ImageSize.Width, this.iglIcons.ImageSize.Height); } else if (drawItem.Client.State == ConnectionState.Error) { e.Graphics.DrawImage(this.iglIcons.Images["cross-button.png"], e.Bounds.Left + 57, e.Bounds.Top + 1, this.iglIcons.ImageSize.Width, this.iglIcons.ImageSize.Height); } else { e.Graphics.DrawImage(this.iglIcons.Images["exclamation-button.png"], e.Bounds.Left + 57, e.Bounds.Top + 1, this.iglIcons.ImageSize.Width, this.iglIcons.ImageSize.Height); } e.Graphics.DrawString(String.Format("[{0}/{1}] {2} [{3}]", drawItem.Client.CurrentServerInfo.PlayerCount, drawItem.Client.CurrentServerInfo.MaxPlayerCount, drawItem.Client.CurrentServerInfo.ServerName, drawItem.Client.HostNamePort), this.cboServerList.Font, SystemBrushes.WindowText, e.Bounds.Left + 75, e.Bounds.Top); if (drawItem.Client.Game != null) { if (drawItem.Client.CurrentServerInfo.GameMod == GameMods.None) { e.Graphics.DrawImage(this.iglGameIcons.Images[String.Format("{0}.png", drawItem.Client.Game.GameType).ToLower()], e.Bounds.Left + 2, e.Bounds.Top + 1, this.iglGameIcons.ImageSize.Width, this.iglGameIcons.ImageSize.Height); } else { e.Graphics.DrawImage(this.iglGameIcons.Images[String.Format("{0}.{1}.png", drawItem.Client.Game.GameType, drawItem.Client.CurrentServerInfo.GameMod).ToLower()], e.Bounds.Left + 2, e.Bounds.Top + 1, this.iglGameIcons.ImageSize.Width, this.iglGameIcons.ImageSize.Height); } } } else { if (drawItem.Client.State == ConnectionState.Connected && drawItem.Client.IsLoggedIn == true) { e.Graphics.DrawImage(this.iglIcons.Images["tick-button.png"], e.Bounds.Left + 2, e.Bounds.Top + 1, this.iglIcons.ImageSize.Width, this.iglIcons.ImageSize.Height); } else if (drawItem.Client.State == ConnectionState.Error) { e.Graphics.DrawImage(this.iglIcons.Images["cross-button.png"], e.Bounds.Left + 2, e.Bounds.Top + 1, this.iglIcons.ImageSize.Width, this.iglIcons.ImageSize.Height); } else { e.Graphics.DrawImage(this.iglIcons.Images["exclamation-button.png"], e.Bounds.Left + 2, e.Bounds.Top + 1, this.iglIcons.ImageSize.Width, this.iglIcons.ImageSize.Height); } e.Graphics.DrawString(drawItem.Client.HostNamePort, this.cboServerList.Font, SystemBrushes.WindowText, e.Bounds.Left + 21, e.Bounds.Top); } } else if (this.cboServerList.ComboBox.Items[e.Index] is uscStartPage) { uscStartPage drawItem = ((uscStartPage)this.cboServerList.ComboBox.Items[e.Index]); e.Graphics.DrawImage(this.iglIcons.Images["home.png"], e.Bounds.Left + 2, e.Bounds.Top + 1, this.iglIcons.ImageSize.Width, this.iglIcons.ImageSize.Height); if (this.m_clocLanguage == null) { e.Graphics.DrawString("Start Page", this.cboServerList.Font, SystemBrushes.WindowText, e.Bounds.Left + 21, e.Bounds.Top); } else { e.Graphics.DrawString(this.m_clocLanguage.GetLocalized("uscStartPage.Title"), this.cboServerList.Font, SystemBrushes.WindowText, e.Bounds.Left + 21, e.Bounds.Top); } } e.Graphics.Dispose(); } }