/[xmltv_parser]/trunk/xmltv_parser/main.cs
ViewVC logotype

Contents of /trunk/xmltv_parser/main.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 29 - (show annotations) (download)
Thu Mar 7 13:20:53 2013 UTC (6 years, 9 months ago) by william
File size: 2573 byte(s)

1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Data;
5 using System.Linq;
6 using System.Drawing;
7 using System.Text;
8 using System.Windows.Forms;
9 using libxmltv.Core;
10 using Enterprise.Logging;
11 using libxmltv.Interfaces;
12
13 namespace xmltv_parser
14 {
15 public partial class main : Form
16 {
17 public main()
18 {
19 InitializeComponent();
20 string log_path = Application.StartupPath;
21 string log_filename = string.Format("{0}.log", typeof(main).Assembly.GetName().Name);
22 gLog.CreateLog(string.Format(@"{0}\{1}", log_path, log_filename), false, LogLevel.kLogLevel_All);
23 }
24
25 //List<IXMLTVChannel> Channels;
26 List<IXMLTVProgram> Programs;
27
28 private void main_Load(object sender, EventArgs e)
29 {
30
31 }
32 private void main_Shown(object sender, EventArgs e)
33 {
34 LoadXMLTVShcedule("20130307_continuum_schedule.xml");
35 CreateControls();
36 }
37
38
39 void LoadXMLTVShcedule(string schedule_xml)
40 {
41 var xmltv_loader = XMLTV.CreateLoader(schedule_xml);
42 var xmltv_parser = XMLTV.CreateParser(xmltv_loader);
43 var p = XMLTV.GetParser(xmltv_parser);
44
45 //var channel_count = p.Channels.Values.Count;
46 //Channels = p.Channels.Values.ToList().GetRange(0, channel_count).ToList();
47 var program_count = p.Programs.Values.Count;
48 var program_list = p.Programs.Values.ToList().OrderBy(s => s.Start);
49 //Programs = program_list(0, program_count).ToList();
50 Programs = new List<IXMLTVProgram>(program_list.ToArray());
51 }
52
53 void CreateControls()
54 {
55 foreach (var program in Programs)
56 {
57 ListViewItem li = new ListViewItem(string.Format("{0} {1}", program.Channel.Number, program.Channel.CallSign));
58 li.SubItems.Add(new ListViewItem.ListViewSubItem(li, program.Title));
59 li.SubItems.Add(new ListViewItem.ListViewSubItem(li, program.SubTitle));
60 li.SubItems.Add(new ListViewItem.ListViewSubItem(li, program.Description));
61 li.SubItems.Add(new ListViewItem.ListViewSubItem(li, program.Start.ToString("yyyy/MM/dd hh:mm tt")));
62 li.SubItems.Add(new ListViewItem.ListViewSubItem(li, program.Stop.ToString("yyyy/MM/dd hh:mm tt")));
63 lstPrograms.Items.Add(li);
64 }
65 }
66 }
67 }
68

  ViewVC Help
Powered by ViewVC 1.1.22