コード例 #1
0
        public List <WebMiniEPG> GetRadioMiniEPGForGroup(int idGroup)
        {
            List <WebMiniEPG> ret = new List <WebMiniEPG>();

            if (!ConnectToDatabase())
            {
                return(ret);
            }
            RadioChannelGroup group = null;

            try
            {
                group = RadioChannelGroup.Retrieve(idGroup);
            }
            catch (Exception)
            {
            }
            if (group == null)
            {
                return(ret);
            }

            IList <RadioGroupMap> maps = group.ReferringRadioGroupMap();

            foreach (RadioGroupMap map in maps)
            {
                ret.Add(new WebMiniEPG(map.ReferencedChannel()));
            }
            return(ret);
        }
コード例 #2
0
        public List <WebChannel> GetChannelsInRadioGroup(int idGroup)
        {
            List <WebChannel> channels = new List <WebChannel>();

            if (!ConnectToDatabase())
            {
                return(channels);
            }
            RadioChannelGroup group = null;

            try
            {
                group = RadioChannelGroup.Retrieve(idGroup);
            }
            catch (Exception)
            {
            }
            if (group == null)
            {
                return(channels);
            }
            IList <RadioGroupMap> maps = group.ReferringRadioGroupMap();

            foreach (RadioGroupMap map in maps)
            {
                channels.Add(new WebChannel(map.ReferencedChannel()));
            }
            return(channels);
        }
コード例 #3
0
        private void renameGroupToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripDropDownItem menuItem = sender as ToolStripDropDownItem;

            if (menuItem == null)
            {
                return;
            }

            TabPage tab = menuItem.Tag as TabPage;

            if (tab == null)
            {
                return;
            }

            RadioChannelGroup group = tab.Tag as RadioChannelGroup;

            if (group == null)
            {
                return;
            }

            GroupNameForm dlg = new GroupNameForm(group.GroupName);

            dlg.ShowDialog(this);

            if (dlg.GroupName.Length == 0)
            {
                return;
            }

            group.GroupName = dlg.GroupName;
            group.Persist();

            tab.Text = dlg.GroupName;

            if (group.ReferringRadioGroupMap().Count > 0 && tabControl1.SelectedIndex == 0)
            {
                this.RefreshContextMenu();
                this.RefreshAllChannels();
            }
            else
            {
                this.RefreshContextMenu();
            }
        }
コード例 #4
0
        private void deleteGroupToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripDropDownItem menuItem = sender as ToolStripDropDownItem;

            if (menuItem == null)
            {
                return;
            }

            TabPage tab = menuItem.Tag as TabPage;

            if (tab == null)
            {
                return;
            }

            RadioChannelGroup group = tab.Tag as RadioChannelGroup;

            if (group == null)
            {
                return;
            }

            DialogResult result = MessageBox.Show(string.Format("Are you sure you want to delete the group '{0}'?",
                                                                group.GroupName), "", MessageBoxButtons.YesNo);

            if (result == DialogResult.No)
            {
                return;
            }

            bool groupIsEmpty = (group.ReferringRadioGroupMap().Count <= 0);

            group.Delete();
            tabControl1.TabPages.Remove(tab);

            if (!groupIsEmpty && tabControl1.SelectedIndex == 0)
            {
                this.RefreshContextMenu();
                this.RefreshAllChannels();
            }
            else
            {
                this.RefreshContextMenu();
            }
        }
コード例 #5
0
        private void mpButtonDelGroup_Click(object sender, EventArgs e)
        {
            GroupSelectionForm dlgGrpSel = new GroupSelectionForm();

            if (dlgGrpSel.ShowDialog(typeof(RadioChannelGroup), this) != DialogResult.OK)
            {
                return;
            }

            RadioChannelGroup group = dlgGrpSel.Group as RadioChannelGroup;

            if (group == null)
            {
                return;
            }

            DialogResult result = MessageBox.Show(string.Format("Are you sure you want to delete the group '{0}'?",
                                                                group.GroupName), "", MessageBoxButtons.YesNo);

            if (result == DialogResult.No)
            {
                return;
            }

            bool isGroupEmpty = (group.ReferringRadioGroupMap().Count <= 0);

            group.Delete();

            if (!isGroupEmpty)
            {
                this.RefreshAll();
            }
            else
            {
                this.RefreshContextMenu();
                this.RefreshTabs();
            }
        }
コード例 #6
0
        private void mpButtonRenameGroup_Click(object sender, EventArgs e)
        {
            GroupSelectionForm dlgGrpSel = new GroupSelectionForm();

            dlgGrpSel.Selection = GroupSelectionForm.SelectionType.ForRenaming;

            if (dlgGrpSel.ShowDialog(typeof(RadioChannelGroup), this) != DialogResult.OK)
            {
                return;
            }

            RadioChannelGroup group = dlgGrpSel.Group as RadioChannelGroup;

            if (group == null)
            {
                return;
            }

            GroupNameForm dlgGrpName = new GroupNameForm(group.GroupName);

            if (dlgGrpName.ShowDialog(this) != DialogResult.OK)
            {
                return;
            }

            group.GroupName = dlgGrpName.GroupName;
            group.Persist();

            if (group.ReferringRadioGroupMap().Count > 0)
            {
                this.RefreshAll();
            }
            else
            {
                this.RefreshContextMenu();
                this.RefreshTabs();
            }
        }
コード例 #7
0
        public void ReLoad()
        {
            //System.Diagnostics.Debugger.Launch();
            try
            {
                SetupDatabaseConnection();
                Log.Info("get channels from database");
                SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof(Channel));
                sb.AddConstraint(Operator.Equals, "isTv", 1);
                sb.AddOrderByField(true, "sortOrder");
                SqlStatement stmt = sb.GetStatement(true);
                channels = ObjectFactory.GetCollection(typeof(Channel), stmt.Execute());
                Log.Info("found:{0} tv channels", channels.Count);
                TvNotifyManager.OnNotifiesChanged();
                m_groups.Clear();

                TvBusinessLayer   layer = new TvBusinessLayer();
                RadioChannelGroup allRadioChannelsGroup =
                    layer.GetRadioChannelGroupByName(TvConstants.RadioGroupNames.AllChannels);
                IList <Channel> radioChannels = layer.GetAllRadioChannels();
                if (radioChannels != null)
                {
                    if (radioChannels.Count > allRadioChannelsGroup.ReferringRadioGroupMap().Count)
                    {
                        foreach (Channel radioChannel in radioChannels)
                        {
                            layer.AddChannelToRadioGroup(radioChannel, allRadioChannelsGroup);
                        }
                    }
                }
                Log.Info("Done.");

                Log.Info("get all groups from database");
                sb = new SqlBuilder(StatementType.Select, typeof(ChannelGroup));
                sb.AddOrderByField(true, "groupName");
                stmt = sb.GetStatement(true);
                IList <ChannelGroup> groups       = ObjectFactory.GetCollection <ChannelGroup>(stmt.Execute());
                IList <GroupMap>     allgroupMaps = GroupMap.ListAll();

                bool hideAllChannelsGroup = false;
                using (
                    Settings xmlreader =
                        new MPSettings())
                {
                    hideAllChannelsGroup = xmlreader.GetValueAsBool("mytv", "hideAllChannelsGroup", false);
                }


                foreach (ChannelGroup group in groups)
                {
                    if (group.GroupName == TvConstants.TvGroupNames.AllChannels)
                    {
                        foreach (Channel channel in channels)
                        {
                            if (channel.IsTv == false)
                            {
                                continue;
                            }
                            bool groupContainsChannel = false;
                            foreach (GroupMap map in allgroupMaps)
                            {
                                if (map.IdGroup != group.IdGroup)
                                {
                                    continue;
                                }
                                if (map.IdChannel == channel.IdChannel)
                                {
                                    groupContainsChannel = true;
                                    break;
                                }
                            }
                            if (!groupContainsChannel)
                            {
                                layer.AddChannelToGroup(channel, TvConstants.TvGroupNames.AllChannels);
                            }
                        }
                        break;
                    }
                }

                groups = ChannelGroup.ListAll();
                foreach (ChannelGroup group in groups)
                {
                    //group.GroupMaps.ApplySort(new GroupMap.Comparer(), false);
                    if (hideAllChannelsGroup && group.GroupName.Equals(TvConstants.TvGroupNames.AllChannels) && groups.Count > 1)
                    {
                        continue;
                    }
                    m_groups.Add(group);
                }
                Log.Info("loaded {0} tv groups", m_groups.Count);

                //TVHome.Connected = true;
            }
            catch (Exception ex)
            {
                Log.Error("TVHome: Error in Reload");
                Log.Error(ex);
                //TVHome.Connected = false;
            }
        }
コード例 #8
0
        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);
                }
            }
        }