/// <summary> /// Adds the index page nodes. /// </summary> /// <param name="connectionString">The connection string.</param> /// <param name="node">The node.</param> /// <param name="databaseName">Name of the database.</param> /// <param name="tableName">Name of the table.</param> /// <param name="indexName">Name of the index.</param> /// <param name="folderImageIndex">Index of the folder image.</param> private void AddIndexPageNodes(string connectionString, TreeNode node, string databaseName, string tableName, string indexName, int folderImageIndex) { // This suppresses the Object Explorer expand behavior ChildrenEnumerated(node, true); List <HobtEntryPoint> entryPoints = Hobt.EntryPoints(connectionString, databaseName, tableName, indexName); bool partitioned = entryPoints.Count > 1; foreach (HobtEntryPoint entryPoint in entryPoints) { TreeNode parentNode; if (partitioned) { parentNode = new TreeNode(string.Format("Partition {0}", entryPoint.PartitionNumber)); parentNode.SelectedImageIndex = folderImageIndex; parentNode.ImageIndex = folderImageIndex; node.Nodes.Add(parentNode); } else { parentNode = node; } TreeNode firstIam = new TreeNode(string.Format("First IAM {0}", entryPoint.FirstIam)); firstIam.SelectedImageKey = "Page"; firstIam.ImageKey = "Page"; firstIam.ContextMenuStrip = contextMenuStrip; firstIam.Tag = entryPoint.FirstIam; TreeNode rootPage = new TreeNode(string.Format("Root Page {0}", entryPoint.RootPage)); rootPage.SelectedImageKey = "Page"; rootPage.ImageKey = "Page"; rootPage.ContextMenuStrip = contextMenuStrip; rootPage.Tag = entryPoint.RootPage; TreeNode firstPage = new TreeNode(string.Format("First Page {0}", entryPoint.FirstPage)); firstPage.SelectedImageKey = "Page"; firstPage.ImageKey = "Page"; firstPage.ContextMenuStrip = contextMenuStrip; firstPage.Tag = entryPoint.FirstPage; parentNode.Nodes.Add(firstIam); parentNode.Nodes.Add(rootPage); parentNode.Nodes.Add(firstPage); } }
/// <summary> /// Handles the BeforeExpand event of the TreeView control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Windows.Forms.TreeViewCancelEventArgs"/> instance containing the event data.</param> private void TreeView_BeforeExpand(object sender, System.Windows.Forms.TreeViewCancelEventArgs e) { if (e.Node.Text == "Indexes") { string tableName = e.Node.Parent.Text; int tableImageIndex = e.Node.Parent.ImageIndex; string databaseName = e.Node.Parent.Parent.Parent.Text; string connectionString = GetConnectionString(e.Node); if (Hobt.HobtType(connectionString, databaseName, tableName) == StructureType.Heap) { TreeNode heapNode = new TreeNode("(Heap)", tableImageIndex, tableImageIndex); e.Node.Nodes.Add(heapNode); AddIndexPageNodes(connectionString, heapNode, databaseName, tableName, string.Empty, e.Node.Parent.Parent.ImageIndex); } } }