[Beginner] Change the text of a label (1 Viewer)

bmt

Portal Member
February 17, 2010
23
0
Home Country
Germany Germany
Hi everyone,

I'm playing around a bit with programming a dummy-plugin. Just to understand how MP works (as there is no complete documentation - if i didn't get this wrong)

That is what I wanted do to:
I want to have a selectButton which changes the text of a label if the button is selected.
What I've allready got:


Code:
namespace something
{
  public class somethingKategorien : GUIWindow

  {

    [SkinControl(2)]    protected GUIToggleButtonControl btnPolitik = null;


    private MPLabel label1;
    
    public somethingKategorien()
    {
      InitializeComponent();      
    }
    

    public override bool Init()
    {
      return Load(GUIGraphicsContext.Skin + @"\somethingKategorien.xml");
    }


    public override int GetID
    {
      get
      {
        return 5001;
      }

      set
      {
      }
    }


        protected override void OnClicked(int controlId, GUIControl control,
    MediaPortal.GUI.Library.Action.ActionType actionType)
    {
      if (control == btnPolitik)
      {
        OnButtonPolitik();
      }

      base.OnClicked(controlId, control, actionType);
    }


    public void OnButtonPolitik()
    {
      label1.Text = "Button was pressed!";
    }




    protected override void OnPageDestroy(int newWindowId)
    {
      base.OnPageDestroy(newWindowId);
      SaveSettings();
    }



    private void SaveSettings()
    {
      using (Settings xmlwriter = new Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))
      {
        xmlwriter.SetValueAsBool("something", "politik", btnPolitik.Selected);
        
      }
    }


    protected override void OnPageLoad()
    {
      base.OnPageLoad();
      SetBtnSelected();
    }

    private void SetBtnSelected()
    {
      using (Settings xmlreader = new Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))
      {
        bool politik = xmlreader.GetValueAsBool("something", "politik", false);
        btnPolitik.Selected = politik;
      }
    }

    private void InitializeComponent()
    {
      this.label1 = new MediaPortal.UserInterface.Controls.MPLabel();
      this.label1.Location = new System.Drawing.Point(16, 24);
      this.label1.Name = "label1";
      this.label1.Size = new System.Drawing.Size(120, 16);
      this.label1.TabIndex = 0;
      this.label1.Text = "Something";
    }
  }
}

So the selectButton works.
But I can't see my label1. What am I doing wrong? Do I have to register this label in my xml-File (somethingKategorien.xml)? Something else?

:D in advance!
 

Users who are viewing this thread

Top Bottom