Convert SD source code project to VS engineering, find the Application.Run () method in the project, found in the RUN method of the StartworkbenchCommand class:
Application.run (f);???
Here, F should be the main interface of SD, then look at F definition - also in the RUN method of the StartworkbenchCommand class:
Form f = (form) Workbenchsingleton.workbench;
From here, WorkbenchSingleton is an extension of Form, otherwise it will not use forced conversion J ~~
In the name of WorkbenchSingleton, it is an implementation of a Singleton mode! Well, it's time to see WorkbenchSingleton.
Hey? ? ? not good! ! ! ! WorkbenchSingleton is just a generals of ordinary pass, not what I think! ! But how can I force the conversion? ? The problem must be on the Workbench attribute of WorkbenchSinglet, hurry up ~~~~~~
No, the workbench property is just simple to return an instance of iWorkbench. Is it ~~~~ Take a look at iWorkBench! Nor ~~~~~~ Depressed! ! ! ! ! !
It seems that only strong attack! ! ! Find WorkbenchSingleton in the current file found in the Run () method of the InitializeWorkbenchCommand class:
DEFAULTWORKBENCH W = New DefaultWorkbench ();
Workbenchsingleton.workbench = W;
I have a play, huh, huh ~ ~ It seems that DefaultWorkBench is what I want! !
Go to DefaultWorkBench found that defaultworkbench is not fake, DefaultWorkBench inherits Form and iWorkbench. But now there is a question: How to ensure that INITIALIZEWORKBENCHCOMMAND.RUN () must be called before startworkbenchcommand.run ()? ? If you don't guarantee, then you will cause initialization failure, the whole system will finish it ~~~~~ I think this is because it is a hand and feet you made in the plugin file, or you see how the SD is the toolbar. How to follow Oriented: First, the file menu is the edit menu. . . . . ? ? ? ? Don't take a look at DEFAULTWORKBENCH first, see what interesting stuff! !
First, in the form of VS.NET, it seems that DefaultWorkBench is just a form on a form, it seems that the SD menu bar, the toolbar, panel ..., etc., it is really hidden from the outside. , Enough cattle ~~~ But how to hang it is still clear, depressed ~~~~~~~~~~ Take a look at the DEFAULTWORKBENCH code!
I don't know, I have 34 methods, 5 attributes, 14 member variables and 3 events, formatted code 667 lines ~~~~ Some people have seen, but I may see it. You can find a focus, that is, what I want! ! ! You look at what I said, this is not in DefaultWorkbench, there are such member variables and a method:
Readonly string mainmenupath = "/ Workbanch / MenuItems";
Public CommandbarManager CommandbarManager = New CommandbarManager ();
Public CommandBar TopMenu = NULL;
Public commandbar [] Toolbars = NULL;
Void CreatemainMenu ()
{
TopMenu = New Commandbar (Commandbarsty.MENU);
CommandBarItem [] Items = (CommandBarItem []) (AddINTREESINGLETON.ADDINTREE.
Gettreenode (MainMenuPath) .BuildchildItems (this)). Toarray (Typeof (CommandBarItem));
TopMenu.Items.clear ();
TopMenu.Items.Addrange (items);
}
Well ~~~~~~~~ Take a look now, put the above code to your own program, it should be it! ! Pray for ing !!!
Open my project, paste the code in Mainform, compile - through, excite ing, run - throw an exception, depressed ing! ! !
Take a closer look, it seems that you can't find the / Workbanch / Menuitems path, which is more depressed, / Workbanch / MenuiteMs path is not defined in CORE? ? Is it not? ? ?
Use the lookup tool to find the Core project, I really didn't find "/ Workbanch / MenuItems"