Reply to thread

Ok, I'll use your previous code example to demo what I mean. See the stuff in bold.


[code]

#region Copyright (C) 2006 Team MediaPortal


/*

 *      Copyright (C) 2006 Team MediaPortal

 *      https://www.team-mediaportal.com

 *

 *  This Program is free software; you can redistribute it and/or modify

 *  it under the terms of the GNU General Public License as published by

 *  the Free Software Foundation; either version 2, or (at your option)

 *  any later version.

 *  

 *  This Program is distributed in the hope that it will be useful,

 *  but WITHOUT ANY WARRANTY; without even the implied warranty of

 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

 *  GNU General Public License for more details.

 *  

 *  You should have received a copy of the GNU General Public License

 *  along with GNU Make; see the file COPYING.  If not, write to

 *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

 *  http://www.gnu.org/copyleft/gpl.html

 *

 */


#endregion


#region XMMImporter: Version History


/*

 *     XMM Importer

 *

 *     Plugin to allow converting Extreme Movie Manager (XMM) databases to

 *     MediaPortal.

 *

 * 060827 - JBL - 0.0.0.1

 * Started 060819.

 *

 * This is my first attempt at a C# program and plugin for MediaPortal.  This first

 * version of XMM Importer is capable of reading Extreme Movie Manager v5 database

 * files and converting the video data into a MediaPortal video database.

 *

 * Current Version Features:

 * + Configuration control through a MediaPortal plugin interface and a

 *   windows form.

 * + Capable of reading XMM v5 database files.

 * + Automatically copies cover files to specified MediaPortal thumbnail directory.

 *

 * Future Work:

 * + Auto detect MediaPortal directories and database files

 * + Save settings to XML or SQLite database to retain settings between uses.

 * + Allow for importing multiple databases by allowing multiple settings in configuration

 *   file

 * + Add more control over import information

 * + Relook over SQLite.NET and other MP database code to see if it would work better

 *   than the current method of working with SQLite databases

 * + Clean up and add more comments to code for next version

 *

 * Known Issues:

 * + The method of access the MP databases probably isn't optimal.  It is currently done

 *   using the alternative SQLite interface and a data reader has to be generated each

 *   time a query needs to be made.  It seems there should be a better way, but seems to

 *   work OK for now.

 * + There are no warnings before clearing the data in the video database.  The next

 *   version should include a warning and even backup the MP video database before working

 *   on it.

 * + Only tried on US English version of Windows.  May not be compatable with different

 *   character sets, but remains to be seen.

 *

 */

#endregion



using System;

using System.Collections.Generic;

using System.Text;

//using System.ComponentModel;

using System.Windows.Forms;

using MediaPortal.GUI.Library;



namespace GUIXMM

{

  /// <summary>

  /// CLASS: XMMImporterPlugin

  /// This is the main plugin interface to MediaPortal.

  /// </summary>

  public class XMMImporterPlugin : GUIWindow, ISetupForm

  {

    public XMMImporterPlugin()

    {

            [b]

   //as you have inherited from GUIWindow in this class, you need to specify a windowId for this window. To do this, do the following:


             GetID=(int)4444;


   // GetID is a property in the GUIWindow class.

[/b]

    }


    #region ISetupForm Members

   

    //Returns the name of the plugin which is shown in the plugin menu

    public string PluginName()

    {

      return "XMMImporter";

    }

    //Returns the description of the plugin is shown in the plugin menu

    public string Description()

    {

      return "Imports XMM Libraries into the MediaPortal database";

    }

    // Returns the author of the plugin which is shown in the plugin menu

    public string Author()

    {

      return "Hesse";

    }

    // Show the setup dialog

    public void ShowPlugin()

    {

      //MessageBox.Show("Nothing to do now");

      XMMImportForm myXMMImporterForm = new XMMImportForm();

      myXMMImporterForm.Show();

    }

    //Indicates whether plugin can be enabled/disabled

    public bool CanEnable()

    {

      return true;

    }

    // Indicates if a plugin is enabled by default

    public bool DefaultEnabled()

    {

      return false;

    }

    // get ID Of windowplugin belonging to this setup

    public int GetWindowId()

    {

      [b]return 4444;  //this window ID has to be *one* of the window ids of your windows - a window is defined as a class that has inherited from GUIWindow.[/b]

    }

    // Indicates if a plugin has its own setup screen

    public bool HasSetup()

    {

      return true;

    }


    /// <summary>

    /// If the plugin should have its own button on the main menu of Media Portal then it

    /// should return true to this method, otherwise if it should not be on home

    /// it should return false

    /// </summary>

    /// <param name="strButtonText">text the button should have</param>

    /// <param name="strButtonImage">image for the button, or empty for default</param>

    /// <param name="strButtonImageFocus">image for the button, or empty for default</param>

    /// <param name="strPictureImage">subpicture for the button or empty for none</param>

    /// <returns>true : plugin needs its own button on home

    ///          false : plugin does not need its own button on home</returns>


    public bool GetHome(out string strButtonText, out string strButtonImage, out string strButtonImageFocus, out string strPictureImage)

    {

      strButtonText = "XMMImporter";

      strButtonImage = "";

      strButtonImageFocus = "";

      strPictureImage = "";

      return true;

    }

    #endregion


  }


  

}

[/code]


That should fix it.


BTW, when you inherited from GUIWindow, you should also override the following methods to do things like load the skin, capture actions/messages etc. Here's the overrides you should do:


[code]

            #region Overrides


            public override bool Init()

            {

                return Load(MediaPortal.GUI.Library.GUIGraphicsContext.Skin + @"\threaddemo.xml");

            }


        public override void OnAction(MediaPortal.GUI.Library.Action action)

            {

                switch (action.wID)

                {

                    case MediaPortal.GUI.Library.Action.ActionType.ACTION_PREVIOUS_MENU:

                        {

                            MediaPortal.GUI.Library.GUIWindowManager.ShowPreviousWindow();

                            return;

                        }

                }


                base.OnAction(action);

            }


            public override bool OnMessage(MediaPortal.GUI.Library.GUIMessage message)

            {

                switch (message.Message)

                {


                    case MediaPortal.GUI.Library.GUIMessage.MessageType.GUI_MSG_WINDOW_INIT:

                        {

                            base.OnMessage(message);

                           

//code here runs every time the window is displayed

MediaPortal.GUI.Library.GUIPropertyManager.SetProperty("#currentmodule", "Plugin Name");

                           

                            break;

                        }

                    case MediaPortal.GUI.Library.GUIMessage.MessageType.GUI_MSG_CLICKED:

                        {


                            break;

                        }


                    case MediaPortal.GUI.Library.GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT:

                        {


                        }

                        break;


                }

                return base.OnMessage(message);


            }

            #endregion

[/code]


HTH


Sam


Top Bottom