Example #1
0
 /// <summary>
 /// Create a new instance of LiveStream.
 /// </summary>
 /// <param name="channel">The channel being streamed.</param>
 /// <param name="rtspUrl">The rtsp URL to the stream.</param>
 /// <param name="streamStartedTimeUtc">The date and time the stream was first started.</param>
 public LiveStream(Channel channel, string rtspUrl, DateTime streamStartedTimeUtc)
 {
     this.Channel = channel;
     this.RtspUrl = rtspUrl;
     this.StreamStartedTime = streamStartedTimeUtc.ToLocalTime();
     this.StreamLastAliveTimeUtc = streamStartedTimeUtc;
 }
Example #2
0
 public ProgramEventArgs(GuideProgramSummary guideProgram, Channel channel, Point location)
 {
     this.GuideProgram = guideProgram;
     this.Channel = channel;
     this.Location = location;
     this.UpcomingProgramId = guideProgram.GetUniqueUpcomingProgramId(channel.ChannelId);
 }
Example #3
0
 public static void AppendProgramDetails(StringBuilder reply, Channel channel, IProgramSummary program)
 {
     reply.AppendFormat("[{0}] {1} {2}-{3} {4}",
         channel.DisplayName,
         GetShortDayDateString(program.StartTime),
         program.StartTime.ToShortTimeString().PadLeft(5, '0'),
         program.StopTime.ToShortTimeString().PadLeft(5, '0'),
         program.CreateProgramTitle());
 }
Example #4
0
 public IProgramSummary GetProgramAt(int number, out Channel channel, out Guid? upcomingProgramId)
 {
     if (--number >= 0)
     {
         if (_guidePrograms != null
             && number < _guidePrograms.Count)
         {
             channel = this.Channel;
             upcomingProgramId = _guidePrograms[number].GetUniqueUpcomingProgramId(channel.ChannelId);
             return _guidePrograms[number];
         }
         else if (_searchedPrograms != null
             && number < _searchedPrograms.Count)
         {
             channel = _searchedPrograms[number].Channel;
             upcomingProgramId = _searchedPrograms[number].GetUniqueUpcomingProgramId();
             return _searchedPrograms[number];
         }
         else if (_upcomingPrograms != null
             && number < _upcomingPrograms.Count)
         {
             channel = _upcomingPrograms[number].Channel;
             upcomingProgramId = _upcomingPrograms[number].UpcomingProgramId;
             return _upcomingPrograms[number];
         }
         else if (_upcomingRecordings != null
             && number < _upcomingRecordings.Count)
         {
             channel = _upcomingRecordings[number].Program.Channel;
             upcomingProgramId = _upcomingRecordings[number].Program.UpcomingProgramId;
             return _upcomingRecordings[number];
         }
     }
     channel = null;
     upcomingProgramId = null;
     return null;
 }
Example #5
0
 public Programs(Channel channel, IList<GuideProgramSummary> guidePrograms)
 {
     _channel = channel;
     _guidePrograms = guidePrograms;
 }
Example #6
0
 private void GetLinkedMessageAndColor(Channel channel, out string message, out Color rowColor)
 {
     bool isAutoLinked;
     bool duplicateChannelsFound;
     LinkedMediaPortalChannel linkedChannel =
        ChannelLinks.GetLinkedMediaPortalChannel(channel, out isAutoLinked, out duplicateChannelsFound);
     if (duplicateChannelsFound)
     {
         message = "More than one channel found, change name or link manually";
         rowColor = Color.Red;
     }
     else if (linkedChannel == null)
     {
         message = "Channel not linked, change name or link manually";
         rowColor = Color.Red;
     }
     else if (isAutoLinked)
     {
         message = "Linked (auto)";
         rowColor = Color.Black;
     }
     else
     {
         message = "Linked to " + linkedChannel.DisplayName;
         rowColor = Color.DarkGreen;
     }
 }
Example #7
0
 private void MergeExtraPrograms(Channel channel, ChannelPrograms channelPrograms, DateTime fromDateTime, DateTime toDateTime)
 {
     if (toDateTime > fromDateTime)
     {
         var guidePrograms = Proxies.GuideService.GetChannelProgramsBetween(channel.GuideChannelId.Value, fromDateTime, toDateTime).Result;
         foreach (GuideProgramSummary guideProgram in guidePrograms)
         {
             channelPrograms.InsertProgram(guideProgram);
         }
     }
 }
Example #8
0
        private string GetChannelProgramIcon(Channel channel, Guid guideProgramId, out GuideUpcomingProgram guideUpcomingProgram)
        {
            Guid upcomingProgramId = UpcomingProgram.GetUniqueUpcomingProgramId(guideProgramId, channel.ChannelId);

            guideUpcomingProgram = null;
            string recordIconImage = null;
            GuideUpcomingProgram upcoming = null;
            ScheduleType type = ScheduleType.Recording;
            if (_model.UpcomingRecordingsById.ContainsKey(upcomingProgramId))
            {
                type = ScheduleType.Recording;
                upcoming = _model.UpcomingRecordingsById[upcomingProgramId];
                guideUpcomingProgram = upcoming;
            }
            else if (_model.UpcomingAlertsById.ContainsKey(upcomingProgramId))
            {
                type = ScheduleType.Alert;
                upcoming = _model.UpcomingAlertsById[upcomingProgramId];
                guideUpcomingProgram = upcoming;
            }
            else if (_model.UpcomingSuggestionsById.ContainsKey(upcomingProgramId))
            {
                type = ScheduleType.Suggestion;
                upcoming = _model.UpcomingSuggestionsById[upcomingProgramId];
            }
            if (upcoming != null
                && upcoming.ChannelId == channel.ChannelId)
            {
                recordIconImage = Utility.GetIconImageFileName(type, upcoming);
            }
            return recordIconImage;
        }
Example #9
0
 private string GetChannelProgramIcon(Channel channel, Guid guideProgramId)
 {
     GuideUpcomingProgram guideUpcomingProgram;
     return GetChannelProgramIcon(channel, guideProgramId, out guideUpcomingProgram);
 }
        /// <summary>
        /// Changes the current channel and channelgroup after a specified delay.
        /// </summary>
        /// <param name="channelGroup">The channelgroup to switch to.</param>
        /// <param name="channel">The channel to switch to</param>
        /// <param name="useZapDelay">If true, the configured zap delay is used. Otherwise it zaps immediately.</param>
        public void ZapToChannel(ChannelGroup channelGroup, Channel channel, bool useZapDelay)
        {
            Log.Debug("ChannelNavigator.ZapToChannel {0} - zapdelay {1}", channel.DisplayName, useZapDelay);

            _zapGroup = channelGroup ?? _currentChannelGroup;
            _zapChannel = channel;

            if (useZapDelay)
            {
                _zapTime = DateTime.Now.AddMilliseconds(_zapDelayMs);
            }
            else
            {
                _zapTime = DateTime.Now;
            }
        }
 /// <summary>
 /// Changes the current channel after a specified delay.
 /// </summary>
 /// <param name="channel">The channel to switch to.</param>
 /// <param name="useZapDelay">If true, the configured zap delay is used. Otherwise it zaps immediately.</param>
 public void ZapToChannel(Channel channel, bool useZapDelay)
 {
     ZapToChannel(null, channel, useZapDelay);
 }
        /// <summary>
        /// Use this when you are sure that the livestream playback was stopped some time ago.
        /// </summary>
        public void StopLiveStream()
        {
            Log.Debug("ChannelNavigator: StopLiveStream()");
            if (_liveStream != null)
            {
                this.ControlAgent.StopLiveStream(_liveStream);
                _liveStream = null;

                if (_currentChannel != null)
                    _navigatorChannels[_currentChannel.ChannelType].PreviousChannel = _currentChannel;
            }

            if (!_doingChannelChange && !_lastChannelChangeFailed)
                _currentChannel = null;
        }
        /// <summary>
        /// Checks if it is time to zap to a different channel. This is called during Process().
        /// </summary>
        public bool CheckChannelChange()
        {
            if (_reentrant)
            {
                return false;
            }
            try
            {
                _reentrant = true;

                // Zapping to another group or channel?
                if (_zapGroup != null || _zapChannel != null)
                {
                    // Time to zap?
                    if (DateTime.Now >= _zapTime)
                    {
                        Log.Debug("ChannelNavigator: CheckChannelChange()_DateTime.Now >= _zapTime,_zapgroup = {0} , _zapchannel = {1}", _zapGroup.GroupName, _zapChannel.DisplayName);
                        // Zapping to another group?
                        if (_zapGroup != null && _zapGroup != _currentChannelGroup)
                        {
                            // Change current group (and possibly zap to the first channel of the group)
                            if (_currentChannelGroup != null)
                            {
                                _navigatorChannels[_currentChannelGroup.ChannelType].PreviousChannelGroup = _currentChannelGroup;
                            }
                            _currentChannelGroup = _zapGroup;
                            RefreshChannelsInGroup(_zapGroup.ChannelType);
                            if (_zapChannel == null
                                && _navigatorChannels[_zapGroup.ChannelType].Channels.Count > 0)
                            {
                                _zapChannel = _navigatorChannels[_zapGroup.ChannelType].Channels[0];
                            }
                        }

                        // Zap to desired channel
                        Channel zappingTo = _zapChannel;
                        _zapChannel = null;
                        _zapGroup = null;

                        if (PluginMain.Navigator.CurrentChannel != null
                            && PluginMain.Navigator.CurrentChannel.ChannelId == zappingTo.ChannelId
                            && _liveStream != null && !_lastChannelChangeFailed)
                        {
                            Log.Debug("ChannelNavigator: CheckChannelChange()_CurrentChannel.ChannelId = zappingTo.ChannelId --> break off zapping");
                            zappingTo = null;
                        }

                        if (zappingTo != null)
                        {
                            if ((this.IsLiveStreamOn && _currentChannel != null
                                && zappingTo.ChannelType != _currentChannel.ChannelType)
                                || (g_Player.Playing && !this.IsLiveStreamOn))
                            {
                                //g_Player needs a comlete stop when the ChannelType changes
                                if (_liveStream != null)
                                {
                                    g_Player.PauseGraph();
                                    Thread.Sleep(100);
                                    this.StopLiveStream();
                                }
                                g_Player.Stop(true);
                                Thread.Sleep(250);
                            }

                            Channel prevChannel = _currentChannel;
                            ChannelGroup prevGroup = _currentChannelGroup;
                            TuneLiveStream(zappingTo);
                            if (prevChannel != null)
                            {
                                _navigatorChannels[prevChannel.ChannelType].PreviousChannel = prevChannel;
                                _navigatorChannels[prevGroup.ChannelType].PreviousChannelGroup = prevGroup;
                            }
                            _navigatorChannels[zappingTo.ChannelType].LastChannel = _currentChannel;
                            _navigatorChannels[zappingTo.ChannelType].LastChannelGroup = _currentChannelGroup;

                            if (zappingTo.ChannelType == ChannelType.Radio)
                            {
                                RadioHome.SetMusicProperties(zappingTo.DisplayName, zappingTo.ChannelId);
                            }

                        }
                        _zapChannelNr = -1;
                        _reentrant = false;
                        return true;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("ChannelNavigator: error CheckChannelChange() = {0}", ex.Message);
            }
            finally
            {
                _reentrant = false;
            }
            return false;
        }
        /// <summary>
        /// Use this when the livestream playback just stopped.
        /// </summary>
        public void AsyncStopLiveStream()
        {
            if (_liveStream != null)
            {
                _streamToStopAsync = _liveStream;
                _liveStream = null;

                if (_currentChannel != null)
                    _navigatorChannels[_currentChannel.ChannelType].PreviousChannel = _currentChannel;

                _asyncStopLiveStreamThread = new Thread(new ThreadStart(AsyncStopLiveStreamThreadMain));
                _asyncStopLiveStreamThread.Start();
            }

            if (!_doingChannelChange && !_lastChannelChangeFailed)
                _currentChannel = null;
        }
        private void TuneLiveStream(Channel channel)
        {
            Log.Debug("ChannelNavigator: TuneLiveStream(), channel = {0}", channel.DisplayName);
            if (channel != null)
            {
                using (SchedulerServiceAgent tvSchedulerAgent = new SchedulerServiceAgent())
                {
                    LiveStream liveStream = _liveStream;
                    CurrentAndNextProgram currentAndNext = tvSchedulerAgent.GetCurrentAndNextForChannel(channel.ChannelId, true, _liveStream);//null);

                    _currentChannel = channel;
                    _doingChannelChange = true;
                    RenderBlackImage();

                    if (liveStream != null)
                    {
                        try
                        {
                            g_Player.PauseGraph();
                            g_Player.OnZapping(0x80);

                            result = this.ControlAgent.TuneLiveStream(channel, ref liveStream);
                            Log.Debug("ChannelNavigator: First try to re-tune the existing TV stream (staying on the same card), result = {0}", result);

                            if (result == LiveStreamResult.Succeeded)
                            {
                                if (_isAnalog)
                                    g_Player.OnZapping(-1);

                                double duration = g_Player.Duration;
                                if (g_Player.Duration < 0.0)
                                    result = LiveStreamResult.UnknownError;
                                else
                                {
                                    g_Player.SeekAbsolute(duration);
                                    g_Player.ContinueGraph();
                                }
                            }
                            else if (result == LiveStreamResult.NoRetunePossible)// not mapped to card, card in use by recorder or other user ---> start new stream
                            {
                                // Now re-try the new channel with a new stream.
                                Log.Debug("ChannelNavigator: Seems a re-tune has failed, stop the current stream and start a new one");
                                SilentlyStopLiveStream(liveStream);
                                result = StartAndPlayNewLiveStream(channel, liveStream);
                            }
                        }
                        catch
                        {
                            result = LiveStreamResult.UnknownError;
                            Log.Error("ChannelNavigator: TuneLiveStream error");
                        }
                    }
                    else
                    {
                        result = StartAndPlayNewLiveStream(channel,liveStream);
                    }

                    _doingChannelChange = false;
                    if (result == LiveStreamResult.Succeeded)
                    {
                        _lastChannelChangeFailed = false;
                        StopRenderBlackImage();
                    }
                    else
                    {
                        _lastChannelChangeFailed = true;
                        SilentlyStopLiveStream(liveStream);
                        ChannelTuneFailedNotifyUser(result, channel);
                    }
                }
            }
        }
Example #16
0
        private void LoadSettings(out string currentChannelName)
        {
            using (global::MediaPortal.Profile.Settings xmlreader = new global::MediaPortal.Profile.MPSettings())
            {
                _cursorX = xmlreader.GetValueAsInt(this.SettingsSection, "ypos", 0);
                _channelOffset = xmlreader.GetValueAsInt(this.SettingsSection, "yoffset", 0);
                _byIndex = xmlreader.GetValueAsBool("mytv", "byindex", true);
                _showChannelNumber = xmlreader.GetValueAsBool("mytv", "showchannelnumber", false);
                _channelNumberMaxLength = xmlreader.GetValueAsInt("mytv", "channelnumbermaxlength", 3);
                _timePerBlock = xmlreader.GetValueAsInt(this.SettingsSection, "timeperblock", 30);
                _hdtvProgramText = xmlreader.GetValueAsString("mytv", "hdtvProgramText", "(HDTV)");
                _guideContinuousScroll = xmlreader.GetValueAsBool("mytv", "continuousScrollGuide", false);
                _loopDelay = xmlreader.GetValueAsInt("gui", "listLoopDelay", 0);
                currentChannelName = xmlreader.GetValueAsString(this.SettingsSection, "channel", String.Empty);

                _currentChannel = PluginMain.Navigator.CurrentChannel ?? PluginMain.Navigator.GetPreviousChannel(_channelType);
                if (_currentChannel != null)
                {
                    currentChannelName = _currentChannel.DisplayName;
                }

                if (_channelOffset < 0)
                {
                    _channelOffset = 0;
                }
            }
            _useNewRecordingButtonColor =
              Utils.FileExistsInCache(Path.Combine(GUIGraphicsContext.Skin, @"media\tvguide_recButton_Focus_middle.png"));
            _useNewPartialRecordingButtonColor =
              Utils.FileExistsInCache(Path.Combine(GUIGraphicsContext.Skin, @"media\tvguide_partRecButton_Focus_middle.png"));
            _useNewNotifyButtonColor =
              Utils.FileExistsInCache(Path.Combine(GUIGraphicsContext.Skin, @"media\tvguide_notifyButton_Focus_middle.png"));
            _useHdProgramIcon =
              Utils.FileExistsInCache(Path.Combine(GUIGraphicsContext.Skin, @"media\tvguide_hd_program.png"));
        }
Example #17
0
 private void updateSingleChannelNumber()
 {
     // update selected channel
     if (!_singleChannelView)
     {
         _singleChannelNumber = _cursorX + _channelOffset;
         if (_singleChannelNumber < 0)
         {
             _singleChannelNumber = 0;
         }
         if (_singleChannelNumber >= _channelList.Count)
         {
             _singleChannelNumber -= _channelList.Count;
         }
         // instead of direct casting us "as"; else it fails for other controls!
         GUIButton3PartControl img = GetControl(_cursorX + (int)Controls.IMG_CHAN1) as GUIButton3PartControl;
         ;
         if (null != img)
         {
             _currentChannel = (Channel)img.Data;
         }
     }
 }
        private void ChannelTuneFailedNotifyUser(LiveStreamResult result, Channel channel)
        {
            string TuningResult = string.Empty;
            switch (result)
            {
                case LiveStreamResult.ChannelTuneFailed:
                    TuningResult = (Utility.GetLocalizedText(TextId.ChannelTuneFailed));
                    break;

                case LiveStreamResult.NoFreeCardFound:
                    TuningResult = (Utility.GetLocalizedText(TextId.NoFreeCardFound));
                    break;

                case LiveStreamResult.NotSupported:
                    TuningResult = (Utility.GetLocalizedText(TextId.NotSupported));
                    break;

                case LiveStreamResult.NoRetunePossible:
                    TuningResult = (Utility.GetLocalizedText(TextId.NoRetunePossible));
                    break;

                case LiveStreamResult.IsScrambled:
                    TuningResult = (Utility.GetLocalizedText(TextId.IsScrambled));
                    break;

                case LiveStreamResult.UnknownError:
                    TuningResult = (Utility.GetLocalizedText(TextId.UnknownError));
                    break;
            }

            if (GUIWindowManager.ActiveWindow == (int)(int)GUIWindow.Window.WINDOW_TVFULLSCREEN)
            {
                // If failed and wasPlaying TV, left screen as it is and show zaposd with error message
                GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_TV_ERROR_NOTIFY, GUIWindowManager.ActiveWindow, 0,
                                                0, 0, 0,
                                                null);

                msg.SendToTargetWindow = true;
                msg.Object = TuningResult; // forward error info object
                msg.TargetWindowId = (int)(int)GUIWindow.Window.WINDOW_TVFULLSCREEN;
                GUIGraphicsContext.SendMessage(msg);
            }
            else
            {
                // if not fulscreen, show notify dialog with the error message
                string caption = string.Empty;
                string tvlogo = string.Empty;
                if (channel != null)
                {
                    _navigatorChannels[_currentChannel.ChannelType].PreviousChannel = channel;
                    _currentChannel = null;

                    using (SchedulerServiceAgent SchedulerAgent = new SchedulerServiceAgent())
                    {
                        tvlogo = Utility.GetLogoImage(channel, SchedulerAgent);
                    }

                    if (channel.ChannelType == ChannelType.Television)
                        caption = GUILocalizeStrings.Get(605) + " - " + channel.DisplayName;
                    else
                        caption = GUILocalizeStrings.Get(665) + " - " + channel.DisplayName;
                }

                GUIDialogNotify pDlgNotify = (GUIDialogNotify)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_NOTIFY);
                if (pDlgNotify != null)
                {
                    pDlgNotify.Reset();
                    pDlgNotify.ClearAll();
                    pDlgNotify.SetHeading(caption);
                    if (!string.IsNullOrEmpty(TuningResult))
                    {
                        pDlgNotify.SetText(TuningResult);
                    }
                    pDlgNotify.SetImage(tvlogo);
                    pDlgNotify.TimeOut = 5;
                    pDlgNotify.DoModal(GUIWindowManager.ActiveWindow);
                }
            }
        }
Example #19
0
 private string GetChannelProgramIcon(Channel channel, Guid guideProgramId, out bool isRecording, out bool isAlert)
 {
     GuideUpcomingProgram guideUpcomingProgram;
     string result = GetChannelProgramIcon(channel, guideProgramId, out guideUpcomingProgram);
     isRecording = (guideUpcomingProgram != null && guideUpcomingProgram.Type == ScheduleType.Recording
         && guideUpcomingProgram.CancellationReason == UpcomingCancellationReason.None);
     isAlert = (guideUpcomingProgram != null && guideUpcomingProgram.Type == ScheduleType.Alert);
     return result;
 }
        private int CreateChannelCell(Channel channel, int top)
        {
            int cellHeight = 0;

            if (_model.ProgramsByChannel.ContainsKey(channel.ChannelId))
            {
                bool isTop = (top == 0);
                cellHeight = isTop ? _height : (_height - 1);

                ChannelCell cell = new ChannelCell()
                {
                    Channel = channel,
                    IsTop = isTop,
                    Rectangle = new Rectangle(0, top, (int) (100 * _widthFactor), cellHeight)
                };
                _channelCells.Add(cell);
            }

            return top + cellHeight;
        }
Example #21
0
        public override bool OnMessage(GUIMessage message)
        {
            try
            {
                switch (message.Message)
                {
                    case GUIMessage.MessageType.GUI_MSG_PERCENTAGE_CHANGED:
                        if (message.SenderControlId == (int)Controls.HORZ_SCROLLBAR)
                        {
                            _needUpdate = true;
                            float fPercentage = (float)message.Param1;
                            fPercentage /= 100.0f;
                            fPercentage *= 24.0f;
                            fPercentage *= 60.0f;
                            _viewingTime = new DateTime(_viewingTime.Year, _viewingTime.Month, _viewingTime.Day, 0, 0, 0, 0);
                            _viewingTime = _viewingTime.AddMinutes((int)fPercentage);
                        }

                        if (message.SenderControlId == (int)Controls.VERT_SCROLLBAR)
                        {
                            _needUpdate = true;
                            float fPercentage = (float)message.Param1;
                            fPercentage /= 100.0f;
                            if (_singleChannelView)
                            {
                                fPercentage *= (float)_totalProgramCount;
                                int iChan = (int)fPercentage;
                                _channelOffset = 0;
                                _cursorX = 0;
                                while (iChan >= _channelCount)
                                {
                                    iChan -= _channelCount;
                                    _channelOffset += _channelCount;
                                }
                                _cursorX = iChan;
                            }
                            else
                            {
                                fPercentage *= (float)_channelList.Count;
                                int iChan = (int)fPercentage;
                                _channelOffset = 0;
                                _cursorX = 0;
                                while (iChan >= _channelCount)
                                {
                                    iChan -= _channelCount;
                                    _channelOffset += _channelCount;
                                }
                                _cursorX = iChan;
                            }
                        }
                        break;

                    case GUIMessage.MessageType.GUI_MSG_WINDOW_DEINIT:
                        {
                            base.OnMessage(message);
                            SaveSettings();
                            //_recordingList.Clear();

                            //_controls = new Dictionary<int, GUIButton3PartControl>();
                            _channelList = null;
                            _recordingList = null;
                            _currentProgram = null;

                            return true;
                        }

                    case GUIMessage.MessageType.GUI_MSG_WINDOW_INIT:
                        {
                            GUIPropertyManager.SetProperty("#itemcount", string.Empty);
                            GUIPropertyManager.SetProperty("#selecteditem", string.Empty);
                            GUIPropertyManager.SetProperty("#selecteditem2", string.Empty);
                            GUIPropertyManager.SetProperty("#selectedthumb", string.Empty);

                            if (_shouldRestore)
                            {
                                DoRestoreSkin();
                            }
                            else
                            {
                                LoadSkin();
                                AllocResources();
                            }

                            InitControls();

                            base.OnMessage(message);

                            string currentChannelName;
                            LoadSettings(out currentChannelName);

                            UpdateOverlayAllowed();
                            GUIGraphicsContext.Overlay = _isOverlayAllowed;

                            // set topbar autohide
                            switch (_autoHideTopbarType)
                            {
                                case AutoHideTopBar.No:
                                    _autoHideTopbar = false;
                                    break;
                                case AutoHideTopBar.Yes:
                                    _autoHideTopbar = true;
                                    break;
                                default:
                                    _autoHideTopbar = GUIGraphicsContext.DefaultTopBarHide;
                                    break;
                            }
                            GUIGraphicsContext.AutoHideTopBar = _autoHideTopbar;
                            GUIGraphicsContext.TopBarHidden = _autoHideTopbar;
                            GUIGraphicsContext.DisableTopBar = _disableTopBar;
                            LoadSettings();
                            GUIControl cntlPanel = GetControl((int)Controls.PANEL_BACKGROUND);
                            GUIImage cntlChannelTemplate = (GUIImage)GetControl((int)Controls.CHANNEL_TEMPLATE);

                            int iHeight = cntlPanel.Height + cntlPanel.YPosition - cntlChannelTemplate.YPosition;
                            int iItemHeight = cntlChannelTemplate.Height;
                            _channelCount = (int)(((float)iHeight) / ((float)iItemHeight));

                            bool isPreviousWindowTvGuideRelated = (message.Param1 == (int)Window.WINDOW_TV_PROGRAM_INFO ||
                                                     message.Param1 == (int)Window.WINDOW_VIDEO_INFO);

                            if (!isPreviousWindowTvGuideRelated)
                            {
                                UnFocus();
                            }

                            GetChannels(true);
                            LoadSchedules(true);
                            _currentProgram = null;
                            if (!isPreviousWindowTvGuideRelated)
                            {
                                _viewingTime = DateTime.Now;
                                _cursorY = 0;
                                _cursorX = 0;
                                _channelOffset = 0;
                                _singleChannelView = false;
                                _showChannelLogos = false;

                                _currentChannel = null;
                                int index = 0;
                                foreach (GuideBaseChannel channel in _channelList)
                                {
                                    if (channel.channel.DisplayName == currentChannelName)
                                    {
                                        _currentChannel = channel.channel;
                                        _cursorX = index;
                                        break;
                                    }
                                    index++;
                                }
                            }

                            while (_cursorX >= _channelCount)
                            {
                                _cursorX -= _channelCount;
                                _channelOffset += _channelCount;
                            }

                            // Mantis 3579: the above lines can lead to too large channeloffset. 
                            // Now we check if the offset is too large, and if it is, we reduce it and increase the cursor position accordingly
                            if (!_guideContinuousScroll && (_channelOffset > _channelList.Count - _channelCount) && (_channelList.Count - _channelCount > 0))
                            {
                                _cursorX += _channelOffset - (_channelList.Count - _channelCount);
                                _channelOffset = _channelList.Count - _channelCount;
                            }

                            GUISpinControl cntlDay = GetControl((int)Controls.SPINCONTROL_DAY) as GUISpinControl;
                            if (cntlDay != null)
                            {
                                DateTime dtNow = DateTime.Now;
                                cntlDay.Reset();
                                cntlDay.SetRange(0, MaxDaysInGuide - 1);
                                for (int iDay = 0; iDay < MaxDaysInGuide; iDay++)
                                {
                                    DateTime dtTemp = dtNow.AddDays(iDay);
                                    string day;
                                    switch (dtTemp.DayOfWeek)
                                    {
                                        case DayOfWeek.Monday:
                                            day = GUILocalizeStrings.Get(657);
                                            break;
                                        case DayOfWeek.Tuesday:
                                            day = GUILocalizeStrings.Get(658);
                                            break;
                                        case DayOfWeek.Wednesday:
                                            day = GUILocalizeStrings.Get(659);
                                            break;
                                        case DayOfWeek.Thursday:
                                            day = GUILocalizeStrings.Get(660);
                                            break;
                                        case DayOfWeek.Friday:
                                            day = GUILocalizeStrings.Get(661);
                                            break;
                                        case DayOfWeek.Saturday:
                                            day = GUILocalizeStrings.Get(662);
                                            break;
                                        default:
                                            day = GUILocalizeStrings.Get(663);
                                            break;
                                    }
                                    day = GetLocalDate(day, dtTemp.Day, dtTemp.Month);
                                    cntlDay.AddLabel(day, iDay);
                                }
                            }
                            else
                            {
                                Log.Debug("TvGuideBase: SpinControl cntlDay is null!");
                            }

                            GUISpinControl cntlTimeInterval = GetControl((int)Controls.SPINCONTROL_TIME_INTERVAL) as GUISpinControl;
                            if (cntlTimeInterval != null)
                            {
                                cntlTimeInterval.Reset();
                                for (int i = 1; i <= 4; i++)
                                {
                                    cntlTimeInterval.AddLabel(String.Empty, i);
                                }
                                cntlTimeInterval.Value = (_timePerBlock / 15) - 1;
                            }
                            else
                            {
                                Log.Debug("TvGuideBase: SpinControl cntlTimeInterval is null!");
                            }

                            if (!isPreviousWindowTvGuideRelated)
                            {
                                Update(true);
                            }
                            else
                            {
                                Update(false);
                            }

                            SetFocus();

                            if (_currentProgram != null)
                            {
                                m_dtStartTime = _currentProgram.StartTime;
                            }
                            UpdateCurrentProgram(false);

                            return true;
                        }
                    //break;

                    case GUIMessage.MessageType.GUI_MSG_CLICKED:
                        int iControl = message.SenderControlId;
                        if (iControl == (int)Controls.SPINCONTROL_DAY)
                        {
                            GUISpinControl cntlDay = GetControl((int)Controls.SPINCONTROL_DAY) as GUISpinControl;
                            int iDay = cntlDay.Value;

                            _viewingTime = DateTime.Now;
                            _viewingTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, _viewingTime.Hour,
                                                        _viewingTime.Minute, 0, 0);
                            _viewingTime = _viewingTime.AddDays(iDay);
                            _recalculateProgramOffset = true;
                            Update(false);
                            SetFocus();
                            return true;
                        }
                        if (iControl == (int)Controls.SPINCONTROL_TIME_INTERVAL)
                        {
                            GUISpinControl cntlTimeInt = GetControl((int)Controls.SPINCONTROL_TIME_INTERVAL) as GUISpinControl;
                            int iInterval = (cntlTimeInt.Value) + 1;
                            if (iInterval > 4)
                            {
                                iInterval = 4;
                            }
                            _timePerBlock = iInterval * 15;
                            Update(false);
                            SetFocus();
                            return true;
                        }
                        if (iControl == (int)Controls.CHANNEL_GROUP_BUTTON)
                        {
                            OnSelectChannelGroup();
                            return true;
                        }
                        if (iControl >= GUIDE_COMPONENTID_START)
                        {
                            if (OnSelectItem(true))
                            {
                                Update(false);
                                SetFocus();
                            }
                        }
                        else if (_cursorY == 0)
                        {
                            OnSwitchMode();
                        }
                        break;
                }
            }
            catch (Exception ex)
            {
                Log.Debug("TvGuideBase: {0}", ex);
            }
            return base.OnMessage(message);
        }
        private int CreateEpgChannelCells(Channel channel, int top)
        {
            DateTime startDate = EpgControl.GetEpgStartTime(_model);
            DateTime endDate = EpgControl.GetEpgEndTime(_model);

            int cellHeight = 0;

            int previousRight = 0;
            if (_model.ProgramsByChannel.ContainsKey(channel.ChannelId))
            {
                bool isTop = (top == 0);
                cellHeight = isTop ? _height : (_height - 1);

                foreach (GuideProgramSummary guideProgram in _model.ProgramsByChannel[channel.ChannelId].Programs)
                {
                    GuideProgramCell cell = new GuideProgramCell();
                    cell.GuideProgram = guideProgram;
                    cell.Channel = channel;
                    cell.IsTop = isTop;
                    cell.ClipLeft = (guideProgram.StartTime < startDate);
                    cell.ClipRight = (guideProgram.StopTime > endDate);
                    cell.StartTime = cell.ClipLeft ? startDate : guideProgram.StartTime;
                    cell.StopTime = cell.ClipRight ? endDate : guideProgram.StopTime;

                    TimeSpan leftSpan = cell.StartTime - startDate;
                    int left = (int)(leftSpan.TotalMinutes * 4 * _widthFactor);

                    if (left > previousRight)
                    {
                        GuideProgramCell emptyCell = new GuideProgramCell();
                        emptyCell.Rectangle = new Rectangle(previousRight, top, left - previousRight, cellHeight);
                        _guideProgramCells.Add(emptyCell);
                    }

                    cell.Rectangle = new Rectangle(left, top, (int)(cell.Duration.TotalMinutes * 4 * _widthFactor), cellHeight);
                    _guideProgramCells.Add(cell);

                    previousRight = cell.Rectangle.Right;
                }
            }
            if (previousRight < this.Width)
            {
                GuideProgramCell emptyCell = new GuideProgramCell();
                emptyCell.Rectangle = new Rectangle(previousRight, top, this.Width, cellHeight);
                _guideProgramCells.Add(emptyCell);
            }

            return top + cellHeight;
        }
 private static void EnsureGuideChannelForDvbEpg(SchedulerServiceAgent tvSchedulerAgent, GuideServiceAgent tvGuideAgent, Channel channel, TvDatabase.Channel mpChannel)
 {
     if (!channel.GuideChannelId.HasValue)
     {
         string externalId = mpChannel.ExternalId;
         if (String.IsNullOrEmpty(externalId))
         {
             externalId = mpChannel.DisplayName;
         }
         channel.GuideChannelId = tvGuideAgent.EnsureChannel(externalId, mpChannel.DisplayName, channel.ChannelType);
         tvSchedulerAgent.AttachChannelToGuide(channel.ChannelId, channel.GuideChannelId.Value);
     }
 }
Example #24
0
        private void Update(bool selectCurrentShow)
        {
            lock (this)
            {
                if (GUIWindowManager.ActiveWindowEx != this.GetID)
                {
                    return;
                }

                // sets button visible state
                UpdateGroupButton();

                _updateTimer = DateTime.Now;
                GUISpinControl cntlDay = GetControl((int)Controls.SPINCONTROL_DAY) as GUISpinControl;

                // Find first day in TVGuide and set spincontrol position
                int iDay = CalcDays();
                for (; iDay < 0; ++iDay)
                {
                    _viewingTime = _viewingTime.AddDays(1.0);
                }
                for (; iDay >= MaxDaysInGuide; --iDay)
                {
                    _viewingTime = _viewingTime.AddDays(-1.0);
                }
                cntlDay.Value = iDay;

                int xpos, ypos;
                GUIControl cntlPanel = GetControl((int)Controls.PANEL_BACKGROUND);
                GUIImage cntlChannelImg = (GUIImage)GetControl((int)Controls.CHANNEL_IMAGE_TEMPLATE);
                GUILabelControl cntlChannelLabel = (GUILabelControl)GetControl((int)Controls.CHANNEL_LABEL_TEMPLATE);
                GUILabelControl labelTime = (GUILabelControl)GetControl((int)Controls.LABEL_TIME1);
                GUIImage cntlHeaderBkgImg = (GUIImage)GetControl((int)Controls.IMG_TIME1);
                GUIImage cntlChannelTemplate = (GUIImage)GetControl((int)Controls.CHANNEL_TEMPLATE);


                _titleDarkTemplate = GetControl((int)Controls.LABEL_TITLE_DARK_TEMPLATE) as GUILabelControl;
                _titleTemplate = GetControl((int)Controls.LABEL_TITLE_TEMPLATE) as GUILabelControl;
                _genreDarkTemplate = GetControl((int)Controls.LABEL_GENRE_DARK_TEMPLATE) as GUILabelControl;
                _genreTemplate = GetControl((int)Controls.LABEL_GENRE_TEMPLATE) as GUILabelControl;

                _programPartialRecordTemplate = GetControl((int)Controls.BUTTON_PROGRAM_PARTIAL_RECORD) as GUIButton3PartControl;
                _programRecordTemplate = GetControl((int)Controls.BUTTON_PROGRAM_RECORD) as GUIButton3PartControl;
                _programNotifyTemplate = GetControl((int)Controls.BUTTON_PROGRAM_NOTIFY) as GUIButton3PartControl;
                _programNotRunningTemplate = GetControl((int)Controls.BUTTON_PROGRAM_NOT_RUNNING) as GUIButton3PartControl;
                _programRunningTemplate = GetControl((int)Controls.BUTTON_PROGRAM_RUNNING) as GUIButton3PartControl;

                _showChannelLogos = cntlChannelImg != null;
                if (_showChannelLogos)
                {
                    cntlChannelImg.IsVisible = false;
                }
                cntlChannelLabel.IsVisible = false;
                cntlHeaderBkgImg.IsVisible = false;
                labelTime.IsVisible = false;
                cntlChannelTemplate.IsVisible = false;
                int iLabelWidth = (cntlPanel.XPosition + cntlPanel.Width - labelTime.XPosition) / 4;

                // add labels for time blocks 1-4
                int iHour, iMin;
                iMin = _viewingTime.Minute;
                _viewingTime = _viewingTime.AddMinutes(-iMin);
                iMin = (iMin / _timePerBlock) * _timePerBlock;
                _viewingTime = _viewingTime.AddMinutes(iMin);

                DateTime dt = new DateTime();
                dt = _viewingTime;

                for (int iLabel = 0; iLabel < 4; iLabel++)
                {
                    xpos = iLabel * iLabelWidth + labelTime.XPosition;
                    ypos = labelTime.YPosition;

                    GUIImage img = GetControl((int)Controls.IMG_TIME1 + iLabel) as GUIImage;
                    if (img == null)
                    {
                        img = new GUIImage(GetID, (int)Controls.IMG_TIME1 + iLabel, xpos, ypos, iLabelWidth - 4,
                                           cntlHeaderBkgImg.RenderHeight, cntlHeaderBkgImg.FileName, 0x0);
                        img.AllocResources();
                        GUIControl cntl2 = (GUIControl)img;
                        Add(ref cntl2);
                    }

                    img.IsVisible = !_singleChannelView;
                    img.Width = iLabelWidth - 4;
                    img.Height = cntlHeaderBkgImg.RenderHeight;
                    img.SetFileName(cntlHeaderBkgImg.FileName);
                    img.SetPosition(xpos, ypos);
                    img.DoUpdate();

                    GUILabelControl label = GetControl((int)Controls.LABEL_TIME1 + iLabel) as GUILabelControl;
                    if (label == null)
                    {
                        label = new GUILabelControl(GetID, (int)Controls.LABEL_TIME1 + iLabel, xpos, ypos, iLabelWidth,
                                                    cntlHeaderBkgImg.RenderHeight, labelTime.FontName, String.Empty,
                                                    labelTime.TextColor, GuideBase.TimeAlignment, labelTime.TextVAlignment, false,
                                                    labelTime.ShadowAngle, labelTime.ShadowDistance, labelTime.ShadowColor);
                        label.AllocResources();
                        GUIControl cntl = (GUIControl)label;
                        this.Add(ref cntl);
                    }
                    iHour = dt.Hour;
                    iMin = dt.Minute;
                    string strTime = dt.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat);
                    label.Label = " " + strTime;
                    dt = dt.AddMinutes(_timePerBlock);

                    label.TextAlignment = GuideBase.TimeAlignment;
                    label.IsVisible = !_singleChannelView;
                    label.Width = iLabelWidth;
                    label.Height = cntlHeaderBkgImg.RenderHeight;
                    label.FontName = labelTime.FontName;
                    label.TextColor = labelTime.TextColor;
                    label.SetPosition(xpos, ypos);
                }

                // add channels...
                int iHeight = cntlPanel.Height + cntlPanel.YPosition - cntlChannelTemplate.YPosition;
                int iItemHeight = cntlChannelTemplate.Height;

                _channelCount = (int)(((float)iHeight) / ((float)iItemHeight));
                for (int iChan = 0; iChan < _channelCount; ++iChan)
                {
                    xpos = cntlChannelTemplate.XPosition;
                    ypos = cntlChannelTemplate.YPosition + iChan * iItemHeight;

                    //this.Remove((int)Controls.IMG_CHAN1+iChan);
                    GUIButton3PartControl imgBut = GetControl((int)Controls.IMG_CHAN1 + iChan) as GUIButton3PartControl;
                    if (imgBut == null)
                    {
                        string strChannelImageFileName = String.Empty;
                        if (_showChannelLogos)
                        {
                            strChannelImageFileName = cntlChannelImg.FileName;
                        }

                        // Use a template control if it exists, otherwise use default values.
                        GUIButton3PartControl buttonTemplate = GetControl((int)Controls.BUTTON_PROGRAM_NOT_RUNNING) as GUIButton3PartControl;
                        if (buttonTemplate != null)
                        {
                            buttonTemplate.IsVisible = false;
                            imgBut = new GUIButton3PartControl(GetID, (int)Controls.IMG_CHAN1 + iChan, xpos, ypos,
                                                               cntlChannelTemplate.Width - 2, cntlChannelTemplate.Height - 2,
                                                               buttonTemplate.TexutureFocusLeftName,
                                                               buttonTemplate.TexutureFocusMidName,
                                                               buttonTemplate.TexutureFocusRightName,
                                                               buttonTemplate.TexutureNoFocusLeftName,
                                                               buttonTemplate.TexutureNoFocusMidName,
                                                               buttonTemplate.TexutureNoFocusRightName,
                                                               strChannelImageFileName);

                            imgBut.TileFillTFL = buttonTemplate.TileFillTFL;
                            imgBut.TileFillTNFL = buttonTemplate.TileFillTNFL;
                            imgBut.TileFillTFM = buttonTemplate.TileFillTFM;
                            imgBut.TileFillTNFM = buttonTemplate.TileFillTNFM;
                            imgBut.TileFillTFR = buttonTemplate.TileFillTFR;
                            imgBut.TileFillTNFR = buttonTemplate.TileFillTNFR;
                        }
                        else
                        {
                            imgBut = new GUIButton3PartControl(GetID, (int)Controls.IMG_CHAN1 + iChan, xpos, ypos,
                                                               cntlChannelTemplate.Width - 2, cntlChannelTemplate.Height - 2,
                                                               "tvguide_button_selected_left.png",
                                                               "tvguide_button_selected_middle.png",
                                                               "tvguide_button_selected_right.png",
                                                               "tvguide_button_light_left.png",
                                                               "tvguide_button_light_middle.png",
                                                               "tvguide_button_light_right.png",
                                                               strChannelImageFileName);
                        }
                        imgBut.AllocResources();
                        GUIControl cntl = (GUIControl)imgBut;
                        Add(ref cntl);
                    }

                    imgBut.Width = cntlChannelTemplate.Width - 2; //labelTime.XPosition-cntlChannelImg.XPosition;
                    imgBut.Height = cntlChannelTemplate.Height - 2; //iItemHeight-2;
                    imgBut.SetPosition(xpos, ypos);
                    imgBut.FontName1 = cntlChannelLabel.FontName;
                    imgBut.TextColor1 = cntlChannelLabel.TextColor;
                    imgBut.Label1 = String.Empty;
                    imgBut.RenderLeft = false;
                    imgBut.RenderRight = false;
                    imgBut.SetShadow1(cntlChannelLabel.ShadowAngle, cntlChannelLabel.ShadowDistance, cntlChannelLabel.ShadowColor);

                    if (_showChannelLogos)
                    {
                        imgBut.TexutureIcon = cntlChannelImg.FileName;
                        imgBut.IconOffsetX = cntlChannelImg.XPosition;
                        imgBut.IconOffsetY = cntlChannelImg.YPosition;
                        imgBut.IconWidth = cntlChannelImg.RenderWidth;
                        imgBut.IconHeight = cntlChannelImg.RenderHeight;
                        imgBut.IconKeepAspectRatio = cntlChannelImg.KeepAspectRatio;
                        imgBut.IconCentered = cntlChannelImg.Centered;
                        imgBut.IconZoom = cntlChannelImg.Zoom;
                    }
                    imgBut.TextOffsetX1 = cntlChannelLabel.XPosition;
                    imgBut.TextOffsetY1 = cntlChannelLabel.YPosition;
                    imgBut.ColourDiffuse = 0xffffffff;
                    imgBut.DoUpdate();
                }

                UpdateHorizontalScrollbar();
                UpdateVerticalScrollbar();

                GetChannels(false);


                string day;
                switch (_viewingTime.DayOfWeek)
                {
                    case DayOfWeek.Monday:
                        day = GUILocalizeStrings.Get(657);
                        break;
                    case DayOfWeek.Tuesday:
                        day = GUILocalizeStrings.Get(658);
                        break;
                    case DayOfWeek.Wednesday:
                        day = GUILocalizeStrings.Get(659);
                        break;
                    case DayOfWeek.Thursday:
                        day = GUILocalizeStrings.Get(660);
                        break;
                    case DayOfWeek.Friday:
                        day = GUILocalizeStrings.Get(661);
                        break;
                    case DayOfWeek.Saturday:
                        day = GUILocalizeStrings.Get(662);
                        break;
                    default:
                        day = GUILocalizeStrings.Get(663);
                        break;
                }
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.View.SDOW", day);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.View.Month", _viewingTime.Month.ToString());
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.View.Day", _viewingTime.Day.ToString());

                //day = String.Format("{0} {1}-{2}", day, _viewingTime.Day, _viewingTime.Month);
                day = Utils.GetShortDayString(_viewingTime);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Day", day);

                //2004 03 31 22 20 00
                string strStart = String.Format("{0}{1:00}{2:00}{3:00}{4:00}{5:00}",
                                                _viewingTime.Year, _viewingTime.Month, _viewingTime.Day,
                                                _viewingTime.Hour, _viewingTime.Minute, 0);
                DateTime dtStop = new DateTime();
                dtStop = _viewingTime;
                dtStop = dtStop.AddMinutes(_numberOfBlocks * _timePerBlock - 1);
                iMin = dtStop.Minute;
                string strEnd = String.Format("{0}{1:00}{2:00}{3:00}{4:00}{5:00}",
                                              dtStop.Year, dtStop.Month, dtStop.Day,
                                              dtStop.Hour, iMin, 0);

                long iStart = Int64.Parse(strStart);
                long iEnd = Int64.Parse(strEnd);


                LoadSchedules(false);

                if (_channelOffset > _channelList.Count)
                {
                    _channelOffset = 0;
                    _cursorX = 0;
                }

                for (int i = 0; i < controlList.Count; ++i)
                {
                    GUIControl cntl = (GUIControl)controlList[i];
                    if (cntl.GetID >= GUIDE_COMPONENTID_START)
                    {
                        cntl.IsVisible = false;
                    }
                }

                if (_singleChannelView)
                {
                    // show all buttons (could be less visible if channels < rows)
                    for (int iChannel = 0; iChannel < _channelCount; iChannel++)
                    {
                        GUIButton3PartControl imgBut = GetControl((int)Controls.IMG_CHAN1 + iChannel) as GUIButton3PartControl;
                        if (imgBut != null)
                            imgBut.IsVisible = true;
                    }

                    Channel channel = (Channel)_channelList[_singleChannelNumber].channel;
                    setGuideHeadingVisibility(false);
                    RenderSingleChannel(channel);
                }
                else
                {
                    List<Channel> visibleChannels = new List<Channel>();

                    int chan = _channelOffset;
                    for (int iChannel = 0; iChannel < _channelCount; iChannel++)
                    {
                        if (chan < _channelList.Count)
                        {
                            visibleChannels.Add(_channelList[chan].channel);
                        }
                        chan++;
                        if (chan >= _channelList.Count && visibleChannels.Count < _channelList.Count)
                        {
                            chan = 0;
                        }
                    }

                    _controller.RefreshChannelsEpgData(visibleChannels, Utils.longtodate(iStart), Utils.longtodate(iEnd));

                    // make sure the TV Guide heading is visiable and the single channel labels are not.
                    setGuideHeadingVisibility(true);
                    SetSingleChannelLabelVisibility(false);
                    chan = _channelOffset;

                    int firstButtonYPos = 0;
                    int lastButtonYPos = 0;

                    for (int iChannel = 0; iChannel < _channelCount; iChannel++)
                    {
                        if (chan < _channelList.Count)
                        {
                            GuideBaseChannel tvGuideChannel = _channelList[chan];
                            RenderChannel(iChannel, tvGuideChannel, iStart, iEnd, selectCurrentShow);
                            // remember bottom y position from last visible button
                            GUIButton3PartControl imgBut = GetControl((int)Controls.IMG_CHAN1 + iChannel) as GUIButton3PartControl;
                            if (imgBut != null)
                            {
                                if (iChannel == 0)
                                    firstButtonYPos = imgBut.YPosition;

                                lastButtonYPos = imgBut.YPosition + imgBut.Height;
                            }
                        }
                        chan++;
                        if (chan >= _channelList.Count && _channelList.Count > _channelCount)
                        {
                            chan = 0;
                        }
                        if (chan > _channelList.Count)
                        {
                            GUIButton3PartControl imgBut = GetControl((int)Controls.IMG_CHAN1 + iChannel) as GUIButton3PartControl;
                            if (imgBut != null)
                            {
                                imgBut.IsVisible = false;
                            }
                        }
                    }

                    GUIImage vertLine = GetControl((int)Controls.VERTICAL_LINE) as GUIImage;
                    if (vertLine != null)
                    {
                        // height taken from last button (bottom) minus the yposition of slider plus the offset of slider in relation to first button
                        vertLine.Height = lastButtonYPos - vertLine.YPosition + (firstButtonYPos - vertLine.YPosition);
                    }
                    // update selected channel
                    _singleChannelNumber = _cursorX + _channelOffset;
                    if (_singleChannelNumber >= _channelList.Count)
                    {
                        _singleChannelNumber -= _channelList.Count;
                    }

                    // instead of direct casting us "as"; else it fails for other controls!
                    GUIButton3PartControl img = GetControl(_cursorX + (int)Controls.IMG_CHAN1) as GUIButton3PartControl;
                    if (null != img)
                    {
                        _currentChannel = (Channel)img.Data;
                    }
                }
                UpdateVerticalScrollbar();
            }
        }
Example #25
0
 public LinkedChannelItem(Channel channel, string message, Color rowColor)
 {
     _channel = channel;
     _message = message;
     _rowColor = rowColor;
 }
Example #26
0
 private string GetChannelLogo(Channel channel)
 {
     string logoImagePath = Utility.GetLogoImage(channel);
     if (!System.IO.File.Exists(logoImagePath))
     {
         logoImagePath = "defaultVideoBig.png";
     }
     return logoImagePath;
 }
Example #27
0
 public IProgramSummary GetProgramAt(int number, out Channel channel)
 {
     Guid? upcomingProgramId;
     return GetProgramAt(number, out channel, out upcomingProgramId);
 }
Example #28
0
        private void SetProperties()
        {
            if (_channelList == null)
            {
                return;
            }
            if (_channelList.Count == 0)
            {
                return;
            }
            int channel = _cursorX + _channelOffset;
            while (channel >= _channelList.Count)
            {
                channel -= _channelList.Count;
            }
            if (channel < 0)
            {
                channel = 0;
            }
            Channel chan = (Channel)_channelList[channel].channel;
            if (chan == null)
            {
                return;
            }
            string strChannel = chan.DisplayName;

            if (!_singleChannelView)
            {
                string strLogo = GetChannelLogo(chan);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.thumb", strLogo);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.ChannelName", strChannel);
                string channelNumber = String.Empty;
                if (_showChannelNumber
                    && chan.LogicalChannelNumber.HasValue)
                {
                    channelNumber = chan.LogicalChannelNumber.Value.ToString();
                    GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.ChannelNumber", channelNumber);
                }
                else
                {
                    GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.ChannelNumber", String.Empty);
                }
            }

            if (_cursorY == 0 || _currentProgram == null)
            {
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Title", String.Empty);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.CompositeTitle", String.Empty);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Time", String.Empty);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Description", String.Empty);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Genre", String.Empty);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.SubTitle", String.Empty);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Episode", String.Empty);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.EpisodeDetail", String.Empty);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Date", String.Empty);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.StarRating", String.Empty);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Classification", String.Empty);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Duration", String.Empty);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.DurationMins", String.Empty);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.TimeFromNow", String.Empty);

                _currentStartTime = 0;
                _currentEndTime = 0;
                _currentTitle = String.Empty;
                _currentTime = String.Empty;
                _currentChannel = chan;
                GUIControl.HideControl(GetID, (int)Controls.IMG_REC_PIN);
            }
            else if (_currentProgram != null)
            {
                string strTime = String.Format("{0}-{1}",
                                               _currentProgram.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat),
                                               _currentProgram.StopTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));

                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Title", _currentProgram.Title);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.CompositeTitle", _currentProgram.Title);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Time", strTime);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Description", _currentProgram.CreateCombinedDescription(true));
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Genre", _currentProgram.Category);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Duration", GetDuration(_currentProgram));
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.DurationMins", GetDurationAsMinutes(_currentProgram));
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.TimeFromNow", GetStartTimeFromNow(_currentProgram));
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Episode", _currentProgram.EpisodeNumberDisplay);
                GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.SubTitle", _currentProgram.SubTitle);

                if (String.IsNullOrEmpty(_currentProgram.Rating))
                {
                    GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Classification", "No Rating");
                }
                else
                {
                    GUIPropertyManager.SetProperty(SkinPropertyPrefix + ".Guide.Classification", _currentProgram.Rating);
                }

                _currentStartTime = Utils.datetolong(_currentProgram.StartTime);
                _currentEndTime = Utils.datetolong(_currentProgram.StopTime);
                _currentTitle = _currentProgram.Title;
                _currentTime = strTime;
                _currentChannel = chan;

                string recordIconImage = GetChannelProgramIcon(chan, _currentProgram.GuideProgramId);
                if (String.IsNullOrEmpty(recordIconImage))
                {
                    GUIControl.HideControl(GetID, (int)Controls.IMG_REC_PIN);
                }
                else
                {
                    GUIImage img = (GUIImage)GetControl((int)Controls.IMG_REC_PIN);
                    img.SetFileName(recordIconImage);
                    GUIControl.ShowControl(GetID, (int)Controls.IMG_REC_PIN);
                }
            }

            _currentRecOrNotify = _currentProgram != null && PluginMain.IsActiveRecording(_currentChannel.ChannelId, _currentProgram);
        }
Example #29
0
        private void SetCellIcon(DataGridViewRow row, int columnIndex, Channel channel, Guid? upcomingProgramId)
        {
            Icon icon = Properties.Resources.TransparentIcon;
            string toolTip = null;
            if (upcomingProgramId.HasValue
                && _allUpcomingGuidePrograms.ContainsKey(upcomingProgramId.Value))
            {
                GuideUpcomingProgram programInfo = _allUpcomingGuidePrograms[upcomingProgramId.Value];

                ProgramIconUtility.GetIconAndToolTip(programInfo.Type, programInfo.CancellationReason, programInfo.IsPartOfSeries,
                    _allUpcomingGuidePrograms.UpcomingRecordings, programInfo.UpcomingRecording, out icon, out toolTip);
            }
            row.Cells[columnIndex].Value = icon;
            row.Cells[columnIndex].ToolTipText = toolTip;
        }
Example #30
0
        private void RenderSingleChannel(Channel channel)
        {
            string strLogo;
            int chan = _channelOffset;
            for (int iChannel = 0; iChannel < _channelCount; iChannel++)
            {
                if (chan < _channelList.Count)
                {
                    Channel tvChan = _channelList[chan].channel;

                    strLogo = GetChannelLogo(tvChan);
                    GUIButton3PartControl img = GetControl(iChannel + (int)Controls.IMG_CHAN1) as GUIButton3PartControl;
                    if (img != null)
                    {
                        if (_showChannelLogos)
                        {
                            img.TexutureIcon = strLogo;
                        }
                        img.Label1 = tvChan.DisplayName;
                        img.Data = tvChan;
                        img.IsVisible = true;
                    }
                }
                chan++;
            }

            List<GuideProgramSummary> programs = new List<GuideProgramSummary>();
            DateTime dtStart = DateTime.Now;
            dtStart = dtStart.AddDays(-1);
            DateTime dtEnd = dtStart.AddDays(30);
            long iStart = Utils.datetolong(dtStart);
            long iEnd = Utils.datetolong(dtEnd);

            if (channel.GuideChannelId.HasValue)
            {
                programs = new List<GuideProgramSummary>(
                    Proxies.GuideService.GetChannelProgramsBetween(channel.GuideChannelId.Value, Utils.longtodate(iStart), Utils.longtodate(iEnd)).Result);
            }

            _totalProgramCount = programs.Count;
            if (_totalProgramCount == 0)
            {
                _totalProgramCount = _channelCount;
            }

            GUILabelControl channelLabel = GetControl((int)Controls.SINGLE_CHANNEL_LABEL) as GUILabelControl;
            GUIImage channelImage = GetControl((int)Controls.SINGLE_CHANNEL_IMAGE) as GUIImage;

            strLogo = GetChannelLogo(channel);
            if (channelImage == null)
            {
                if (strLogo.Length > 0)
                {
                    channelImage = new GUIImage(GetID, (int)Controls.SINGLE_CHANNEL_IMAGE,
                                                GetControl((int)Controls.LABEL_TIME1).XPosition,
                                                GetControl((int)Controls.LABEL_TIME1).YPosition - 15,
                                                40, 40, strLogo, Color.White);
                    channelImage.AllocResources();
                    GUIControl temp = (GUIControl)channelImage;
                    Add(ref temp);
                }
            }
            else
            {
                channelImage.SetFileName(strLogo);
            }

            if (channelLabel == null)
            {
                channelLabel = new GUILabelControl(GetID, (int)Controls.SINGLE_CHANNEL_LABEL,
                                                   channelImage.XPosition + 44,
                                                   channelImage.YPosition + 10,
                                                   300, 40, "font16", channel.DisplayName, 4294967295, GUIControl.Alignment.Left,
                                                   GUIControl.VAlignment.Top,
                                                   true, 0, 0, 0xFF000000);
                channelLabel.AllocResources();
                GUIControl temp = channelLabel;
                Add(ref temp);
            }

            SetSingleChannelLabelVisibility(true);

            channelLabel.Label = channel.DisplayName;
            if (strLogo.Length > 0)
            {
                channelImage.SetFileName(strLogo);
            }

            if (channelLabel != null)
            {
                channelLabel.Label = channel.DisplayName;
            }
            if (_recalculateProgramOffset)
            {
                _recalculateProgramOffset = false;
                bool found = false;
                for (int i = 0; i < programs.Count; i++)
                {
                    GuideProgramSummary program = programs[i];
                    if (program.StartTime <= _viewingTime && program.StopTime >= _viewingTime)
                    {
                        _programOffset = i;
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    _programOffset = 0;
                }
            }
            else if (_programOffset < programs.Count)
            {
                int day = programs[_programOffset].StartTime.DayOfYear;
                bool changed = false;
                while (day > _viewingTime.DayOfYear)
                {
                    _viewingTime = _viewingTime.AddDays(1.0);
                    changed = true;
                }
                while (day < _viewingTime.DayOfYear)
                {
                    _viewingTime = _viewingTime.AddDays(-1.0);
                    changed = true;
                }
                if (changed)
                {
                    GUISpinControl cntlDay = GetControl((int)Controls.SPINCONTROL_DAY) as GUISpinControl;

                    // Find first day in TVGuide and set spincontrol position
                    int iDay = CalcDays();
                    for (; iDay < 0; ++iDay)
                    {
                        _viewingTime = _viewingTime.AddDays(1.0);
                    }
                    for (; iDay >= MaxDaysInGuide; --iDay)
                    {
                        _viewingTime = _viewingTime.AddDays(-1.0);
                    }
                    cntlDay.Value = iDay;
                }
            }
            // ichan = number of rows
            for (int ichan = 0; ichan < _channelCount; ++ichan)
            {
                GUIButton3PartControl imgCh = GetControl(ichan + (int)Controls.IMG_CHAN1) as GUIButton3PartControl;
                imgCh.TexutureIcon = "";

                int iStartXPos = GetControl(0 + (int)Controls.LABEL_TIME1).XPosition;
                int height = GetControl((int)Controls.IMG_CHAN1 + 1).YPosition;
                height -= GetControl((int)Controls.IMG_CHAN1).YPosition;
                int width = GetControl((int)Controls.LABEL_TIME1 + 1).XPosition;
                width -= GetControl((int)Controls.LABEL_TIME1).XPosition;

                int iTotalWidth = width * _numberOfBlocks;

                GuideProgramSummary program;
                int offset = _programOffset;
                if (offset + ichan < programs.Count)
                {
                    program = programs[offset + ichan];
                }
                else
                {
                    // bugfix for 0 items
                    if (programs.Count == 0)
                    {
                        program = new GuideProgramSummary()
                        {
                            StartTime = _viewingTime,
                            StopTime = _viewingTime,
                            StartTimeUtc = _viewingTime.ToUniversalTime(),
                            StopTimeUtc = _viewingTime.ToUniversalTime(),
                            Title = String.Empty,
                            Category = String.Empty
                        };
                    }
                    else
                    {
                        program = programs[programs.Count - 1];
                        if (program.StopTime.DayOfYear == _viewingTime.DayOfYear)
                        {
                            program = new GuideProgramSummary()
                            {
                                StartTime = program.StopTime,
                                StopTime = program.StopTime,
                                StartTimeUtc = program.StartTimeUtc,
                                StopTimeUtc = program.StopTimeUtc,
                                Title = String.Empty,
                                Category = String.Empty
                            };
                        }
                        else
                        {
                            program = new GuideProgramSummary()
                            {
                                StartTime = _viewingTime,
                                StopTime = _viewingTime,
                                StartTimeUtc = _viewingTime.ToUniversalTime(),
                                StopTimeUtc = _viewingTime.ToUniversalTime(),
                                Title = String.Empty,
                                Category = String.Empty
                            };
                        }
                    }
                }

                int ypos = GetControl(ichan + (int)Controls.IMG_CHAN1).YPosition;
                int iControlId = GUIDE_COMPONENTID_START + ichan * RowID + 0 * ColID;
                GUIButton3PartControl img = GetControl(iControlId) as GUIButton3PartControl;
                GUIButton3PartControl buttonTemplate = GetControl((int)Controls.BUTTON_PROGRAM_NOT_RUNNING) as GUIButton3PartControl;

                if (img == null)
                {
                    if (buttonTemplate != null)
                    {
                        buttonTemplate.IsVisible = false;
                        img = new GUIButton3PartControl(GetID, iControlId, iStartXPos, ypos, iTotalWidth, height - 2,
                                                        buttonTemplate.TexutureFocusLeftName,
                                                        buttonTemplate.TexutureFocusMidName,
                                                        buttonTemplate.TexutureFocusRightName,
                                                        buttonTemplate.TexutureNoFocusLeftName,
                                                        buttonTemplate.TexutureNoFocusMidName,
                                                        buttonTemplate.TexutureNoFocusRightName,
                                                        String.Empty);

                        img.TileFillTFL = buttonTemplate.TileFillTFL;
                        img.TileFillTNFL = buttonTemplate.TileFillTNFL;
                        img.TileFillTFM = buttonTemplate.TileFillTFM;
                        img.TileFillTNFM = buttonTemplate.TileFillTNFM;
                        img.TileFillTFR = buttonTemplate.TileFillTFR;
                        img.TileFillTNFR = buttonTemplate.TileFillTNFR;
                    }
                    else
                    {
                        img = new GUIButton3PartControl(GetID, iControlId, iStartXPos, ypos, iTotalWidth, height - 2,
                                                        "tvguide_button_selected_left.png",
                                                        "tvguide_button_selected_middle.png",
                                                        "tvguide_button_selected_right.png",
                                                        "tvguide_button_light_left.png",
                                                        "tvguide_button_light_middle.png",
                                                        "tvguide_button_light_right.png",
                                                        String.Empty);
                    }
                    img.AllocResources();
                    img.ColourDiffuse = GetColorForGenre(program.Category);
                    GUIControl cntl = (GUIControl)img;
                    Add(ref cntl);
                }
                else
                {
                    if (buttonTemplate != null)
                    {
                        buttonTemplate.IsVisible = false;
                        img.TexutureFocusLeftName = buttonTemplate.TexutureFocusLeftName;
                        img.TexutureFocusMidName = buttonTemplate.TexutureFocusMidName;
                        img.TexutureFocusRightName = buttonTemplate.TexutureFocusRightName;
                        img.TexutureNoFocusLeftName = buttonTemplate.TexutureNoFocusLeftName;
                        img.TexutureNoFocusMidName = buttonTemplate.TexutureNoFocusMidName;
                        img.TexutureNoFocusRightName = buttonTemplate.TexutureNoFocusRightName;
                        img.TileFillTFL = buttonTemplate.TileFillTFL;
                        img.TileFillTNFL = buttonTemplate.TileFillTNFL;
                        img.TileFillTFM = buttonTemplate.TileFillTFM;
                        img.TileFillTNFM = buttonTemplate.TileFillTNFM;
                        img.TileFillTFR = buttonTemplate.TileFillTFR;
                        img.TileFillTNFR = buttonTemplate.TileFillTNFR;
                    }
                    else
                    {
                        img.TexutureFocusLeftName = "tvguide_button_selected_left.png";
                        img.TexutureFocusMidName = "tvguide_button_selected_middle.png";
                        img.TexutureFocusRightName = "tvguide_button_selected_right.png";
                        img.TexutureNoFocusLeftName = "tvguide_button_light_left.png";
                        img.TexutureNoFocusMidName = "tvguide_button_light_middle.png";
                        img.TexutureNoFocusRightName = "tvguide_button_light_right.png";
                    }
                    img.Focus = false;
                    img.SetPosition(iStartXPos, ypos);
                    img.Width = iTotalWidth;
                    img.ColourDiffuse = GetColorForGenre(program.Category);
                    img.IsVisible = true;
                    img.DoUpdate();
                }
                img.RenderLeft = false;
                img.RenderRight = false;

                bool isRecording;
                bool isAlert;
                string recordIconImage = GetChannelProgramIcon(channel, program.GuideProgramId, out isRecording,out isAlert);

                img.Data = program;
                img.ColourDiffuse = GetColorForGenre(program.Category);
                height = height - 10;
                height /= 2;
                int iWidth = iTotalWidth;
                if (iWidth > 10)
                {
                    iWidth -= 10;
                }
                else
                {
                    iWidth = 1;
                }

                DateTime dt = DateTime.Now;

                img.TextOffsetX1 = 5;
                img.TextOffsetY1 = 5;
                img.FontName1 = "font13";
                img.TextColor1 = 0xffffffff;

                img.Label1 = program.CreateProgramTitle();

                string strTimeSingle = String.Format("{0}",
                                                     program.StartTime.ToString("t", CultureInfo.CurrentCulture.DateTimeFormat));

                if (program.StartTime.DayOfYear != _viewingTime.DayOfYear)
                {
                    img.Label1 = String.Format("{0} {1}", Utility.GetShortDayDateString(program.StartTime), program.CreateProgramTitle());
                }

                GUILabelControl labelTemplate;
                if (IsRunningAt(program, dt))
                {
                    labelTemplate = _titleDarkTemplate;
                }
                else
                {
                    labelTemplate = _titleTemplate;
                }

                if (labelTemplate != null)
                {
                    img.FontName1 = labelTemplate.FontName;
                    img.TextColor1 = labelTemplate.TextColor;
                    img.TextOffsetX1 = labelTemplate.XPosition;
                    img.TextOffsetY1 = labelTemplate.YPosition;
                    img.SetShadow1(labelTemplate.ShadowAngle, labelTemplate.ShadowDistance, labelTemplate.ShadowColor);
                }
                img.TextOffsetX2 = 5;
                img.TextOffsetY2 = img.Height / 2;
                img.FontName2 = "font13";
                img.TextColor2 = 0xffffffff;
                img.Label2 = "";
                if (IsRunningAt(program, dt))
                {
                    img.TextColor2 = 0xff101010;
                    labelTemplate = _genreDarkTemplate;
                }
                else
                {
                    labelTemplate = _genreTemplate;
                }

                if (labelTemplate != null)
                {
                    img.FontName2 = labelTemplate.FontName;
                    img.TextColor2 = labelTemplate.TextColor;
                    img.Label2 = program.Category;
                    img.TextOffsetX2 = labelTemplate.XPosition;
                    img.TextOffsetY2 = labelTemplate.YPosition;
                    img.SetShadow2(labelTemplate.ShadowAngle, labelTemplate.ShadowDistance, labelTemplate.ShadowColor);
                }
                imgCh.Label1 = strTimeSingle;
                imgCh.TexutureIcon = "";

                if (IsRunningAt(program, dt))
                {
                    GUIButton3PartControl buttonRunningTemplate = _programRunningTemplate;
                    if (buttonRunningTemplate != null)
                    {
                        buttonRunningTemplate.IsVisible = false;
                        img.TexutureFocusLeftName = buttonRunningTemplate.TexutureFocusLeftName;
                        img.TexutureFocusMidName = buttonRunningTemplate.TexutureFocusMidName;
                        img.TexutureFocusRightName = buttonRunningTemplate.TexutureFocusRightName;
                        img.TexutureNoFocusLeftName = buttonRunningTemplate.TexutureNoFocusLeftName;
                        img.TexutureNoFocusMidName = buttonRunningTemplate.TexutureNoFocusMidName;
                        img.TexutureNoFocusRightName = buttonRunningTemplate.TexutureNoFocusRightName;
                        img.TileFillTFL = buttonRunningTemplate.TileFillTFL;
                        img.TileFillTNFL = buttonRunningTemplate.TileFillTNFL;
                        img.TileFillTFM = buttonRunningTemplate.TileFillTFM;
                        img.TileFillTNFM = buttonRunningTemplate.TileFillTNFM;
                        img.TileFillTFR = buttonRunningTemplate.TileFillTFR;
                        img.TileFillTNFR = buttonRunningTemplate.TileFillTNFR;
                    }
                    else
                    {
                        img.TexutureFocusLeftName = "tvguide_button_selected_left.png";
                        img.TexutureFocusMidName = "tvguide_button_selected_middle.png";
                        img.TexutureFocusRightName = "tvguide_button_selected_right.png";
                        img.TexutureNoFocusLeftName = "tvguide_button_left.png";
                        img.TexutureNoFocusMidName = "tvguide_button_middle.png";
                        img.TexutureNoFocusRightName = "tvguide_button_right.png";
                    }
                }

                img.SetPosition(img.XPosition, img.YPosition);

                img.TexutureIcon = String.Empty;

                if (recordIconImage != null && isAlert)
                {
                    GUIButton3PartControl buttonNotifyTemplate = GetControl((int)Controls.BUTTON_PROGRAM_NOTIFY) as GUIButton3PartControl;
                    if (buttonNotifyTemplate != null)
                    {
                        buttonNotifyTemplate.IsVisible = false;
                        img.TexutureFocusLeftName = buttonNotifyTemplate.TexutureFocusLeftName;
                        img.TexutureFocusMidName = buttonNotifyTemplate.TexutureFocusMidName;
                        img.TexutureFocusRightName = buttonNotifyTemplate.TexutureFocusRightName;
                        img.TexutureNoFocusLeftName = buttonNotifyTemplate.TexutureNoFocusLeftName;
                        img.TexutureNoFocusMidName = buttonNotifyTemplate.TexutureNoFocusMidName;
                        img.TexutureNoFocusRightName = buttonNotifyTemplate.TexutureNoFocusRightName;
                        img.TileFillTFL = buttonNotifyTemplate.TileFillTFL;
                        img.TileFillTNFL = buttonNotifyTemplate.TileFillTNFL;
                        img.TileFillTFM = buttonNotifyTemplate.TileFillTFM;
                        img.TileFillTNFM = buttonNotifyTemplate.TileFillTNFM;
                        img.TileFillTFR = buttonNotifyTemplate.TileFillTFR;
                        img.TileFillTNFR = buttonNotifyTemplate.TileFillTNFR;

                        // Use of the button template control implies use of the icon.  Use a blank image if the icon is not desired.
                        img.TexutureIcon = Thumbs.TvNotifyIcon;
                        img.IconOffsetX = buttonNotifyTemplate.IconOffsetX;
                        img.IconOffsetY = buttonNotifyTemplate.IconOffsetY;
                        img.IconAlign = buttonNotifyTemplate.IconAlign;
                        img.IconVAlign = buttonNotifyTemplate.IconVAlign;
                        img.IconInlineLabel1 = buttonNotifyTemplate.IconInlineLabel1;
                    }
                    else
                    {
                        if (_useNewNotifyButtonColor)
                        {
                            img.TexutureFocusLeftName = "tvguide_notifyButton_Focus_left.png";
                            img.TexutureFocusMidName = "tvguide_notifyButton_Focus_middle.png";
                            img.TexutureFocusRightName = "tvguide_notifyButton_Focus_right.png";
                            img.TexutureNoFocusLeftName = "tvguide_notifyButton_noFocus_left.png";
                            img.TexutureNoFocusMidName = "tvguide_notifyButton_noFocus_middle.png";
                            img.TexutureNoFocusRightName = "tvguide_notifyButton_noFocus_right.png";
                        }
                        else
                        {
                            img.TexutureIcon = Thumbs.TvNotifyIcon;
                        }
                    }
                }

                if (recordIconImage != null)
                {
                    //bool bPartialRecording = program.IsPartialRecordingSeriesPending;
                    GUIButton3PartControl buttonRecordTemplate = GetControl((int)Controls.BUTTON_PROGRAM_RECORD) as GUIButton3PartControl;

                    // Select the partial recording template if needed.
                    //if (bPartialRecording)
                    //{
                    //    buttonRecordTemplate = GetControl((int)Controls.BUTTON_PROGRAM_PARTIAL_RECORD) as GUIButton3PartControl;
                    //}

                    if (isRecording)
                    {
                        if (buttonRecordTemplate != null)
                        {
                            buttonRecordTemplate.IsVisible = false;
                            img.TexutureFocusLeftName = buttonRecordTemplate.TexutureFocusLeftName;
                            img.TexutureFocusMidName = buttonRecordTemplate.TexutureFocusMidName;
                            img.TexutureFocusRightName = buttonRecordTemplate.TexutureFocusRightName;
                            img.TexutureNoFocusLeftName = buttonRecordTemplate.TexutureNoFocusLeftName;
                            img.TexutureNoFocusMidName = buttonRecordTemplate.TexutureNoFocusMidName;
                            img.TexutureNoFocusRightName = buttonRecordTemplate.TexutureNoFocusRightName;
                            img.TileFillTFL = buttonRecordTemplate.TileFillTFL;
                            img.TileFillTNFL = buttonRecordTemplate.TileFillTNFL;
                            img.TileFillTFM = buttonRecordTemplate.TileFillTFM;
                            img.TileFillTNFM = buttonRecordTemplate.TileFillTNFM;
                            img.TileFillTFR = buttonRecordTemplate.TileFillTFR;
                            img.TileFillTNFR = buttonRecordTemplate.TileFillTNFR;

                            // Use of the button template control implies use of the icon.  Use a blank image if the icon is not desired.
                            //if (bConflict)
                            //{
                            //    img.TexutureFocusLeftName = "tvguide_recButton_Focus_left.png";
                            //    img.TexutureFocusMidName = "tvguide_recButton_Focus_middle.png";
                            //    img.TexutureFocusRightName = "tvguide_recButton_Focus_right.png";
                            //    img.TexutureNoFocusLeftName = "tvguide_recButton_noFocus_left.png";
                            //    img.TexutureNoFocusMidName = "tvguide_recButton_noFocus_middle.png";
                            //    img.TexutureNoFocusRightName = "tvguide_recButton_noFocus_right.png";
                            //}
                            img.IconOffsetX = buttonRecordTemplate.IconOffsetX;
                            img.IconOffsetY = buttonRecordTemplate.IconOffsetY;
                            img.IconAlign = buttonRecordTemplate.IconAlign;
                            img.IconVAlign = buttonRecordTemplate.IconVAlign;
                            img.IconInlineLabel1 = buttonRecordTemplate.IconInlineLabel1;
                        }
                        else
                        {
                            //if (bPartialRecording && _useNewPartialRecordingButtonColor)
                            //{
                            //    img.TexutureFocusLeftName = "tvguide_partRecButton_Focus_left.png";
                            //    img.TexutureFocusMidName = "tvguide_partRecButton_Focus_middle.png";
                            //    img.TexutureFocusRightName = "tvguide_partRecButton_Focus_right.png";
                            //    img.TexutureNoFocusLeftName = "tvguide_partRecButton_noFocus_left.png";
                            //    img.TexutureNoFocusMidName = "tvguide_partRecButton_noFocus_middle.png";
                            //    img.TexutureNoFocusRightName = "tvguide_partRecButton_noFocus_right.png";
                            //}
                            //else
                            {
                                if (_useNewRecordingButtonColor)
                                {
                                    img.TexutureFocusLeftName = "tvguide_recButton_Focus_left.png";
                                    img.TexutureFocusMidName = "tvguide_recButton_Focus_middle.png";
                                    img.TexutureFocusRightName = "tvguide_recButton_Focus_right.png";
                                    img.TexutureNoFocusLeftName = "tvguide_recButton_noFocus_left.png";
                                    img.TexutureNoFocusMidName = "tvguide_recButton_noFocus_middle.png";
                                    img.TexutureNoFocusRightName = "tvguide_recButton_noFocus_right.png";
                                }
                            }
                        }
                    }

                    img.TexutureIcon = recordIconImage;
                }
            }
        }