/// <param name="connection">May be null, in which case a new connection will be created</param> protected void ConnectToServer(IXenConnection conn, string hostname, int port, string username, string password, string version) { if (conn == null) { XenConnection connection = new XenConnection(); connection.CachePopulated += conn_CachePopulated; connection.fromDialog = true; conn = connection; } else if (!_changedPass) { conn.EndConnect(); // in case we're already connected } conn.Hostname = hostname; conn.Port = port; conn.Username = username; conn.Password = password; conn.ExpectPasswordIsCorrect = false; conn.Version = version; if (!_changedPass) { XenConnectionUI.BeginConnect(conn, true, Owner, false); } }
protected override void OnFormClosing(FormClosingEventArgs e) { if (_connection.InProgress && !_connection.IsConnected && !endBegun) { //if we are still trying to connect then we need to end it. This call will close this dialog as well, //so set a guard to skip this block when we re-enter. endBegun = true; _connection.EndConnect(); e.Cancel = true; //CA-65004: if this dialog is closed by closing the parent form, returning //without calling the base class method causes the parent form to stay open if (e.CloseReason == CloseReason.FormOwnerClosing && getOwnerForm() == ownerForm) { ownerForm.Close(); } return; } if (_connection != null) { XenConnectionUI.connectionDialogs.Remove(_connection); } base.OnFormClosing(e); }
private void formClosing(object sender, FormClosingEventArgs e) { Form dialog = (Form)sender; if (dialog.DialogResult == DialogResult.Cancel) { if (_connection != null) { _connection.EndConnect(); } } }
private void DoDisconnect(IXenConnection connection) { string msg = string.Format(Messages.CONNECTION_CLOSED_NOTICE_TEXT, connection.Hostname); ActionBase notice = new ActionBase(msg, msg, false, true); notice.Pool = Helpers.GetPoolOfOne(connection); notice.Host = Helpers.GetMaster(connection); log.Warn($"Connection to {connection.Hostname} closed."); MainWindowCommandInterface.CloseActiveWizards(connection); XenDialogBase.CloseAll(connection); connection.EndConnect(); MainWindowCommandInterface.SaveServerList(); }
/// <param name="connection">May be null, in which case a new connection will be created</param> protected void ConnectToServer(IXenConnection conn, string hostname, int port, string username, string password, string version) { if (conn == null) { XenConnection connection = new XenConnection(); connection.CachePopulated += conn_CachePopulated; connection.fromDialog = true; conn = connection; } else if (!_changedPass) { conn.EndConnect(); // in case we're already connected } conn.Hostname = hostname; conn.Port = port; conn.Username = username; conn.Password = password; conn.ExpectPasswordIsCorrect = false; conn.Version = version; if (!_changedPass) XenConnectionUI.BeginConnect(conn, true, Owner, false); }
private void DoDisconnect(IXenConnection connection) { string msg = string.Format(Messages.CONNECTION_CLOSED_NOTICE_TEXT, connection.Hostname); log.Warn(msg); ActionBase notice = new ActionBase(ActionType.Information, msg, msg, false); notice.Pool = Helpers.GetPoolOfOne(connection); notice.Host = Helpers.GetMaster(connection); MainWindowCommandInterface.CloseActiveWizards(connection); XenDialogBase.CloseAll(connection); connection.EndConnect(); MainWindowCommandInterface.SaveServerList(); MainWindowCommandInterface.Refresh(); }