//===============================================================================
// Name : frmMain.cs
// Purpose : Assembly Explorer main window.
// Description :
// Created : 05.Nov.2002 by Langleyben Leon, leon@srl.co.il
// Last modified :
//===============================================================================
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Reflection;
using Microsoft.Win32;
namespace AssemblyExplorer
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class frmMain : System.Windows.Forms.Form
{
#region Private Constants
private const int TYPE_ASSEMBLY = 0;
private const int TYPE_MODULE = 1;
private const int TYPE_CLASS = 2;
private const int TYPE_INTERFACE = 3;
private const int TYPE_ENUM = 4;
private const int TYPE_FIELD = 5;
private const int TYPE_METHOD = 6;
private const int TYPE_PROPERTY = 7;
private const int TYPE_PARAMETER = 8;
private const int TYPE_RETVAL = 9;
private const int TYPE_EVENT = 10;
private const string REG_KEY = @"Software\AssemblyExplorer";
#endregion
#region Private Fields
private string m_sPath = String.Empty;
private string m_sModule = String.Empty;
private string m_sType = String.Empty;
private Module[] mdls = null;
private Assembly oAssembly;
private int iModule = -1;
private bool displayTree = false;
#endregion
#region Window Management Code
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem mnuFile;
private System.Windows.Forms.MenuItem mnuExit;
private System.Windows.Forms.MenuItem mnuInfo;
private System.Windows.Forms.MenuItem mnuAbout;
private System.Windows.Forms.ToolTip toolTip;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.TreeView tv;
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.Panel paneTree;
private System.Windows.Forms.Label lblProperties;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.PictureBox pictureBox5;
private System.Windows.Forms.ListBox lstTypes;
private System.Windows.Forms.ListBox lstModules;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.ListBox lstProperties;
private System.Windows.Forms.ListBox lstMethods;
private System.Windows.Forms.ListBox lstEvents;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.PictureBox pictureBox4;
private System.Windows.Forms.ListBox lstFields;
private System.Windows.Forms.PictureBox pictureBox6;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Panel panelSimple;
private System.Windows.Forms.PictureBox pictureBox3;
private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.MenuItem menuItem6;
private System.Windows.Forms.MenuItem menuItem7;
private System.Windows.Forms.MenuItem menuItem8;
private System.Windows.Forms.MenuItem menuItem9;
private System.Windows.Forms.MenuItem menuItem10;
private System.Windows.Forms.Label label3;
private MethodProperties methodProperties1;
private EventProperties eventProperties1;
private PropertyProperties propertyProperties1;
private FieldProperties fieldProperties1;
private TypeProperties typeProperties1;
private ParameterProperties parameterProperties1;
private System.Windows.Forms.MenuItem menuSepRecent;
private System.ComponentModel.IContainer components;
public frmMain()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
SetRecent();
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmMain));
this.mnuAbout = new System.Windows.Forms.MenuItem();
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.mnuFile = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
this.menuItem7 = new System.Windows.Forms.MenuItem();
this.mnuExit = new System.Windows.Forms.MenuItem();
this.menuSepRecent = new System.Windows.Forms.MenuItem();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem10 = new System.Windows.Forms.MenuItem();
this.menuItem9 = new System.Windows.Forms.MenuItem();
this.menuItem8 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.mnuInfo = new System.Windows.Forms.MenuItem();
this.paneTree = new System.Windows.Forms.Panel();
this.parameterProperties1 = new AssemblyExplorer.ParameterProperties();
this.typeProperties1 = new AssemblyExplorer.TypeProperties();
this.fieldProperties1 = new AssemblyExplorer.FieldProperties();
this.propertyProperties1 = new AssemblyExplorer.PropertyProperties();
this.eventProperties1 = new AssemblyExplorer.EventProperties();
this.methodProperties1 = new AssemblyExplorer.MethodProperties();
this.tv = new System.Windows.Forms.TreeView();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.panelSimple = new System.Windows.Forms.Panel();
this.label3 = new System.Windows.Forms.Label();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.pictureBox3 = new System.Windows.Forms.PictureBox();
this.lstFields = new System.Windows.Forms.ListBox();
this.pictureBox6 = new System.Windows.Forms.PictureBox();
this.label6 = new System.Windows.Forms.Label();
this.lblProperties = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.pictureBox5 = new System.Windows.Forms.PictureBox();
this.lstTypes = new System.Windows.Forms.ListBox();
this.lstModules = new System.Windows.Forms.ListBox();
this.label4 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.lstProperties = new System.Windows.Forms.ListBox();
this.lstMethods = new System.Windows.Forms.ListBox();
this.lstEvents = new System.Windows.Forms.ListBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.pictureBox4 = new System.Windows.Forms.PictureBox();
this.paneTree.SuspendLayout();
this.panelSimple.SuspendLayout();
this.SuspendLayout();
//
// mnuAbout
//
this.mnuAbout.Index = 0;
this.mnuAbout.Text = "&About...";
this.mnuAbout.Click += new System.EventHandler(this.mnuAbout_Click);
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnuFile,
this.menuItem1,
this.mnuInfo});
//
// mnuFile
//
this.mnuFile.Index = 0;
this.mnuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem6,
this.menuItem7,
this.mnuExit,
this.menuSepRecent});
this.mnuFile.Text = "&File";
//
// menuItem6
//
this.menuItem6.Index = 0;
this.menuItem6.Text = "&Open";
this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
//
// menuItem7
//
this.menuItem7.Index = 1;
this.menuItem7.Text = "-";
//
// mnuExit
//
this.mnuExit.Index = 2;
this.mnuExit.Text = "&Exit";
this.mnuExit.Click += new System.EventHandler(this.mnuExit_Click);
//
// menuSepRecent
//
this.menuSepRecent.Index = 3;
this.menuSepRecent.Text = "-";
this.menuSepRecent.Visible = false;
//
// menuItem1
//
this.menuItem1.Index = 1;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem10,
this.menuItem9,
this.menuItem8,
this.menuItem2,
this.menuItem3,
this.menuItem4,
this.menuItem5});
this.menuItem1.Text = "&View";
//
// menuItem10
//
this.menuItem10.Checked = true;
this.menuItem10.Index = 0;
this.menuItem10.RadioCheck = true;
this.menuItem10.Text = "Simple View";
this.menuItem10.Click += new System.EventHandler(this.menuItem10_Click);
//
// menuItem9
//
this.menuItem9.Index = 1;
this.menuItem9.RadioCheck = true;
this.menuItem9.Text = "Tree view";
this.menuItem9.Click += new System.EventHandler(this.menuItem9_Click);
//
// menuItem8
//
this.menuItem8.Index = 2;
this.menuItem8.Text = "-";
//
// menuItem2
//
this.menuItem2.Checked = true;
this.menuItem2.Index = 3;
this.menuItem2.Text = "Show Private";
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
//
// menuItem3
//
this.menuItem3.Checked = true;
this.menuItem3.Index = 4;
this.menuItem3.Text = "Show Instance";
this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
//
// menuItem4
//
this.menuItem4.Checked = true;
this.menuItem4.Index = 5;
this.menuItem4.Text = "Show Static";
this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
//
// menuItem5
//
this.menuItem5.Index = 6;
this.menuItem5.Text = "Show Derived";
this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
//
// mnuInfo
//
this.mnuInfo.Index = 2;
this.mnuInfo.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnuAbout});
this.mnuInfo.Text = "&Help";
//
// paneTree
//
this.paneTree.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.paneTree.Controls.AddRange(new System.Windows.Forms.Control[] {
this.parameterProperties1,
this.typeProperties1,
this.fieldProperties1,
this.propertyProperties1,
this.eventProperties1,
this.methodProperties1,
this.tv});
this.paneTree.Name = "paneTree";
this.paneTree.Size = new System.Drawing.Size(1000, 628);
this.paneTree.TabIndex = 5;
//
// parameterProperties1
//
this.parameterProperties1.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right);
this.parameterProperties1.Location = new System.Drawing.Point(472, 8);
this.parameterProperties1.Name = "parameterProperties1";
this.parameterProperties1.Size = new System.Drawing.Size(520, 616);
this.parameterProperties1.TabIndex = 6;
this.parameterProperties1.Visible = false;
//
// typeProperties1
//
this.typeProperties1.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right);
this.typeProperties1.Location = new System.Drawing.Point(472, 8);
this.typeProperties1.Name = "typeProperties1";
this.typeProperties1.Size = new System.Drawing.Size(520, 616);
this.typeProperties1.TabIndex = 5;
this.typeProperties1.Visible = false;
//
// fieldProperties1
//
this.fieldProperties1.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right);
this.fieldProperties1.Location = new System.Drawing.Point(472, 8);
this.fieldProperties1.Name = "fieldProperties1";
this.fieldProperties1.Size = new System.Drawing.Size(520, 616);
this.fieldProperties1.TabIndex = 4;
this.fieldProperties1.Visible = false;
//
// propertyProperties1
//
this.propertyProperties1.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right);
this.propertyProperties1.Location = new System.Drawing.Point(472, 8);
this.propertyProperties1.Name = "propertyProperties1";
this.propertyProperties1.Size = new System.Drawing.Size(520, 616);
this.propertyProperties1.TabIndex = 3;
this.propertyProperties1.Visible = false;
//
// eventProperties1
//
this.eventProperties1.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right);
this.eventProperties1.Location = new System.Drawing.Point(472, 8);
this.eventProperties1.Name = "eventProperties1";
this.eventProperties1.Size = new System.Drawing.Size(520, 616);
this.eventProperties1.TabIndex = 2;
this.eventProperties1.Visible = false;
//
// methodProperties1
//
this.methodProperties1.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right);
this.methodProperties1.Location = new System.Drawing.Point(474, 8);
this.methodProperties1.Name = "methodProperties1";
this.methodProperties1.Size = new System.Drawing.Size(518, 624);
this.methodProperties1.TabIndex = 1;
this.methodProperties1.Visible = false;
//
// tv
//
this.tv.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.tv.ImageList = this.imageList1;
this.tv.Location = new System.Drawing.Point(8, 8);
this.tv.Name = "tv";
this.tv.Size = new System.Drawing.Size(458, 616);
this.tv.TabIndex = 0;
this.tv.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.tv_AfterSelect);
//
// imageList1
//
this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
//
// panelSimple
//
this.panelSimple.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.panelSimple.Controls.AddRange(new System.Windows.Forms.Control[] {
this.label3,
this.pictureBox2,
this.pictureBox3,
this.lstFields,
this.pictureBox6,
this.label6,
this.lblProperties,
this.label5,
this.pictureBox5,
this.lstTypes,
this.lstModules,
this.label4,
this.label2,
this.label1,
this.lstProperties,
this.lstMethods,
this.lstEvents,
this.pictureBox1,
this.pictureBox4});
this.panelSimple.Name = "panelSimple";
this.panelSimple.Size = new System.Drawing.Size(998, 628);
this.panelSimple.TabIndex = 6;
//
// label3
//
this.label3.Location = new System.Drawing.Point(794, 11);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(62, 16);
this.label3.TabIndex = 23;
this.label3.Text = "&Properties";
//
// pictureBox2
//
this.pictureBox2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox2.Image = ((System.Drawing.Bitmap)(resources.GetObject("pictureBox2.Image")));
this.pictureBox2.Location = new System.Drawing.Point(504, 8);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(16, 16);
this.pictureBox2.TabIndex = 22;
this.pictureBox2.TabStop = false;
//
// pictureBox3
//
this.pictureBox3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox3.Image = ((System.Drawing.Bitmap)(resources.GetObject("pictureBox3.Image")));
this.pictureBox3.Location = new System.Drawing.Point(760, 8);
this.pictureBox3.Name = "pictureBox3";
this.pictureBox3.Size = new System.Drawing.Size(18, 16);
this.pictureBox3.TabIndex = 21;
this.pictureBox3.TabStop = false;
//
// lstFields
//
this.lstFields.Anchor = (((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.lstFields.HorizontalScrollbar = true;
this.lstFields.IntegralHeight = false;
this.lstFields.Location = new System.Drawing.Point(760, 368);
this.lstFields.Name = "lstFields";
this.lstFields.Size = new System.Drawing.Size(232, 260);
this.lstFields.Sorted = true;
this.lstFields.TabIndex = 18;
//
// pictureBox6
//
this.pictureBox6.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox6.Cursor = System.Windows.Forms.Cursors.Default;
this.pictureBox6.Image = ((System.Drawing.Bitmap)(resources.GetObject("pictureBox6.Image")));
this.pictureBox6.Location = new System.Drawing.Point(760, 344);
this.pictureBox6.Name = "pictureBox6";
this.pictureBox6.Size = new System.Drawing.Size(18, 16);
this.pictureBox6.TabIndex = 20;
this.pictureBox6.TabStop = false;
//
// label6
//
this.label6.Location = new System.Drawing.Point(792, 347);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(144, 16);
this.label6.TabIndex = 19;
this.label6.Text = "&Fields:";
//
// lblProperties
//
this.lblProperties.Location = new System.Drawing.Point(552, -84);
this.lblProperties.Name = "lblProperties";
this.lblProperties.Size = new System.Drawing.Size(144, 34);
this.lblProperties.TabIndex = 12;
this.lblProperties.Text = "&Properties:";
//
// label5
//
this.label5.Location = new System.Drawing.Point(26, 197);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(56, 16);
this.label5.TabIndex = 11;
this.label5.Text = "&Types:";
//
// pictureBox5
//
this.pictureBox5.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox5.Image = ((System.Drawing.Bitmap)(resources.GetObject("pictureBox5.Image")));
this.pictureBox5.Location = new System.Drawing.Point(2, 198);
this.pictureBox5.Name = "pictureBox5";
this.pictureBox5.Size = new System.Drawing.Size(14, 16);
this.pictureBox5.TabIndex = 16;
this.pictureBox5.TabStop = false;
//
// lstTypes
//
this.lstTypes.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left);
this.lstTypes.HorizontalScrollbar = true;
this.lstTypes.IntegralHeight = false;
this.lstTypes.Location = new System.Drawing.Point(0, 218);
this.lstTypes.Name = "lstTypes";
this.lstTypes.Size = new System.Drawing.Size(250, 410);
this.lstTypes.Sorted = true;
this.lstTypes.TabIndex = 4;
this.lstTypes.SelectedIndexChanged += new System.EventHandler(this.lstTypes_SelectedIndexChanged);
//
// lstModules
//
this.lstModules.HorizontalScrollbar = true;
this.lstModules.IntegralHeight = false;
this.lstModules.Location = new System.Drawing.Point(0, 32);
this.lstModules.Name = "lstModules";
this.lstModules.Size = new System.Drawing.Size(250, 160);
this.lstModules.Sorted = true;
this.lstModules.TabIndex = 5;
this.lstModules.SelectedIndexChanged += new System.EventHandler(this.lstModules_SelectedIndexChanged);
//
// label4
//
this.label4.Location = new System.Drawing.Point(24, 10);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(64, 16);
this.label4.TabIndex = 13;
this.label4.Text = "&Modules:";
//
// label2
//
this.label2.Location = new System.Drawing.Point(530, 11);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(144, 16);
this.label2.TabIndex = 10;
this.label2.Text = "&Methods:";
//
// label1
//
this.label1.Location = new System.Drawing.Point(284, 10);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(144, 16);
this.label1.TabIndex = 9;
this.label1.Text = "&Events:";
//
// lstProperties
//
this.lstProperties.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right);
this.lstProperties.HorizontalScrollbar = true;
this.lstProperties.IntegralHeight = false;
this.lstProperties.Location = new System.Drawing.Point(760, 32);
this.lstProperties.Name = "lstProperties";
this.lstProperties.Size = new System.Drawing.Size(232, 304);
this.lstProperties.Sorted = true;
this.lstProperties.TabIndex = 6;
//
// lstMethods
//
this.lstMethods.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left);
this.lstMethods.HorizontalScrollbar = true;
this.lstMethods.IntegralHeight = false;
this.lstMethods.Location = new System.Drawing.Point(503, 32);
this.lstMethods.Name = "lstMethods";
this.lstMethods.Size = new System.Drawing.Size(250, 596);
this.lstMethods.Sorted = true;
this.lstMethods.TabIndex = 8;
//
// lstEvents
//
this.lstEvents.Anchor = ((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left);
this.lstEvents.HorizontalScrollbar = true;
this.lstEvents.IntegralHeight = false;
this.lstEvents.Location = new System.Drawing.Point(256, 32);
this.lstEvents.Name = "lstEvents";
this.lstEvents.Size = new System.Drawing.Size(240, 596);
this.lstEvents.Sorted = true;
this.lstEvents.TabIndex = 7;
//
// pictureBox1
//
this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox1.Image = ((System.Drawing.Bitmap)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(256, 8);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(16, 16);
this.pictureBox1.TabIndex = 14;
this.pictureBox1.TabStop = false;
//
// pictureBox4
//
this.pictureBox4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox4.Image = ((System.Drawing.Bitmap)(resources.GetObject("pictureBox4.Image")));
this.pictureBox4.Location = new System.Drawing.Point(1, 8);
this.pictureBox4.Name = "pictureBox4";
this.pictureBox4.Size = new System.Drawing.Size(16, 16);
this.pictureBox4.TabIndex = 15;
this.pictureBox4.TabStop = false;
//
// frmMain
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(1000, 633);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.paneTree,
this.panelSimple});
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Menu = this.mainMenu1;
this.Name = "frmMain";
this.Text = "Assembly Explorer";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Load += new System.EventHandler(this.frmMain_Load);
this.paneTree.ResumeLayout(false);
this.panelSimple.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new frmMain());
}
#endregion
#region General Methods
private void ListAllModules()
{
try
{
if (oAssembly == null)
return;
mdls = oAssembly.GetModules();
if (displayTree)
ListModulesTV();
else
ListModulesPlain();
}
catch
{
MessageBox.Show("Can't load modules from assembly");
}
}
private void ListAllModules(string sPath)
{
try
{
if (m_sPath.CompareTo(sPath) == 0)
return;
m_sPath = sPath;
oAssembly = Assembly.LoadFrom(sPath);
ListAllModules();
}
catch
{
MessageBox.Show("Can't load modules from assembly");
}
}
private BindingFlags GetFilter()
{
BindingFlags filter = BindingFlags.Public | BindingFlags.IgnoreReturn;
if (menuItem2.Checked)
filter |= BindingFlags.NonPublic;
if (menuItem3.Checked)
filter |= BindingFlags.Instance;
if (menuItem4.Checked)
filter |= BindingFlags.Static;
if (!menuItem5.Checked)
filter |= BindingFlags.DeclaredOnly;
else
filter |= BindingFlags.FlattenHierarchy;
return filter;
}
private void RefreshMembers()
{
string str = m_sPath;
m_sPath = String.Empty;
m_sModule = String.Empty;
ListAllModules(str);
}
private void SetView()
{
panelSimple.Visible = displayTree;
menuItem10.Checked = displayTree;
displayTree = !displayTree;
paneTree.Visible = displayTree;
menuItem9.Checked = displayTree;
ListAllModules();
HideProperties(-1);
}
private void SetRecent()
{
for (int i = 1; i < 7; i++)
{
RegistryKey rk = Registry.CurrentUser.OpenSubKey(REG_KEY, true);
if (rk != null)
{
if (rk.GetValue("Recent"+i) != null)
{
mnuFile.MenuItems.Add("&" + i + ". " + rk.GetValue("Recent"+i).ToString(),
new System.EventHandler(this.menuRecent_Click));
}
else
{
if (i > 1)
menuSepRecent.Visible = true;
break;
}
}
}
}
#endregion
#region Create Simple View Methods
private void ListModulesPlain()
{
lstModules.Items.Clear();
lstTypes.Items.Clear();
for (int i = 0; i < mdls.Length; i++)
lstModules.Items.Add(mdls[i].Name);
if (mdls.Length > 0)
lstModules.SelectedIndex = 0;
}
private void ListTypes(string sModule)
{
try
{
if (mdls == null)
return;
if (mdls.Length == 0)
return;
if (m_sModule.CompareTo(sModule) == 0)
return;
m_sModule = sModule;
m_sType = String.Empty;
lstTypes.Items.Clear();
for (int i = 0; i < mdls.Length; i++)
{
if (sModule.CompareTo(mdls[i].Name) == 0)
{
iModule = i;
foreach (Type oType in mdls[i].GetTypes())
lstTypes.Items.Add(oType.Name);
lstTypes.SelectedIndex = 0;
return;
}
}
}
catch
{
MessageBox.Show("Can't load types from assembly");
}
}
private void ListAllMembers(string sType)
{
try
{
if (m_sType.CompareTo(sType) == 0)
return;
m_sType = sType;
lstEvents.Items.Clear();
lstMethods.Items.Clear();
lstProperties.Items.Clear();
lstFields.Items.Clear();
foreach (Type oType in mdls[iModule].GetTypes())
{
if (sType == oType.Name)
{
foreach (MemberInfo oMember in oType.GetMembers(GetFilter()))
{
if (oMember is EventInfo)
lstEvents.Items.Add(oMember.ToString());
else if (oMember is MethodInfo)
lstMethods.Items.Add(oMember);
else if (oMember is PropertyInfo)
lstProperties.Items.Add(oMember.ToString());
else if (oMember is FieldInfo)
lstFields.Items.Add(oMember.ToString());
}
return;
}
}
}
catch
{
MessageBox.Show("Can't load members from assembly");
}
}
#endregion
#region Create TreeView Methods
private void ListModulesTV()
{
HideProperties(-1);
tv.Nodes.Clear();
tv.Nodes.Add(new TreeNode(oAssembly.ToString()));
for (int i = 0; i < mdls.Length; i++)
{
int index = tv.Nodes[0].Nodes.Add(new TreeNode(mdls[i].Name));
ListTypesTv(mdls[i], tv.Nodes[0].Nodes[index]);
}
}
private void ListTypesTv(Module mdl, TreeNode node)
{
SetImage(node, 1);
foreach (Type oType in mdl.GetTypes())
ListMembersTV(oType, node);
}
private void ListMembersTV(Type oType, TreeNode parentNode)
{
int index = parentNode.Nodes.Add(new TreeNode(oType.Name));
TreeNode node = parentNode.Nodes[index];
node.Tag = oType;
if (oType.IsInterface)
SetImage(node, 3);
else if (oType.IsClass)
SetImage(node, 2);
else if (oType.IsEnum)
SetImage(node, 4);
else if (oType.IsValueType)
SetImage(node, 2);
foreach (MemberInfo oMember in oType.GetMembers(GetFilter()))
{
if (oMember is Type)
ListMembersTV((Type) oMember, node);
else
{
index = node.Nodes.Add(new TreeNode(oMember.ToString()));
node.Nodes[index].Tag = oMember;
if (oMember is EventInfo)
SetImage(node.Nodes[index], 10);
else if (oMember is MethodInfo)
ListParametersTV((MethodBase)oMember, node.Nodes[index]);
else if (oMember is ConstructorInfo)
ListParametersTV((MethodBase)oMember, node.Nodes[index]);
else if (oMember is PropertyInfo)
SetImage(node.Nodes[index], 7);
else if (oMember is FieldInfo)
SetImage(node.Nodes[index], 5);
}
}
}
private void ListParametersTV(MethodBase oMember, TreeNode node)
{
SetImage(node, 6);
foreach (ParameterInfo oPar in oMember.GetParameters())
{
int index = node.Nodes.Add(new TreeNode(oPar.Name));
node.Nodes[index].Tag = oPar;
if (oPar.IsRetval)
SetImage(node.Nodes[index], 9);
else
SetImage(node.Nodes[index], 8);
}
}
private void SetImage(TreeNode node, int index)
{
node.ImageIndex = index;
node.SelectedImageIndex = index;
}
private void HideProperties(int index)
{
methodProperties1.Visible = (index == TYPE_METHOD);
eventProperties1.Visible = (index == TYPE_EVENT);
propertyProperties1.Visible = (index == TYPE_PROPERTY);
fieldProperties1.Visible = (index == TYPE_FIELD);
typeProperties1.Visible = (index == TYPE_CLASS || index == TYPE_INTERFACE || index == TYPE_ENUM);
parameterProperties1.Visible = (index == TYPE_PARAMETER || index == TYPE_RETVAL);
}
#endregion
#region Menu Events
private void mnuExit_Click(object sender, System.EventArgs e)
{
if (m_sPath.Length > 0)
{
try
{
Registry.CurrentUser.DeleteSubKeyTree(REG_KEY);
}
catch {}
RegistryKey rk = Registry.CurrentUser.CreateSubKey(REG_KEY);
if (rk != null)
{
rk.SetValue("Recent1", m_sPath);
string str = String.Empty;
int count = 2;
for (int i = 4; i < mnuFile.MenuItems.Count; i++)
{
str = mnuFile.MenuItems[i].Text.Substring(4);
if (str.ToLower().CompareTo(m_sPath.ToLower()) != 0)
{
rk.SetValue("Recent"+count, str);
count++;
}
}
}
}
Application.Exit();
}
private void menuRecent_Click(object sender, System.EventArgs e)
{
ListAllModules(((MenuItem)sender).Text.Substring(4));
}
private void mnuAbout_Click(object sender, System.EventArgs e)
{
string msg = this.Text +
"\nVersion: " + Application.ProductVersion +
"\nBy: Leon Langleyben, \n\tSoftware Resources (S.A.B) Ltd. leon@srl.co.il" +
"\nSpecial thanks to C. Garc�a, \n\tDENKFABRIK - Switzerland \n\tFor original idea and implementation.";
MessageBox.Show(msg, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void menuItem2_Click(object sender, System.EventArgs e)
{
menuItem2.Checked = !menuItem2.Checked;
RefreshMembers();
}
private void menuItem3_Click(object sender, System.EventArgs e)
{
menuItem3.Checked = !menuItem3.Checked;
RefreshMembers();
}
private void menuItem4_Click(object sender, System.EventArgs e)
{
menuItem4.Checked = !menuItem4.Checked;
RefreshMembers();
}
private void menuItem5_Click(object sender, System.EventArgs e)
{
menuItem5.Checked = !menuItem5.Checked;
RefreshMembers();
}
private void menuItem6_Click(object sender, System.EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
if (DialogResult.OK == ofd.ShowDialog())
{
ListAllModules(ofd.FileName);
}
}
private void menuItem9_Click(object sender, System.EventArgs e)
{
if (!menuItem9.Checked)
SetView();
}
private void menuItem10_Click(object sender, System.EventArgs e)
{
if (!menuItem10.Checked)
SetView();
}
#endregion
#region Other Events
private void lstTypes_SelectedIndexChanged(object sender, System.EventArgs e)
{
ListAllMembers(lstTypes.Text);
}
private void lstModules_SelectedIndexChanged(object sender, System.EventArgs e)
{
ListTypes(lstModules.Text);
}
private void frmMain_Load(object sender, System.EventArgs e)
{
SetView();
}
private void tv_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
{
int index = tv.SelectedNode.ImageIndex;
HideProperties(index);
switch (index)
{
case TYPE_CLASS:
case TYPE_INTERFACE:
case TYPE_ENUM:
typeProperties1.SetObject(tv.SelectedNode.Tag);
break;
case TYPE_FIELD:
fieldProperties1.SetObject(tv.SelectedNode.Tag);
break;
case TYPE_METHOD:
methodProperties1.SetObject( tv.SelectedNode.Tag);
break;
case TYPE_PROPERTY:
propertyProperties1.SetObject(tv.SelectedNode.Tag);
break;
case TYPE_PARAMETER:
case TYPE_RETVAL:
parameterProperties1.SetObject(tv.SelectedNode.Tag);
break;
case TYPE_EVENT:
eventProperties1.SetObject(tv.SelectedNode.Tag);
break;
}
}
#endregion
}
}