|
using System;
using System.Windows;
using System.Windows.Controls;
using System.Xml.Linq;
using System.Linq;
using System.Collections.Generic;
using System.Windows.Media.Imaging;
namespace MediaPlayer
{
public class DataAcces
{
public static void SetRightVertPanel(StackPanel elem)
{
XDocument xDoc = XDocument.Load("Data.xml");
var xVids = from v in xDoc.Descendants("Video")
where v.Attribute("img").Value.Length>0 && v.Attribute("vid").Value.Length>0
select new
{
img = v.Attribute("img").Value,
vid = v.Attribute("vid").Value,
id = v.Attribute("id").Value
};
elem.Children.Clear();
foreach (var v in xVids)
{
Image img = new Image();
img.Source = new BitmapImage(new Uri(v.img, UriKind.Relative));
img.Margin = new Thickness(1, 4, 1, 0);
img.Width = 50;
elem.Children.Add(img);
}
}
public static string GetVideoName(string imgPara)
{
XDocument xDoc = XDocument.Load("Data.xml");
var xVids = from v in xDoc.Descendants("Video")
where v.Attribute("img").Value.Equals(imgPara)
select new
{
img = v.Attribute("img").Value,
vid = v.Attribute("vid").Value,
id = v.Attribute("id").Value
};
if (xVids.Count() > 0)
{
return xVids.First().vid;
}
else
return "";
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
B.E. in Information Technology
MCTS(.NET 2.0 )