Purpose

In an effort to reduce duplicate code among the internal plugins provided by MediaPortal, a base class for these was created, called WindowPluginBase, which contains this shared code, which is mostly centered around Layouts management, for now.

This document will present and explain the different properties and methods this class exposes and the guidelines to follow so, you, as a plugin developer, can evaluate and determine wether your plugin can take advantage of these, thus reducing your development time and being consistent, in certain aspects at least, to the internal plugins.

Details

Most properties and methods exposed are declared virtual giving you the flexibility to pick and choose those which suit your plugin.

The class provides these common controls: the facade, the layouts button, the sort button and the views button.

[SkinControl(50)]
protected GUIFacadeControl facadeLayout = null;
[SkinControl(2)]
protected GUIButtonControl btnLayouts = null;
[SkinControl(3)]
protected GUISortButtonControl btnSortBy = null;
[SkinControl(5)]
protected GUIButtonControl btnViews = null;

 

The following variables are provided:

protected Layout currentLayout = Layout.List; //self-explanatory
protected bool m_bSortAscending; //indicates wether sorting is ascending or not
protected ViewHandler handler;

ViewHandler is a class that can be used for defining and manipulating Custom Views (Not documented yet. Meanwhile please take a look in MediaPortal's source code and also look at the VideoHandler and MusicHandler classes for example of usage.)

 

 protected virtual Layout CurrentLayout {get; set;}

Gets or set the current facade layout. Note that setting this property won't actually change the facade's layout. To change the facade's layout, first set the desired layout with CurrentLayout and then call SwitchLayout().

 

protected virtual bool CurrentSortAsc {get; set;}

Gets or sets wether sorting is ascending or not. Note that setting this property won't change the sorting in the facade.. It is up to the developer to implement that logic.  If you want this value to persist when the page is closed or when MeidaPortal is closed then this value should be loaded/saved within LoadSettings/SaveSettings methods.

 

protected virtual string SerializeName {get;}

With this property you specify a name for your plugin. It is extremely important to override this property as Loadsettings() and SaveSettings() use this property for loading and saving settings under the SerializaName in Mediaportal.xml. (This property should probably be declared as abstract)

 

protected virtual void LoadSettings()

This method is used to load values from Mediaportal.xml.   It can be used in conjunction with SaveSettings to return to the previous state.   If you want to load settings each time the window is loaded this should be called from OnPageLoad().   If you want settings to be loaded once when MediaPortal this should be called in Init().

This method provides no functionality and it is up to the developer to implement this.

 

protected virtual void SaveSettings()

This method saves settings to Mediaportal.xml. SaveSettings() and should be used in conjunction with LoadSettings().  If you want to save settings each time the window is closed (eg. the user switches to a new screen) this should be called from OnPageDestroyed().  If you want settings to only be saved when MediaPortal closes then this should be called from DeInit().

This method provides no functionality and it is up to the developer to implement this.

 

protected virtual bool AllowLayout(Layout layout)

In this method you specify wether a certain layout of the standard layouts will be supported by your plugin. The base implementation allows all of the standard layouts. This method is used by OnShowLayouts() to determine which layouts should be shown in the Layouts Dialog.

 

protected virtual void SwitchLayout()

This methods switches the facade's layout to the value returned by CurrentLayout and then calls UpdateButtonStates().

 

protected virtual void OnShowLayouts()

This method shows a dialog providing the plugin's allowed layouts(see above) and switches the facade's layout to the one the user chooses.

 

protected virtual void UpdateButtonStates()

This method updates the label on the layouts button to the current layout's value. It also updates the sort order indicator in the sort button accordingly. If using a ViewHandler, it will also set the skin property #view to the ViewHandler's  LocalizedCurrentView value.

 

protected virtual void LoadDirectory(string path) {}

The base method has no implementation. You can use it for the obvious to keep consistency with other plugins.

 

protected virtual bool GetKeyboard(ref string strLine)

You can use this method for whenever your plugin needs to show a Standard Virtual Keyboard. strLine is the text that will be displayed initially in the input box and the value to use after the keyboard is closed.

 

protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)

WindowPluginBase's implementation of this method does several things depending on the control clicked and the action passed by the engine:

 

protected virtual void OnShowSort()

This method is called by Onclicked() when the sort button is pressed. The base class provides no implementation.

 

protected virtual void OnInfo(int iItem) {}

This method is called by OnClicked() if the ActionType is ACTION_SHOW_INFO. iItem is the index of the selected item in the facade. The base class provides no implementation.

 

protected virtual void OnClick(int iItem) {}

This method is called by OnClicked() if the ActionType is ACTION_SELECT_ITEM. iItem is the index of the selected item in the facade. The base class provides no implementation.

 

protected virtual void OnQueueItem(int iItem) {}

This method is called by OnClicked() if the ActionType is ACTION_QUEUE_ITEM. iItem is the index of the selected item in the facade. The base class provides no implementation.

 

protected virtual void OnShowViews() 

This method must always be overriden and the base method must never be called. The base implementation only deals with the MyMusic and MyVideos plugins. In the future we hope to provide a base implementation suitable for all plugins.

Additional Information and References

XML/Code Samples

 

Screenshots