public static IChannelGroup ToChannelGroup(this TvDatabase.RadioChannelGroup radioGroup)
 {
     if (radioGroup == null)
     {
         return(null);
     }
     // Note: this temporary workaround uses negative group ids to be able to separate them later. This can be removed once there is a
     // dedicated radio group interface (if required).
     return(new ChannelGroup {
         ChannelGroupId = -radioGroup.IdGroup, Name = radioGroup.GroupName, MediaType = MediaType.Radio, SortOrder = radioGroup.SortOrder
     });
 }
Exemplo n.º 2
0
        private void EnsureChildren(TreeNode node)
        {
            try
            {
                if (node.Nodes.Count == 1 &&
                    String.IsNullOrEmpty(node.Nodes[0].Text))
                {
                    int    groupId;
                    string groupName;
                    int    groupSequence;
                    TvDatabase.ChannelGroup group = node.Tag as TvDatabase.ChannelGroup;
                    if (group == null)
                    {
                        TvDatabase.RadioChannelGroup radioGroup = node.Tag as TvDatabase.RadioChannelGroup;
                        groupId       = radioGroup.IdGroup;
                        groupName     = radioGroup.GroupName;
                        groupSequence = 0;
                    }
                    else
                    {
                        groupId       = group.IdGroup;
                        groupName     = group.GroupName;
                        groupSequence = group.SortOrder;
                    }

                    List <TvDatabase.Channel> channels = Utility.GetAllChannelsInGroup(this.Context.ChannelType, groupId);

                    node.Nodes.Clear();
                    foreach (TvDatabase.Channel channel in channels)
                    {
                        if (ChannelLinks.GetChannelLinkForMediaPortalChannel(channel) == null &&
                            !ChannelLinks.IsAutoLinked(channel))
                        {
                            TreeNode channelNode = new TreeNode(channel.DisplayName);
                            channelNode.Tag = new ImportChannelsContext.ImportChannel(channel, groupId < 0 ? null : groupName, groupSequence);
                            node.Nodes.Add(channelNode);
                        }
                    }
                    _recordingsTreeView.InitializeNodesState(node.Nodes);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }