/[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 62 by william, Fri Mar 8 14:24:17 2013 UTC revision 79 by william, Sat Mar 9 11:40:15 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();
27              ListViewSorter Sorter = new ListViewSorter();              ListViewSorter Sorter = new ListViewSorter();
28              lstPrograms.ListViewItemSorter = Sorter;              lstPrograms.ListViewItemSorter = Sorter;
   
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    
57          private void ReportProgress(int progress)          private void ReportProgress(int progress)
58          {          {
59              if (this.InvokeRequired)              try
60              {              {
61                  try                  if (this.InvokeRequired)
62                  {                  {
63                      this.Invoke((Action)(delegate { ReportProgress(progress); }));                      try
64                        {
65                            this.Invoke((Action)(delegate { ReportProgress(progress); }));
66                        }
67                        catch { }
68                        return;
69                  }                  }
70                  catch { }                  progress_status.Value = progress;
                 return;  
71              }              }
72              progress_status.Value = progress;              catch (Exception ex) { Debug.WriteLine(ex.ToString()); }
73          }          }
74          private void gLog_ReportProgress(object sender, ReportProgressEventArgs e) { ReportProgress(e.Progress); }          private void gLog_ReportProgress(object sender, ReportProgressEventArgs e) { ReportProgress(e.Progress); }
75    
# Line 79  namespace xmltv_parser Line 99  namespace xmltv_parser
99    
100          void UpdateStatus(string logmessage)          void UpdateStatus(string logmessage)
101          {          {
102                if (this.InvokeRequired)
103                {
104                    try
105                    {
106                        this.Invoke((Action)(delegate { UpdateStatus(logmessage); }));
107                    }
108                    catch { }
109                    return;
110                }
111              txtStatus.Text = logmessage.Replace(System.Environment.NewLine, "");              txtStatus.Text = logmessage.Replace(System.Environment.NewLine, "");
112          }          }
113          void UpdateLogOutput(string logmessage)          void UpdateLogOutput(string logmessage)
114          {          {
115              if (txtLog.InvokeRequired)              if (this.InvokeRequired)
116              {              {
117                  try                  try
118                  {                  {
119                      txtLog.Invoke((Action)(delegate { UpdateLogOutput(logmessage); }));                      this.Invoke((Action)(delegate { UpdateLogOutput(logmessage); }));
120                  }                  }
121                  catch { }                  catch { }
122                  return;                  return;
# Line 113  namespace xmltv_parser Line 142  namespace xmltv_parser
142          void LoadXMLTVShcedule(string schedule_xml)          void LoadXMLTVShcedule(string schedule_xml)
143          {          {
144              //XMLTV.CreateInstance(schedule_xml, new EventHandler<CancelEventArgs>(xmltv_cancelevent));              //XMLTV.CreateInstance(schedule_xml, new EventHandler<CancelEventArgs>(xmltv_cancelevent));
145              XMLTV.CreateInstance(schedule_xml);              XMLTV.CreateInstance(schedule_xml, new EventHandler<EventArgs>(XMLTV_OnInstanceCreated));
146              XMLTV.OnInstanceCreated += new EventHandler<EventArgs>(XMLTV_OnInstanceCreated);              //XMLTV.OnInstanceCreated += new EventHandler<EventArgs>(XMLTV_OnInstanceCreated);
147          }          }
148    
149          void XMLTV_OnInstanceCreated(object sender, EventArgs e)          void XMLTV_OnInstanceCreated(object sender, EventArgs e)
# Line 123  namespace xmltv_parser Line 152  namespace xmltv_parser
152              var instance = XMLTV.GetInstance();              var instance = XMLTV.GetInstance();
153              if (instance != null)              if (instance != null)
154              {              {
155                  var program_count = instance.Programs.Values.Count;                  var program_count = instance.Programs.Count;
156                  var program_list = instance.Programs.Values.ToList().OrderBy(s => s.Start);                  var program_list = instance.Programs.ToList().OrderBy(s => s.Start);
157                  //Programs = program_list(0, program_count).ToList();                  //Programs = program_list(0, program_count).ToList();
158                  Programs = new List<IXMLTVProgram>(program_list.ToArray());                  Programs = new List<IXMLTVProgram>(program_list.ToArray());
159              }              }

Legend:
Removed from v.62  
changed lines
  Added in v.79

  ViewVC Help
Powered by ViewVC 1.1.22