NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 82 83 84 85 86 … 93 Next »
Developing Panels

 
  • 0 Vote(s) - 0 Average
Developing Panels
Jeff
Offline

Posting Freak

Posts: 1,933
Threads: 69
Joined: Oct 2004
#1
2004-12-02, 07:01 PM
I am trying to add a penel to the DVD2MPEG plug-in so that it can display status on the main menu page. The only example I could find to use as a template was the sysinfo plug-in. I;ve tried to modify it and adapt it to fit what I guessed to be the strtcure for panels in .23.8 but I get the following error

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.InvalidCastException: Specified cast is not valid.
at GBPVR.Public.SkinHelper.getNamedImageNonCached(String name, Hashtable parameters)
at GBPVR.Public.SkinHelper.getNamedImage(String name, Hashtable parameters)
at DVD2MPEGPlugin.DVD2MPEGTask.renderPanel()
at bv.a(Boolean& A_0)
at n.v()
at bv.b(String A_0)
at n.a(Message& A_0)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


My render panel routine is

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
public Image renderPanel()
{
Hashtable args = new Hashtable();

// setup skin helper
XmlDocument document = new XmlDocument();
document.Load(PluginHelperFactory.getPluginHelper().GetSkinRootDirectory() + "\\panels\\dvdtompeg.xml");


SkinHelper myskinHelper = new SkinHelper(document, PluginHelperFactory.getPluginHelper().GetSkinRootDirectory() + getSkinSubdirectory());


string conversionState=" ";
switch (currentRipState)
{
case RippingState.Besweet:
conversionState = "Converting DVD audio";
break;

case RippingState.Decrypt:
conversionState = "Decrypting DVD";
break;

case RippingState.Mplex:
conversionState = "Building MPEG file";
break;
}

args["@ConversionState"] = conversionState;
DateTime currentTime = DateTime.Now;
args["@Time"] = currentTime.ToShortTimeString();
args["@Date1"] = currentTime.DayOfWeek;
args["@Date2"] = currentTime.ToShortDateString();

Image offScreenBmp = myskinHelper.getNamedImage("DVDtoMPEGPanel",args);
Graphics offScreenDC = Graphics.FromImage(offScreenBmp);
offScreenDC.DrawImage(offScreenBmp, 500, 100);
offScreenDC.Dispose();

return offScreenBmp;
}


[/QUOTE]

Any ideas what I am doing wrong?

Thanks
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,683
Threads: 767
Joined: Nov 2003
#2
2004-12-02, 07:14 PM
The error indicates one of the arguments in Args is not the correct type. Possibly currentTime.DayOfWeek? What type is that?
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,683
Threads: 767
Joined: Nov 2003
#3
2004-12-02, 07:22 PM
Here is the clock panel, for anyone that is interested:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">using System;
using System.Collections;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Xml;

using GBPVR.Backend.Common;
using GBPVR.Public;

namespace GBPVR.Panels
{
/// <summary>
/// Summary description for ClockPanel.
/// </summary>
public class ClockPanel : IInfoPanel
{
private DateTime lastRenderTime = DateTime.Now.AddMinutes(-1);
private Image panelImage;
private SkinHelper skinHelper;
private bool initialized = false;

/// <summary>Returns the panel name. This is used for looking up its placement in skin.xml files</summary>
public string getPanelName()
{
return "Clock";
}

/// <summary>Called every second or so when the panel is visible</summary>
public bool panelNeedsRendering()
{
if (lastRenderTime.Minute != DateTime.Now.Minute)
{
lastRenderTime = DateTime.Now;
return true;
}
return false;
}

private void initialize()
{
initialized = true;

// setup skin helper
XmlDocument document = new XmlDocument();
document.Load(SystemConfiguration.getInstance().getSkinConfiguration().getSkinDirectory() + "panels\\Clock.xml");
skinHelper = new SkinHelper(document, SystemConfiguration.getInstance().getSkinConfiguration().getSkinDirectory() + "panels\\");
}

/// <summary>Is called by GBPVR to render the image shown to the user</summary>
public Image renderPanel()
{
if (!initialized)
{
initialize();
}

Hashtable imageParameters = new Hashtable();
imageParameters.Add("@ClockText1", DateTime.Now.ToShortTimeString());
imageParameters.Add("@ClockText2", DateTime.Now.ToLongDateString());
panelImage = skinHelper.getNamedImageNonCached("Clock", imageParameters);

// return rendered image
return panelImage;
}
}
}
[/QUOTE]
Jeff
Offline

Posting Freak

Posts: 1,933
Threads: 69
Joined: Oct 2004
#4
2004-12-02, 07:40 PM
That was it; thanks.
Huw
Offline

Member

Posts: 219
Threads: 7
Joined: Oct 2004
#5
2004-12-02, 10:26 PM
I think some kind of simple panel manager is going to be needed soon, otherwise we will have a heap of plugins with panels and no space to display them in [Image: smile.gif]
Jeff
Offline

Posting Freak

Posts: 1,933
Threads: 69
Joined: Oct 2004
#6
2004-12-02, 11:00 PM
I have another question. I am trying to access the value of a state variable in my panel render procudure and the value I see is always the initial value it was set to. Other procedures in the same class seem to see a diffrent value for the same variable. I don't really understand much of the details of C# interfaces and such; I am just a brute-force programmer. Is there some subtley going on or something special I need to do to access a variable in the panel render routine that is set in some other routine?

Thanks
Jeff
Offline

Posting Freak

Posts: 1,933
Threads: 69
Joined: Oct 2004
#7
2004-12-03, 11:46 PM
I figured out how to fix the problem although I don't understand why this was needed. I defined the variable I wanted to access to be &quot;static&quot; and now it works. I've added a panel that does the same thing as the Time panel when then is nothing going on and that displays the current state of the conversion process below the date/time when one is active.
jasonf
Offline

Member

Posts: 121
Threads: 7
Joined: Oct 2004
#8
2004-12-04, 02:45 AM
It was probably in how you were trying to access the variable then.

Static members belong to the class, while non-static members belong to the instance.  What's this mean?  Consider the following:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
public class Test
{
  // Constructor
  public Test() {}

  // Static method
  public static int getX()
  {
     return 100;
  }

  // Instance method
  public int getY()
  {
     return 500;
  }
}
[/QUOTE]

The class is &quot;Test&quot;, and all static members are accessed from the class itself.  In this example, the only static member is the getX() function:

int x = Test.getX();

Note that we don't need to instantiate an object in order to execute static methods.

If we instantiate the class into an object, then the getY() function is accessible from the object variable:

Test test1 = new Test();
int y = test1.getY();


So, since you're variable magically started working after you made it static, then it tells me that you were trying to access the variable from the class instead of from an instantiated object (which might very well be appropriate for what you were trying to do, but hopefully this helps you to understand what &quot;static&quot; means).
JasonF
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  Developing Android TV client fred250 2 1,809 2020-11-16, 06:33 PM
Last Post: fred250
  I want to start developing plugins...but how? OrenShapir 6 4,048 2014-11-18, 10:38 PM
Last Post: mvallevand
  Anyone interested in developing a Skin Plugin? Hairy 13 4,968 2011-07-10, 04:13 PM
Last Post: mvallevand
  Panels! Ommina 5 2,184 2008-03-11, 07:08 PM
Last Post: sub
  Question about developing a Plugin ACE1234 2 1,889 2007-11-19, 06:44 PM
Last Post: elite
  Panels? Old Dog 35 8,964 2006-01-07, 02:38 AM
Last Post: LilY0da
  Developing plugins sub 92 28,245 2006-01-05, 12:06 PM
Last Post: Old Dog
  Developing a skin. Need input. daphatty 4 2,184 2005-04-13, 02:59 PM
Last Post: reboot
  Developing on a Non-PVR PC ejk 2 1,341 2005-01-21, 04:07 PM
Last Post: ejk
  Use of Panels decreases performance? PeterM 5 2,334 2004-12-04, 05:14 PM
Last Post: PeterM

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D, modified by NextPVR - Powered by MyBB

Linear Mode
Threaded Mode