private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog wSchemaDialog = new OpenFileDialog();

            wSchemaDialog.DefaultExt      = "dll";
            wSchemaDialog.CheckFileExists = true;

            wSchemaDialog.Filter       = "DLL Files (*.dll;*.exe)|*.dll;*.exe|All Files (*.*)|*.*";
            wSchemaDialog.ShowReadOnly = true;

            MenuItemList wMenuItemList = new MenuItemList();


            if (wSchemaDialog.ShowDialog() == DialogResult.OK)
            {
                MenuItem wMenuItem = new MenuItem();
                Assembly ass       = new Assembly(wSchemaDialog.FileName);
                lblFileName.Text = wSchemaDialog.FileName;
                foreach (AssemblyClass wAssemblyClass in ass.ClassCollections)
                {
                    if (wAssemblyClass.BaseType != null)
                    {
                        if (wAssemblyClass.BaseType.Name.Contains("Form"))
                        {
                            wMenuItem = new MenuItem();
                            wMenuItem.AssemblyInfo = wAssemblyClass.FullyQualifiedName;
                            wMenuItem.FormName     = wAssemblyClass.Name;
                            wMenuItemList.Add(wMenuItem);
                        }
                    }
                }

                listBox1.DataSource = wMenuItemList;
            }
        }
示例#2
0
        static void LoadRecursive(TreeNode pTreeNodeRoot, MenuItemList pMenuItemChilds)
        {
            TreeNode wTreeNodeChild = null;

            foreach (MenuItem wMenuItem in pMenuItemChilds)
            {
                wTreeNodeChild     = new TreeNode(wMenuItem.DisplayName);
                wTreeNodeChild.Tag = wMenuItem;

                pTreeNodeRoot.Nodes.Add(wTreeNodeChild);

                LoadRecursive(wTreeNodeChild, wMenuItem.MenuItemList);
            }
        }