Questions on writing my first plugin | Page 5

Discussion in 'Plugin Development' started by huha, March 20, 2012.

  1. morpheus_xx
    • Team MediaPortal

    morpheus_xx Lead Dev MP2

    Joined:
    March 24, 2007
    Messages:
    10,905
    Likes Received:
    4,701
    Ratings:
    +6,738 / 11
    Home Country:
    Germany Germany
    Show System Specs
    Hi,

    nice to see your progress, great work (y)!

    VisualStudio automatically sets all new .xaml to "Compile", and "Page". This needs to be changed in the file properties, see screenshot here:

    build_options.png

    "Userdefined tool" (Benutzerdefiniertes Tool)needs to be removed, BuildAction should be set to "content" (Inhalt). Sorry, that my previous answer was not exact enough.

    To your questions:
    1) I don't know an answer yet, have not needed it until now. I will check this and let you know later.

    2) The hover images are coupled with the Workflow Transitions. Let's take the SlimTv client plugin as example. In the "Skin\default\workflow\SlimTvClient-actions.xaml" I defined the navigation options. The first entry is the "home menu button":

    <?xml version="1.0" encoding="utf-8"?>
    <Workflow DescriptorVersion="1.0">
    <MenuActions>
    <PushNavigationTransition Id="B4A9199F-6DD4-4bda-A077-DE9C081F7703"
    Name="Home->SlimTvClient"
    DisplayCategory="A-SlimTvClient"
    SortOrder="a"
    SourceStates="7F702D9C-F2DD-42da-9ED8-0BA92F07787F"
    TargetState="C7646667-5E63-48c7-A490-A58AC9518CFA"
    DisplayTitle="SlimTvClient"/>

    I decided to use the unique menu action ID also for hover file names. Good thing is, they are independent from plugin names or localization.
    So the related hover image you'll find in
    Reflexion\Images\B4A9199F-6DD4-4bda-A077-DE9C081F7703.jpg



    So if you have your own menu actions, simply add another image with the {guid}.jpg.

    3) The assembly version will have a common number in the next published builds. I introduced a common version file include for this. But on the other hand I would not rely to much on the .dll AssemblyVersion. Each plugin comes with it's plugin.xml descriptor:

    <Plugin
    DescriptorVersion="1.0"
    Name="SlimTvClient"
    PluginId="{63040BB4-4638-49b7-A82F-F4530D4D43B9}"
    Author="Morpheus_xx"
    Copyright="GPL"
    Description="The SlimTvClient plugin provides the GUI and Player for basic TV capabilities."
    PluginVersion="1.0">

    In the past I didn't change any version number here, but in next public build we should do this. I don't have a code part available yet, that exposes the version number, but I think it must be sth. like IPluginManager to call.

    I would recommend that you don't try to support older version of SlimTv. Until now each "release" is to be considered as unstable (project is situated in Incubator).

    4) I had never issues with settings manager, we rely on it all over MP2. Save() does write Settings immediatly to disk. Load() does the same. If the file is not available, the default values are used (see the property attributes).


    I hope this helps a bit, please continue asking! This also helps others to learn more about MP2 :)

    Morpheus
     
    • Like Like x 2
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. huha
    • Premium Supporter

    huha Extension Developer

    Joined:
    January 3, 2008
    Messages:
    890
    Likes Received:
    550
    Gender:
    Male
    Ratings:
    +622 / 0
    Home Country:
    Germany Germany
    Show System Specs
    Hi Morpheus,
    thanks again for your help!
    - compiling works now out of one project file incliding the .xaml files. This is great.
    - the hover picture works great
    - I will use the plugin.xml version number in the future, but will wait for the next release of MP2

    - On the settings manager I am still struggling. It works fine if i change a setting within the configuration manager. Then the file is immediately writtten. However, if I am saving a setting within a model file, the .xml file is written after the client is closed.
    I had the following code used in the Result_GUI model, and it is called from the function ExitModelContext(NavigationContext oldContext, NavigationContext newContext) or Deactivate(NavigationContext oldContext, NavigationContext newContext):

    Code (Text):
    1. try
    2.             {
    3.                 ISettingsManager settingsManager = ServiceRegistration.Get<ISettingsManager>();
    4.                 TvWishListMP2Settings settings = settingsManager.Load<TvWishListMP2Settings>();
    5.  
    6.                 //settings.TvWishItemSeparator = TvWishItemSeparator;
    7.  
    8.                 settings.Sort = mymessages.Sort;
    9.                 settings.SortReverse = mymessages.SortReverse;
    10.  
    11.                 settings.Email = mymessages.Email;
    12.                 settings.Deleted = mymessages.Deleted;
    13.                 Log.Debug("mymessages.Deleted=" + mymessages.Deleted.ToString());
    14.                 settings.Conflicts = mymessages.Conflicts;
    15.                 settings.Scheduled = mymessages.Scheduled;
    16.                 settings.Recorded = mymessages.Recorded;
    17.                 Log.Debug("mymessages.Recorded=" + mymessages.Recorded.ToString());
    18.                 settings.View = mymessages.View;
    19.  
    20.                 settingsManager.Save(settings);
    21.                 Log.Debug("Settings have been saved");
    22.             }
    23.             catch (Exception exc)
    24.             {
    25.                 Log.Debug("Error SaveSettings: Exception " + exc.Message);
    26.             }
    It looks like writting the .xml setting file is delayed if the command is used outside the configuration manager. Is this a bug in MP2?
    ( I am using the official summer built release)
     
  4. morpheus_xx
    • Team MediaPortal

    morpheus_xx Lead Dev MP2

    Joined:
    March 24, 2007
    Messages:
    10,905
    Likes Received:
    4,701
    Ratings:
    +6,738 / 11
    Home Country:
    Germany Germany
    Show System Specs
    I think this is the issue. Deactivate and ExitModelContext are executed when you are leaving your plugin screens, or MP2 shuts down.

    Are you reacting on some messages (mymessages)? In this case it would be better to save the settings in the message handler.

    If not, save settings directly in commands/action that you invoke.
     
  5. huha
    • Premium Supporter

    huha Extension Developer

    Joined:
    January 3, 2008
    Messages:
    890
    Likes Received:
    550
    Gender:
    Male
    Ratings:
    +622 / 0
    Home Country:
    Germany Germany
    Show System Specs
    I am directly calling the savesettings function when the plugin screen is left in the model. I will change that and use the message handler. Thanks!
     
Loading...

Users Viewing Thread (Users: 0, Guests: 0)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!