/// <summary> /// Sets and opens the current active connection used to browse schemas and DB objects. /// </summary> /// <param name="connection">A <see cref="MySqlWorkbenchConnection"/> object representing the connection to a MySQL server instance selected by users.</param> /// <param name="givePanelFocus">Flag indicating whether the <see cref="SchemaSelectionPanel"/> is given focus.</param> public PasswordDialogFlags OpenConnection(MySqlWorkbenchConnection connection, bool givePanelFocus) { WbConnection = connection; var passwordFlags = WbConnection.TestConnectionAndRetryOnWrongPassword(); if (passwordFlags.ConnectionSuccess && SchemaSelectionPanel2.SetConnection(WbConnection) && givePanelFocus) { RefreshWbConnectionTimeouts(); SchemaSelectionPanel2.BringToFront(); } return(passwordFlags); }
/// <summary> /// Closes the current connection, editing tables and puts the schema panel in focus. /// </summary> /// <param name="askToCloseConnections">Flag indicating whether users are asked for confirmation before closing active <see cref="EditConnectionInfo"/>.</param> /// <param name="givePanelFocus">Flag indicating whether the <see cref="SchemaSelectionPanel"/> is given focus.</param> /// <returns><c>true</c> if the schema and its open <see cref="EditConnectionInfo"/> objects are closed, <c>false</c> otherwise.</returns> public bool CloseSchema(bool askToCloseConnections, bool givePanelFocus) { if (askToCloseConnections && WorkbookConnectionInfos.GetWorkbookEditConnectionInfos(Globals.ThisAddIn.ActiveWorkbook).Count > 0) { // If there are Active OldStoredEditConnectionInfos warn the users that by closing the schema the active EditConnectionInfos will be closed. var dr = MiscUtilities.ShowCustomizedWarningDialog(Resources.ActiveEditConnectionInfosCloseWarningTitle, Resources.ActiveEditConnectionInfosCloseWarningDetail); if (dr == DialogResult.No) { return(false); } } WorkbookConnectionInfos.CloseWorkbookEditConnectionInfos(Globals.ThisAddIn.ActiveWorkbook); if (givePanelFocus) { SchemaSelectionPanel2.BringToFront(); } return(true); }