Application PlugIn with Interface

  • Thread starter Thread starter Raphael
  • Start date Start date
R

Raphael

Hi, I'm creating an application that has a Tab control. I
would like to create a series of plug-in DLL's which will
make up each tab. The class for each tab inherits the Tab
control, and implements an interface so I can recognize
it...I've gotten that far...

My problem, is that I need to be able to get the controls
that are defined in the DLL, to the application. So, If
someone codes a button in the DLL, it will show up in the
tab control on my app once I add the tab that is defined
by the class...my problem is how can I get the onClick
even to get passed from my application, to the DLL?
 
Hi Raphael,
Thanks for using MSDN Newsgroup. My understanding to your problem now
is
you have an TabControl in your application, and you want to let your Plugin
in the DLL draw it's own interface on every tab page( I think it's TabPage
not TabControl right?) The Problem is that you don't know how to get the
controls defined in your derived TabPage Control and associate them with
events. If I was wrong, please let me know. And I want to make sure some
points before giving you adivse.
1. Is your Dll a .NET Control Library?
2. which event would you associate your controles in your plugin. the event
handler is defined out side the Plugin or still instide the same Plugin?

Anyway, I think you may also think about passing the reference of the
TabPage in an initialization method of your Plugin Control, Then you can do
the initiliaztion in your plugin control. and it's easy to associate the
controls
with the events inside the same control.
If you want to associate ouside event to the inner controls in your
TabPage.
The number of the events you want to associate with the controls is
very small, maybe you can define some
properties on your control for setting and getting the value (like a
facade).
Or you need Enumerate the Controls property of your TabPage Property to
find the Control by 'Name', and then associate the event handler to it.

Is this helpful to your, If you still have problems on it, please let me
know!
Thanks !


Best regards,

Ying-Shen Yu [MS]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Raphael" <[email protected]>
| Sender: "Raphael" <[email protected]>
| Subject: Application PlugIn with Interface
| Date: Wed, 10 Sep 2003 10:18:37 -0700
| Lines: 12
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcN3v5J5d9Hfe2qoTeGWql0RdCBHEA==
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:52064
| NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| Hi, I'm creating an application that has a Tab control. I
| would like to create a series of plug-in DLL's which will
| make up each tab. The class for each tab inherits the Tab
| control, and implements an interface so I can recognize
| it...I've gotten that far...
|
| My problem, is that I need to be able to get the controls
| that are defined in the DLL, to the application. So, If
| someone codes a button in the DLL, it will show up in the
| tab control on my app once I add the tab that is defined
| by the class...my problem is how can I get the onClick
| even to get passed from my application, to the DLL?
|
 
Hi Ying-Shen, you are very close!



For all intents and purposed, I'm not really using a
TabControl, I'm using a docking window.
DockHost
-DockPanel
-DocControl


My DLL's will inherit the DocControl class. They will
implement my plugIn interface so they can be found. My
application will check for the DLL, see if it implements
the proper interface, then load the DLL.

The thing is, when I loads the DLL, or more to the point:

For intIndex = 0 To Plugins.Length - 1
objPlugin = DirectCast
(plugInServices.CreateInstance(Plugins(intIndex)),
DMCInterface.IPlugin)

Trace.WriteLine("Found Add-In: " & Plugins
(intIndex).ClassName.ToString & ":" & objPlugin.Name)
dc = New DockingSuite.DockControl
dc.Text = objPlugin.Name
dp.Controls.Add(dc)
Next

My control is added, but the buttons and textboxes that I
defined in them are not visible. So I thought I should
created a property which would enumerate all the controls
in the dll, and return them. Then, I would add the
controls found in the DLL, to the dockControl object...

For intIndex = 0 To Plugins.Length - 1
objPlugin = DirectCast
(plugInServices.CreateInstance(Plugins(intIndex)),
DMCInterface.IPlugin)

Trace.WriteLine("Found Add-In: " & Plugins
(intIndex).ClassName.ToString & ":" & objPlugin.Name)
dc = New DockingSuite.DockControl
dc.Text = objPlugin.Name
Dim ar As ArrayList
Dim c As Object
ar = objPlugin.ControlsCollection
objPlugin.Initialize(objHost)
Trace.WriteLine("Found " & ar.Count & " Add-
In Controls")
For Each c In ar
Trace.WriteLine(" -" &
c.GetType.ToString & " Add-In Controls")
dc.Controls.Add(c)
Next
dp.Controls.Add(dc)
Next

This worked, in that now I could see the controls. But
when I clicked on them, nothing happened. I want to pass
the click even BACK to the DLL, so that the Button1_Click
method in my DLL responds to the click from the
dockControl, now located in the application.


Hope this makes more sense. I know I'm close, I just need
to tie the ends.

Thanks alot for your help!









-----Original Message-----
Hi Raphael,
Thanks for using MSDN Newsgroup. My understanding to your problem now
is
you have an TabControl in your application, and you want to let your Plugin
in the DLL draw it's own interface on every tab page( I think it's TabPage
not TabControl right?) The Problem is that you don't know how to get the
controls defined in your derived TabPage Control and associate them with
events. If I was wrong, please let me know. And I want to make sure some
points before giving you adivse.
1. Is your Dll a .NET Control Library?
2. which event would you associate your controles in your plugin. the event
handler is defined out side the Plugin or still instide the same Plugin?

Anyway, I think you may also think about passing the reference of the
TabPage in an initialization method of your Plugin Control, Then you can do
the initiliaztion in your plugin control. and it's easy to associate the
controls
with the events inside the same control.
If you want to associate ouside event to the inner controls in your
TabPage.
The number of the events you want to associate with the controls is
very small, maybe you can define some
properties on your control for setting and getting the value (like a
facade).
Or you need Enumerate the Controls property of your TabPage Property to
find the Control by 'Name', and then associate the event handler to it.

Is this helpful to your, If you still have problems on it, please let me
know!
Thanks !


Best regards,

Ying-Shen Yu [MS]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Raphael" <[email protected]>
| Sender: "Raphael" <[email protected]>
| Subject: Application PlugIn with Interface
| Date: Wed, 10 Sep 2003 10:18:37 -0700
| Lines: 12
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcN3v5J5d9Hfe2qoTeGWql0RdCBHEA==
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:52064
| NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| Hi, I'm creating an application that has a Tab control. I
| would like to create a series of plug-in DLL's which will
| make up each tab. The class for each tab inherits the Tab
| control, and implements an interface so I can recognize
| it...I've gotten that far...
|
| My problem, is that I need to be able to get the controls
| that are defined in the DLL, to the application. So, If
| someone codes a button in the DLL, it will show up in the
| tab control on my app once I add the tab that is defined
| by the class...my problem is how can I get the onClick
| even to get passed from my application, to the DLL?
|

.
 
Hi Raphael,
Thanks for your detail information, that's very helpful for me to
understand your problem correctly.
First I'd like to make sure one thing. In your reply, You mentions that
your control had been added,
I'd like to make sure what is your control refer to?
Did you refer to the DockingSuite.DockControl?
Your control is derived from the Winform controls class, right?
What's the relation of your control and the controls in plugin?
Are they contained in your control?(In otherword your control is the
container of the plugin controls).

For I'm not very familiar with your problem, I can only give you a
suggestion, you may try this way.

For intlIndex = 0 To Plugins.Length - 1
'create your plugin instance
objPlugin = DirectCast
(plugInServices.CreateInstance(Plugins(intIndex)), DMCInterface.IPlugin)
'create your control instance
dc = New DockingSuite.DockControl
dc.Text = objPlugin.Name
'add your controls in this method, you may refer to the
InitializeComponent code generated by VS.NET.
objPlugin.Initialize(dc)
dp.Controls.Add(dc)
Next

Now You can initialize your controls in the objPlugin.Initialize(Control
ctl) method,
you can easily add event handlers to the controls in it. don't forget to
add the controls in plugins to the
ctl.Controls collection at last.

If you still have problems on this issue, please let me know.

Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Raph" <[email protected]>
| Sender: "Raph" <[email protected]>
| References: <[email protected]>
<[email protected]>
| Subject: RE: Application PlugIn with Interface
| Date: Thu, 11 Sep 2003 07:09:11 -0700
| Lines: 188
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcN4bkXfMG1RY0GCSI2BpSoMkoNeSw==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:52152
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| Hi Ying-Shen, you are very close!
|
|
|
| For all intents and purposed, I'm not really using a
| TabControl, I'm using a docking window.
| DockHost
| -DockPanel
| -DocControl
|
|
| My DLL's will inherit the DocControl class. They will
| implement my plugIn interface so they can be found. My
| application will check for the DLL, see if it implements
| the proper interface, then load the DLL.
|
| The thing is, when I loads the DLL, or more to the point:
|
| For intIndex = 0 To Plugins.Length - 1
| objPlugin = DirectCast
| (plugInServices.CreateInstance(Plugins(intIndex)),
| DMCInterface.IPlugin)
|
| Trace.WriteLine("Found Add-In: " & Plugins
| (intIndex).ClassName.ToString & ":" & objPlugin.Name)
| dc = New DockingSuite.DockControl
| dc.Text = objPlugin.Name
| dp.Controls.Add(dc)
| Next
|
| My control is added, but the buttons and textboxes that I
| defined in them are not visible. So I thought I should
| created a property which would enumerate all the controls
| in the dll, and return them. Then, I would add the
| controls found in the DLL, to the dockControl object...
|
| For intIndex = 0 To Plugins.Length - 1
| objPlugin = DirectCast
| (plugInServices.CreateInstance(Plugins(intIndex)),
| DMCInterface.IPlugin)
|
| Trace.WriteLine("Found Add-In: " & Plugins
| (intIndex).ClassName.ToString & ":" & objPlugin.Name)
| dc = New DockingSuite.DockControl
| dc.Text = objPlugin.Name
| Dim ar As ArrayList
| Dim c As Object
| ar = objPlugin.ControlsCollection
| objPlugin.Initialize(objHost)
| Trace.WriteLine("Found " & ar.Count & " Add-
| In Controls")
| For Each c In ar
| Trace.WriteLine(" -" &
| c.GetType.ToString & " Add-In Controls")
| dc.Controls.Add(c)
| Next
| dp.Controls.Add(dc)
| Next
|
| This worked, in that now I could see the controls. But
| when I clicked on them, nothing happened. I want to pass
| the click even BACK to the DLL, so that the Button1_Click
| method in my DLL responds to the click from the
| dockControl, now located in the application.
|
|
| Hope this makes more sense. I know I'm close, I just need
| to tie the ends.
|
| Thanks alot for your help!
|
|
|
|
|
|
|
|
|
|
| >-----Original Message-----
| >Hi Raphael,
| > Thanks for using MSDN Newsgroup. My understanding
| to your problem now
| >is
| >you have an TabControl in your application, and you want
| to let your Plugin
| >in the DLL draw it's own interface on every tab page( I
| think it's TabPage
| >not TabControl right?) The Problem is that you don't
| know how to get the
| >controls defined in your derived TabPage Control and
| associate them with
| >events. If I was wrong, please let me know. And I want
| to make sure some
| >points before giving you adivse.
| >1. Is your Dll a .NET Control Library?
| >2. which event would you associate your controles in
| your plugin. the event
| >handler is defined out side the Plugin or still instide
| the same Plugin?
| >
| > Anyway, I think you may also think about passing the
| reference of the
| >TabPage in an initialization method of your Plugin
| Control, Then you can do
| >the initiliaztion in your plugin control. and it's easy
| to associate the
| >controls
| >with the events inside the same control.
| > If you want to associate ouside event to the inner
| controls in your
| >TabPage.
| > The number of the events you want to associate with
| the controls is
| >very small, maybe you can define some
| >properties on your control for setting and getting the
| value (like a
| >facade).
| > Or you need Enumerate the Controls property of your
| TabPage Property to
| >find the Control by 'Name', and then associate the event
| handler to it.
| >
| >Is this helpful to your, If you still have problems on
| it, please let me
| >know!
| >Thanks !
| >
| >
| >Best regards,
| >
| >Ying-Shen Yu [MS]
| >Microsoft Online Partner Support
| >Get Secure! - www.microsoft.com/security
| >
| >This posting is provided "as is" with no warranties and
| confers no rights.
| >
| >--------------------
| >| Content-Class: urn:content-classes:message
| >| From: "Raphael" <[email protected]>
| >| Sender: "Raphael" <[email protected]>
| >| Subject: Application PlugIn with Interface
| >| Date: Wed, 10 Sep 2003 10:18:37 -0700
| >| Lines: 12
| >| Message-ID: <[email protected]>
| >| MIME-Version: 1.0
| >| Content-Type: text/plain;
| >| charset="iso-8859-1"
| >| Content-Transfer-Encoding: 7bit
| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| X-MimeOLE: Produced By Microsoft MimeOLE
| V5.50.4910.0300
| >| Thread-Index: AcN3v5J5d9Hfe2qoTeGWql0RdCBHEA==
| >| Newsgroups:
| microsoft.public.dotnet.framework.windowsforms
| >| Path: cpmsftngxa06.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| >microsoft.public.dotnet.framework.windowsforms:52064
| >| NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
| >| X-Tomcat-NG:
| microsoft.public.dotnet.framework.windowsforms
| >|
| >| Hi, I'm creating an application that has a Tab
| control. I
| >| would like to create a series of plug-in DLL's which
| will
| >| make up each tab. The class for each tab inherits the
| Tab
| >| control, and implements an interface so I can
| recognize
| >| it...I've gotten that far...
| >|
| >| My problem, is that I need to be able to get the
| controls
| >| that are defined in the DLL, to the application. So,
| If
| >| someone codes a button in the DLL, it will show up in
| the
| >| tab control on my app once I add the tab that is
| defined
| >| by the class...my problem is how can I get the onClick
| >| even to get passed from my application, to the DLL?
| >|
| >
| >.
| >
|
 
OK we're getting close!!

With this:
| DockHost
| -DockPanel
| -DocControl

The main application has the DockHost, and the DockPanel.
The add-ins will inherit the DocControl Class. So, in my
code, I'm essentially adding the enumerated DLL that
implement the proper interface for a DockControl, and add
them to my existing DockPanel.

I just want to be able to
1. see the controls define in the DLL (ie passing them up
to the dc)
-This could be a point of confusion. See, I'd have
thought that by imheriting the DockControl class, that
the controls would automatically be "painted" but that
doesn't seem to be the case. It's seem like I'm creating
a DockControl object, and using the "data" from the DLL
to create the controls based on what was found in the
DLL. It seems like I'm missing something....is that
where calling the intialize method of the plugin comes in?




2. have the application send the events for the controls
that it adds..this way, each DLL is responsible for
handling its' events.


Almost there! Thanks so much, you are alot of help!
-----Original Message-----
Hi Raphael,
Thanks for your detail information, that's very helpful for me to
understand your problem correctly.
First I'd like to make sure one thing. In your reply, You mentions that
your control had been added,
I'd like to make sure what is your control refer to?
Did you refer to the DockingSuite.DockControl?
Your control is derived from the Winform controls class, right?
What's the relation of your control and the controls in plugin?
Are they contained in your control?(In otherword your control is the
container of the plugin controls).

For I'm not very familiar with your problem, I can only give you a
suggestion, you may try this way.

For intlIndex = 0 To Plugins.Length - 1
'create your plugin instance
objPlugin = DirectCast
(plugInServices.CreateInstance(Plugins(intIndex)), DMCInterface.IPlugin)
'create your control instance
dc = New DockingSuite.DockControl
dc.Text = objPlugin.Name
'add your controls in this method, you may refer to the
InitializeComponent code generated by VS.NET.
objPlugin.Initialize(dc)
dp.Controls.Add(dc)
Next

Now You can initialize your controls in the objPlugin.Initialize(Control
ctl) method,
you can easily add event handlers to the controls in it. don't forget to
add the controls in plugins to the
ctl.Controls collection at last.

If you still have problems on this issue, please let me know.

Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Raph" <[email protected]>
| Sender: "Raph" <[email protected]>
| References: <[email protected]>
<[email protected]>
| Subject: RE: Application PlugIn with Interface
| Date: Thu, 11 Sep 2003 07:09:11 -0700
| Lines: 188
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcN4bkXfMG1RY0GCSI2BpSoMkoNeSw==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:52152
| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| Hi Ying-Shen, you are very close!
|
|
|
| For all intents and purposed, I'm not really using a
| TabControl, I'm using a docking window.
| DockHost
| -DockPanel
| -DocControl
|
|
| My DLL's will inherit the DocControl class. They will
| implement my plugIn interface so they can be found. My
| application will check for the DLL, see if it implements
| the proper interface, then load the DLL.
|
| The thing is, when I loads the DLL, or more to the point:
|
| For intIndex = 0 To Plugins.Length - 1
| objPlugin = DirectCast
| (plugInServices.CreateInstance(Plugins(intIndex)),
| DMCInterface.IPlugin)
|
| Trace.WriteLine("Found Add-In: " & Plugins
| (intIndex).ClassName.ToString & ":" & objPlugin.Name)
| dc = New DockingSuite.DockControl
| dc.Text = objPlugin.Name
| dp.Controls.Add(dc)
| Next
|
| My control is added, but the buttons and textboxes that I
| defined in them are not visible. So I thought I should
| created a property which would enumerate all the controls
| in the dll, and return them. Then, I would add the
| controls found in the DLL, to the dockControl object...
|
| For intIndex = 0 To Plugins.Length - 1
| objPlugin = DirectCast
| (plugInServices.CreateInstance(Plugins(intIndex)),
| DMCInterface.IPlugin)
|
| Trace.WriteLine("Found Add-In: " & Plugins
| (intIndex).ClassName.ToString & ":" & objPlugin.Name)
| dc = New DockingSuite.DockControl
| dc.Text = objPlugin.Name
| Dim ar As ArrayList
| Dim c As Object
| ar = objPlugin.ControlsCollection
| objPlugin.Initialize(objHost)
| Trace.WriteLine("Found " & ar.Count & " Add-
| In Controls")
| For Each c In ar
| Trace.WriteLine(" -" &
| c.GetType.ToString & " Add-In Controls")
| dc.Controls.Add(c)
| Next
| dp.Controls.Add(dc)
| Next
|
| This worked, in that now I could see the controls. But
| when I clicked on them, nothing happened. I want to pass
| the click even BACK to the DLL, so that the Button1_Click
| method in my DLL responds to the click from the
| dockControl, now located in the application.
|
|
| Hope this makes more sense. I know I'm close, I just need
| to tie the ends.
|
| Thanks alot for your help!
|
|
|
|
|
|
|
|
|
|
| >-----Original Message-----
| >Hi Raphael,
| > Thanks for using MSDN Newsgroup. My understanding
| to your problem now
| >is
| >you have an TabControl in your application, and you want
| to let your Plugin
| >in the DLL draw it's own interface on every tab page( I
| think it's TabPage
| >not TabControl right?) The Problem is that you don't
| know how to get the
| >controls defined in your derived TabPage Control and
| associate them with
| >events. If I was wrong, please let me know. And I want
| to make sure some
| >points before giving you adivse.
| >1. Is your Dll a .NET Control Library?
| >2. which event would you associate your controles in
| your plugin. the event
| >handler is defined out side the Plugin or still instide
| the same Plugin?
| >
| > Anyway, I think you may also think about passing the
| reference of the
| >TabPage in an initialization method of your Plugin
| Control, Then you can do
| >the initiliaztion in your plugin control. and it's easy
| to associate the
| >controls
| >with the events inside the same control.
| > If you want to associate ouside event to the inner
| controls in your
| >TabPage.
| > The number of the events you want to associate with
| the controls is
| >very small, maybe you can define some
| >properties on your control for setting and getting the
| value (like a
| >facade).
| > Or you need Enumerate the Controls property of your
| TabPage Property to
| >find the Control by 'Name', and then associate the event
| handler to it.
| >
| >Is this helpful to your, If you still have problems on
| it, please let me
| >know!
| >Thanks !
| >
| >
| >Best regards,
| >
| >Ying-Shen Yu [MS]
| >Microsoft Online Partner Support
| >Get Secure! - www.microsoft.com/security
| >
| >This posting is provided "as is" with no warranties and
| confers no rights.
| >
| >--------------------
| >| Content-Class: urn:content-classes:message
| >| From: "Raphael" <[email protected]>
| >| Sender: "Raphael" <[email protected]>
| >| Subject: Application PlugIn with Interface
| >| Date: Wed, 10 Sep 2003 10:18:37 -0700
| >| Lines: 12
| >| Message-ID: <[email protected]>
| >| MIME-Version: 1.0
| >| Content-Type: text/plain;
| >| charset="iso-8859-1"
| >| Content-Transfer-Encoding: 7bit
| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| X-MimeOLE: Produced By Microsoft MimeOLE
| V5.50.4910.0300
| >| Thread-Index: AcN3v5J5d9Hfe2qoTeGWql0RdCBHEA==
| >| Newsgroups:
| microsoft.public.dotnet.framework.windowsforms
| >| Path: cpmsftngxa06.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| >microsoft.public.dotnet.framework.windowsforms:52064
| >| NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
| >| X-Tomcat-NG:
| microsoft.public.dotnet.framework.windowsforms
| >|
| >| Hi, I'm creating an application that has a Tab
| control. I
| >| would like to create a series of plug-in DLL's which
| will
| >| make up each tab. The class for each tab inherits the
| Tab
| >| control, and implements an interface so I can
| recognize
| >| it...I've gotten that far...
| >|
| >| My problem, is that I need to be able to get the
| controls
| >| that are defined in the DLL, to the application. So,
| If
| >| someone codes a button in the DLL, it will show up in
| the
| >| tab control on my app once I add the tab that is
| defined
| >| by the class...my problem is how can I get the onClick
| >| even to get passed from my application, to the DLL?
| >|
| >
| >.
| >
|

.
 
Hi Raphael,
You may try add an Initialize method to you Plugin inteface. like
public interface IPlugin
{
void Initialize(Control.ControlCollection ctl);
}
and implement it in your plugin class
//save the controls collection for future use, you may remove it if it has
no use to your //plugin
<code snippet>
private Control.ControlCollection controls = null;
public void Initialize(Control.ControlCollection ctl)
{
controls = ctl;
txtBox1 = new TextBox();
txtBox1.Location = new Point(10,10);
txtBox1.Size = new Size(100,10);
txtBox1.Text = "Hello World";
//Add your event handlers here, and define them in your
plugin class library.
txtBox1.TextChanged += new EventHandler(txtBox1_TextChanged);
//.......
//Don't forget add it to your container's controls array.
controls.Add(txtBox1);
}
</code snippet>
And in your program
//load your plugins from assembly.
//....
//get the interface
PluginsLib.IPlugin plugin = new PluginsLib.Class1();
//create your DocControl object, here, for simplicity I just used an Panel
names panel1
//pass the Controls array to your plugin by calling Initialize method.
plugin.Initialize(panel1.Controls);

Does this answer your question?
If you still have problem on this issue, please let me know.

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Raph" <[email protected]>
| Sender: "Raph" <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| Subject: RE: Application PlugIn with Interface
| Date: Fri, 12 Sep 2003 07:07:47 -0700
| Lines: 340
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcN5Nz7AGuAthzkJRJm+5GAKQL+uRA==
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:52233
| NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| OK we're getting close!!
|
| With this:
| | DockHost
| | -DockPanel
| | -DocControl
|
| The main application has the DockHost, and the DockPanel.
| The add-ins will inherit the DocControl Class. So, in my
| code, I'm essentially adding the enumerated DLL that
| implement the proper interface for a DockControl, and add
| them to my existing DockPanel.
|
| I just want to be able to
| 1. see the controls define in the DLL (ie passing them up
| to the dc)
| -This could be a point of confusion. See, I'd have
| thought that by imheriting the DockControl class, that
| the controls would automatically be "painted" but that
| doesn't seem to be the case. It's seem like I'm creating
| a DockControl object, and using the "data" from the DLL
| to create the controls based on what was found in the
| DLL. It seems like I'm missing something....is that
| where calling the intialize method of the plugin comes in?
|
|
|
|
| 2. have the application send the events for the controls
| that it adds..this way, each DLL is responsible for
| handling its' events.
|
|
| Almost there! Thanks so much, you are alot of help!
|
| >-----Original Message-----
| >Hi Raphael,
| > Thanks for your detail information, that's very
| helpful for me to
| >understand your problem correctly.
| >First I'd like to make sure one thing. In your reply,
| You mentions that
| >your control had been added,
| > I'd like to make sure what is your control refer to?
| >Did you refer to the DockingSuite.DockControl?
| >Your control is derived from the Winform controls class,
| right?
| >What's the relation of your control and the controls in
| plugin?
| >Are they contained in your control?(In otherword your
| control is the
| >container of the plugin controls).
| >
| >For I'm not very familiar with your problem, I can only
| give you a
| >suggestion, you may try this way.
| >
| >For intlIndex = 0 To Plugins.Length - 1
| > 'create your plugin instance
| > objPlugin = DirectCast
| >(plugInServices.CreateInstance(Plugins(intIndex)),
| DMCInterface.IPlugin)
| > 'create your control instance
| > dc = New DockingSuite.DockControl
| > dc.Text = objPlugin.Name
| > 'add your controls in this method, you may refer to
| the
| >InitializeComponent code generated by VS.NET.
| > objPlugin.Initialize(dc)
| > dp.Controls.Add(dc)
| >Next
| >
| >Now You can initialize your controls in the
| objPlugin.Initialize(Control
| >ctl) method,
| >you can easily add event handlers to the controls in it.
| don't forget to
| >add the controls in plugins to the
| >ctl.Controls collection at last.
| >
| >If you still have problems on this issue, please let me
| know.
| >
| >Thanks!
| >
| >Best regards,
| >
| >Ying-Shen Yu [MSFT]
| >Microsoft Online Partner Support
| >Get Secure! - www.microsoft.com/security
| >
| >This posting is provided "AS IS" with no warranties and
| confers no rights.
| >
| >--------------------
| >| Content-Class: urn:content-classes:message
| >| From: "Raph" <[email protected]>
| >| Sender: "Raph" <[email protected]>
| >| References: <[email protected]>
| ><[email protected]>
| >| Subject: RE: Application PlugIn with Interface
| >| Date: Thu, 11 Sep 2003 07:09:11 -0700
| >| Lines: 188
| >| Message-ID: <[email protected]>
| >| MIME-Version: 1.0
| >| Content-Type: text/plain;
| >| charset="iso-8859-1"
| >| Content-Transfer-Encoding: 7bit
| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| Thread-Index: AcN4bkXfMG1RY0GCSI2BpSoMkoNeSw==
| >| X-MimeOLE: Produced By Microsoft MimeOLE
| V5.50.4910.0300
| >| Newsgroups:
| microsoft.public.dotnet.framework.windowsforms
| >| Path: cpmsftngxa06.phx.gbl
| >| Xref: cpmsftngxa06.phx.gbl
| >microsoft.public.dotnet.framework.windowsforms:52152
| >| NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
| >| X-Tomcat-NG:
| microsoft.public.dotnet.framework.windowsforms
| >|
| >| Hi Ying-Shen, you are very close!
| >|
| >|
| >|
| >| For all intents and purposed, I'm not really using a
| >| TabControl, I'm using a docking window.
| >| DockHost
| >| -DockPanel
| >| -DocControl
| >|
| >|
| >| My DLL's will inherit the DocControl class. They will
| >| implement my plugIn interface so they can be found. My
| >| application will check for the DLL, see if it
| implements
| >| the proper interface, then load the DLL.
| >|
| >| The thing is, when I loads the DLL, or more to the
| point:
| >|
| >| For intIndex = 0 To Plugins.Length - 1
| >| objPlugin = DirectCast
| >| (plugInServices.CreateInstance(Plugins(intIndex)),
| >| DMCInterface.IPlugin)
| >|
| >| Trace.WriteLine("Found Add-In: " & Plugins
| >| (intIndex).ClassName.ToString & ":" & objPlugin.Name)
| >| dc = New DockingSuite.DockControl
| >| dc.Text = objPlugin.Name
| >| dp.Controls.Add(dc)
| >| Next
| >|
| >| My control is added, but the buttons and textboxes
| that I
| >| defined in them are not visible. So I thought I should
| >| created a property which would enumerate all the
| controls
| >| in the dll, and return them. Then, I would add the
| >| controls found in the DLL, to the dockControl object...
| >|
| >| For intIndex = 0 To Plugins.Length - 1
| >| objPlugin = DirectCast
| >| (plugInServices.CreateInstance(Plugins(intIndex)),
| >| DMCInterface.IPlugin)
| >|
| >| Trace.WriteLine("Found Add-In: " & Plugins
| >| (intIndex).ClassName.ToString & ":" & objPlugin.Name)
| >| dc = New DockingSuite.DockControl
| >| dc.Text = objPlugin.Name
| >| Dim ar As ArrayList
| >| Dim c As Object
| >| ar = objPlugin.ControlsCollection
| >| objPlugin.Initialize(objHost)
| >| Trace.WriteLine("Found " & ar.Count & "
| Add-
| >| In Controls")
| >| For Each c In ar
| >| Trace.WriteLine(" -" &
| >| c.GetType.ToString & " Add-In Controls")
| >| dc.Controls.Add(c)
| >| Next
| >| dp.Controls.Add(dc)
| >| Next
| >|
| >| This worked, in that now I could see the controls. But
| >| when I clicked on them, nothing happened. I want to
| pass
| >| the click even BACK to the DLL, so that the
| Button1_Click
| >| method in my DLL responds to the click from the
| >| dockControl, now located in the application.
| >|
| >|
| >| Hope this makes more sense. I know I'm close, I just
| need
| >| to tie the ends.
| >|
| >| Thanks alot for your help!
| >|
| >|
| >|
| >|
| >|
| >|
| >|
| >|
| >|
| >|
| >| >-----Original Message-----
| >| >Hi Raphael,
| >| > Thanks for using MSDN Newsgroup. My
| understanding
| >| to your problem now
| >| >is
| >| >you have an TabControl in your application, and you
| want
| >| to let your Plugin
| >| >in the DLL draw it's own interface on every tab page(
| I
| >| think it's TabPage
| >| >not TabControl right?) The Problem is that you don't
| >| know how to get the
| >| >controls defined in your derived TabPage Control and
| >| associate them with
| >| >events. If I was wrong, please let me know. And I
| want
| >| to make sure some
| >| >points before giving you adivse.
| >| >1. Is your Dll a .NET Control Library?
| >| >2. which event would you associate your controles in
| >| your plugin. the event
| >| >handler is defined out side the Plugin or still
| instide
| >| the same Plugin?
| >| >
| >| > Anyway, I think you may also think about passing
| the
| >| reference of the
| >| >TabPage in an initialization method of your Plugin
| >| Control, Then you can do
| >| >the initiliaztion in your plugin control. and it's
| easy
| >| to associate the
| >| >controls
| >| >with the events inside the same control.
| >| > If you want to associate ouside event to the
| inner
| >| controls in your
| >| >TabPage.
| >| > The number of the events you want to associate
| with
| >| the controls is
| >| >very small, maybe you can define some
| >| >properties on your control for setting and getting
| the
| >| value (like a
| >| >facade).
| >| > Or you need Enumerate the Controls property of
| your
| >| TabPage Property to
| >| >find the Control by 'Name', and then associate the
| event
| >| handler to it.
| >| >
| >| >Is this helpful to your, If you still have problems
| on
| >| it, please let me
| >| >know!
| >| >Thanks !
| >| >
| >| >
| >| >Best regards,
| >| >
| >| >Ying-Shen Yu [MS]
| >| >Microsoft Online Partner Support
| >| >Get Secure! - www.microsoft.com/security
| >| >
| >| >This posting is provided "as is" with no warranties
| and
| >| confers no rights.
| >| >
| >| >--------------------
| >| >| Content-Class: urn:content-classes:message
| >| >| From: "Raphael" <[email protected]>
| >| >| Sender: "Raphael" <[email protected]>
| >| >| Subject: Application PlugIn with Interface
| >| >| Date: Wed, 10 Sep 2003 10:18:37 -0700
| >| >| Lines: 12
| >| >| Message-ID: <[email protected]>
| >| >| MIME-Version: 1.0
| >| >| Content-Type: text/plain;
| >| >| charset="iso-8859-1"
| >| >| Content-Transfer-Encoding: 7bit
| >| >| X-Newsreader: Microsoft CDO for Windows 2000
| >| >| X-MimeOLE: Produced By Microsoft MimeOLE
| >| V5.50.4910.0300
| >| >| Thread-Index: AcN3v5J5d9Hfe2qoTeGWql0RdCBHEA==
| >| >| Newsgroups:
| >| microsoft.public.dotnet.framework.windowsforms
| >| >| Path: cpmsftngxa06.phx.gbl
| >| >| Xref: cpmsftngxa06.phx.gbl
| >| >microsoft.public.dotnet.framework.windowsforms:52064
| >| >| NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
| >| >| X-Tomcat-NG:
| >| microsoft.public.dotnet.framework.windowsforms
| >| >|
| >| >| Hi, I'm creating an application that has a Tab
| >| control. I
| >| >| would like to create a series of plug-in DLL's
| which
| >| will
| >| >| make up each tab. The class for each tab inherits
| the
| >| Tab
| >| >| control, and implements an interface so I can
| >| recognize
| >| >| it...I've gotten that far...
| >| >|
| >| >| My problem, is that I need to be able to get the
| >| controls
| >| >| that are defined in the DLL, to the application.
| So,
| >| If
| >| >| someone codes a button in the DLL, it will show up
| in
| >| the
| >| >| tab control on my app once I add the tab that is
| >| defined
| >| >| by the class...my problem is how can I get the
| onClick
| >| >| even to get passed from my application, to the DLL?
| >| >|
| >| >
| >| >.
| >| >
| >|
| >
| >.
| >
|
 
Hi,

I have done the same kind of thing in the last couple of days. I have not
clear all of your remaining posts but this is what I did and worked:

- Your pluggins DLLs provides usercontrols, that is, clases derived directly
from the UserControl class. Each usercontrol has its own controls (buttons,
lists, etc.) with its own event handlers and its logic.

- The host receives instances of the usercontrols and places them in dialog.

- Each usercontrol implements an Interface, say IPropertyPage with the
following methods:

* Initialize(...): called by the host when the usercontrol must initializate
* Cleanup(...): called by the host when the usercontrol must do cleaning
chores
* SetData(...): when the user clicks the OK button of the dialog, the host
calls this method on each usercontrol to transfer the data from the user
interface to an object to be used later by the host when the dialog is
closed.

In this design:

- The usercontrols are not aware where they will be hosted: it can be
tabpages of tabcontrol, but it could be panels selected with a listbox to
the left (like the Options dialog of VS.Net)

- The host does not need to handle events from controls inside the
usercontrols. It communicates with them when needed through the methods of
the interface.

-The communication is always from the host to the usercontrols, these ones
notify nothing the host.

About this last one statement, if you REALLY need the reverse then the
usercontrol must expose events that could be fired by events in its inner
controls, and your host must add/remove event handlers dynamically
(AddHandler/Remove Handle in VB.Net) to each usercontrol instance to handle
them. But it is better to avoid this, letting the usercontrol to do its
things internally, and requesting the results later through the interface.

HTH,

Carlos Quintero
 
Back
Top