Results 1 to 8 of 8

Thread: Plug-in Interface

  1. #1

    Thread Starter
    Lively Member D.Viddy's Avatar
    Join Date
    May 2003
    Location
    Soldotna, Alaska
    Posts
    108

    Plug-in Interface

    http://www.divil.co.uk/net/articles/plugins/plugins.asp

    I have found this article on the topic. It is a very good article, but all it describes is how to access plug-in methods. I would like to know how to import a panel (or other control) created by a plug-in. All of the panel events can stay in the plug-in. Is there an easy way to do this without changing everything this guy has created? Or can you suggest a better article explaining implementation of plug-ins in a VB.NET application?

    http://www.divil.co.uk/net/articles/plugins/plugins.asp
    ~Dylan
    ~http://www.codebend.net
    ~The place for Internet Development help.

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Well the way I do it is to send a reference of my form, or whatever container to use to put new controls on, to the plugin via some kind of loading method of the plugin.

    Sub Load(ByRef myForm as System.Windows.Forms.Form)

    Then the plugin takes that reference and adds whatever it needs to to the pased form.

    I used a TabControl for a test I did once where the plugin added a new tab to the main apps form

    looked like this

    VB Code:
    1. Public Class Chat
    2.     Implements Interfaces.IPlugin
    3.  
    4.     Dim tb As TextBox
    5.     Public Sub Panel_Init(ByRef tab As TabControl) Implements Interfaces.IPlugin.Panel_Init
    6.         Dim page As TabPage
    7.         Dim x As Long
    8.  
    9.         Dim tb2 As TextBox
    10.         Dim g As New GroupBox()
    11.  
    12.         ' Create a new tab
    13.         page = New TabPage()
    14.         page.Text = "Chat"
    15.         page.Name = "Chat"
    16.  
    17.         g.Name = "beauh"
    18.         g.Tag = CStr(page.TabIndex)
    19.         g.Text = "blah"
    20.         g.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left Or AnchorStyles.Right Or AnchorStyles.Top
    21.  
    22.         ' Create textbox that will appear in Home tab
    23.         tb = New TextBox()
    24.         tb.Name = "tbChat"
    25.         tb.Multiline = True
    26.         tb.Top = g.Top + 15
    27.         tb.Left = g.Left + 8
    28.         tb.Height = g.Height - 400
    29.         tb.Width = g.Width - 16
    30.         tb.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left Or AnchorStyles.Right Or AnchorStyles.Top
    31.         ' Add textbox to tab page and tab page to tab container.
    32.  
    33.  
    34.         tb2 = New TextBox()
    35.         tb2.Name = "tbSend"
    36.         tb2.Multiline = True
    37.         tb2.Top = g.Height - 75
    38.         tb2.Height = 50
    39.         tb2.Left = g.Left + 8
    40.         tb2.Width = g.Width - 16
    41.         tb2.Anchor = AnchorStyles.Bottom Or AnchorStyles.Left Or AnchorStyles.Right
    42.         ' Add textbox to tab page and tab page to tab container.
    43.         g.Controls.Add(tb)
    44.         g.Controls.Add(tb2)
    45.         page.Controls.Add(g)
    46.         tab.TabPages.Add(page)
    47.         'tb = Nothing
    48.         SharedDLLTest.Test.Name = "Hello"
    49.         'MessageBox.Show(System.Environment.UserName)
    50.  
    51.     End Sub
    52.  
    53.     Private Sub go() Implements Interfaces.IPlugin.go
    54.         tb.Text = SharedDLLTest.Test.PluginCollection.Count
    55.     End Sub
    56. End Class
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Lively Member D.Viddy's Avatar
    Join Date
    May 2003
    Location
    Soldotna, Alaska
    Posts
    108
    That's awesome, thanks a bunch. That really helped, I'm gonna try it when I get home. I see that you are the main authority on plug-ins.
    ~Dylan
    ~http://www.codebend.net
    ~The place for Internet Development help.

  4. #4
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    i've tried seting to my form a reference to the panel and that wont work, at least the way i did

    anyways i overcame the problem adding the panel to the form control's collection
    \m/\m/

  5. #5

    Thread Starter
    Lively Member D.Viddy's Avatar
    Join Date
    May 2003
    Location
    Soldotna, Alaska
    Posts
    108
    How do I handle events on the plugin, Say I created a new tab page like Cander posted, How do I handle events on that tab page?
    ~Dylan
    ~http://www.codebend.net
    ~The place for Internet Development help.

  6. #6

    Thread Starter
    Lively Member D.Viddy's Avatar
    Join Date
    May 2003
    Location
    Soldotna, Alaska
    Posts
    108
    *bump*
    ~Dylan
    ~http://www.codebend.net
    ~The place for Internet Development help.

  7. #7
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    when you create the plugin just do its events as they will get attached to it when you load the panel with your main form
    \m/\m/

  8. #8

    Thread Starter
    Lively Member D.Viddy's Avatar
    Join Date
    May 2003
    Location
    Soldotna, Alaska
    Posts
    108
    Thanks for the speady reply, I think I have kinda figured it out. I'm just working on how to get info to the main form calling the plugin now.
    ~Dylan
    ~http://www.codebend.net
    ~The place for Internet Development help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width