A little help ?

Discussion in 'General Development (no feature request here!)' started by wizard123, January 8, 2015.

  1. wizard123
    • Team MediaPortal

    wizard123 Design Group

    Joined:
    January 24, 2012
    Messages:
    2,499
    Likes Received:
    1,695
    Gender:
    Male
    Occupation:
    genius
    Ratings:
    +2,919 / 11
    Home Country:
    United Kingdom United Kingdom
    Hi Guys

    I currently have the plugin template setup in visual studio and have complied then used inside mediaportal no problem. My question is how would i go about creating an image control that is available to be displayed in the home screen and displays whatever is set in the c# code plugin. A bit like displaying latest media from latestmediahandler.

    I've got to be honest the wiki is shoddy at best for examples in plugin code.

    Hopefully someone can give me some ideas.

    Thanks


     
    • Like Like x 1
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. wizard123
    • Team MediaPortal

    wizard123 Design Group

    Joined:
    January 24, 2012
    Messages:
    2,499
    Likes Received:
    1,695
    Gender:
    Male
    Occupation:
    genius
    Ratings:
    +2,919 / 11
    Home Country:
    United Kingdom United Kingdom
    No one ? wow it's even quieter than i thought :eek:
     
  4. Lightning303
    • Premium Supporter

    Lightning303 MP Donator

    Joined:
    September 12, 2009
    Messages:
    798
    Likes Received:
    384
    Gender:
    Male
    Ratings:
    +578 / 0
    Home Country:
    Germany Germany
    Show System Specs
    Sorry :(, i could only tell you how to open some dialogs, but it sounds like thats not what you want to do.
    How about checking the latestmediahandler source and see how they do it? Thats how i would try to figure this one out :).

    https://code.google.com/p/latestmediahandler/
     
  5. wizard123
    • Team MediaPortal

    wizard123 Design Group

    Joined:
    January 24, 2012
    Messages:
    2,499
    Likes Received:
    1,695
    Gender:
    Male
    Occupation:
    genius
    Ratings:
    +2,919 / 11
    Home Country:
    United Kingdom United Kingdom
    Thanks, i have scrolled through that source but found nothing that indicated what i'm after :( i'm sure it would only take a dev 10 minutes to put together what i want but have not found anyone willing to help :cry:
     
  6. mrj

    mrj Portal Pro

    Joined:
    January 27, 2012
    Messages:
    251
    Likes Received:
    45
    Ratings:
    +101 / 1
    Show System Specs
    Hi wizard
    You can try something like this

    In code
    GUIPropertyManager.SetProperty("#picture", "picturefile.jpg");


    in XML

    <control>
    <description>an Image</description>
    <type>image</type>
    <id>5</id>
    <posX>75</posX>
    <posY>370</posY>
    <texture>#picture</texture>
    </control>


    N.B
    NOT tested
    /mrj
     
    Last edited: January 9, 2015
    • Agree Agree x 1
  7. Edalex
    • Premium Supporter

    Edalex Community Plugin Dev

    Joined:
    January 3, 2008
    Messages:
    2,908
    Likes Received:
    713
    Gender:
    Male
    Location:
    Saratov
    Ratings:
    +1,229 / 9
    Home Country:
    Russian Federation Russian Federation
    Show System Specs
    Last edited: January 9, 2015
  8. wizard123
    • Team MediaPortal

    wizard123 Design Group

    Joined:
    January 24, 2012
    Messages:
    2,499
    Likes Received:
    1,695
    Gender:
    Male
    Occupation:
    genius
    Ratings:
    +2,919 / 11
    Home Country:
    United Kingdom United Kingdom
    Thank you both for the replies much apprieciated :)

    @Edalex i have added the example posted above but i get this error

    'MediaPortal.GUI.Library.GUIPropertyManager.SetProperty(string, string)' is a 'method' but is used like a 'type'

    Am i missing a reference ?
     
  9. Edalex
    • Premium Supporter

    Edalex Community Plugin Dev

    Joined:
    January 3, 2008
    Messages:
    2,908
    Likes Received:
    713
    Gender:
    Male
    Location:
    Saratov
    Ratings:
    +1,229 / 9
    Home Country:
    Russian Federation Russian Federation
    Show System Specs
    Nope, looks like you added this in the wrong place in code as your probably doing this outside the class.
    it should be like this as I think:
    Code (C#):
    1. namespace MyPlugin
    2. {
    3.     public class MyClass
    4.     {
    5.         public void SetProp
    6.         {
    7.         GUIPropertyManager.SetProperty("#picture", "picturefile.jpg");
    8.         }
    9.     }
    10. }
    You could attach your cs file to look at.
     
  10. mrj

    mrj Portal Pro

    Joined:
    January 27, 2012
    Messages:
    251
    Likes Received:
    45
    Ratings:
    +101 / 1
    Show System Specs
    Hi wizard
    add
    using MediaPortal.GUI.Library;
    if u haven't done so
     
  11. wizard123
    • Team MediaPortal

    wizard123 Design Group

    Joined:
    January 24, 2012
    Messages:
    2,499
    Likes Received:
    1,695
    Gender:
    Male
    Occupation:
    genius
    Ratings:
    +2,919 / 11
    Home Country:
    United Kingdom United Kingdom
    It is literally the template code from wiki still at the moment

    Code (C):
    1. using System;
    2. using System.Windows.Forms;
    3. using MediaPortal.GUI.Library;
    4. using MediaPortal.Dialogs;
    5. using System.Threading.Tasks;
    6. using System.Linq;
    7. using System.Text;
    8.  
    9. namespace AthenaPlugin
    10. {
    11.     public class Class1 : GUIWindow, ISetupForm
    12.     {
    13.         [SkinControlAttribute(2)]
    14.         protected GUIButtonControl buttonOne = null;
    15.         [SkinControlAttribute(3)]
    16.         protected GUIButtonControl buttonTwo = null;
    17.  
    18.         public void SetProp
    19.         {
    20.         GUIPropertyManager.SetProperty("#picture", "picturefile.jpg");
    21.         }
    22.  
    23.         public Class1()
    24.         {
    25.  
    26.         }
    27.  
    28.         #region ISetupForm Members
    29.  
    30.         // Returns the name of the plugin which is shown in the plugin menu
    31.         public string PluginName()
    32.         {
    33.             return "AthenaPlugin";
    34.         }
    35.  
    36.         // Returns the description of the plugin is shown in the plugin menu
    37.         public string Description()
    38.         {
    39.             return "My First plugin tutorial";
    40.         }
    41.  
    42.         // Returns the author of the plugin which is shown in the plugin menu
    43.         public string Author()
    44.         {
    45.             return "Wizard123";
    46.         }
    47.  
    48.         // show the setup dialog
    49.         public void ShowPlugin()
    50.         {
    51.             MessageBox.Show("Nothing to configure, this is just an example");
    52.         }
    53.  
    54.         // Indicates whether plugin can be enabled/disabled
    55.         public bool CanEnable()
    56.         {
    57.             return true;
    58.         }
    59.  
    60.         // Get Windows-ID
    61.         public int GetWindowId()
    62.         {
    63.             // WindowID of windowplugin belonging to this setup
    64.             // enter your own unique code
    65.             return 5678;
    66.         }
    67.  
    68.         // Indicates if plugin is enabled by default;
    69.         public bool DefaultEnabled()
    70.         {
    71.             return true;
    72.         }
    73.  
    74.         // indicates if a plugin has it's own setup screen
    75.         public bool HasSetup()
    76.         {
    77.             return true;
    78.         }
    79.  
    80.         /// <summary>
    81.         /// If the plugin should have it's own button on the main menu of Mediaportal then it
    82.         /// should return true to this method, otherwise if it should not be on home
    83.         /// it should return false
    84.         /// </summary>
    85.         /// <param name="strButtonText">text the button should have</param>
    86.         /// <param name="strButtonImage">image for the button, or empty for default</param>
    87.         /// <param name="strButtonImageFocus">image for the button, or empty for default</param>
    88.         /// <param name="strPictureImage">subpicture for the button or empty for none</param>
    89.         /// <returns>true : plugin needs it's own button on home
    90.         /// false : plugin does not need it's own button on home</returns>
    91.  
    92.         public bool GetHome(out string strButtonText, out string strButtonImage,
    93.           out string strButtonImageFocus, out string strPictureImage)
    94.         {
    95.             strButtonText = PluginName();
    96.             strButtonImage = String.Empty;
    97.             strButtonImageFocus = String.Empty;
    98.             strPictureImage = String.Empty;
    99.             return true;
    100.         }
    101.  
    102.         // With GetID it will be an window-plugin / otherwise a process-plugin
    103.         // Enter the id number here again
    104.         public override int GetID
    105.         {
    106.             get
    107.             {
    108.                 return 5678;
    109.             }
    110.  
    111.             set
    112.             {
    113.             }
    114.         }
    115.  
    116.         #endregion
    117.  
    118.         public override bool Init()
    119.         {
    120.             return Load(GUIGraphicsContext.Skin + @"\AthenaPlugin.xml");
    121.         }
    122.  
    123.         protected override void OnClicked(int controlId, GUIControl control,
    124.           MediaPortal.GUI.Library.Action.ActionType actionType)
    125.         {
    126.             if (control == buttonOne)
    127.                 OnButtonOne();
    128.             if (control == buttonTwo)
    129.                 OnButtonTwo();
    130.             base.OnClicked(controlId, control, actionType);
    131.         }
    132.  
    133.         private void OnButtonOne()
    134.         {
    135.             GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow(
    136.               (int)GUIWindow.Window.WINDOW_DIALOG_OK);
    137.             dlg.SetHeading("Button has been pressed");
    138.             dlg.SetLine(1, "You pressed button 1");
    139.             dlg.SetLine(2, String.Empty);
    140.             dlg.SetLine(3, String.Empty);
    141.             dlg.DoModal(GUIWindowManager.ActiveWindow);
    142.         }
    143.  
    144.         private void OnButtonTwo()
    145.         {
    146.             GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow(
    147.               (int)GUIWindow.Window.WINDOW_DIALOG_OK);
    148.             dlg.SetHeading("Button has been pressed");
    149.             dlg.SetLine(1, "You pressed button 2");
    150.             dlg.SetLine(2, String.Empty);
    151.             dlg.SetLine(3, String.Empty);
    152.             dlg.DoModal(GUIWindowManager.ActiveWindow);
    153.         }
    154.  
    155.     }
    156.  
    157. }
     
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!