/[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/08 14:24:17	62
+++ trunk/xmltv_parser/main.cs	2013/03/09 12:45:23	84
@@ -1,4 +1,6 @@
-´╗┐using System;
+´╗┐//#define DISABLE_RELEASE_MODE_KLOGLEVEL_DEBUG // when defined will turn off kLogLevel_Debug messages, in release mode
+//#define DISABLE_DEBUG_MODE_KLOGLEVEL_VERBOSE_DEBUG // when defined will turn off kLogLevel_VerboseDebug message, in debug mode
+using System;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
@@ -12,29 +14,43 @@
 using System.IO;
 using System.Runtime.Serialization.Formatters.Binary;
 using System.Threading;
+using System.Diagnostics;
 
 namespace xmltv_parser
 {
 
     public partial class main : Form
     {
-        //bool form_closing = false;
-        //private IXMLTVRuntimeInstance xmltv;
-        private bool IsUnix
-        {
-            get { return System.Environment.OSVersion.Platform == PlatformID.Unix; }
-        }
-
         public main()
         {
             InitializeComponent();
             ListViewSorter Sorter = new ListViewSorter();
             lstPrograms.ListViewItemSorter = Sorter;
-
             string log_path = Application.StartupPath;
             string log_filename = string.Format("{0}.log", typeof(main).Assembly.GetName().Name);
             gLog.CreateLog(string.Format(@"{0}\{1}", log_path, log_filename), false, LogLevel.kLogLevel_All_NoProgress, new EventHandler<LoggerOnFlushEventArgs>(Log_OnFlush));
-            gLog.SetLogLevel(gLog.LogLevel & ~LogLevel.kLogLevel_VerboseDebug);
+#if DEBUG
+            LogLevel gLevel = gLog.LogLevel;
+#if DISABLE_DEBUG_MODE_KLOGLEVEL_VERBOSE_DEBUG
+            gLevel &= ~LogLevel.kLogLevel_VerboseDebug;
+#else
+            gLevel |= LogLevel.kLogLevel_VerboseDebug;
+#endif
+            gLevel |= LogLevel.kLogLevel_Debug;
+            gLog.SetLogLevel(gLevel);
+#else
+            LogLevel gLevel = LogLevel.kLogLevel_Default; // set the default log level: Info, Warn, Error, Debug
+            // it is OK for kLogLevel_Debug to be set in Release mode ... must of the chatty messages are from kLogLevel_VerboseDebug
+#if DISABLE_RELEASE_MODE_KLOGLEVEL_DEBUG
+            gLevel &= ~LogLevel.kLogLevel_Debug;
+#else
+            gLevel |= LogLevel.kLogLevel_Debug;
+#endif
+            gLevel &= ~LogLevel.kLogLevel_VerboseDebug; // ensure this is not set, ever in release mode         
+            gLog.SetLogLevel(gLevel);
+#endif
+
+
             gLog.ReportProgressEvent += new EventHandler<ReportProgressEventArgs>(gLog_ReportProgress);
         }
 
@@ -49,6 +65,7 @@
                 catch { }
                 return;
             }
+            if (this.IsDisposed) { return; }
             progress_status.Value = progress;
         }
         private void gLog_ReportProgress(object sender, ReportProgressEventArgs e) { ReportProgress(e.Progress); }
@@ -79,15 +96,24 @@
 
         void UpdateStatus(string logmessage)
         {
+            if (this.InvokeRequired)
+            {
+                try
+                {
+                    this.Invoke((Action)(delegate { UpdateStatus(logmessage); }));
+                }
+                catch { }
+                return;
+            }
             txtStatus.Text = logmessage.Replace(System.Environment.NewLine, "");
         }
         void UpdateLogOutput(string logmessage)
         {
-            if (txtLog.InvokeRequired)
+            if (this.InvokeRequired)
             {
                 try
                 {
-                    txtLog.Invoke((Action)(delegate { UpdateLogOutput(logmessage); }));
+                    this.Invoke((Action)(delegate { UpdateLogOutput(logmessage); }));
                 }
                 catch { }
                 return;
@@ -113,8 +139,8 @@
         void LoadXMLTVShcedule(string schedule_xml)
         {
             //XMLTV.CreateInstance(schedule_xml, new EventHandler<CancelEventArgs>(xmltv_cancelevent));
-            XMLTV.CreateInstance(schedule_xml);
-            XMLTV.OnInstanceCreated += new EventHandler<EventArgs>(XMLTV_OnInstanceCreated);
+            XMLTV.CreateInstance(schedule_xml, new EventHandler<EventArgs>(XMLTV_OnInstanceCreated));
+            //XMLTV.OnInstanceCreated += new EventHandler<EventArgs>(XMLTV_OnInstanceCreated);
         }
 
         void XMLTV_OnInstanceCreated(object sender, EventArgs e)
@@ -123,8 +149,8 @@
             var instance = XMLTV.GetInstance();
             if (instance != null)
             {
-                var program_count = instance.Programs.Values.Count;
-                var program_list = instance.Programs.Values.ToList().OrderBy(s => s.Start);
+                var program_count = instance.Programs.Count;
+                var program_list = instance.Programs.ToList().OrderBy(s => s.Start);
                 //Programs = program_list(0, program_count).ToList();
                 Programs = new List<IXMLTVProgram>(program_list.ToArray());
             }

 

  ViewVC Help
Powered by ViewVC 1.1.22