Example #1
0
        /// <summary>
        /// Searches for Workbench connections to load on the Connections list, if Workbench is not installed it loads connections created locally in MySQL for Excel.
        /// <param name="reloadConnections">Flag indicating if connections are to be re-read from the connections file.</param>
        /// </summary>
        public void LoadConnections(bool reloadConnections)
        {
            if (reloadConnections)
            {
                MySqlWorkbench.Connections.Load();
            }

            // Avoids flickering of connections list while adding the items to it.
            ConnectionsList.BeginUpdate();

            // Clear currently loaded connections
            foreach (TreeNode node in ConnectionsList.Nodes)
            {
                node.Nodes.Clear();
            }

            // Load connections just obtained from Workbench or locally created
            foreach (var conn in MySqlWorkbench.Connections.Where(conn => conn.IsListable).OrderBy(conn => conn.Name))
            {
                conn.AllowZeroDateTimeValues = true;
                AddConnectionToList(conn);
            }

            // Expand connection nodes
            ConnectionsList.ExpandAll();
            if (ConnectionsList.Nodes.Count > 0)
            {
                ConnectionsList.Nodes[0].EnsureVisible();
            }

            // Avoids flickering of connections list while adding the items to it.
            ConnectionsList.EndUpdate();
        }
Example #2
0
        /// <summary>
        /// Searches for Workbench connections to load on the Connections list, if Workbench is not installed it loads connections created locally in MySQL for Excel.
        /// <param name="reloadConnections">Flag indicating if connections are to be re-read from the connections file.</param>
        /// </summary>
        public void LoadConnections(bool reloadConnections)
        {
            Cursor = Cursors.WaitCursor;
            if (reloadConnections)
            {
                MySqlWorkbench.Connections.Load(true);
            }

            // Avoids flickering of connections list while adding the items to it.
            ConnectionsList.BeginUpdate();

            // Clear currently loaded connections
            foreach (TreeNode node in ConnectionsList.Nodes)
            {
                node.Nodes.Clear();
            }

            // Load connections just obtained from Workbench or locally created
            foreach (var conn in MySqlWorkbench.Connections.OrderBy(conn => conn.Name).Where(conn => !conn.IsUnknownConnection && !conn.IsXConnection))
            {
                conn.SetAdditionalConnectionProperties();
                AddConnectionToList(conn);
            }

            // Expand connection nodes
            ConnectionsList.ExpandAll();
            if (ConnectionsList.Nodes.Count > 0)
            {
                ConnectionsList.Nodes[0].EnsureVisible();
            }

            // Avoids flickering of connections list while adding the items to it.
            ConnectionsList.EndUpdate();
            Cursor = Cursors.Default;
        }