A little help ? (1 Viewer)

wizard123

Retired Team Member
  • Premium Supporter
  • January 24, 2012
    2,569
    2,680
    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
     

    wizard123

    Retired Team Member
  • Premium Supporter
  • January 24, 2012
    2,569
    2,680
    Home Country
    United Kingdom United Kingdom
    • Thread starter
    • Moderator
    • #2
    No one ? wow it's even quieter than i thought :eek:
     

    wizard123

    Retired Team Member
  • Premium Supporter
  • January 24, 2012
    2,569
    2,680
    Home Country
    United Kingdom United Kingdom
    • Thread starter
    • Moderator
    • #4
    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:
     

    mrj

    Portal Pro
    January 27, 2012
    252
    100
    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:

    wizard123

    Retired Team Member
  • Premium Supporter
  • January 24, 2012
    2,569
    2,680
    Home Country
    United Kingdom United Kingdom
    • Thread starter
    • Moderator
    • #7
    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 ?
     

    Edalex

    Community Plugin Dev
  • Premium Supporter
  • January 3, 2008
    2,955
    1,264
    Saratov
    Home Country
    Russian Federation Russian Federation
    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:
    C#:
    namespace MyPlugin
    {
        public class MyClass
        {
            public void SetProp
            {
            GUIPropertyManager.SetProperty("#picture", "picturefile.jpg");
            }
        }
    }
    You could attach your cs file to look at.
     

    mrj

    Portal Pro
    January 27, 2012
    252
    100
    Hi wizard
    add
    using MediaPortal.GUI.Library;
    if u haven't done so
     

    wizard123

    Retired Team Member
  • Premium Supporter
  • January 24, 2012
    2,569
    2,680
    Home Country
    United Kingdom United Kingdom
    • Thread starter
    • Moderator
    • #10
    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:
    C#:
    namespace MyPlugin
    {
        public class MyClass
        {
            public void SetProp
            {
            GUIPropertyManager.SetProperty("#picture", "picturefile.jpg");
            }
        }
    }
    You could attach your cs file to look at.

    It is literally the template code from wiki still at the moment

    Code:
    using System;
    using System.Windows.Forms;
    using MediaPortal.GUI.Library;
    using MediaPortal.Dialogs;
    using System.Threading.Tasks;
    using System.Linq;
    using System.Text;
    
    namespace AthenaPlugin
    {
        public class Class1 : GUIWindow, ISetupForm
        {
            [SkinControlAttribute(2)]
            protected GUIButtonControl buttonOne = null;
            [SkinControlAttribute(3)]
            protected GUIButtonControl buttonTwo = null;
    
            public void SetProp
            {
            GUIPropertyManager.SetProperty("#picture", "picturefile.jpg");
            }
    
            public Class1()
            {
    
            }
    
            #region ISetupForm Members
    
            // Returns the name of the plugin which is shown in the plugin menu
            public string PluginName()
            {
                return "AthenaPlugin";
            }
    
            // Returns the description of the plugin is shown in the plugin menu
            public string Description()
            {
                return "My First plugin tutorial";
            }
    
            // Returns the author of the plugin which is shown in the plugin menu
            public string Author()
            {
                return "Wizard123";
            }
    
            // show the setup dialog
            public void ShowPlugin()
            {
                MessageBox.Show("Nothing to configure, this is just an example");
            }
    
            // Indicates whether plugin can be enabled/disabled
            public bool CanEnable()
            {
                return true;
            }
    
            // Get Windows-ID
            public int GetWindowId()
            {
                // WindowID of windowplugin belonging to this setup
                // enter your own unique code
                return 5678;
            }
    
            // Indicates if plugin is enabled by default;
            public bool DefaultEnabled()
            {
                return true;
            }
    
            // indicates if a plugin has it's own setup screen
            public bool HasSetup()
            {
                return true;
            }
    
            /// <summary>
            /// If the plugin should have it's own button on the main menu of Mediaportal 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 it's own button on home
            /// false : plugin does not need it's own button on home</returns>
    
            public bool GetHome(out string strButtonText, out string strButtonImage,
              out string strButtonImageFocus, out string strPictureImage)
            {
                strButtonText = PluginName();
                strButtonImage = String.Empty;
                strButtonImageFocus = String.Empty;
                strPictureImage = String.Empty;
                return true;
            }
    
            // With GetID it will be an window-plugin / otherwise a process-plugin
            // Enter the id number here again
            public override int GetID
            {
                get
                {
                    return 5678;
                }
    
                set
                {
                }
            }
    
            #endregion
    
            public override bool Init()
            {
                return Load(GUIGraphicsContext.Skin + @"\AthenaPlugin.xml");
            }
    
            protected override void OnClicked(int controlId, GUIControl control,
              MediaPortal.GUI.Library.Action.ActionType actionType)
            {
                if (control == buttonOne)
                    OnButtonOne();
                if (control == buttonTwo)
                    OnButtonTwo();
                base.OnClicked(controlId, control, actionType);
            }
    
            private void OnButtonOne()
            {
                GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow(
                  (int)GUIWindow.Window.WINDOW_DIALOG_OK);
                dlg.SetHeading("Button has been pressed");
                dlg.SetLine(1, "You pressed button 1");
                dlg.SetLine(2, String.Empty);
                dlg.SetLine(3, String.Empty);
                dlg.DoModal(GUIWindowManager.ActiveWindow);
            }
    
            private void OnButtonTwo()
            {
                GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow(
                  (int)GUIWindow.Window.WINDOW_DIALOG_OK);
                dlg.SetHeading("Button has been pressed");
                dlg.SetLine(1, "You pressed button 2");
                dlg.SetLine(2, String.Empty);
                dlg.SetLine(3, String.Empty);
                dlg.DoModal(GUIWindowManager.ActiveWindow);
            }
    
        }
    
    }
     

    Users who are viewing this thread

    Top Bottom