/// <summary>The exec load database details.</summary> /// <returns>The exec load database details.</returns> private bool ExecLoadDatabaseDetails() { bool populate = false; string connection = string.Empty; bool success = false; try { _hostWindow.SetPointerState(Cursors.WaitCursor); if (_metaDataService == null) { _metaDataService = DatabaseMetaDataService.Create(_services.Settings.ConnectionDefinition.ProviderName); } connection = _metaDataService.GetDescription(); populate = true; } catch (Exception exp) { string msg = string.Format( "{0}\r\n\r\nCheck the connection and select 'Reset Database Connection'.", exp.Message); _hostWindow.DisplaySimpleMessageBox(_hostWindow.Instance, msg, "DB Connection Error"); _hostWindow.SetStatus(this, exp.Message); } finally { _hostWindow.SetPointerState(Cursors.Default); } if (populate) { try { _hostWindow.SetPointerState(Cursors.WaitCursor); _model = _metaDataService.GetDbObjectModel(_services.Settings.ConnectionDefinition.ConnectionString); } finally { _hostWindow.SetPointerState(Cursors.Default); } BuildTreeFromDbModel(connection); _hostWindow.SetStatus(this, string.Empty); success = true; } else { _populated = false; DatabaseTreeView.CollapseAll(); } return(success); }
/// <summary>The select node.</summary> /// <param name="treeNode">The tree node.</param> private void SelectNode(TreeNode treeNode) { if (treeNode.Parent != null) { treeNode.Parent.EnsureVisible(); } treeNode.EnsureVisible(); DatabaseTreeView.SelectedNode = treeNode; treeNode.Expand(); DatabaseTreeView.Focus(); }
private void DatabaseTreeView_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { Point p = new Point(e.X, e.Y); TreeNode node = DatabaseTreeView.GetNodeAt(p); if (node != null) { DatabaseTreeView.SelectedNode = node; ShowItemInfo(node.Name); contextMenuStrip1.Show(this, p); } } }
private void BuildDatabaseTree() { DatabaseTree = new TreeNode("Databases"); foreach (var database in dbContext.SchemaQuery.GetDatabases()) { TreeNode dbNode = new TreeNode(database.Name); foreach (var table in database.Tables) { TreeNode tbNode = new TreeNode(table.Name); dbNode.Nodes.Add(tbNode); } DatabaseTree.Nodes.Add(dbNode); } DatabaseTreeView.Nodes.Add(DatabaseTree); DatabaseTreeView.Refresh(); // Add event handlers. DatabaseTreeView.NodeMouseClick += DatabaseTreeView_NodeMouseClick; }