/[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/13 13:45:05	128
+++ trunk/xmltv_parser/main.cs	2013/03/13 14:03:47	129
@@ -1,5 +1,6 @@
 //#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
+//#define USE_DYNAMIC_SORTING_FILTERING_CONTROLS // when defined will setup dynamic sorting and filtering controls for XMLTV Data
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
@@ -189,13 +190,59 @@
                     catch { }
                     return;
                 }
-                Type t;
-                object datasource = XMLTV.CreateBindingSourceFromData(XMLTV.GetPrograms(), out t);
+                Type data_type;
+                object datasource = XMLTV.CreateBindingSourceFromData(XMLTV.GetPrograms(), out data_type);
+                CreatControlsFromType(data_type);
                 //XMLTV.CreateSorterFromDataSource(ref datasource, "title");
                 dataGrid.DataSource = datasource;
             }
             catch (Exception ex) { gLog.Error.WriteLine(ex.ToString()); }
         }
+
+        
+        void CreatControlsFromType(Type data_type)
+        {
+#if USE_DYNAMIC_SORTING_FILTERING_CONTROLS
+              _CreatControlsFromType(data_type);
+#else
+            gLog.Warn.WriteLine("Dynamic creation of sorting and filtering controls has not been enabled.");
+            gLog.Warn.WriteLine("To enable: #define USE_DYNAMIC_SORTING_FILTERING_CONTROLS");
+#endif
+        }
+        [Conditional("USE_DYNAMIC_SORTING_FILTERING_CONTROLS")]
+        void _CreatControlsFromType(Type data_type)
+        {
+            string strType = data_type.Name;
+            switch (strType)
+            {
+                case "IChannelDefintionList": CreateChannelDefinitionControls(data_type); break;
+                case "IProgramDefinitionList": CreateProgramDefinitionControls(data_type); break;
+                case "IXMLTVSource": CreateSourceDefinitionControls(data_type); break;
+                default: CreateDefaultControls(data_type); break;
+            }
+        }
+        [Conditional("USE_DYNAMIC_SORTING_FILTERING_CONTROLS")]
+        void CreateDefaultControls(Type data_type)
+        {
+            // no default controls
+            gLog.Warn.WriteLine("No controls have been defined for: {0}", data_type.Name);
+        }
+        [Conditional("USE_DYNAMIC_SORTING_FILTERING_CONTROLS")]
+        void CreateSourceDefinitionControls(Type data_type)
+        {
+            // no controls needed
+            gLog.Warn.WriteLine("No controls have been defined for: {0}", data_type.Name);
+        }
+        [Conditional("USE_DYNAMIC_SORTING_FILTERING_CONTROLS")]
+        void CreateChannelDefinitionControls(Type data_type)
+        {
+            gLog.Warn.WriteLine("No controls have been defined for: {0}", data_type.Name);
+        }
+        [Conditional("USE_DYNAMIC_SORTING_FILTERING_CONTROLS")]
+        void CreateProgramDefinitionControls(Type data_type)
+        {
+            gLog.Warn.WriteLine("No controls have been defined for: {0}", data_type.Name);
+        }
         #endregion
 
     }

 

  ViewVC Help
Powered by ViewVC 1.1.22