public override async Task <AsyncResult <IList <IChannelGroup> > > GetChannelGroupsAsync() { await _initComplete.Task; var groups = TvDatabase.ChannelGroup.ListAll() .OrderBy(tvGroup => tvGroup.SortOrder) .Select(tvGroup => tvGroup.ToChannelGroup()) .Union( RadioChannelGroup.ListAll() .OrderBy(radioGroup => radioGroup.SortOrder) .Select(radioGroup => radioGroup.ToChannelGroup()) ) .ToList(); return(new AsyncResult <IList <IChannelGroup> >(true, groups)); }
private void UpdateMenuAndTabs() { addToFavoritesToolStripMenuItem.DropDownItems.Clear(); IList <RadioChannelGroup> groups = RadioChannelGroup.ListAll(); foreach (RadioChannelGroup group in groups) { ToolStripMenuItem item = new ToolStripMenuItem(group.GroupName); item.Tag = group; item.Click += addToFavoritesToolStripMenuItem_Click; addToFavoritesToolStripMenuItem.DropDownItems.Add(item); } }
private void RefreshContextMenu() { addToFavoritesToolStripMenuItem.DropDownItems.Clear(); IList <RadioChannelGroup> groups = RadioChannelGroup.ListAll(); foreach (RadioChannelGroup group in groups) { ToolStripMenuItem item = new ToolStripMenuItem(group.GroupName); item.Tag = group; item.Click += OnAddToFavoritesMenuItem_Click; addToFavoritesToolStripMenuItem.DropDownItems.Add(item); } ToolStripMenuItem itemNew = new ToolStripMenuItem("New..."); itemNew.Click += OnAddToFavoritesMenuItem_Click; addToFavoritesToolStripMenuItem.DropDownItems.Add(itemNew); }
private void GetGroupNames() { if (_isRadio) { IList <RadioChannelGroup> groups = RadioChannelGroup.ListAll(); _groupNames = new List <string>(); foreach (RadioChannelGroup group in groups) { _groupNames.Add(group.GroupName); } } else { IList <ChannelGroup> groups = ChannelGroup.ListAll(); _groupNames = new List <string>(); foreach (ChannelGroup group in groups) { _groupNames.Add(group.GroupName); } } }
protected override void LoadDirectory(string strNewDirectory) { GUIListItem SelectedItem = facadeLayout.SelectedListItem; if (SelectedItem != null) { if (SelectedItem.IsFolder && SelectedItem.Label != "..") { directoryHistory.Set(SelectedItem.Label, currentFolder); } } currentFolder = strNewDirectory; GUIControl.ClearControl(GetID, facadeLayout.GetID); int totalItems = 0; if (currentFolder == null || currentFolder == "..") { IList <RadioChannelGroup> groups = RadioChannelGroup.ListAll(); foreach (RadioChannelGroup group in groups) { if (hideAllChannelsGroup && group.GroupName.Equals(TvConstants.RadioGroupNames.AllChannels) && groups.Count > 1) { continue; } if (group.GroupName == rootGroup) { continue; } GUIListItem item = new GUIListItem(); item.Label = group.GroupName; item.IsFolder = true; item.MusicTag = group; item.ThumbnailImage = String.Empty; Utils.SetDefaultIcons(item); string thumbnail = Utils.GetCoverArt(Thumbs.Radio, "folder_" + group.GroupName); if (!string.IsNullOrEmpty(thumbnail)) { item.IconImageBig = thumbnail; item.IconImage = thumbnail; item.ThumbnailImage = thumbnail; } facadeLayout.Add(item); totalItems++; } if (rootGroup != "(none)") { TvBusinessLayer layer = new TvBusinessLayer(); RadioChannelGroup root = layer.GetRadioChannelGroupByName(rootGroup); if (root != null) { IList <RadioGroupMap> maps = root.ReferringRadioGroupMap(); foreach (RadioGroupMap map in maps) { Channel channel = map.ReferencedChannel(); GUIListItem item = new GUIListItem(); if (_currentChannel != null) { if (channel.IdChannel == _currentChannel.IdChannel) { selectedItemIndex = totalItems - 1; } } item.Label = channel.DisplayName; item.IsFolder = false; item.MusicTag = channel; if (channel.IsWebstream()) { item.IconImageBig = "DefaultMyradioStreamBig.png"; item.IconImage = "DefaultMyradioStream.png"; } else { item.IconImageBig = "DefaultMyradioBig.png"; item.IconImage = "DefaultMyradio.png"; } string thumbnail = Utils.GetCoverArt(Thumbs.Radio, channel.DisplayName); if (!string.IsNullOrEmpty(thumbnail)) { item.IconImageBig = thumbnail; item.IconImage = thumbnail; item.ThumbnailImage = thumbnail; } facadeLayout.Add(item); totalItems++; } } } selectedGroup = null; } else { TvBusinessLayer layer = new TvBusinessLayer(); RadioChannelGroup group = layer.GetRadioChannelGroupByName(currentFolder); if (group == null) { return; } selectedGroup = group; lastFolder = currentFolder; GUIListItem item = new GUIListItem(); item.Label = ".."; item.IsFolder = true; item.MusicTag = null; item.ThumbnailImage = String.Empty; Utils.SetDefaultIcons(item); facadeLayout.Add(item); IList <RadioGroupMap> maps = group.ReferringRadioGroupMap(); foreach (RadioGroupMap map in maps) { Channel channel = map.ReferencedChannel(); if (channel != null) { item = new GUIListItem(); item.Label = channel.DisplayName; item.IsFolder = false; item.MusicTag = channel; item.AlbumInfoTag = map; if (channel.IsWebstream()) { item.IconImageBig = "DefaultMyradioStreamBig.png"; item.IconImage = "DefaultMyradioStream.png"; } else { item.IconImageBig = "DefaultMyradioBig.png"; item.IconImage = "DefaultMyradio.png"; } string thumbnail = Utils.GetCoverArt(Thumbs.Radio, channel.DisplayName); if (!string.IsNullOrEmpty(thumbnail)) { item.IconImageBig = thumbnail; item.IconImage = thumbnail; item.ThumbnailImage = thumbnail; } facadeLayout.Add(item); totalItems++; } } } SwitchLayout(); OnSort(); //set object count label GUIPropertyManager.SetProperty("#itemcount", Utils.GetObjectCountLabel(totalItems)); SelectCurrentItem(); SetLabels(); for (int i = 0; i < facadeLayout.Count; ++i) { GUIListItem item = facadeLayout[i]; if (item != null) { Channel channel = item.MusicTag as Channel; if ((channel != null) && (_currentChannel != null)) { if (channel.IdChannel == _currentChannel.IdChannel) { selectedItemIndex = i++; break; } } } //set selected item if (selectedItemIndex >= 0) { GUIControl.SelectItemControl(GetID, facadeLayout.GetID, selectedItemIndex); } } }
private void Export(string fileName, bool exporttv, bool exporttvgroups, bool exportradio, bool exportradiogroups, bool exportschedules) { XmlDocument xmlDoc = new XmlDocument(); XmlNode rootElement = xmlDoc.CreateElement("tvserver"); AddAttribute(rootElement, "version", "1.0"); XmlNode nodeServers = xmlDoc.CreateElement("servers"); IList <Server> servers = Server.ListAll(); foreach (Server server in servers) { XmlNode nodeServer = xmlDoc.CreateElement("server"); AddAttribute(nodeServer, "HostName", server.HostName); AddAttribute(nodeServer, "IdServer", server.IdServer); AddAttribute(nodeServer, "IsMaster", server.IsMaster); XmlNode nodeCards = xmlDoc.CreateElement("cards"); IList <Card> cards = Card.ListAll(); foreach (Card card in cards) { XmlNode nodeCard = xmlDoc.CreateElement("card"); AddAttribute(nodeCard, "IdCard", card.IdCard); AddAttribute(nodeCard, "DevicePath", card.DevicePath); AddAttribute(nodeCard, "Enabled", card.Enabled); AddAttribute(nodeCard, "CamType", card.CamType); AddAttribute(nodeCard, "GrabEPG", card.GrabEPG); AddAttribute(nodeCard, "LastEpgGrab", card.LastEpgGrab); AddAttribute(nodeCard, "Name", card.Name); AddAttribute(nodeCard, "Priority", card.Priority); AddAttribute(nodeCard, "RecordingFolder", card.RecordingFolder); nodeCards.AppendChild(nodeCard); } nodeServer.AppendChild(nodeCards); nodeServers.AppendChild(nodeServer); } rootElement.AppendChild(nodeServers); XmlNode nodechannels = xmlDoc.CreateElement("channels"); IList <Channel> channels = Channel.ListAll(); foreach (Channel channel in channels) { // Only export TV or radio channels if the corresponding checkbox was checked if ((channel.IsTv && !exporttv) || (channel.IsRadio && !exportradio)) { continue; } XmlNode nodechannel = xmlDoc.CreateElement("channel"); AddAttribute(nodechannel, "GrabEpg", channel.GrabEpg); AddAttribute(nodechannel, "IdChannel", channel.IdChannel); AddAttribute(nodechannel, "IsRadio", channel.IsRadio); AddAttribute(nodechannel, "IsTv", channel.IsTv); AddAttribute(nodechannel, "LastGrabTime", channel.LastGrabTime); AddAttribute(nodechannel, "SortOrder", channel.SortOrder); AddAttribute(nodechannel, "TimesWatched", channel.TimesWatched); AddAttribute(nodechannel, "TotalTimeWatched", channel.TotalTimeWatched); AddAttribute(nodechannel, "VisibleInGuide", channel.VisibleInGuide); AddAttribute(nodechannel, "DisplayName", channel.DisplayName); XmlNode nodeMaps = xmlDoc.CreateElement("mappings"); foreach (ChannelMap map in channel.ReferringChannelMap()) { XmlNode nodeMap = xmlDoc.CreateElement("map"); AddAttribute(nodeMap, "IdCard", map.IdCard); AddAttribute(nodeMap, "IdChannel", map.IdChannel); AddAttribute(nodeMap, "IdChannelMap", map.IdChannelMap); nodeMaps.AppendChild(nodeMap); } nodechannel.AppendChild(nodeMaps); XmlNode nodeTuningDetails = xmlDoc.CreateElement("TuningDetails"); foreach (TuningDetail detail in channel.ReferringTuningDetail()) { XmlNode nodeTune = xmlDoc.CreateElement("tune"); AddAttribute(nodeTune, "IdChannel", detail.IdChannel); AddAttribute(nodeTune, "IdTuning", detail.IdTuning); AddAttribute(nodeTune, "Bandwidth", detail.Bandwidth); AddAttribute(nodeTune, "ChannelNumber", detail.ChannelNumber); AddAttribute(nodeTune, "ChannelType", detail.ChannelType); AddAttribute(nodeTune, "CountryId", detail.CountryId); AddAttribute(nodeTune, "Diseqc", detail.Diseqc); AddAttribute(nodeTune, "FreeToAir", detail.FreeToAir); AddAttribute(nodeTune, "Frequency", detail.Frequency); AddAttribute(nodeTune, "MajorChannel", detail.MajorChannel); AddAttribute(nodeTune, "MinorChannel", detail.MinorChannel); AddAttribute(nodeTune, "Modulation", detail.Modulation); AddAttribute(nodeTune, "Name", detail.Name); AddAttribute(nodeTune, "NetworkId", detail.NetworkId); AddAttribute(nodeTune, "PmtPid", detail.PmtPid); AddAttribute(nodeTune, "Polarisation", detail.Polarisation); AddAttribute(nodeTune, "Provider", detail.Provider); AddAttribute(nodeTune, "ServiceId", detail.ServiceId); AddAttribute(nodeTune, "SwitchingFrequency", detail.SwitchingFrequency); AddAttribute(nodeTune, "Symbolrate", detail.Symbolrate); AddAttribute(nodeTune, "TransportId", detail.TransportId); AddAttribute(nodeTune, "TuningSource", detail.TuningSource); AddAttribute(nodeTune, "VideoSource", detail.VideoSource); AddAttribute(nodeTune, "AudioSource", detail.AudioSource); AddAttribute(nodeTune, "IsVCRSignal", detail.IsVCRSignal); AddAttribute(nodeTune, "SatIndex", detail.SatIndex); AddAttribute(nodeTune, "InnerFecRate", detail.InnerFecRate); AddAttribute(nodeTune, "Band", detail.Band); AddAttribute(nodeTune, "Pilot", detail.Pilot); AddAttribute(nodeTune, "RollOff", detail.RollOff); AddAttribute(nodeTune, "Url", detail.Url); AddAttribute(nodeTune, "Bitrate", detail.Bitrate); nodeTuningDetails.AppendChild(nodeTune); } nodechannel.AppendChild(nodeTuningDetails); nodechannels.AppendChild(nodechannel); } rootElement.AppendChild(nodechannels); // exporting the schedules if (exportschedules) { XmlNode nodeSchedules = xmlDoc.CreateElement("schedules"); IList <Schedule> schedules = Schedule.ListAll(); foreach (Schedule schedule in schedules) { XmlNode nodeSchedule = xmlDoc.CreateElement("schedule"); AddAttribute(nodeSchedule, "ChannelName", schedule.ReferencedChannel().DisplayName); AddAttribute(nodeSchedule, "ProgramName", schedule.ProgramName); AddAttribute(nodeSchedule, "StartTime", schedule.StartTime); AddAttribute(nodeSchedule, "EndTime", schedule.EndTime); AddAttribute(nodeSchedule, "KeepDate", schedule.KeepDate); AddAttribute(nodeSchedule, "PreRecordInterval", schedule.PreRecordInterval); AddAttribute(nodeSchedule, "PostRecordInterval", schedule.PostRecordInterval); AddAttribute(nodeSchedule, "Priority", schedule.Priority); AddAttribute(nodeSchedule, "Quality", schedule.Quality); AddAttribute(nodeSchedule, "Directory", schedule.Directory); AddAttribute(nodeSchedule, "KeepMethod", schedule.KeepMethod); AddAttribute(nodeSchedule, "MaxAirings", schedule.MaxAirings); AddAttribute(nodeSchedule, "RecommendedCard", schedule.RecommendedCard); AddAttribute(nodeSchedule, "ScheduleType", schedule.ScheduleType); AddAttribute(nodeSchedule, "Series", schedule.Series); nodeSchedules.AppendChild(nodeSchedule); } rootElement.AppendChild(nodeSchedules); } // exporting tv channel groups if (exporttvgroups) { XmlNode nodeChannelGroups = xmlDoc.CreateElement("channelgroups"); IList <ChannelGroup> channelgroups = ChannelGroup.ListAll(); foreach (ChannelGroup group in channelgroups) { XmlNode nodeChannelGroup = xmlDoc.CreateElement("channelgroup"); AddAttribute(nodeChannelGroup, "GroupName", group.GroupName); AddAttribute(nodeChannelGroup, "SortOrder", group.SortOrder.ToString()); XmlNode nodeGroupMap = xmlDoc.CreateElement("mappings"); IList <GroupMap> maps = group.ReferringGroupMap(); foreach (GroupMap map in maps) { XmlNode nodeMap = xmlDoc.CreateElement("map"); AddAttribute(nodeMap, "ChannelName", map.ReferencedChannel().DisplayName); AddAttribute(nodeMap, "SortOrder", map.SortOrder.ToString()); nodeGroupMap.AppendChild(nodeMap); } nodeChannelGroup.AppendChild(nodeGroupMap); nodeChannelGroups.AppendChild(nodeChannelGroup); } rootElement.AppendChild(nodeChannelGroups); } // exporting radio channel groups if (exportradiogroups) { XmlNode nodeRadioChannelGroups = xmlDoc.CreateElement("radiochannelgroups"); IList <RadioChannelGroup> radiochannelgroups = RadioChannelGroup.ListAll(); foreach (RadioChannelGroup radiogroup in radiochannelgroups) { XmlNode nodeRadioChannelGroup = xmlDoc.CreateElement("radiochannelgroup"); AddAttribute(nodeRadioChannelGroup, "GroupName", radiogroup.GroupName); AddAttribute(nodeRadioChannelGroup, "SortOrder", radiogroup.SortOrder.ToString()); XmlNode nodeRadioGroupMap = xmlDoc.CreateElement("mappings"); IList <RadioGroupMap> maps = radiogroup.ReferringRadioGroupMap(); foreach (RadioGroupMap map in maps) { XmlNode nodeMap = xmlDoc.CreateElement("map"); AddAttribute(nodeMap, "ChannelName", map.ReferencedChannel().DisplayName); AddAttribute(nodeMap, "SortOrder", map.SortOrder.ToString()); nodeRadioGroupMap.AppendChild(nodeMap); } nodeRadioChannelGroup.AppendChild(nodeRadioGroupMap); nodeRadioChannelGroups.AppendChild(nodeRadioChannelGroup); } rootElement.AppendChild(nodeRadioChannelGroups); } xmlDoc.AppendChild(rootElement); xmlDoc.Save(fileName); MessageBox.Show(this, "The selected items have been exported to " + fileName); }
public IList <WebChannelGroup> GetRadioGroupsByRange(int start, int end, string filter = null, WebSortField?sort = WebSortField.User, WebSortOrder?order = WebSortOrder.Asc) { return(RadioChannelGroup.ListAll().Select(chg => chg.ToWebChannelGroup()).Filter(filter).SortGroupList(sort, order).TakeRange(start, end).ToList()); }
public WebIntResult GetRadioGroupCount(string filter = null) { return(RadioChannelGroup.ListAll().Select(chg => chg.ToWebChannelGroup()).Filter(filter).Count()); }
public IList <WebTVSearchResult> Search(string text, WebTVSearchResultType?type = null) { if (String.IsNullOrWhiteSpace(text)) { return(new List <WebTVSearchResult>()); } text = text.ToLower(); IEnumerable <WebTVSearchResult> result = new List <WebTVSearchResult>(); if (type == null || type == WebTVSearchResultType.TVChannel || type == WebTVSearchResultType.RadioChannel) { result = result.Concat(Channel.ListAll() .Where(channel => channel.DisplayName.Contains(text, StringComparison.CurrentCultureIgnoreCase)) .Select(channel => new WebTVSearchResult() { Id = channel.IdChannel.ToString(), Score = 50 + (int)Math.Round((decimal)text.Length / channel.DisplayName.Length * 50), Title = channel.DisplayName, Type = channel.IsTv ? WebTVSearchResultType.TVChannel : WebTVSearchResultType.RadioChannel }) .Where(r => type == null || r.Type == type)); } if (type == null || type == WebTVSearchResultType.TVGroup) { result = result.Concat(ChannelGroup.ListAll() .Where(group => group.GroupName.Contains(text, StringComparison.CurrentCultureIgnoreCase)) .Select(group => new WebTVSearchResult() { Id = group.IdGroup.ToString(), Score = 50 + (int)Math.Round((decimal)text.Length / group.GroupName.Length * 50), Title = group.GroupName, Type = WebTVSearchResultType.TVGroup, })); } if (type == null || type == WebTVSearchResultType.RadioGroup) { result = result.Concat(RadioChannelGroup.ListAll() .Where(group => group.GroupName.Contains(text, StringComparison.CurrentCultureIgnoreCase)) .Select(group => new WebTVSearchResult() { Id = group.IdGroup.ToString(), Score = 50 + (int)Math.Round((decimal)text.Length / group.GroupName.Length * 50), Title = group.GroupName, Type = WebTVSearchResultType.RadioGroup })); } if (type == null || type == WebTVSearchResultType.Recording) { result = result.Concat(Recording.ListAll() .Where(rec => rec.Title.Contains(text, StringComparison.CurrentCultureIgnoreCase)) .Select(rec => new WebTVSearchResult() { Id = rec.IdRecording.ToString(), Score = 50 + (int)Math.Round((decimal)text.Length / rec.Title.Length * 50), Title = rec.Title, Type = WebTVSearchResultType.Recording, StartTime = rec.StartTime, EndTime = rec.EndTime, ChannelName = GetChannelDisplayName(rec.IdChannel) })); } if (type == null || type == WebTVSearchResultType.Schedule) { result = result.Concat(Schedule.ListAll() .Where(schedule => schedule.ProgramName.Contains(text, StringComparison.CurrentCultureIgnoreCase)) .Select(schedule => new WebTVSearchResult() { Id = schedule.IdSchedule.ToString(), Score = 50 + (int)Math.Round((decimal)text.Length / schedule.ProgramName.Length * 50), Title = schedule.ProgramName, Type = WebTVSearchResultType.Schedule, ChannelName = GetChannelDisplayName(schedule.IdChannel) })); } if (type == null || type == WebTVSearchResultType.Program) { result = result.Concat(_tvBusiness.SearchPrograms("%" + text + "%") .Select(program => new WebTVSearchResult() { Id = program.IdProgram.ToString(), Score = (int)Math.Round(((decimal)text.Length / program.Title.Length * 50) - Math.Abs((decimal)(program.StartTime - DateTime.Now).TotalDays)), Title = program.Title, Type = WebTVSearchResultType.Program, StartTime = program.StartTime, EndTime = program.EndTime, ChannelName = GetChannelDisplayName(program.IdChannel) })); } return(result.OrderByDescending(x => x.Score).ToList()); }
public IList <WebChannelGroup> GetRadioGroups(WebSortField?sort = WebSortField.User, WebSortOrder?order = WebSortOrder.Asc) { return(RadioChannelGroup.ListAll().Select(chg => chg.ToWebChannelGroup()).SortGroupList(sort, order).ToList()); }
public WebIntResult GetRadioGroupCount() { return(RadioChannelGroup.ListAll().Count); }
private void LoadGroups(Type groupType) { if (groupType == typeof(ChannelGroup)) { IList <ChannelGroup> tmp = ChannelGroup.ListAll(); foreach (ChannelGroup group in tmp) { bool isFixedGroupName = ( group.GroupName == TvConstants.TvGroupNames.AllChannels || ( _SelectionType == SelectionType.ForRenaming && ( group.GroupName == TvConstants.TvGroupNames.Analog || group.GroupName == TvConstants.TvGroupNames.DVBC || group.GroupName == TvConstants.TvGroupNames.DVBS || group.GroupName == TvConstants.TvGroupNames.DVBT) ) ); if (!isFixedGroupName) { _groups.Add(group); } } } else if (groupType == typeof(RadioChannelGroup)) { IList <RadioChannelGroup> tmp = RadioChannelGroup.ListAll(); foreach (RadioChannelGroup group in tmp) { bool isFixedGroupName = ( group.GroupName == TvConstants.RadioGroupNames.AllChannels || ( _SelectionType == SelectionType.ForRenaming && ( group.GroupName == TvConstants.RadioGroupNames.Analog || group.GroupName == TvConstants.RadioGroupNames.DVBC || group.GroupName == TvConstants.RadioGroupNames.DVBS || group.GroupName == TvConstants.RadioGroupNames.DVBT) ) ); if (!isFixedGroupName) { _groups.Add(group); } } } else { return; } try { foreach (object group in _groups) { string name = group.GetType().InvokeMember("GroupName", System.Reflection.BindingFlags.GetProperty, null, group, null). ToString(); listBox1.Items.Add(name); if (name == _preselectedGroupName) { listBox1.SelectedIndex = listBox1.Items.Count - 1; } } } catch (Exception exp) { Log.Error("LoadGroups error: {0}", exp.Message); } if (listBox1.SelectedIndex <= -1 && listBox1.Items.Count > 0) { listBox1.SelectedIndex = 0; } }