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

Diff of /trunk/xmltv_parser/main.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/xmltv_parser/main.cs	2013/03/07 12:51:53	28
+++ trunk/xmltv_parser/main.cs	2013/03/07 13:20:53	29
@@ -2,11 +2,13 @@
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
+using System.Linq;
 using System.Drawing;
 using System.Text;
 using System.Windows.Forms;
 using libxmltv.Core;
 using Enterprise.Logging;
+using libxmltv.Interfaces;
 
 namespace xmltv_parser
 {
@@ -20,16 +22,47 @@
             gLog.CreateLog(string.Format(@"{0}\{1}", log_path, log_filename), false, LogLevel.kLogLevel_All);
         }
 
+        //List<IXMLTVChannel> Channels;
+        List<IXMLTVProgram> Programs;
+
         private void main_Load(object sender, EventArgs e)
         {
 
         }
         private void main_Shown(object sender, EventArgs e)
+        {            
+            LoadXMLTVShcedule("20130307_continuum_schedule.xml");
+            CreateControls();
+        }
+
+
+        void LoadXMLTVShcedule(string schedule_xml)
         {
-            var xmltv_loader = XMLTV.CreateLoader("20130307_continuum_schedule.xml");
+            var xmltv_loader = XMLTV.CreateLoader(schedule_xml);
             var xmltv_parser = XMLTV.CreateParser(xmltv_loader);
             var p = XMLTV.GetParser(xmltv_parser);
-            //p.TestParse()            
+
+            //var channel_count = p.Channels.Values.Count;
+            //Channels = p.Channels.Values.ToList().GetRange(0, channel_count).ToList();
+            var program_count = p.Programs.Values.Count;
+            var program_list = p.Programs.Values.ToList().OrderBy(s => s.Start);
+            //Programs = program_list(0, program_count).ToList();
+            Programs = new List<IXMLTVProgram>(program_list.ToArray());
+        }
+
+        void CreateControls()
+        {
+            foreach (var program in Programs)
+            {
+                ListViewItem li = new ListViewItem(string.Format("{0} {1}", program.Channel.Number, program.Channel.CallSign));
+                li.SubItems.Add(new ListViewItem.ListViewSubItem(li, program.Title));
+                li.SubItems.Add(new ListViewItem.ListViewSubItem(li, program.SubTitle));
+                li.SubItems.Add(new ListViewItem.ListViewSubItem(li, program.Description));
+                li.SubItems.Add(new ListViewItem.ListViewSubItem(li, program.Start.ToString("yyyy/MM/dd hh:mm tt")));
+                li.SubItems.Add(new ListViewItem.ListViewSubItem(li, program.Stop.ToString("yyyy/MM/dd hh:mm tt")));
+                lstPrograms.Items.Add(li);
+            }
         }
     }
 }
+

 

  ViewVC Help
Powered by ViewVC 1.1.22