Problem beginning plugin (1 Viewer)

jmhecker

Portal Member
January 8, 2009
47
17
Home Country
United States of America United States of America
I am working a plugin for MediaPortal (obviously, heh), and I am having 1 small issue when starting.

I followed the instructions to the T that are shown in the Plugin Developers Guide, but I am running into 1 small issue that seems to be holding me back.

I am using VB.Net, which _should_ work fine, .Net compiles to the same code regardless...the line in question is:

using MediaPortal.Dialogs;
which translates to VB.Net as:
Imports MediaPortal.Dialogs

I am getting an error of:

Code:
Namespace or type specified in the Imports 'MediaPortal.Dialogs'
doesn't contain any public member or cannot be found. Make sure the namespace
or the type is defined and contains at least one public member. Make sure the
imported element name doesn't use any aliases.

I have added the core.dll reference as directed, as well as System.Windows.Forms, etc. Is there something that I am missing, or perhaps that the documentation isn't covering?

Not having the ability to import MediaPortal.Dialogs can be quite a cramp in development :p

EDIT:
I have attempted to use the C# code that is shown in the Plugin Development Guide, and I get the error of:
Code:
Error	1	The type or namespace name 'Dialogs' does not exist in the namespace 'MediaPortal'
(are you missing an assembly reference?)

Which brings me to ask: Is there a chance I am missing an assembly reference? And if so, which?

EDIT #2:

SO, THATS what Dialogs.dll is for.....
 

jmhecker

Portal Member
January 8, 2009
47
17
Home Country
United States of America United States of America
Okay, got back to the computer to start getting this going again, and it appears I am a bit rusty. One more issue is causing me to prevent compiling the 'basic example' plugin. This is the sub causing the problem:

Code:
        Protected Overloads Overrides Sub OnClicked(ByVal controlId As Integer, ByVal control As GUIControl, ByVal actionType As MediaPortal.GUI.Library.Action.ActionType)
            If [U]control = buttonOne[/U] Then
                OnButtonOne()
            End If
            If [U]control = buttonTwo[/U] Then
                OnButtonTwo()
            End If
            MyBase.OnClicked(controlId, control, actionType)
        End Sub

It is throwing an error of:
Code:
Operator '=' is not defined for types 'MediaPortal.GUI.Library.GUIControl' and MediaPortal.GUI.Library.GUIButtonControl'

It seems that VB.Net is unable to compare buttomOne and control. So, I tried casting types back and forth to see if perhaps VB.Net was just not seeing them properly or something, to no avail.

Does anyone have any ideas?

EDIT:
I underlined the 2 things that have blue squiggly underlines in the VB.Net IDE.
 

WileECoyote

MP Donator
  • Premium Supporter
  • October 14, 2008
    1,156
    220
    Cary, NC
    Home Country
    United States of America United States of America
    In C# you have to have a double equals to compare...

    If control == buttonOne Then

    Not sure about VB though...

    Also, in c# you have to define the control...

    Button myButton = (Button)control;

    Then compare...

    If myButton == buttonOne Then

    EDIT: Also, why not have seperate OnClicked events for each button, rather than trying to combine into one?
     

    jmhecker

    Portal Member
    January 8, 2009
    47
    17
    Home Country
    United States of America United States of America
    In VB, == is simply = for comparisons (in C#, = is used to set the value...not always the case in VB)

    Anyways, I couldn't get past this problem using it the way it was, so I simply resorted to comparing the ControlID of the button that was pressed to what is coded into the plugin. Works like a charm.
     

    WileECoyote

    MP Donator
  • Premium Supporter
  • October 14, 2008
    1,156
    220
    Cary, NC
    Home Country
    United States of America United States of America
    In VB, == is simply = for comparisons (in C#, = is used to set the value...not always the case in VB)

    Anyways, I couldn't get past this problem using it the way it was, so I simply resorted to comparing the ControlID of the button that was pressed to what is coded into the plugin. Works like a charm.

    Yea, either way it wouldnt work without casting 'control' to type Button...
     

    jmhecker

    Portal Member
    January 8, 2009
    47
    17
    Home Country
    United States of America United States of America
    Rather than starting a new thread, I thought I would just continue to ask for assistance in this one.

    In regards to the database management...does MP have a database class that I should use, or should I grab the system.data.sqlite and import that into my project? I tried to add a reference to the sqlite.dll that is in the MP, but its components are not accessible.

    Also, if I grab System.Data.Sqlite from its webpage (System.Data.SQLite), would I be required to distribute that with my plugin?

    It seems to me that there should be a way to add a reference to one of the MP DLLs, and utilize that for the SQLite connections (that way everything stays uniform). Is there such a thing, and I am missing it?

    I have added a reference to Databases.dll, but I havent seen anything in that which does what I am thinking...still looking around though

    EDIT: I have gotten past that point, but am wondering how to get information from the MP configuration (IE: Where databases should be kept at, skin files, etc). I know where they are on my machine, but as each system can be different, I would need to pull that info from the database...I see a lot of things referring to ReadConfig() from the MediaPortal source code, but am not seeing where that function is being declared at.

    EDIT 2:
    Nevermind, I see that it is simply referring to AppData, and CommanApplicationData. Works for me :)
     

    marvenius

    Portal Pro
    September 3, 2008
    523
    47
    Belgium
    Home Country
    Netherlands Netherlands
    EDIT: I have gotten past that point, but am wondering how to get information from the MP configuration (IE: Where databases should be kept at, skin files, etc). I know where they are on my machine, but as each system can be different, I would need to pull that info from the database...I see a lot of things referring to ReadConfig() from the MediaPortal source code, but am not seeing where that function is being declared at.
    All I know is that the configuration is kept within MediaPortal.xml. There is even a MediaPortal.Configuration namespace to be used, giving you access to the different items like database dir, thumb folder and such.
     

    jmhecker

    Portal Member
    January 8, 2009
    47
    17
    Home Country
    United States of America United States of America
    In C# you have to have a double equals to compare...

    If control == buttonOne Then

    Not sure about VB though...

    Also, in c# you have to define the control...

    Button myButton = (Button)control;

    Then compare...

    If myButton == buttonOne Then

    EDIT: Also, why not have seperate OnClicked events for each button, rather than trying to combine into one?

    WileECoyote:

    I have figured out how to reference the buttons in this example without having to Cast the buttons at all.
    Code:
                If control Is buttonOne Then
                    OnButtonOne()
                End If
                If control Is buttonTwo Then
                    OnButtonTwo()
                End If

    Using the "Is" Operator (which I found NO documentation on) seems to do the trick. I compiled and tested, and it worked flawlessly. I took another plugin that was written in C#, and converted it to VB.Net using SharpDevelop, and that converted it to what is shown above, rather than having "Is" be "=" as the online converters were doing.
     

    Users who are viewing this thread

    Top Bottom