first project some comments on code
LearnExpression Support Forum
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        



first project some comments on code Expand / Collapse
Author
Message
Posted 6/19/2008 7:41:45 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 6/21/2008 8:42:42 PM
Posts: 1, Visits: 10
I'm posting this code to see if anybody would have any suggestions for a better way to this. It gets the image and title from a netflix xml file. It  works but it seems like I might have done more then I needed to and made it more complicated then it needs to be. Any comments or suggestions would be greatly appreciated.

Heres the code:

private void PopulateQueueView()

{

string QueueUrl = ("http://rss.netflix.com/QueueRSS?id="+ NetflixRSSID);

XmlDocument QueueDoc = new XmlDocument();

QueueDoc.Load(QueueUrl);

XmlNodeList TitleData = QueueDoc.GetElementsByTagName("title");

XmlNodeList LinkData = QueueDoc.GetElementsByTagName("link");

XmlNodeList DescriptionData = QueueDoc.GetElementsByTagName("description");

int count = TitleData.Count;

int i;

for (i = 1; i < count; i++)

{

string Description = DescriptionData[i].InnerXml;

Regex Exp = new Regex("(?<=img src=[\x27\x22])(?<Url>[^\x27\x22]*)(?=[\x27\x22])", RegexOptions.Singleline);

Match IdString = Exp.Match(Description);

Group result = IdString.Groups["Url"];

Grid lvigrid = new Grid();

lvigrid.Margin = new Thickness(0, 0, 5, 0);

lvigrid.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;

RowDefinition imgrow = new RowDefinition();

RowDefinition titlerow = new RowDefinition();

imgrow.Height = new GridLength(0, GridUnitType.Auto);

titlerow.Height = new GridLength(0, GridUnitType.Auto);

lvigrid.RowDefinitions.Add(imgrow);

lvigrid.RowDefinitions.Add(titlerow);

TextBlock title = new TextBlock();

title.TextAlignment = TextAlignment.Center;

string temptext = TitleData[i].InnerXml.ToString();

char[] MyChar = { '0' };

string text = temptext.TrimStart(MyChar);

title.Text = text;

title.FontFamily = new System.Windows.Media.FontFamily("ariel");

title.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;

title.FontSize = 12;

title.Width = 116;

title.TextTrimming = TextTrimming.WordEllipsis;

Image img = new Image();

img.Margin = new Thickness(0, 3, 0, 3);

img.Width = 112;

img.Height = 122;

BitmapImage bmp = new BitmapImage(new Uri(result.Value));

img.Source = bmp;

lvigrid.Children.Add(img);

lvigrid.Children.Add(title);

Grid.SetRow(img, 0);

Grid.SetRow(title, 1);

lvigrid.ToolTip = title.Text;

lvigrid.Tag = LinkData[i].InnerText;

QueueListview.Items.Add(lvigrid);

}

QueuePop = 1;

}

Post #1392
« Prev Topic | Next Topic »


Reading This Topic Expand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.

Permissions Expand / Collapse

All times are GMT -6:00, Time now is 11:39am

Powered By InstantForum.NET v4.1.4 © 2009
Execution: 0.047. 13 queries. Compression Disabled.