--- trunk/libxmltv/Core/DataSourceBindable.cs 2013/03/10 18:19:12 120 +++ trunk/libxmltv/Core/DataSourceBindable.cs 2013/03/10 19:32:56 123 @@ -8,26 +8,121 @@ { public class ChannelList : List, IDataSourceBindable { + private class ChannelDefintion + { + public ChannelDefintion() + { + ChannelId = string.Empty; + ChannelName = string.Empty; + } + public string ChannelId { get; internal set; } + public string ChannelName { get; internal set; } + } + //static private List known_columns; + //static ChannelList() + //{ + // known_columns = new List(); + // known_columns.Add("Id"); + // known_columns.Add("Name"); + //} public ChannelList() { } + + public object CreateBindableDataSource() { object bindable = new object(); + List list = new List(); + + foreach (var t in this) + { + try + { + ChannelDefintion definition = new ChannelDefintion(); + definition.ChannelId = t.Id; + definition.ChannelName = t.MetaData[XMLTVConstants.Channels.ChannelDisplayName].FirstOrDefault().Value.ToString(); + list.Add(definition); + } + catch (Exception ex) { throw ex; } + } + list = list.OrderBy(s => s.ChannelName).ToList(); + bindable = list; return bindable; } } public class ProgramList : List, IDataSourceBindable { + private class ProgramDefintion + { + public ProgramDefintion() + { + //ChannelId = string.Empty; + ChannelName = string.Empty; + Start = new DateTime(); + Stop = new DateTime(); + Description = string.Empty; + Title = string.Empty; + SubTitle = string.Empty; + } + //public string ChannelId { get; internal set; } + public string ChannelName { get; internal set; } + public DateTime Start { get; internal set; } + public DateTime Stop { get; internal set; } + public string Title { get; internal set; } + public string SubTitle { get; internal set; } + public string Description { get; internal set; } + } public ProgramList() { } public object CreateBindableDataSource() { object bindable = new object(); + List list = new List(); + + foreach (var t in this) + { + try + { + ProgramDefintion definition = new ProgramDefintion(); + string ChannelId = t.MetaData[XMLTVConstants.Programs.ProgramChannelId].ToString(); + //definition.ChannelId = ChannelId; + + var channels = XMLTV.GetChannels(); + if (channels != null) + { + var channel = channels.Find(p => p.Id == ChannelId); + if (channel != null) + { + definition.ChannelName = channel.MetaData[XMLTVConstants.Channels.ChannelDisplayName].FirstOrDefault().Value.ToString(); + } + else + { + definition.ChannelName = string.Empty; + } + } + else + { + definition.ChannelName = string.Empty; + } + definition.Start = (DateTime)t.MetaData[XMLTVConstants.Programs.ProgramStart]; + definition.Stop = (DateTime)t.MetaData[XMLTVConstants.Programs.ProgramStop]; + definition.Description = t.MetaData[XMLTVConstants.Programs.ProgramDescription].ToString(); + definition.Title = t.MetaData[XMLTVConstants.Programs.ProgramTitle].ToString(); + definition.SubTitle = t.MetaData[XMLTVConstants.Programs.ProgramSubTitle].ToString(); + list.Add(definition); + } + catch (Exception ex) { throw ex; } + } + + list = list.OrderBy(s => s.Start).ToList(); + + bindable = list; return bindable; } } public class ExtraList : List, IDataSourceBindable { + public ExtraList() { } public object CreateBindableDataSource()