/[xmltv_parser]/trunk/libxmltv/Core/DataSourceBindable.cs
ViewVC logotype

Diff of /trunk/libxmltv/Core/DataSourceBindable.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/libxmltv/Core/DataSourceBindable.cs	2013/03/13 15:50:07	134
+++ trunk/libxmltv/Core/DataSourceBindable.cs	2013/03/13 16:59:40	137
@@ -100,6 +100,7 @@
                     var col = args.First().ToString().ToLower();
                     switch (col)
                     {
+                        case "channelnumber": ordered = descending ? list.OrderByDescending(s => s.ChannelNumber) : list.OrderBy(s => s.ChannelNumber); break;
                         case "channelname": ordered = descending ? list.OrderByDescending(s => s.ChannelName) : list.OrderBy(s => s.ChannelName); break;
                         case "start": ordered = descending ? list.OrderByDescending(s => s.Start) : list.OrderBy(s => s.Start); break;
                         case "stop": ordered = descending ? list.OrderByDescending(s => s.Stop) : list.OrderBy(s => s.Stop); break;
@@ -113,7 +114,8 @@
                         col = arg.ToLower();
                         switch (col)
                         {
-                            case "channelname": ordered = descending ? ordered.ThenByDescending(s => s.ChannelName) : ordered.ThenBy(s => s.ChannelName); break;
+                            case "channelnumber": ordered = descending ? ordered.ThenByDescending(s => s.ChannelNumber) : ordered.ThenBy(s => s.ChannelNumber); break;
+                            case "channelname": ordered = descending ? list.OrderByDescending(s => s.ChannelName) : list.OrderBy(s => s.ChannelName); break;
                             case "start": ordered = descending ? ordered.ThenByDescending(s => s.Start) : ordered.ThenBy(s => s.Start); break;
                             case "stop": ordered = descending ? ordered.ThenByDescending(s => s.Stop) : ordered.ThenBy(s => s.Stop); break;
                             case "description": ordered = descending ? ordered.ThenByDescending(s => s.Description) : ordered.ThenBy(s => s.Description); break;
@@ -145,6 +147,7 @@
 
                     switch (columnname)
                     {
+                        case "channelnumber": ordered = list.ToList().FindAll(s => s.ChannelNumber.ToString().ToLower().Contains(filtertext)); break;
                         case "channelname": ordered = list.ToList().FindAll(s => s.ChannelName.ToLower().Contains(filtertext)); break;
                         case "start":
                         case "stop":
@@ -170,6 +173,7 @@
             public ProgramDefintion()
             {
                 //ChannelId = string.Empty;
+                ChannelNumber = 0;
                 ChannelName = string.Empty;
                 Start = new DateTime();
                 Stop = new DateTime();
@@ -178,6 +182,7 @@
                 SubTitle = string.Empty;
             }
             //public string ChannelId { get; internal set; }
+            public int ChannelNumber { get; internal set; }
             public string ChannelName { get; internal set; }
             public DateTime Start { get; internal set; }
             public DateTime Stop { get; internal set; }
@@ -221,16 +226,20 @@
                         var channel = channels.Find(p => p.Id == ChannelId);
                         if (channel != null)
                         {
-                            definition.ChannelName = channel.MetaData[XMLTVConstants.Channels.ChannelDisplayName].FirstOrDefault().Value.ToString();
+                            var channelname = channel.MetaData[XMLTVConstants.Channels.ChannelDisplayName].FirstOrDefault().Value.ToString();
+                            var split = channelname.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
+                            definition.ChannelNumber = Convert.ToInt32(split.First());
+                            definition.ChannelName = string.IsNullOrEmpty(split.Last()) ? string.Empty : split.Last().ToString();
+
                         }
                         else
                         {
-                            definition.ChannelName = string.Empty;
+                            definition.ChannelNumber = 0;
                         }
                     }
                     else
                     {
-                        definition.ChannelName = string.Empty;
+                        definition.ChannelNumber = 0;
                     }
                     definition.Start = (DateTime)t.MetaData[XMLTVConstants.Programs.ProgramStart];
                     definition.Stop = (DateTime)t.MetaData[XMLTVConstants.Programs.ProgramStop];

 

  ViewVC Help
Powered by ViewVC 1.1.22