Пример #1
0
        /// <summary>
        /// Save a modified or new guide channel.  A new guide channel is recognized by a Guid.Empty ID.
        /// </summary>
        /// <param name="channel">The guide channel to save.</param>
        /// <returns>The saved guide channel.</returns>
        public async Task <GuideChannel> SaveChannel(GuideChannel channel)
        {
            var request = NewRequest(HttpMethod.Post, "SaveChannel");

            request.AddBody(channel);
            return(await ExecuteAsync <GuideChannel>(request).ConfigureAwait(false));
        }
Пример #2
0
        private GuideChannel GetGuideChannelForChannel(Channel channel)
        {
            GuideChannel guideChannel  = null;
            var          guideChannels = Proxies.GuideService.GetAllChannels(_currentChannelType).Result;

            foreach (GuideChannel gChannel in guideChannels)
            {
                if (gChannel.GuideChannelId == channel.GuideChannelId.Value)
                {
                    guideChannel = gChannel;
                }
            }
            return(guideChannel);
        }
Пример #3
0
        private GuideChannel GetGuideChannelForChannel(Channel channel)
        {
            GuideChannel guideChannel = null;

            GuideChannel[] guideChannels = GuideAgent.GetAllChannels(_currentChannelType);
            if (guideChannels != null && guideChannels.Length > 0)
            {
                foreach (GuideChannel gChannel in guideChannels)
                {
                    if (gChannel.GuideChannelId == channel.GuideChannelId.Value)
                    {
                        guideChannel = gChannel;
                    }
                }
            }
            return(guideChannel);
        }
Пример #4
0
        private void OnChangeGuideChannel(Channel channel)
        {
            var guideChannels = Proxies.GuideService.GetAllChannels(_currentChannelType).Result;

            if (guideChannels != null && guideChannels.Count > 0)
            {
                GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                if (dlg != null)
                {
                    dlg.Reset();
                    dlg.SetHeading(Utility.GetLocalizedText(TextId.SelectGuideChannel));
                    dlg.Add(Utility.GetLocalizedText(TextId.None));

                    int y = 0;
                    for (int i = 0; i < guideChannels.Count; i++)
                    {
                        GUIListItem item = new GUIListItem();
                        item.Label = guideChannels[i].Name;
                        if (channel.GuideChannelId.HasValue && (guideChannels[i].GuideChannelId == channel.GuideChannelId.Value))
                        {
                            item.IsPlayed = true;
                            y             = i + 1;
                        }
                        dlg.Add(item);
                    }
                    dlg.SelectedLabel = y;

                    dlg.DoModal(GetID);
                    if (dlg.SelectedId > 0)
                    {
                        if (dlg.SelectedLabel <= 0)
                        {
                            channel.GuideChannelId = null;
                            Proxies.SchedulerService.SaveChannel(channel).Wait();
                        }
                        else
                        {
                            GuideChannel guideChannel = guideChannels[dlg.SelectedLabel - 1];
                            Proxies.SchedulerService.AttachChannelToGuide(channel.ChannelId, guideChannel.GuideChannelId).Wait();
                        }
                    }
                }
            }
        }
Пример #5
0
 private void _deleteButton_Click(object sender, EventArgs e)
 {
     if (_channelsDataGridView.SelectedRows.Count > 0)
     {
         List <GuideChannel> channelsToRemove = new List <GuideChannel>();
         foreach (DataGridViewRow row in _channelsDataGridView.SelectedRows)
         {
             GuideChannel guideChannel = row.DataBoundItem as GuideChannel;
             if (guideChannel != null)
             {
                 channelsToRemove.Add(guideChannel);
             }
         }
         foreach (GuideChannel guideChannel in channelsToRemove)
         {
             _guideChannels.Remove(guideChannel);
             _deletedChannels.Add(guideChannel);
         }
         _channelsDataGridView.ClearSelection();
     }
 }
Пример #6
0
    protected override void GetChannels(bool refresh)
    {
      if (refresh || _channelList == null)
      {
        if (_channelList != null)
        {
          if (_channelList.Count < _channelCount)
          {
            _previousChannelCount = _channelList.Count;
          }
          else
          {
            _previousChannelCount = _channelCount;
          }
        }
        _channelList = new List<GuideChannel>();
      }

      if (_channelList.Count == 0)
      {
        try
        {
          if (Radio.SelectedGroup != null)
          {
            TvBusinessLayer layer = new TvBusinessLayer();
            IList<Channel> channels = layer.GetRadioGuideChannelsForGroup(Radio.SelectedGroup.IdGroup);
            foreach (Channel chan in channels)
            {
              GuideChannel tvGuidChannel = new GuideChannel();
              tvGuidChannel.channel = chan;

              if (tvGuidChannel.channel.VisibleInGuide && tvGuidChannel.channel.IsRadio)
              {
                if (_showChannelNumber)
                {

                  if (_byIndex)
                  {
                    tvGuidChannel.channelNum = _channelList.Count + 1;
                  }
                  else
                  {
                    tvGuidChannel.channelNum = tvGuidChannel.channel.ChannelNumber;
                  }
                }
                tvGuidChannel.strLogo = GetChannelLogo(tvGuidChannel.channel.DisplayName);
                _channelList.Add(tvGuidChannel);
              }
            }
          }
        }
        catch { }

        if (_channelList.Count == 0)
        {
          GuideChannel tvGuidChannel = new GuideChannel();
          tvGuidChannel.channel = new Channel(false, true, 0, DateTime.MinValue, false,
                                              DateTime.MinValue, 0, true, "", GUILocalizeStrings.Get(911), 10000);
          for (int i = 0; i < 10; ++i)
          {
            _channelList.Add(tvGuidChannel);
          }
        }
      }
    }
Пример #7
0
    protected override void RenderChannel(ref Dictionary<int, List<Program>> mapPrograms, int iChannel, GuideChannel tvGuideChannel,
                               long iStart, long iEnd, bool selectCurrentShow)
    {
      int channelNum = 0;
      Channel channel = tvGuideChannel.channel;

      if (!_byIndex)
      {
        channelNum = channel.ChannelNumber;
      }
      else
      {
        channelNum = _channelList.IndexOf(tvGuideChannel) + 1;
      }

      GUIButton3PartControl img = GetControl(iChannel + (int)Controls.IMG_CHAN1) as GUIButton3PartControl;
      if (img != null)
      {
        if (_showChannelLogos)
        {
          img.TexutureIcon = tvGuideChannel.strLogo;
        }
        if (channelNum > 0 && _showChannelNumber)
        {
          img.Label1 = channelNum + " " + channel.DisplayName;
        }
        else
        {
          img.Label1 = channel.DisplayName;
        }
        img.Data = channel;
        img.IsVisible = true;
      }


      List<Program> programs = null;
      if (mapPrograms.ContainsKey(channel.IdChannel))
        programs = mapPrograms[channel.IdChannel];
      
      bool noEPG = (programs == null || programs.Count == 0);
      if (noEPG)
      {
        DateTime dt = Utils.longtodate(iEnd);
        long iProgEnd = Utils.datetolong(dt);
        Program prog = new Program(channel.IdChannel, Utils.longtodate(iStart), Utils.longtodate(iProgEnd),
                                   GUILocalizeStrings.Get(736), "", "", Program.ProgramState.None, DateTime.MinValue,
                                   string.Empty,
                                   string.Empty, string.Empty, string.Empty, -1, string.Empty, -1);
        if (programs == null)
        {
          programs = new List<Program>();
        }
        programs.Add(prog);
      }

      int iProgram = 0;
      int iPreviousEndXPos = 0;

      int width = GetControl((int)Controls.LABEL_TIME1 + 1).XPosition;
      width -= GetControl((int)Controls.LABEL_TIME1).XPosition;

      int height = 0;
      GUIControl guiControl = GetControl((int)Controls.IMG_CHAN1 + 1);
      if (guiControl != null)
      {
        height = guiControl.YPosition;
        height -= GetControl((int)Controls.IMG_CHAN1).YPosition;
      }
      else
      {
        height = GetControl((int)Controls.IMG_CHAN1).Height;
      }

      foreach (Program program in programs)
      {
        if (Utils.datetolong(program.EndTime) <= iStart)
          continue;

        string strTitle = TVUtil.GetDisplayTitle(program);
        bool bStartsBefore = false;
        bool bEndsAfter = false;
        
        if (Utils.datetolong(program.StartTime) < iStart)
          bStartsBefore = true;

        if (Utils.datetolong(program.EndTime) > iEnd)
          bEndsAfter = true;

        DateTime dtBlokStart = new DateTime();
        dtBlokStart = _viewingTime;
        dtBlokStart = dtBlokStart.AddMilliseconds(-dtBlokStart.Millisecond);
        dtBlokStart = dtBlokStart.AddSeconds(-dtBlokStart.Second);

        bool bSeries = false;
        bool bRecording = false;
        bool bConflict = false;
        bool bPartialRecording = false;

        bConflict = program.HasConflict;
        bSeries = (program.IsRecordingSeries || program.IsRecordingSeriesPending);
        bRecording = bSeries || (program.IsRecording || program.IsRecordingOncePending || program.IsPartialRecordingSeriesPending);
        bPartialRecording = program.IsPartialRecordingSeriesPending;
        bool bManual = program.IsRecordingManual;

        if (noEPG && !bRecording)
        {
          bRecording = IsRecordingNoEPG(channel);
        }

        bool bProgramIsHD = program.Description.Contains(_hdtvProgramText);

        int iStartXPos = 0;
        int iEndXPos = 0;
        for (int iBlok = 0; iBlok < _numberOfBlocks; iBlok++)
        {
          float fWidthEnd = (float)width;
          DateTime dtBlokEnd = dtBlokStart.AddMinutes(_timePerBlock - 1);
          if (program.RunningAt(dtBlokStart, dtBlokEnd))
          {
            //dtBlokEnd = dtBlokStart.AddSeconds(_timePerBlock * 60);
            if (program.EndTime <= dtBlokEnd)
            {
              TimeSpan dtSpan = dtBlokEnd - program.EndTime;
              int iEndMin = _timePerBlock - (dtSpan.Minutes);

              fWidthEnd = (((float)iEndMin) / ((float)_timePerBlock)) * ((float)(width));
              if (bEndsAfter)
              {
                fWidthEnd = (float)width;
              }
            }

            if (iStartXPos == 0)
            {
              TimeSpan ts = program.StartTime - dtBlokStart;
              int iStartMin = ts.Hours * 60;
              iStartMin += ts.Minutes;
              if (ts.Seconds == 59)
              {
                iStartMin += 1;
              }
              float fWidth = (((float)iStartMin) / ((float)_timePerBlock)) * ((float)(width));

              if (bStartsBefore)
              {
                fWidth = 0;
              }

              iStartXPos = GetControl(iBlok + (int)Controls.LABEL_TIME1).XPosition;
              iStartXPos += (int)fWidth;
              iEndXPos = GetControl(iBlok + (int)Controls.LABEL_TIME1).XPosition + (int)fWidthEnd;
            }
            else
            {
              iEndXPos = GetControl(iBlok + (int)Controls.LABEL_TIME1).XPosition + (int)fWidthEnd;
            }
          }
          dtBlokStart = dtBlokStart.AddMinutes(_timePerBlock);
        }

        if (iStartXPos >= 0)
        {
          if (iPreviousEndXPos > iStartXPos)
          {
            iStartXPos = iPreviousEndXPos;
          }
          if (iEndXPos <= iStartXPos + 5)
          {
            iEndXPos = iStartXPos + 6; // at least 1 pixel width
          }

          int ypos = GetControl(iChannel + (int)Controls.IMG_CHAN1).YPosition;
          int iControlId = GUIDE_COMPONENTID_START + iChannel * RowID + iProgram * ColID;
          int iWidth = iEndXPos - iStartXPos;
          if (iWidth > 3)
          {
            iWidth -= 3;
          }
          else
          {
            iWidth = 1;
          }

          string TexutureFocusLeftName = "tvguide_button_selected_left.png";
          string TexutureFocusMidName = "tvguide_button_selected_middle.png";
          string TexutureFocusRightName = "tvguide_button_selected_right.png";
          string TexutureNoFocusLeftName = "tvguide_button_light_left.png";
          string TexutureNoFocusMidName = "tvguide_button_light_middle.png";
          string TexutureNoFocusRightName = "tvguide_button_light_right.png";

          bool TileFillTFL = false;
          bool TileFillTNFL = false;
          bool TileFillTFM = false;
          bool TileFillTNFM = false;
          bool TileFillTFR = false;
          bool TileFillTNFR = false;

          if (_programNotRunningTemplate != null)
          {
            _programNotRunningTemplate.IsVisible = false;

            TexutureFocusLeftName = _programNotRunningTemplate.TexutureFocusLeftName;
            TexutureFocusMidName = _programNotRunningTemplate.TexutureFocusMidName;
            TexutureFocusRightName = _programNotRunningTemplate.TexutureFocusRightName;
            TexutureNoFocusLeftName = _programNotRunningTemplate.TexutureNoFocusLeftName;
            TexutureNoFocusMidName = _programNotRunningTemplate.TexutureNoFocusMidName;
            TexutureNoFocusRightName = _programNotRunningTemplate.TexutureNoFocusRightName;

            TileFillTFL = _programNotRunningTemplate.TileFillTFL;
            TileFillTNFL = _programNotRunningTemplate.TileFillTNFL;
            TileFillTFM = _programNotRunningTemplate.TileFillTFM;
            TileFillTNFM = _programNotRunningTemplate.TileFillTNFM;
            TileFillTFR = _programNotRunningTemplate.TileFillTFR;
            TileFillTNFR = _programNotRunningTemplate.TileFillTNFR;
          }

          bool isNew = false;

          if (!_controls.TryGetValue((int)iControlId, out img))
          {
            img = new GUIButton3PartControl(GetID, iControlId, iStartXPos, ypos, iWidth, height - 2,
                                            TexutureFocusLeftName,
                                            TexutureFocusMidName,
                                            TexutureFocusRightName,
                                            TexutureNoFocusLeftName,
                                            TexutureNoFocusMidName,
                                            TexutureNoFocusRightName,
                                            String.Empty);

            isNew = true;
          }
          else
          {
            img.Focus = false;
            img.SetPosition(iStartXPos, ypos);
            img.Width = iWidth;
            img.IsVisible = true;
            img.DoUpdate();
          }

          img.RenderLeft = false;
          img.RenderRight = false;
          img.StretchIfNotRendered = true;

          img.TexutureIcon = String.Empty;
          if (program.Notify)
          {
            if (_programNotifyTemplate != null)
            {
              _programNotifyTemplate.IsVisible = false;

              TexutureFocusLeftName = _programNotifyTemplate.TexutureFocusLeftName;
              TexutureFocusMidName = _programNotifyTemplate.TexutureFocusMidName;
              TexutureFocusRightName = _programNotifyTemplate.TexutureFocusRightName;
              TexutureNoFocusLeftName = _programNotifyTemplate.TexutureNoFocusLeftName;
              TexutureNoFocusMidName = _programNotifyTemplate.TexutureNoFocusMidName;
              TexutureNoFocusRightName = _programNotifyTemplate.TexutureNoFocusRightName;
              
              TileFillTFL = _programNotifyTemplate.TileFillTFL;
              TileFillTNFL = _programNotifyTemplate.TileFillTNFL;
              TileFillTFM = _programNotifyTemplate.TileFillTFM;
              TileFillTNFM = _programNotifyTemplate.TileFillTNFM;
              TileFillTFR = _programNotifyTemplate.TileFillTFR;
              TileFillTNFR = _programNotifyTemplate.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 = _programNotifyTemplate.IconOffsetX;
              img.IconOffsetY = _programNotifyTemplate.IconOffsetY;
              img.IconAlign = _programNotifyTemplate.IconAlign;
              img.IconVAlign = _programNotifyTemplate.IconVAlign;
              img.IconInlineLabel1 = _programNotifyTemplate.IconInlineLabel1;
            }
            else
            {
              if (_useNewNotifyButtonColor)
              {
                TexutureFocusLeftName = "tvguide_notifyButton_Focus_left.png";
                TexutureFocusMidName = "tvguide_notifyButton_Focus_middle.png";
                TexutureFocusRightName = "tvguide_notifyButton_Focus_right.png";
                TexutureNoFocusLeftName = "tvguide_notifyButton_noFocus_left.png";
                TexutureNoFocusMidName = "tvguide_notifyButton_noFocus_middle.png";
                TexutureNoFocusRightName = "tvguide_notifyButton_noFocus_right.png";
              }
              else
              {
                img.TexutureIcon = Thumbs.TvNotifyIcon;
              }
            }
          }
          if (bRecording)
          {
            GUIButton3PartControl buttonRecordTemplate = _programRecordTemplate;

            // Select the partial recording template if needed.
            if (bPartialRecording)
            {
              buttonRecordTemplate = _programPartialRecordTemplate;
            }

            if (buttonRecordTemplate != null)
            {
              buttonRecordTemplate.IsVisible = false;

              TexutureFocusLeftName = buttonRecordTemplate.TexutureFocusLeftName;
              TexutureFocusMidName = buttonRecordTemplate.TexutureFocusMidName;
              TexutureFocusRightName = buttonRecordTemplate.TexutureFocusRightName;
              TexutureNoFocusLeftName = buttonRecordTemplate.TexutureNoFocusLeftName;
              TexutureNoFocusMidName = buttonRecordTemplate.TexutureNoFocusMidName;
              TexutureNoFocusRightName = buttonRecordTemplate.TexutureNoFocusRightName;
              
              TileFillTFL = buttonRecordTemplate.TileFillTFL;
              TileFillTNFL = buttonRecordTemplate.TileFillTNFL;
              TileFillTFM = buttonRecordTemplate.TileFillTFM;
              TileFillTNFM = buttonRecordTemplate.TileFillTNFM;
              TileFillTFR = buttonRecordTemplate.TileFillTFR;
              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.TexutureIcon = Thumbs.TvConflictRecordingIcon;
              }
              else if (bSeries)
              {
                img.TexutureIcon = Thumbs.TvRecordingSeriesIcon;
              }
              else
              {
                img.TexutureIcon = Thumbs.TvRecordingIcon;
              }
              img.IconOffsetX = buttonRecordTemplate.IconOffsetX;
              img.IconOffsetY = buttonRecordTemplate.IconOffsetY;
              img.IconAlign = buttonRecordTemplate.IconAlign;
              img.IconVAlign = buttonRecordTemplate.IconVAlign;
              img.IconInlineLabel1 = buttonRecordTemplate.IconInlineLabel1;
            }
            else
            {
              if (bPartialRecording && _useNewPartialRecordingButtonColor)
              {
                TexutureFocusLeftName = "tvguide_partRecButton_Focus_left.png";
                TexutureFocusMidName = "tvguide_partRecButton_Focus_middle.png";
                TexutureFocusRightName = "tvguide_partRecButton_Focus_right.png";
                TexutureNoFocusLeftName = "tvguide_partRecButton_noFocus_left.png";
                TexutureNoFocusMidName = "tvguide_partRecButton_noFocus_middle.png";
                TexutureNoFocusRightName = "tvguide_partRecButton_noFocus_right.png";
              }
              else
              {
                if (_useNewRecordingButtonColor)
                {
                  TexutureFocusLeftName = "tvguide_recButton_Focus_left.png";
                  TexutureFocusMidName = "tvguide_recButton_Focus_middle.png";
                  TexutureFocusRightName = "tvguide_recButton_Focus_right.png";
                  TexutureNoFocusLeftName = "tvguide_recButton_noFocus_left.png";
                  TexutureNoFocusMidName = "tvguide_recButton_noFocus_middle.png";
                  TexutureNoFocusRightName = "tvguide_recButton_noFocus_right.png";
                }
                else
                {
                  if (bConflict)
                  {
                    img.TexutureIcon = Thumbs.TvConflictRecordingIcon;
                  }
                  else if (bSeries)
                  {
                    img.TexutureIcon = Thumbs.TvRecordingSeriesIcon;
                  }
                  else
                  {
                    img.TexutureIcon = Thumbs.TvRecordingIcon;
                  }
                }
              }
            }
          }

          DateTime dt = DateTime.Now;

          img.TexutureIcon2 = String.Empty;
          if (bProgramIsHD)
          {
            if (program.IsRunningAt(dt) && _programRunningTemplate != null)
            {
              img.TexutureIcon2 = _programRunningTemplate.TexutureIcon2;
              img.Icon2Align = _programRunningTemplate.Icon2Align;
              img.Icon2VAlign = _programRunningTemplate.Icon2VAlign;
              img.Icon2OffsetX = _programRunningTemplate.Icon2OffsetX;
              img.Icon2OffsetY = _programRunningTemplate.Icon2OffsetY;
              img.Icon2InlineLabel1 = _programRunningTemplate.Icon2InlineLabel1;
            }
            else if (!program.IsRunningAt(dt) && _programNotRunningTemplate != null)
            {
              img.TexutureIcon2 = _programNotRunningTemplate.TexutureIcon2;
              img.Icon2Align = _programNotRunningTemplate.Icon2Align;
              img.Icon2VAlign = _programNotRunningTemplate.Icon2VAlign;
              img.Icon2OffsetX = _programNotRunningTemplate.Icon2OffsetX;
              img.Icon2OffsetY = _programNotRunningTemplate.Icon2OffsetY;
              img.Icon2InlineLabel1 = _programNotRunningTemplate.Icon2InlineLabel1;
            }
            else
            {
              if (_useHdProgramIcon)
              {
                img.TexutureIcon2 = "tvguide_hd_program.png";
                img.Icon2Align = GUIControl.Alignment.ALIGN_LEFT;
                img.Icon2VAlign = GUIControl.VAlignment.ALIGN_MIDDLE;
                img.Icon2OffsetX = 5;
                img.Icon2OffsetY = 0;
                img.Icon2InlineLabel1 = true;
              }
            }
          }
          img.Data = program.Clone();
          img.ColourDiffuse = GetColorForGenre(program.Genre);

          iWidth = iEndXPos - iStartXPos;
          if (iWidth > 10)
          {
            iWidth -= 10;
          }
          else
          {
            iWidth = 1;
          }

          img.TextOffsetX1 = 5;
          img.TextOffsetY1 = 5;
          img.FontName1 = "font13";
          img.TextColor1 = 0xffffffff;
          img.Label1 = strTitle;
          GUILabelControl labelTemplate;
          if (program.IsRunningAt(dt))
          {
            labelTemplate = _titleDarkTemplate;
          }
          else
          {
            labelTemplate = _titleTemplate;
          }

          if (labelTemplate != null)
          {
            img.FontName1 = labelTemplate.FontName;
            img.TextColor1 = labelTemplate.TextColor;
            img.TextColor2 = labelTemplate.TextColor;
            img.TextOffsetX1 = labelTemplate.XPosition;
            img.TextOffsetY1 = labelTemplate.YPosition;
            img.SetShadow1(labelTemplate.ShadowAngle, labelTemplate.ShadowDistance, labelTemplate.ShadowColor);

            // This is a legacy behavior check.  Adding labelTemplate.XPosition and labelTemplate.YPosition requires
            // skinners to add these values to the skin xml unless this check exists.  Perform a sanity check on the
            // x,y position to ensure it falls into the bounds of the button.  If it does not then fall back to use the
            // legacy values.  This check is necessary because the x,y position (without skin file changes) will be taken
            // from either the references.xml control template or the controls coded defaults.
            if (img.TextOffsetY1 > img.Height)
            {
              // Set legacy values.
              img.TextOffsetX1 = 5;
              img.TextOffsetY1 = 5;
            }
          }
          img.TextOffsetX2 = 5;
          img.TextOffsetY2 = img.Height / 2;
          img.FontName2 = "font13";
          img.TextColor2 = 0xffffffff;

          if (program.IsRunningAt(dt))
          {
            labelTemplate = _genreDarkTemplate;
          }
          else
          {
            labelTemplate = _genreTemplate;
          }
          if (labelTemplate != null)
          {
            img.FontName2 = labelTemplate.FontName;
            img.TextColor2 = labelTemplate.TextColor;
            img.Label2 = program.Genre;
            img.TextOffsetX2 = labelTemplate.XPosition;
            img.TextOffsetY2 = labelTemplate.YPosition;
            img.SetShadow2(labelTemplate.ShadowAngle, labelTemplate.ShadowDistance, labelTemplate.ShadowColor);

            // This is a legacy behavior check.  Adding labelTemplate.XPosition and labelTemplate.YPosition requires
            // skinners to add these values to the skin xml unless this check exists.  Perform a sanity check on the
            // x,y position to ensure it falls into the bounds of the button.  If it does not then fall back to use the
            // legacy values.  This check is necessary because the x,y position (without skin file changes) will be taken
            // from either the references.xml control template or the controls coded defaults.
            if (img.TextOffsetY2 > img.Height)
            {
              // Set legacy values.
              img.TextOffsetX2 = 5;
              img.TextOffsetY2 = 5;
            }
          }

          if (program.IsRunningAt(dt))
          {
            GUIButton3PartControl buttonRunningTemplate = _programRunningTemplate;
            if (!bRecording && !bPartialRecording && buttonRunningTemplate != null)
            {
              buttonRunningTemplate.IsVisible = false;
              TexutureFocusLeftName = buttonRunningTemplate.TexutureFocusLeftName;
              TexutureFocusMidName = buttonRunningTemplate.TexutureFocusMidName;
              TexutureFocusRightName = buttonRunningTemplate.TexutureFocusRightName;
              TexutureNoFocusLeftName = buttonRunningTemplate.TexutureNoFocusLeftName;
              TexutureNoFocusMidName = buttonRunningTemplate.TexutureNoFocusMidName;
              TexutureNoFocusRightName = buttonRunningTemplate.TexutureNoFocusRightName;
              TileFillTFL = buttonRunningTemplate.TileFillTFL;
              TileFillTNFL = buttonRunningTemplate.TileFillTNFL;
              TileFillTFM = buttonRunningTemplate.TileFillTFM;
              TileFillTNFM = buttonRunningTemplate.TileFillTNFM;
              TileFillTFR = buttonRunningTemplate.TileFillTFR;
              TileFillTNFR = buttonRunningTemplate.TileFillTNFR;
            }
            else if (bRecording && _useNewRecordingButtonColor)
            {
              TexutureFocusLeftName = "tvguide_recButton_Focus_left.png";
              TexutureFocusMidName = "tvguide_recButton_Focus_middle.png";
              TexutureFocusRightName = "tvguide_recButton_Focus_right.png";
              TexutureNoFocusLeftName = "tvguide_recButton_noFocus_left.png";
              TexutureNoFocusMidName = "tvguide_recButton_noFocus_middle.png";
              TexutureNoFocusRightName = "tvguide_recButton_noFocus_right.png";
            }
            else if (!(bRecording && bPartialRecording && _useNewRecordingButtonColor))
            {
              TexutureFocusLeftName = "tvguide_button_selected_left.png";
              TexutureFocusMidName = "tvguide_button_selected_middle.png";
              TexutureFocusRightName = "tvguide_button_selected_right.png";
              TexutureNoFocusLeftName = "tvguide_button_left.png";
              TexutureNoFocusMidName = "tvguide_button_middle.png";
              TexutureNoFocusRightName = "tvguide_button_right.png";
            }
            if (selectCurrentShow && iChannel == _cursorX)
            {
              _cursorY = iProgram + 1;
              _currentProgram = program;
              m_dtStartTime = program.StartTime;
              SetProperties();
            }
          }

          if (bEndsAfter)
          {
            img.RenderRight = true;

            // If no template found then use default texture names.
            // Texture names already set if using template.
            if (_programNotRunningTemplate == null)
            {
              TexutureFocusRightName = "tvguide_arrow_selected_right.png";
              TexutureNoFocusRightName = "tvguide_arrow_light_right.png";
            }

            if (program.IsRunningAt(dt) && _programRunningTemplate == null)
            {
              TexutureNoFocusRightName = "tvguide_arrow_right.png";
            }
          }
          if (bStartsBefore)
          {
            img.RenderLeft = true;

            if (_programNotRunningTemplate == null)
            {
              TexutureFocusLeftName = "tvguide_arrow_selected_left.png";
              TexutureNoFocusLeftName = "tvguide_arrow_light_left.png";
            }

            if (program.IsRunningAt(dt) && _programRunningTemplate == null)
            {
              TexutureNoFocusLeftName = "tvguide_arrow_left.png";
            }
          }

          img.TexutureFocusLeftName = TexutureFocusLeftName;
          img.TexutureFocusMidName = TexutureFocusMidName;
          img.TexutureFocusRightName = TexutureFocusRightName;
          img.TexutureNoFocusLeftName = TexutureNoFocusLeftName;
          img.TexutureNoFocusMidName = TexutureNoFocusMidName;
          img.TexutureNoFocusRightName = TexutureNoFocusRightName;

          img.TileFillTFL = TileFillTFL;
          img.TileFillTNFL = TileFillTNFL;
          img.TileFillTFM = TileFillTFM;
          img.TileFillTNFM = TileFillTNFM;
          img.TileFillTFR = TileFillTFR;
          img.TileFillTNFR = TileFillTNFR;

          if (isNew)
          {
            img.AllocResources();
            GUIControl cntl = (GUIControl)img;
            _controls.Add((int)iControlId, img);
            Add(ref cntl);
          }
          else
            img.DoUpdate();
          iProgram++;
        }
        iPreviousEndXPos = iEndXPos;
      }
    }
Пример #8
0
 protected abstract void RenderChannel(ref Dictionary <int, List <Program> > programs, int iChannel, GuideChannel tvGuideChannel, long iStart, long iEnd, bool selectCurrentShow);
Пример #9
0
        protected void Update(bool selectCurrentShow)
        {
            lock (this)
            {
                if (GUIWindowManager.ActiveWindowEx != this.GetID)
                {
                    return;
                }

                // Skin settings may have changed via the MP GUI, reload them.
                LoadSkinSettings();

                // sets button visible state
                UpdateGroupButton();

                GUIButton3PartControl cntlChannelGroup = GetControl((int)Controls.CHANNEL_GROUP_BUTTON) as GUIButton3PartControl;
                cntlChannelGroup.RenderLeft           = false;
                cntlChannelGroup.RenderRight          = false;
                cntlChannelGroup.StretchIfNotRendered = true;
                if (_useColorsForButtons)
                {
                    cntlChannelGroup.ColourDiffuse = _guideColorGroupButton;
                }

                _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, labelTime.TextAlignment, 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 = GUIControl.Alignment.ALIGN_LEFT;
                    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;

                            imgBut.OverlayFileNameTFL  = buttonTemplate.OverlayFileNameTFL;
                            imgBut.OverlayFileNameTNFL = buttonTemplate.OverlayFileNameTNFL;
                            imgBut.OverlayFileNameTFM  = buttonTemplate.OverlayFileNameTFM;
                            imgBut.OverlayFileNameTNFM = buttonTemplate.OverlayFileNameTNFM;
                            imgBut.OverlayFileNameTFR  = buttonTemplate.OverlayFileNameTFR;
                            imgBut.OverlayFileNameTNFR = buttonTemplate.OverlayFileNameTNFR;
                        }
                        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.StretchIfNotRendered = true;
                    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.ImageAlignment == GUIControl.Alignment.ALIGN_CENTER);
                        imgBut.IconZoom            = cntlChannelImg.Zoom;
                    }
                    imgBut.TextOffsetX1 = cntlChannelLabel.XPosition;
                    imgBut.TextOffsetY1 = cntlChannelLabel.YPosition;
                    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
                {
                    TvBusinessLayer layer = new TvBusinessLayer();

                    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;
                        }
                    }
                    Dictionary <int, List <Program> > programs = layer.GetProgramsForAllChannels(Utils.longtodate(iStart),
                                                                                                 Utils.longtodate(iEnd),
                                                                                                 visibleChannels);
                    // 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;

                    int channelCount = _channelCount;
                    if (_previousChannelCount > channelCount)
                    {
                        channelCount = _previousChannelCount;
                    }

                    for (int iChannel = 0; iChannel < channelCount; iChannel++)
                    {
                        if (chan < _channelList.Count)
                        {
                            GuideChannel tvGuideChannel = (GuideChannel)_channelList[chan];
                            RenderChannel(ref programs, 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();

                if (_showGenreKey)
                {
                    RenderGenreKey();
                }
            }
        }
Пример #10
0
 protected abstract void RenderChannel(ref Dictionary<int, List<Program>> programs, int iChannel, GuideChannel tvGuideChannel, long iStart, long iEnd, bool selectCurrentShow);
Пример #11
0
    protected override void GetChannels(bool refresh)
    {
      if (refresh || _channelList == null)
      {
        _channelList = new List<GuideChannel>();
      }

      if (_channelList.Count == 0)
      {
        try
        {
          if (TVHome.Navigator.CurrentGroup != null)
          {
            TvBusinessLayer layer = new TvBusinessLayer();
            IList<Channel> channels = layer.GetTVGuideChannelsForGroup(TVHome.Navigator.CurrentGroup.IdGroup);
            foreach (Channel chan in channels)
            {
              GuideChannel tvGuidChannel = new GuideChannel();
              tvGuidChannel.channel = chan;

              if (tvGuidChannel.channel.VisibleInGuide && tvGuidChannel.channel.IsTv)
              {
                if (_showChannelNumber)
                {

                  if (_byIndex)
                  {
                    tvGuidChannel.channelNum = _channelList.Count + 1;
                  }
                  else
                  {
                    foreach (TuningDetail detail in tvGuidChannel.channel.ReferringTuningDetail())
                      tvGuidChannel.channelNum = detail.ChannelNumber;
                  }
                }
                tvGuidChannel.strLogo = GetChannelLogo(tvGuidChannel.channel.DisplayName);
                _channelList.Add(tvGuidChannel);
              }
            }
          }
        }
        catch { }

        if (_channelList.Count == 0)
        {
          GuideChannel tvGuidChannel = new GuideChannel();
          tvGuidChannel.channel = new Channel(false, true, 0, DateTime.MinValue, false,
                                              DateTime.MinValue, 0, true, "", GUILocalizeStrings.Get(911));
          for (int i = 0; i < 10; ++i)
          {
            _channelList.Add(tvGuidChannel);
          }
        }
      }
    }
Пример #12
0
        private void OnChannelSelected(GUIListItem item, int iItem, bool isAllChannelList)
        {
            Channel channel = item.TVTag as Channel;

            if (channel == null)
            {
                return;
            }

            if (isAllChannelList)
            {
                GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                if (dlg != null)
                {
                    dlg.Reset();
                    dlg.SetHeading(channel.DisplayName);

                    dlg.Add(Utility.GetLocalizedText(TextId.AddToGroup));
                    if (channel.VisibleInGuide)
                    {
                        dlg.Add(Utility.GetLocalizedText(TextId.HideFromGuide));
                    }
                    else
                    {
                        dlg.Add(Utility.GetLocalizedText(TextId.ShowInGuide));
                    }

                    string text = Utility.GetLocalizedText(TextId.None);
                    if (channel.GuideChannelId.HasValue)
                    {
                        GuideChannel ch = GetGuideChannelForChannel(channel);
                        if (ch != null)
                        {
                            text = ch.Name;
                        }
                    }
                    dlg.Add(Utility.GetLocalizedText(TextId.GuideChannel) + ": " + text);
                    dlg.Add(Utility.GetLocalizedText(TextId.DeleteChannel));

                    dlg.DoModal(GetID);
                    if (dlg.SelectedId > 0)
                    {
                        _savingNeeded = true;

                        switch (dlg.SelectedLabel)
                        {
                        case 0:
                        {
                            _channelsInGroupList.Add(item);
                            _allChannelsList.RemoveItem(iItem);
                        }
                        break;

                        case 1:
                        {
                            if (channel.VisibleInGuide)
                            {
                                item.IsPlayed          = true;
                                channel.VisibleInGuide = false;
                            }
                            else
                            {
                                item.IsPlayed          = false;
                                channel.VisibleInGuide = true;
                            }
                            Proxies.SchedulerService.SaveChannel(channel).Wait();
                        }
                        break;

                        case 2:
                        {
                            OnChangeGuideChannel(channel);
                            item.TVTag = Proxies.SchedulerService.GetChannelById(channel.ChannelId).Result;
                        }
                        break;

                        case 3:
                        {
                            if (OnDeleteChannel(channel))
                            {
                                _allChannelsList.RemoveItem(iItem);
                            }
                        }
                        break;
                        }
                    }
                }
            }
            else// channels in group list
            {
                if (!item.IsRemote)
                {
                    GUIDialogMenu dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                    if (dlg != null)
                    {
                        dlg.Reset();
                        dlg.SetHeading(channel.DisplayName);

                        dlg.Add(Utility.GetLocalizedText(TextId.MoveChannel));
                        dlg.Add(Utility.GetLocalizedText(TextId.DeleteChannelFromGroup));
                        if (channel.VisibleInGuide)
                        {
                            dlg.Add(Utility.GetLocalizedText(TextId.HideFromGuide));
                        }
                        else
                        {
                            dlg.Add(Utility.GetLocalizedText(TextId.ShowInGuide));
                        }

                        string text = Utility.GetLocalizedText(TextId.None);
                        if (channel.GuideChannelId.HasValue)
                        {
                            GuideChannel ch = GetGuideChannelForChannel(channel);
                            if (ch != null)
                            {
                                text = ch.Name;
                            }
                        }
                        dlg.Add(Utility.GetLocalizedText(TextId.GuideChannel) + ": " + text);
                        dlg.Add(Utility.GetLocalizedText(TextId.DeleteChannel));

                        dlg.DoModal(GetID);
                        if (dlg.SelectedId > 0)
                        {
                            _savingNeeded = true;

                            switch (dlg.SelectedLabel)
                            {
                            case 0:
                                item.IsRemote = true;
                                break;

                            case 1:
                            {
                                _channelsInGroupList.RemoveItem(iItem);
                                _allChannelsList.Add(item);
                            }
                            break;

                            case 2:
                            {
                                if (channel.VisibleInGuide)
                                {
                                    item.IsPlayed          = true;
                                    channel.VisibleInGuide = false;
                                }
                                else
                                {
                                    item.IsPlayed          = false;
                                    channel.VisibleInGuide = true;
                                }
                                Proxies.SchedulerService.SaveChannel(channel).Wait();
                            }
                            break;

                            case 3:
                            {
                                OnChangeGuideChannel(channel);
                                item.TVTag = Proxies.SchedulerService.GetChannelById(channel.ChannelId).Result;
                            }
                            break;

                            case 4:
                            {
                                if (OnDeleteChannel(channel))
                                {
                                    _channelsInGroupList.RemoveItem(iItem);
                                }
                            }
                            break;
                            }
                        }
                    }
                }
                else
                {
                    item.IsRemote = false;
                }
            }
        }