Exemple #1
0
        /// <summary>
        /// Fill the list with channels
        /// </summary>
        private void FillChannelList()
        {
            using (SchedulerServiceAgent tvSchedulerAgent = new SchedulerServiceAgent())
            {
                _channelsListControl.Clear();

                int i = 0;
                int SelectedID = 0;
                string ChannelLogo = string.Empty;

                if (_currentGroup != null)
                {
                    _currentAndNextPrograms = new List<CurrentAndNextProgram>(
                        tvSchedulerAgent.GetCurrentAndNextForGroup(_currentGroup.ChannelGroupId, true, true, PluginMain.Navigator.LiveStream));
                }
                else
                {
                    _currentAndNextPrograms = new List<CurrentAndNextProgram>();
                }

                Channel currentChannel = PluginMain.Navigator.CurrentChannel;
                Channel prevChannel = PluginMain.Navigator.GetPreviousChannel(this.ChannelType);

                foreach (CurrentAndNextProgram currentAndNext in _currentAndNextPrograms)
                {
                    i++;
                    sb.Length = 0;
                    GUIListItem item = new GUIListItem("");
                    item.TVTag = currentAndNext.Channel;

                    sb.Append(currentAndNext.Channel.DisplayName);
                    ChannelLogo = Utility.GetLogoImage(currentAndNext.Channel, tvSchedulerAgent);

                    if (!string.IsNullOrEmpty(ChannelLogo))
                    {
                        item.IconImageBig = ChannelLogo;
                        item.IconImage = ChannelLogo;
                    }
                    else
                    {
                        item.IconImageBig = string.Empty;
                        item.IconImage = string.Empty;
                    }

                    ActiveRecording activeRecording;
                    if (PluginMain.IsChannelRecording(currentAndNext.Channel.ChannelId, out activeRecording))
                    {
                        if (_showStateIcons)
                        {
                            item.PinImage = RecordingIcon;
                        }
                        else
                        {
                            sb.Append(" ");
                            sb.Append(recordingText);
                        }
                        item.IsPlayed = (currentAndNext.LiveState == ChannelLiveState.NotTunable
                            || currentAndNext.LiveState == ChannelLiveState.NoFreeCard);
                    }
                    else
                    {
                        switch (currentAndNext.LiveState)
                        {
                            case ChannelLiveState.NotTunable:
                            case ChannelLiveState.NoFreeCard:
                                item.IsPlayed = true;
                                if (_showStateIcons)
                                {
                                    item.PinImage = UnavailableIcon;
                                }
                                else
                                {
                                    sb.Append(" ");
                                    sb.Append(unavailableText);
                                }
                                break;

                            default:
                                item.IsPlayed = false;
                                if (_showStateIcons)
                                {
                                    item.PinImage = AvailableIcon;
                                }
                                break;
                        }
                    }

                    if (currentChannel != null)
                    {
                        if (currentChannel.ChannelId == currentAndNext.Channel.ChannelId)
                        {
                            item.IsRemote = true;
                            SelectedID = _channelsListControl.Count;

                            if (_showStateIcons && item.PinImage != RecordingIcon
                                && item.PinImage != UnavailableIcon)
                            {
                                item.PinImage = TimeshiftingIcon;
                            }
                            else if (!_showStateIcons)
                            {
                                sb.Append(" ");
                                sb.Append(timeshiftingText);
                            }
                        }
                    }
                    else if (prevChannel != null
                        && prevChannel.ChannelId == currentAndNext.Channel.ChannelId)
                    {
                        item.IsRemote = true;
                        SelectedID = _channelsListControl.Count;
                    }

                    sbTmp.Length = 0;

                    bool hasNow = currentAndNext.Current != null;
                    if (hasNow)
                    {
                        sbTmp.Append(currentAndNext.Current.CreateProgramTitle());
                    }
                    else
                    {
                        sbTmp.Append(noDataAvailableText);
                    }

                    item.Label2 = sbTmp.ToString();
                    sbTmp.Insert(0, nowText);
                    item.Label3 = sbTmp.ToString();

                    sbTmp.Length = 0;

                    if (_showChannelNumber)
                    {
                        sb.Append(" - ");
                        if (!_byIndex)
                        {
                            if (currentAndNext.Channel.LogicalChannelNumber.HasValue)
                            {
                                sb.Append(currentAndNext.Channel.LogicalChannelNumber.Value.ToString());
                            }
                        }
                        else
                        {
                            sb.Append(i);
                        }
                    }

                    if (hasNow)
                    {
                        sb.Append(" - ");
                        sb.Append(currentAndNext.CurrentPercentageComplete);
                        sb.Append("%");
                    }

                    if (currentAndNext.Next != null)
                    {
                        sbTmp.Append(/*currentAndNext.Next.StartTime.ToShortTimeString() + " " + */currentAndNext.Next.CreateProgramTitle());
                    }
                    else
                    {
                        sbTmp.Append(noDataAvailableText);
                    }

                    item.Label2 = sb.ToString();
                    sbTmp.Insert(0, nextText);
                    item.Label = sbTmp.ToString();

                    _channelsListControl.Add(item);
                }
                _channelsListControl.SelectedListItemIndex = SelectedID;
                Log.Debug("miniguide: state check + filling channel list completed");

                if (_channelsListControl.GetID == 37)
                {
                    GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SETFOCUS, GetID, 0, 37, 0, 0, null);
                    OnMessage(msg);
                }

                sb.Length = 0;
                sbTmp.Length = 0;
            }
        }
Exemple #2
0
        private void CacheMiniGuide()
        {
            lock (chacheLock)
            {
                System.Threading.Thread.Sleep(8000);
                while (!PluginMain.IsConnected())
                {
                    Thread.Sleep(2000);
                }
                Log.Debug("CacheChannelsThread: started");
                using (SchedulerServiceAgent tvSchedulerAgent = new SchedulerServiceAgent())
                {
                    List<CurrentAndNextProgram> _currentAndNextPrograms = new List<CurrentAndNextProgram>();
                    try
                    {
                        ChannelGroup currgroup = PluginMain.Navigator.CurrentGroup;
                        if (currgroup != null)
                        {
                            _currentAndNextPrograms = new List<CurrentAndNextProgram>(tvSchedulerAgent.GetCurrentAndNextForGroup(PluginMain.Navigator.CurrentGroup.ChannelGroupId, true, true, null));
                        }

                        List<ChannelGroup> groups = PluginMain.Navigator.GetGroups(ChannelType.Television);
                        foreach (ChannelGroup group in groups)
                        {
                            _currentAndNextPrograms = new List<CurrentAndNextProgram>(tvSchedulerAgent.GetCurrentAndNextForGroup(group.ChannelGroupId, true, true, null));
                        }
                    }
                    catch { Log.Error("CacheChannelsThread: error"); }
                    _currentAndNextPrograms.Clear();
                    _currentAndNextPrograms = null;
                }
                Log.Debug("CacheChannelsThread: ended");
            }
        }
Exemple #3
0
        private void CacheMiniGuide()
        {
            lock (chacheLock)
            {
                System.Threading.Thread.Sleep(8000);
                while (!PluginMain.IsConnected())
                {
                    Thread.Sleep(2000);
                }
                Log.Debug("CacheChannelsThread: started");
                using (SchedulerServiceAgent tvSchedulerAgent = new SchedulerServiceAgent())
                {
                    List <CurrentAndNextProgram> _currentAndNextPrograms = new List <CurrentAndNextProgram>();
                    try
                    {
                        ChannelGroup currgroup = PluginMain.Navigator.CurrentGroup;
                        if (currgroup != null)
                        {
                            _currentAndNextPrograms = new List <CurrentAndNextProgram>(tvSchedulerAgent.GetCurrentAndNextForGroup(PluginMain.Navigator.CurrentGroup.ChannelGroupId, true, true, null));
                        }

                        List <ChannelGroup> groups = PluginMain.Navigator.GetGroups(ChannelType.Television);
                        foreach (ChannelGroup group in groups)
                        {
                            _currentAndNextPrograms = new List <CurrentAndNextProgram>(tvSchedulerAgent.GetCurrentAndNextForGroup(group.ChannelGroupId, true, true, null));
                        }
                    }
                    catch { Log.Error("CacheChannelsThread: error"); }
                    _currentAndNextPrograms.Clear();
                    _currentAndNextPrograms = null;
                }
                Log.Debug("CacheChannelsThread: ended");
            }
        }
Exemple #4
0
        /// <summary>
        /// Fill the list with channels
        /// </summary>
        private void FillChannelList()
        {
            using (SchedulerServiceAgent tvSchedulerAgent = new SchedulerServiceAgent())
            {
                _channelsListControl.Clear();

                int    i           = 0;
                int    SelectedID  = 0;
                string ChannelLogo = string.Empty;

                if (_currentGroup != null)
                {
                    _currentAndNextPrograms = new List <CurrentAndNextProgram>(
                        tvSchedulerAgent.GetCurrentAndNextForGroup(_currentGroup.ChannelGroupId, true, true, PluginMain.Navigator.LiveStream));
                }
                else
                {
                    _currentAndNextPrograms = new List <CurrentAndNextProgram>();
                }

                Channel currentChannel = PluginMain.Navigator.CurrentChannel;
                Channel prevChannel    = PluginMain.Navigator.GetPreviousChannel(this.ChannelType);

                foreach (CurrentAndNextProgram currentAndNext in _currentAndNextPrograms)
                {
                    i++;
                    sb.Length = 0;
                    GUIListItem item = new GUIListItem("");
                    item.TVTag = currentAndNext.Channel;

                    sb.Append(currentAndNext.Channel.DisplayName);
                    ChannelLogo = Utility.GetLogoImage(currentAndNext.Channel, tvSchedulerAgent);

                    if (!string.IsNullOrEmpty(ChannelLogo))
                    {
                        item.IconImageBig = ChannelLogo;
                        item.IconImage    = ChannelLogo;
                    }
                    else
                    {
                        item.IconImageBig = string.Empty;
                        item.IconImage    = string.Empty;
                    }

                    ActiveRecording activeRecording;
                    if (PluginMain.IsChannelRecording(currentAndNext.Channel.ChannelId, out activeRecording))
                    {
                        if (_showStateIcons)
                        {
                            item.PinImage = RecordingIcon;
                        }
                        else
                        {
                            sb.Append(" ");
                            sb.Append(recordingText);
                        }
                        item.IsPlayed = (currentAndNext.LiveState == ChannelLiveState.NotTunable ||
                                         currentAndNext.LiveState == ChannelLiveState.NoFreeCard);
                    }
                    else
                    {
                        switch (currentAndNext.LiveState)
                        {
                        case ChannelLiveState.NotTunable:
                        case ChannelLiveState.NoFreeCard:
                            item.IsPlayed = true;
                            if (_showStateIcons)
                            {
                                item.PinImage = UnavailableIcon;
                            }
                            else
                            {
                                sb.Append(" ");
                                sb.Append(unavailableText);
                            }
                            break;

                        default:
                            item.IsPlayed = false;
                            if (_showStateIcons)
                            {
                                item.PinImage = AvailableIcon;
                            }
                            break;
                        }
                    }

                    if (currentChannel != null)
                    {
                        if (currentChannel.ChannelId == currentAndNext.Channel.ChannelId)
                        {
                            item.IsRemote = true;
                            SelectedID    = _channelsListControl.Count;

                            if (_showStateIcons && item.PinImage != RecordingIcon &&
                                item.PinImage != UnavailableIcon)
                            {
                                item.PinImage = TimeshiftingIcon;
                            }
                            else if (!_showStateIcons)
                            {
                                sb.Append(" ");
                                sb.Append(timeshiftingText);
                            }
                        }
                    }
                    else if (prevChannel != null &&
                             prevChannel.ChannelId == currentAndNext.Channel.ChannelId)
                    {
                        item.IsRemote = true;
                        SelectedID    = _channelsListControl.Count;
                    }

                    sbTmp.Length = 0;

                    bool hasNow = currentAndNext.Current != null;
                    if (hasNow)
                    {
                        sbTmp.Append(currentAndNext.Current.CreateProgramTitle());
                    }
                    else
                    {
                        sbTmp.Append(noDataAvailableText);
                    }

                    item.Label2 = sbTmp.ToString();
                    sbTmp.Insert(0, nowText);
                    item.Label3 = sbTmp.ToString();

                    sbTmp.Length = 0;

                    if (_showChannelNumber)
                    {
                        sb.Append(" - ");
                        if (!_byIndex)
                        {
                            if (currentAndNext.Channel.LogicalChannelNumber.HasValue)
                            {
                                sb.Append(currentAndNext.Channel.LogicalChannelNumber.Value.ToString());
                            }
                        }
                        else
                        {
                            sb.Append(i);
                        }
                    }

                    if (hasNow)
                    {
                        sb.Append(" - ");
                        sb.Append(currentAndNext.CurrentPercentageComplete);
                        sb.Append("%");
                    }

                    if (currentAndNext.Next != null)
                    {
                        sbTmp.Append(/*currentAndNext.Next.StartTime.ToShortTimeString() + " " + */ currentAndNext.Next.CreateProgramTitle());
                    }
                    else
                    {
                        sbTmp.Append(noDataAvailableText);
                    }

                    item.Label2 = sb.ToString();
                    sbTmp.Insert(0, nextText);
                    item.Label = sbTmp.ToString();

                    _channelsListControl.Add(item);
                }
                _channelsListControl.SelectedListItemIndex = SelectedID;
                Log.Debug("miniguide: state check + filling channel list completed");

                if (_channelsListControl.GetID == 37)
                {
                    GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_SETFOCUS, GetID, 0, 37, 0, 0, null);
                    OnMessage(msg);
                }

                sb.Length    = 0;
                sbTmp.Length = 0;
            }
        }