/[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 146 by william, Thu Mar 14 14:20:27 2013 UTC revision 248 by william, Fri Mar 22 16:41:42 2013 UTC
# Line 1  Line 1 
1  //#define DISABLE_RELEASE_MODE_KLOGLEVEL_DEBUG // when defined will turn off kLogLevel_Debug messages, in release mode  #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  //#define DISABLE_DEBUG_MODE_KLOGLEVEL_VERBOSE_DEBUG // when defined will turn off kLogLevel_VerboseDebug message, in debug mode
3  //#define USE_DYNAMIC_SORTING_FILTERING_CONTROLS // when defined will setup dynamic sorting and filtering controls for XMLTV Data  //#define USE_DYNAMIC_SORTING_FILTERING_CONTROLS // when defined will setup dynamic sorting and filtering controls for XMLTV Data
4  using System;  using System;
# Line 23  namespace xmltv_parser Line 23  namespace xmltv_parser
23    
24      public partial class main : Form      public partial class main : Form
25      {      {
26            const long MAX_LOG_FILESIZE_IN_BYTES = 250000; //250kb max
27            void TruncateLogFile(FileInfo log_file)
28            {
29                if (!log_file.Exists)
30                {
31                    gLog.CreateLog(log_file.FullName, false, LogLevel.kLogLevel_All_NoProgress, new EventHandler<LoggerOnFlushEventArgs>(Log_OnFlush));
32                }
33                else
34                {
35                    if (log_file.Length > MAX_LOG_FILESIZE_IN_BYTES)
36                    {
37                        string match = string.Format("{0}.*", log_file.Name);
38                        var files = Directory.GetFiles(log_file.Directory.FullName, match).ToList();
39                        files.RemoveAt(0);
40                        files.TrimExcess();
41                        int count = files.Count;
42                        if (log_file.Exists)
43                        {
44                            File.Copy(log_file.FullName, string.Format("{0}.{1}", log_file.FullName, count));
45                        }
46                        gLog.CreateLog(log_file.FullName, true, LogLevel.kLogLevel_All_NoProgress, new EventHandler<LoggerOnFlushEventArgs>(Log_OnFlush));
47                    }
48                    else
49                    {
50                        gLog.CreateLog(log_file.FullName, false, LogLevel.kLogLevel_All_NoProgress, new EventHandler<LoggerOnFlushEventArgs>(Log_OnFlush));
51                    }
52                }
53            }
54    
55          public main()          public main()
56          {          {
57              InitializeComponent();              InitializeComponent();
58              ListViewSorter Sorter = new ListViewSorter();              ListViewSorter Sorter = new ListViewSorter();
59              //lstPrograms.ListViewItemSorter = Sorter;              //lstPrograms.ListViewItemSorter = Sorter;
60    
61              string log_path = Application.StartupPath;              string log_path = Application.StartupPath;
62              string log_filename = string.Format("{0}.log", typeof(main).Assembly.GetName().Name);              string log_filename = string.Format("{0}.log", typeof(main).Assembly.GetName().Name);
63              gLog.CreateLog(string.Format(@"{0}\{1}", log_path, log_filename), false, LogLevel.kLogLevel_All_NoProgress, new EventHandler<LoggerOnFlushEventArgs>(Log_OnFlush));              FileInfo log_file = new FileInfo(string.Format(@"{0}\{1}", log_path, log_filename));
64                TruncateLogFile(log_file);            
65  #if DEBUG  #if DEBUG
66              LogLevel gLevel = gLog.LogLevel;              LogLevel gLevel = gLog.LogLevel;
67  #if DISABLE_DEBUG_MODE_KLOGLEVEL_VERBOSE_DEBUG  #if DISABLE_DEBUG_MODE_KLOGLEVEL_VERBOSE_DEBUG
# Line 220  namespace xmltv_parser Line 251  namespace xmltv_parser
251  #if USE_DYNAMIC_SORTING_FILTERING_CONTROLS  #if USE_DYNAMIC_SORTING_FILTERING_CONTROLS
252                _CreatControlsFromType(data_type);                _CreatControlsFromType(data_type);
253  #else  #else
254              gLog.Warn.WriteLine("Dynamic creation of sorting and filtering controls has not been enabled.");              gLog.Verbose.Warn.WriteLine("Dynamic creation of sorting and filtering controls has not been enabled.");
255              gLog.Warn.WriteLine("To enable: #define USE_DYNAMIC_SORTING_FILTERING_CONTROLS");              gLog.Verbose.Warn.WriteLine("To enable: #define USE_DYNAMIC_SORTING_FILTERING_CONTROLS");
256  #endif  #endif
257          }          }
258          [Conditional("USE_DYNAMIC_SORTING_FILTERING_CONTROLS")]          [Conditional("USE_DYNAMIC_SORTING_FILTERING_CONTROLS")]
# Line 240  namespace xmltv_parser Line 271  namespace xmltv_parser
271          void CreateDefaultControls(Type data_type)          void CreateDefaultControls(Type data_type)
272          {          {
273              // no default controls              // no default controls
274              gLog.Warn.WriteLine("No controls have been defined for: {0}", data_type.Name);              gLog.Verbose.Warn.WriteLine("No controls have been defined for: {0}", data_type.Name);
275          }          }
276          [Conditional("USE_DYNAMIC_SORTING_FILTERING_CONTROLS")]          [Conditional("USE_DYNAMIC_SORTING_FILTERING_CONTROLS")]
277          void CreateSourceDefinitionControls(Type data_type)          void CreateSourceDefinitionControls(Type data_type)
278          {          {
279              // no controls needed              // no controls needed
280              gLog.Warn.WriteLine("No controls have been defined for: {0}", data_type.Name);              gLog.Verbose.Warn.WriteLine("No controls have been defined for: {0}", data_type.Name);
281          }          }
282          [Conditional("USE_DYNAMIC_SORTING_FILTERING_CONTROLS")]          [Conditional("USE_DYNAMIC_SORTING_FILTERING_CONTROLS")]
283          void CreateChannelDefinitionControls(Type data_type)          void CreateChannelDefinitionControls(Type data_type)
284          {          {
285              gLog.Warn.WriteLine("No controls have been defined for: {0}", data_type.Name);              gLog.Verbose.Warn.WriteLine("No controls have been defined for: {0}", data_type.Name);
286          }          }
287          [Conditional("USE_DYNAMIC_SORTING_FILTERING_CONTROLS")]          [Conditional("USE_DYNAMIC_SORTING_FILTERING_CONTROLS")]
288          void CreateProgramDefinitionControls(Type data_type)          void CreateProgramDefinitionControls(Type data_type)
289          {          {
290              gLog.Warn.WriteLine("No controls have been defined for: {0}", data_type.Name);              gLog.Verbose.Warn.WriteLine("No controls have been defined for: {0}", data_type.Name);
291          }          }
292          #endregion          #endregion
293    
# Line 295  namespace xmltv_parser Line 326  namespace xmltv_parser
326                  try                  try
327                  {                  {
328                      IProgramDefinition program = list[RowIndex];                      IProgramDefinition program = list[RowIndex];
329                        ProgramEntryControl c = new ProgramEntryControl(program);
330                        c.Dock = DockStyle.Fill;
331                        split_bottom.Panel2.Controls.Clear();
332                        split_bottom.Panel2.Controls.Add(c);                    
333                  }                  }
334                  catch (Exception ex)                  catch (Exception ex)
335                  {                  {
# Line 369  namespace xmltv_parser Line 404  namespace xmltv_parser
404              object data = XMLTV.CreateBindingSourceFromData(XMLTV.GetPrograms(), out data_type);              object data = XMLTV.CreateBindingSourceFromData(XMLTV.GetPrograms(), out data_type);
405              XMLTV.CreateFilterFromDataSource(ref data, column, txtFilterText.Text);              XMLTV.CreateFilterFromDataSource(ref data, column, txtFilterText.Text);
406              dataGrid.DataSource = data;              dataGrid.DataSource = data;
407                dataGrid_SelectionChanged(dataGrid, new EventArgs());
408          }          }
409          private RadioButton GetSelectedFilteringControl()          private RadioButton GetSelectedFilteringControl()
410          {          {
# Line 382  namespace xmltv_parser Line 418  namespace xmltv_parser
418              }              }
419              if (!control_selected)              if (!control_selected)
420              {              {
421                  gLog.Warn.WriteLine("Unkown filter value used.  Was not: channelname, title, subtitle, description, start, or stop.");                  gLog.Verbose.Warn.WriteLine("Unkown filter value used.  Was not: channelname, title, subtitle, description, start, or stop.");
422                  //throw new InvalidOperationException("No filtering control is currently selected.");                  //throw new InvalidOperationException("No filtering control is currently selected.");
423                  return button;                  return button;
424              }              }
# Line 449  namespace xmltv_parser Line 485  namespace xmltv_parser
485              RadioButton radio = (sender as RadioButton);              RadioButton radio = (sender as RadioButton);
486              UpdateFilterText(radio, dataGrid);              UpdateFilterText(radio, dataGrid);
487          }          }
488            private void radio_filter_rating_CheckedChanged(object sender, EventArgs e)
489            {
490                RadioButton radio = (sender as RadioButton);
491                UpdateFilterText(radio, dataGrid);
492            }
493          #endregion          #endregion
494          #region Sorting events          #region Sorting events
495          private bool Descending = false;          private bool Descending = false;
# Line 460  namespace xmltv_parser Line 501  namespace xmltv_parser
501              XMLTV.CreateSorterFromDataSource(ref data, Descending, column);              XMLTV.CreateSorterFromDataSource(ref data, Descending, column);
502              dataGrid.DataSource = data;              dataGrid.DataSource = data;
503              ToggleDescedning();              ToggleDescedning();
504                dataGrid_SelectionChanged(dataGrid, new EventArgs());
505          }          }
506          private RadioButton GetSelectedSortControl()          private RadioButton GetSelectedSortControl()
507          {          {
# Line 485  namespace xmltv_parser Line 527  namespace xmltv_parser
527              SortByColumn(button);              SortByColumn(button);
528          }          }
529          #endregion          #endregion
530    
531            private void dataGrid_Click(object sender, EventArgs e)
532            {
533                dataGrid_SelectionChanged(dataGrid, new EventArgs());
534            }
535    
536          
537      }      }
538  }  }
539    

Legend:
Removed from v.146  
changed lines
  Added in v.248

  ViewVC Help
Powered by ViewVC 1.1.22