/[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 127 by william, Wed Mar 13 12:00:01 2013 UTC revision 131 by william, Wed Mar 13 15:16:59 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
4  using System;  using System;
5  using System.Collections.Generic;  using System.Collections.Generic;
6  using System.ComponentModel;  using System.ComponentModel;
# Line 189  namespace xmltv_parser Line 190  namespace xmltv_parser
190                      catch { }                      catch { }
191                      return;                      return;
192                  }                  }
193                  object datasource = XMLTV.CreateDataSourceFromObject(XMLTV.GetPrograms());                  Type data_type;
194                  XMLTV.CreateSorterFromDataSource(ref datasource, "title");                  object datasource = XMLTV.CreateBindingSourceFromData(XMLTV.GetPrograms(), out data_type);
195                    CreatControlsFromType(data_type);
196                    //XMLTV.CreateSorterFromDataSource(ref datasource, "title");
197                  dataGrid.DataSource = datasource;                  dataGrid.DataSource = datasource;
198                    flow_datagrid_sort.Enabled = true;
199              }              }
200              catch (Exception ex) { gLog.Error.WriteLine(ex.ToString()); }              catch (Exception ex) { gLog.Error.WriteLine(ex.ToString()); }
201          }          }
202    
203            
204            void CreatControlsFromType(Type data_type)
205            {
206    #if USE_DYNAMIC_SORTING_FILTERING_CONTROLS
207                  _CreatControlsFromType(data_type);
208    #else
209                gLog.Warn.WriteLine("Dynamic creation of sorting and filtering controls has not been enabled.");
210                gLog.Warn.WriteLine("To enable: #define USE_DYNAMIC_SORTING_FILTERING_CONTROLS");
211    #endif
212            }
213            [Conditional("USE_DYNAMIC_SORTING_FILTERING_CONTROLS")]
214            void _CreatControlsFromType(Type data_type)
215            {
216                string strType = data_type.Name;
217                switch (strType)
218                {
219                    case "IChannelDefintionList": CreateChannelDefinitionControls(data_type); break;
220                    case "IProgramDefinitionList": CreateProgramDefinitionControls(data_type); break;
221                    case "IXMLTVSource": CreateSourceDefinitionControls(data_type); break;
222                    default: CreateDefaultControls(data_type); break;
223                }
224            }
225            [Conditional("USE_DYNAMIC_SORTING_FILTERING_CONTROLS")]
226            void CreateDefaultControls(Type data_type)
227            {
228                // no default controls
229                gLog.Warn.WriteLine("No controls have been defined for: {0}", data_type.Name);
230            }
231            [Conditional("USE_DYNAMIC_SORTING_FILTERING_CONTROLS")]
232            void CreateSourceDefinitionControls(Type data_type)
233            {
234                // no controls needed
235                gLog.Warn.WriteLine("No controls have been defined for: {0}", data_type.Name);
236            }
237            [Conditional("USE_DYNAMIC_SORTING_FILTERING_CONTROLS")]
238            void CreateChannelDefinitionControls(Type data_type)
239            {
240                gLog.Warn.WriteLine("No controls have been defined for: {0}", data_type.Name);
241            }
242            [Conditional("USE_DYNAMIC_SORTING_FILTERING_CONTROLS")]
243            void CreateProgramDefinitionControls(Type data_type)
244            {
245                gLog.Warn.WriteLine("No controls have been defined for: {0}", data_type.Name);
246            }
247            #endregion    
248    
249    
250            #region Column Sorting Support
251            private bool Descending = false;
252            private void ToggleDescedning() { Descending = Descending ? false : true; }
253            private void btnResetSort_Click(object sender, EventArgs e)
254            {
255                Type data_type;
256                object datasource = XMLTV.CreateBindingSourceFromData(XMLTV.GetPrograms(), out data_type);
257                dataGrid.DataSource = datasource;
258                ToggleDescedning();
259            }
260            private void btnSortChannelName_Click(object sender, EventArgs e)
261            {
262                object data = dataGrid.DataSource;
263                XMLTV.CreateSorterFromDataSource(ref data, Descending, "channelname");
264                dataGrid.DataSource = data;
265                ToggleDescedning();
266            }
267    
268            private void btnSortStart_Click(object sender, EventArgs e)
269            {
270                object data = dataGrid.DataSource;
271                XMLTV.CreateSorterFromDataSource(ref data, Descending, "start");
272                dataGrid.DataSource = data;
273                ToggleDescedning();
274            }
275            private void btnSortStop_Click(object sender, EventArgs e)
276            {
277                object data = dataGrid.DataSource;
278                XMLTV.CreateSorterFromDataSource(ref data, Descending, "stop");
279                dataGrid.DataSource = data;
280                ToggleDescedning();
281            }
282            private void btnSortTitle_Click(object sender, EventArgs e)
283            {
284                object data = dataGrid.DataSource;
285                XMLTV.CreateSorterFromDataSource(ref data, Descending, "title");
286                dataGrid.DataSource = data;
287                ToggleDescedning();
288            }
289            private void btnSortSubTitle_Click(object sender, EventArgs e)
290            {
291                object data = dataGrid.DataSource;
292                XMLTV.CreateSorterFromDataSource(ref data, Descending, "subtitle");
293                dataGrid.DataSource = data;
294                ToggleDescedning();
295            }
296            private void btnSortDescription_Click(object sender, EventArgs e)
297            {
298                object data = dataGrid.DataSource;
299                XMLTV.CreateSorterFromDataSource(ref data, Descending, "description");
300                dataGrid.DataSource = data;
301                ToggleDescedning();
302            }
303          #endregion          #endregion
304    
305          
306      }      }
307  }  }
308    

Legend:
Removed from v.127  
changed lines
  Added in v.131

  ViewVC Help
Powered by ViewVC 1.1.22