public static TreeNode MakeOtherType(this TreeNode parent, Func <object, bool> condition, TreeNodeType newType) { foreach (TreeNode node in parent.Nodes) { TreeNodeTag tag = node.Tag as TreeNodeTag; if (tag != null) { if (condition(tag.Object)) { tag.Type = newType; } } } return(parent); }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { propertyGrid1.Hide(); hexBoxControl1.Hide(); resourceControl1.Hide(); tablesControl1.Hide(); disassemblerControl1.Hide(); object tag = e.Node.Tag; if (tag is TreeNodeTag) { TreeNodeTag treeNodeTag = tag as TreeNodeTag; if (treeNodeTag.Object != null) { switch (treeNodeTag.Type) { case TreeNodeType.PropertyGrid: propertyGrid1.SelectedObject = treeNodeTag.Object; propertyGrid1.Show(); break; case TreeNodeType.HexBox: hexBoxControl1.SetByteProvider(GetCurrentAssembly(), ((IByteProvider)treeNodeTag.Object)); hexBoxControl1.Show(); break; case TreeNodeType.ResourcesTree: resourceControl1.SetRootDirectory(treeNodeTag.Object as ResourceDirectory); resourceControl1.Show(); break; case TreeNodeType.TablesTree: tablesControl1.SetTablesHeap(treeNodeTag.Object as TablesHeap); tablesControl1.Show(); break; case TreeNodeType.Disassembler: disassemblerControl1.SetAssembly(GetCurrentAssembly()); disassemblerControl1.Show(); break; } } } }
private void disassembleToolStripMenuItem_Click(object sender, EventArgs e) { if (treeView1.SelectedNode != null) { TreeNodeTag tag = treeView1.SelectedNode.Tag as TreeNodeTag; if (tag.Object is Section) { TreeNode root = GetRootNode(); foreach (TreeNode node in root.Nodes) { if (node.Tag != null && ((TreeNodeTag)node.Tag).Type == TreeNodeType.Disassembler) { node.EnsureVisible(); treeView1.SelectedNode = node; disassemblerControl1.DisassembleSection(tag.Object as Section); break; } } } } }