/[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

revision 63 by william, Fri Mar 8 14:26:48 2013 UTC revision 86 by william, Sat Mar 9 13:51:58 2013 UTC
# Line 1  Line 1 
1  ´╗┐using System;  ´╗┐//#define DISABLE_RELEASE_MODE_KLOGLEVEL_DEBUG // when defined will turn off kLogLevel_Debug messages, in release mode
2    //#define DISABLE_DEBUG_MODE_KLOGLEVEL_VERBOSE_DEBUG // when defined will turn off kLogLevel_VerboseDebug message, in debug mode
3    using System;
4  using System.Collections.Generic;  using System.Collections.Generic;
5  using System.ComponentModel;  using System.ComponentModel;
6  using System.Data;  using System.Data;
# Line 12  using libxmltv.Interfaces; Line 14  using libxmltv.Interfaces;
14  using System.IO;  using System.IO;
15  using System.Runtime.Serialization.Formatters.Binary;  using System.Runtime.Serialization.Formatters.Binary;
16  using System.Threading;  using System.Threading;
17    using System.Diagnostics;
18    
19  namespace xmltv_parser  namespace xmltv_parser
20  {  {
21    
22      public partial class main : Form      public partial class main : Form
23      {      {
         //bool form_closing = false;  
         //private IXMLTVRuntimeInstance xmltv;  
         private bool IsUnix  
         {  
             get { return System.Environment.OSVersion.Platform == PlatformID.Unix; }  
         }  
   
24          public main()          public main()
25          {          {
26              InitializeComponent();              InitializeComponent();
# Line 33  namespace xmltv_parser Line 29  namespace xmltv_parser
29              string log_path = Application.StartupPath;              string log_path = Application.StartupPath;
30              string log_filename = string.Format("{0}.log", typeof(main).Assembly.GetName().Name);              string log_filename = string.Format("{0}.log", typeof(main).Assembly.GetName().Name);
31              gLog.CreateLog(string.Format(@"{0}\{1}", log_path, log_filename), false, LogLevel.kLogLevel_All_NoProgress, new EventHandler<LoggerOnFlushEventArgs>(Log_OnFlush));              gLog.CreateLog(string.Format(@"{0}\{1}", log_path, log_filename), false, LogLevel.kLogLevel_All_NoProgress, new EventHandler<LoggerOnFlushEventArgs>(Log_OnFlush));
32              gLog.SetLogLevel(gLog.LogLevel & ~LogLevel.kLogLevel_VerboseDebug);  #if DEBUG
33                LogLevel gLevel = gLog.LogLevel;
34    #if DISABLE_DEBUG_MODE_KLOGLEVEL_VERBOSE_DEBUG
35                gLevel &= ~LogLevel.kLogLevel_VerboseDebug;
36    #else
37                gLevel |= LogLevel.kLogLevel_VerboseDebug;
38    #endif
39                gLevel |= LogLevel.kLogLevel_Debug;
40                gLog.SetLogLevel(gLevel);
41    #else
42                LogLevel gLevel = LogLevel.kLogLevel_Default; // set the default log level: Info, Warn, Error, Debug
43                // it is OK for kLogLevel_Debug to be set in Release mode ... must of the chatty messages are from kLogLevel_VerboseDebug
44    #if DISABLE_RELEASE_MODE_KLOGLEVEL_DEBUG
45                gLevel &= ~LogLevel.kLogLevel_Debug;
46    #else
47                gLevel |= LogLevel.kLogLevel_Debug;
48    #endif
49                gLevel &= ~LogLevel.kLogLevel_VerboseDebug; // ensure this is not set, ever in release mode        
50                gLog.SetLogLevel(gLevel);
51    #endif
52    
53    
54              gLog.ReportProgressEvent += new EventHandler<ReportProgressEventArgs>(gLog_ReportProgress);              gLog.ReportProgressEvent += new EventHandler<ReportProgressEventArgs>(gLog_ReportProgress);
55          }          }
56    
# Line 48  namespace xmltv_parser Line 65  namespace xmltv_parser
65                  catch { }                  catch { }
66                  return;                  return;
67              }              }
68                if (this.IsDisposed) { return; }
69              progress_status.Value = progress;              progress_status.Value = progress;
70          }          }
71          private void gLog_ReportProgress(object sender, ReportProgressEventArgs e) { ReportProgress(e.Progress); }          private void gLog_ReportProgress(object sender, ReportProgressEventArgs e) { ReportProgress(e.Progress); }
# Line 78  namespace xmltv_parser Line 96  namespace xmltv_parser
96    
97          void UpdateStatus(string logmessage)          void UpdateStatus(string logmessage)
98          {          {
99                if (this.InvokeRequired)
100                {
101                    try
102                    {
103                        this.Invoke((Action)(delegate { UpdateStatus(logmessage); }));
104                    }
105                    catch { }
106                    return;
107                }
108              txtStatus.Text = logmessage.Replace(System.Environment.NewLine, "");              txtStatus.Text = logmessage.Replace(System.Environment.NewLine, "");
109          }          }
110          void UpdateLogOutput(string logmessage)          void UpdateLogOutput(string logmessage)
111          {          {
112              if (txtLog.InvokeRequired)              if (this.InvokeRequired)
113              {              {
114                  try                  try
115                  {                  {
116                      txtLog.Invoke((Action)(delegate { UpdateLogOutput(logmessage); }));                      this.Invoke((Action)(delegate { UpdateLogOutput(logmessage); }));
117                  }                  }
118                  catch { }                  catch { }
119                  return;                  return;
# Line 112  namespace xmltv_parser Line 139  namespace xmltv_parser
139          void LoadXMLTVShcedule(string schedule_xml)          void LoadXMLTVShcedule(string schedule_xml)
140          {          {
141              //XMLTV.CreateInstance(schedule_xml, new EventHandler<CancelEventArgs>(xmltv_cancelevent));              //XMLTV.CreateInstance(schedule_xml, new EventHandler<CancelEventArgs>(xmltv_cancelevent));
142              XMLTV.CreateInstance(schedule_xml);              XMLTV.CreateInstance(schedule_xml, new EventHandler<EventArgs>(XMLTV_OnInstanceCreated));
143              XMLTV.OnInstanceCreated += new EventHandler<EventArgs>(XMLTV_OnInstanceCreated);              //XMLTV.OnInstanceCreated += new EventHandler<EventArgs>(XMLTV_OnInstanceCreated);
144          }          }
145    
146          void XMLTV_OnInstanceCreated(object sender, EventArgs e)          void XMLTV_OnInstanceCreated(object sender, EventArgs e)
# Line 122  namespace xmltv_parser Line 149  namespace xmltv_parser
149              var instance = XMLTV.GetInstance();              var instance = XMLTV.GetInstance();
150              if (instance != null)              if (instance != null)
151              {              {
152                  var program_count = instance.Programs.Values.Count;                  var program_count = instance.Programs.Count;
153                  var program_list = instance.Programs.Values.ToList().OrderBy(s => s.Start);                  var program_list = instance.Programs.ToList().OrderBy(s => s.GetProperty(XMLTVConstants.Programs.ProgramStart).ToString());
154                  //Programs = program_list(0, program_count).ToList();                  //Programs = program_list(0, program_count).ToList();
155                  Programs = new List<IXMLTVProgram>(program_list.ToArray());                  Programs = new List<IXMLTVProgram>(program_list.ToArray());
156              }              }
# Line 149  namespace xmltv_parser Line 176  namespace xmltv_parser
176              List<ListViewItem> items = new List<ListViewItem>();              List<ListViewItem> items = new List<ListViewItem>();
177              foreach (var program in Programs)              foreach (var program in Programs)
178              {              {
179                  ListViewItem li = new ListViewItem(string.Format("{0} {1}", program.Channel.Number, program.Channel.CallSign));                  IXMLTVChannel Channel = null;
180                    var instance = XMLTV.GetInstance();
181                    var id = program.GetProperty(XMLTVConstants.Programs.ProgramChannelId).ToString();
182                    Channel = instance.Channels.Find(m => m.Id == id);
183                    ListViewItem li = new ListViewItem(string.Format("{0} {1}", Channel.Number, Channel.CallSign));
184                  li.Tag = program;                  li.Tag = program;
185                  li.SubItems.Add(new ListViewItem.ListViewSubItem(li, program.Title));                  li.SubItems.Add(new ListViewItem.ListViewSubItem(li, program.GetProperty(XMLTVConstants.Programs.ProgramTitle).ToString()));
186                  li.SubItems.Add(new ListViewItem.ListViewSubItem(li, program.SubTitle));                  li.SubItems.Add(new ListViewItem.ListViewSubItem(li, program.GetProperty(XMLTVConstants.Programs.ProgramSubTitle).ToString()));
187                  li.SubItems.Add(new ListViewItem.ListViewSubItem(li, program.Description));                  li.SubItems.Add(new ListViewItem.ListViewSubItem(li, program.GetProperty(XMLTVConstants.Programs.ProgramDescription).ToString()));
188                  li.SubItems.Add(new ListViewItem.ListViewSubItem(li, program.Start.ToString("yyyy/MM/dd hh:mm tt")));                  li.SubItems.Add(new ListViewItem.ListViewSubItem(li, ((DateTime)program.GetProperty(XMLTVConstants.Programs.ProgramStart)).ToString("yyyy/MM/dd hh:mm tt")));
189                  li.SubItems.Add(new ListViewItem.ListViewSubItem(li, program.Stop.ToString("yyyy/MM/dd hh:mm tt")));                  li.SubItems.Add(new ListViewItem.ListViewSubItem(li, ((DateTime)program.GetProperty(XMLTVConstants.Programs.ProgramStop)).ToString("yyyy/MM/dd hh:mm tt")));
190                  //lstPrograms.Items.Add(li);                  //lstPrograms.Items.Add(li);
191                  items.Add(li);                  items.Add(li);
192              }              }

Legend:
Removed from v.63  
changed lines
  Added in v.86

  ViewVC Help
Powered by ViewVC 1.1.22