NextPVR Forums
  • ______
  • Home
  • New Posts
  • Wiki
  • Members
  • Help
  • Search
  • Register
  • Login
  • Home
  • Wiki
  • Members
  • Help
  • Search
NextPVR Forums Public Developers v
« Previous 1 … 87 88 89 90 91 … 93 Next »
how do I access a variable from different class

 
  • 0 Vote(s) - 0 Average
how do I access a variable from different class
tkgafs
Offline

Senior Member

Posts: 594
Threads: 61
Joined: Jun 2004
#1
2004-09-18, 11:10 AM
hello,

I know this is a bit off topic but hopefully a more experienced c# programmer can point me in the correct direction

I am trying to make what I thought was small amendment to the jukebox plugin so that it will display a deafult image if no image is available in the current folder.

I want to read the variable userDir defined in the class FileSelectionTask from the function render in the class CurrentTrackTask , but I have no idea how to do it.

code fragments as follows
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
public class FileSelectionTask
{
private string userDir;

public void AddMusicDir(string name)
{
if (userDir == "")
{
userDir = name; // I want to read userDir
}
dbDirs.Enqueue(name);
}
}

public class CurrentTrackTask
{
public void Render(Graphics g)
{
.... lots of code

I'd like to say
string noIndexName = userDir + "\\noimage.jpg";
and then use it later in the function
}
[/QUOTE]

I have treid things like FileSelectionTask.userDir
or creating public static string topMusicDir in the FileSelectionTask and copying userDir to it.

then referencing topMusicDir or FileSelctionTask.topMusicDir from the other class

but nothing seems to give me the contents of the variable

any *pointers [Image: rock.gif] gratefully received

tkgafs
sub
Offline

Administrator

NextPVR HQ, New Zealand
Posts: 106,626
Threads: 767
Joined: Nov 2003
#2
2004-09-18, 05:17 PM
To access these methods in the FileSelectionTask class, your CurrentTrackTask needs to contain a variable of this type. In your constructor, you might create an instance of this class.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
public class FileSelectionTask
{
private string userDir;

public void AddMusicDir(string name)
{
if (userDir == "")
{
userDir = name; // I want to read userDir
}
dbDirs.Enqueue(name);
}

.... GetMusicDir()....
}

public class CurrentTrackTask
{
private FileSelectionTask fileSelectionTask;

CurrentTrackTask()
{
fileSelectionTask = new FileSelectionTask()

....
fileSelectionTask.AddMusicDir("c:\\mymusic");
}

public void Render(Graphics g)
{
.... lots of code

string noIndexName = fileSelectionTask.GetMusicDir() + "\\noimage.jpg";
}[/QUOTE]
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Possibly Related Threads…
Thread Author Replies Views Last Post
  NextPVR 5: When is PIN Required for API Access? pkscout 3 2,629 2020-05-26, 04:45 AM
Last Post: sub
  API access to artwork and deleting recordings cncb 29 15,380 2016-11-06, 02:20 AM
Last Post: mvallevand
  Access 'Stay on top' setting from a plugin? McBainUK 5 2,344 2011-11-07, 04:43 PM
Last Post: sub
  Settings config screen for class IEventNotification plugin imilne 9 3,440 2011-09-17, 06:06 PM
Last Post: sub
  Access ImportHDPVRChannelsForm mvallevand 62 14,267 2011-08-09, 03:37 AM
Last Post: mvallevand
  UiElement class tmrt 1 1,320 2010-10-05, 05:09 PM
Last Post: sub
  Access to Schedules inside standalone progs dero 1 1,367 2008-12-09, 12:03 PM
Last Post: dero
  Linking gbpvr.db3 to Access 2003: get readonly tables Khurram 5 3,887 2008-09-11, 08:35 AM
Last Post: Khurram
  Access to FSE switch idkpmiller 12 4,162 2008-07-05, 04:01 PM
Last Post: whurlston
  Access DB and DateTime idkpmiller 5 2,307 2008-04-14, 10:37 AM
Last Post: idkpmiller

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

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

Linear Mode
Threaded Mode