didu cmy

didu cmy

  • NA
  • 1
  • 0

C# (newbie) Xml playlist based slide show

Mar 28 2007 2:23 AM
I am reading some values from an Xml file assigning them to variables and then trying to display them. the problem is it waits for the loop to end to pass back the control to the function in the form load that called my process to read and assign the values and then check for if anything else is left in the form_load function to be operated if not then the display the most recent file it encountered which is the last file in Xml and that way it skips all the remaining files in the Xml. private void Form1_Load(object sender, EventArgs e) { CheckForFile(); } public void CheckForFile() { LoadPlaylist((System.Convert.ToString(@"C:\PlayerLibrary\config\ab.xml"))); } public void LoadPlaylist(string strFileName) { string strItemName = ""; XmlTextReader playlistReader = new XmlTextReader(strFileName); while (playlistReader.Read() && (playlistReader.NodeType == XmlNodeType.Element || playlistReader.NodeType == XmlNodeType.Whitespace)) { if (playlistReader.HasAttributes && playlistReader.Name == "name") { strItemName = playlistReader.GetAttribute("location"); playFile(strItemName); break; } } playlistReader.Close(); } public void playFile(string playFileName) { string fileExtention = ""; fileExtention = playFileName.Substring(playFileName.Length - 3, 3); //check if the file is image type then display it using pBoxPlayer if (fileExtention == "bmp" || fileExtention == "jpg" || fileExtention == "JPG" || fileExtention == "BMP" || fileExtention == "gif" || fileExtention == "Gif" || fileExtention == "PNG" || fileExtention == "png") { this.pBoxPlayer.Load(playFileName); this.pBoxPlayer.Visible = true; this.Show(); this.pBoxPlayer.Show(); } } }