Plugin Architecture - Create a parent MDI form of interest to children in the DLL

I am experimenting with the plugin architecture for my company's internal business system. I was able to read all .DLLs in the Plugin folder that implement a specific interface. What I'm trying to figure out is the best way to communicate between the parent MDI host application and the forms that will be in the .DLL that I intend to make MDI children.

Currently, I am only returning ToolStripMenuItem objects from .DLL to be added to the parent MDI. I also tested that events connected in .LLL to ToolStripMenuItems propagate to code in .LLL. I also managed to return the Form object through the interface and open this form, as the plugin folder is "scanned".

However, I do not quite understand how I will make these forms MDI children. In addition, any other forms living in .LLL must also be MDI children. I created the VS 2008 Addin project to see what is happening, and it seems that Addin is accepting the Application object to which it adds ToolStripMenuItems, and performs other operations. Code for creating a menu inside .DLL. This is the opposite of what I have done so far when the MDI requests a ToolStripMenuItem from each .DLL and adds the returned object to its own menu.

Will my plugin architecture accept an application object in the same way as I could get forms to open as an MDI parent? Am I asking others, currently unknown to me, for headaches, NOT passing the application object to .DLL?

+3
1

- . , , PluginManager .

, :

    ''' <summary>
'''The IPluginManager interface is implemented by whatever component manages your gui
'''It provides a means for plugins to access GUI elements of the application
''' </summary>
Public Interface IPluginManager

    ''' <summary>
    '''The MDIForm property allows the plugin to display itself
    '''inside of the application main MDI form (ie.  plugin.form.mdiparent=mdiform)
    ''' </summary>
    ReadOnly Property MDIForm() As Form
    ReadOnly Property Toolbar() As ToolBar

    ''' <summary>
    '''Allows the plugin to request that the application main menu be updated
    ''' </summary>
    ''' <param name="Menu">The menu to add to the main menu</param>
    Sub UpdateMainMenu(ByVal Menu As Menu)

    ''' <summary>
    '''Allows the plugin to request that the application workspace toolbar be updated
    ''' </summary>
    ''' <param name="Buttons">the collection of toolbar buttons to add to the toolbar</param>
    Sub UpdateToolbarButtons(ByVal Buttons As ToolBar.ToolBarButtonCollection)

End Interface

:

    ''' <summary>
'''The IPlugin interface is implemented by all plugins
'''It provides a standardized means for the pluginmanager
'''to communicate with a plugin, without knowing the plugin explicitly
''' </summary>
Public Interface IPlugin

    ''' <summary>
    '''Allows the plugin to be intialized first before it asked to run
    ''' </summary>
    Sub Initialize()

    ''' <summary>
    '''Allows the pluginmanager to register itself with the plugin
    '''so the plugin can listen to events from the pluginmanager
    ''' </summary>
    ''' <param name="PluginManager">A plugin manager that implements the IPluginManager interface</param>
    Sub RegisterPluginManager(ByVal PluginManager As IPluginManager)

    ''' <summary>
    '''Requests the plugin to run its functionality
    ''' </summary>
    Sub Run()

End Interface

, PluginManager ( , ), , . PluginManager Intializes, ().

, ( ), MDIParent MDIForm, IPluginManager. !

, .

+4

Source: https://habr.com/ru/post/1729973/


All Articles