AllocResources() public method

Allocate the DirectX resources needed for rendering this GUIImage.
public AllocResources ( ) : void
return void
    /// <summary>
    /// Method to render a single item of the filmstrip
    /// </summary>
    /// <param name="bFocus">true if item shown be drawn focused, false for normal mode</param>
    /// <param name="dwPosX">x-coordinate of the item</param>
    /// <param name="dwPosY">y-coordinate of the item</param>
    /// <param name="pItem">item itself</param>
    private void RenderItem(int itemNumber, float timePassed, bool bFocus, int dwPosX, int dwPosY, GUIListItem pItem)
    {
      if (_font == null)
      {
        return;
      }
      if (pItem == null)
      {
        return;
      }
      if (dwPosY < 0)
      {
        return;
      }

      bool itemFocused = bFocus == true && Focus && _listType == GUIListControl.ListType.CONTROL_LIST;

      float fTextHeight = 0, fTextWidth = 0;
      _font.GetTextExtent("W", ref fTextWidth, ref fTextHeight);

      float fTextPosY = (float)dwPosY + (float)_textureHeight;

      TransformMatrix tm = null;
      long dwColor = _textColor;
      if (pItem.Selected)
      {
        dwColor = _selectedColor;
      }
      if (pItem.IsPlayed)
      {
        dwColor = _playedColor;
      }
      if (!bFocus && Focus)
      {
        dwColor = Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb();
      }
      if (pItem.IsRemote)
      {
        dwColor = _remoteColor;
        if (pItem.IsDownloading)
        {
          dwColor = _downloadColor;
        }
      }
      if (pItem.IsBdDvdFolder)
      {
        dwColor = _bdDvdDirectoryColor;
      }
      if (!Focus)
      {
        dwColor &= DimColor;
      }

      //uint currentTime = (uint) (DXUtil.Timer(DirectXTimer.GetAbsoluteTime)*1000.0);
      uint currentTime = (uint)System.Windows.Media.Animation.AnimationTimer.TickCount;
      // Set oversized value
      int iOverSized = 0;

      if (itemFocused && _enableFocusZoom)
      {
        iOverSized = (_thumbNailWidth + _thumbNailHeight) / THUMBNAIL_OVERSIZED_DIVIDER;
      }
      GUIImage pImage = null;

      if (pItem.HasThumbnail)
      {
        pImage = pItem.Thumbnail;
        if (null == pImage && _sleeper == 0 && !IsAnimating)
        {
          pImage = new GUIImage(0, 0, _thumbNailPositionX - iOverSized + dwPosX,
                                _thumbNailPositionY - iOverSized + dwPosY, _thumbNailWidth + 2 * iOverSized,
                                _thumbNailHeight + 2 * iOverSized, pItem.ThumbnailImage, 0x0);
          pImage.ParentControl = this;
          pImage.KeepAspectRatio = _keepAspectRatio;
          pImage.ZoomFromTop = !pItem.IsFolder && _zoom;
          pImage.ImageAlignment = _imageAlignment;
          pImage.ImageVAlignment = _imageVAlignment;
          pImage.FlipX = _flipX;
          pImage.FlipY = _flipY;
          pImage.DiffuseFileName = _diffuseFileName;
          pImage.MaskFileName = _textureMask;
          pImage.SetAnimations(_allThumbAnimations);
          pImage.AllocResources();

          pItem.Thumbnail = pImage;
          pImage.SetPosition(_thumbNailPositionX - iOverSized + dwPosX, _thumbNailPositionY - iOverSized + dwPosY);
          pImage.DimColor = DimColor;
          _sleeper += SLEEP_FRAME_COUNT;
        }
        if (null != pImage)
        {
          if (pImage.TextureHeight == 0 && pImage.TextureWidth == 0)
          {
            pImage.SafeDispose();
            pImage.AllocResources();
          }
          pImage.ZoomFromTop = !pItem.IsFolder && _zoom;
          pImage.ImageAlignment = _imageAlignment;
          pImage.ImageVAlignment = _imageVAlignment;
          pImage.Width = _thumbNailWidth + 2 * iOverSized;
          pImage.Height = _thumbNailHeight + 2 * iOverSized;
          pImage.SetPosition(_thumbNailPositionX + dwPosX - iOverSized, _thumbNailPositionY - iOverSized + dwPosY);
          pImage.DimColor = DimColor;
          if (pImage.Focus != itemFocused)
          {
            _imageFolderFocus[itemNumber].Focus = !itemFocused; // ensure that _imageFolderFocus is in sync with pImage 
            _imageFolder[itemNumber].Focus = !itemFocused;
            _frameFocusControl[itemNumber].Focus = !itemFocused;
            _frameControl[itemNumber].Focus = !itemFocused;
          }
          if (itemFocused)
          {
            pImage.ColourDiffuse = 0xffffffff;
            pImage.Focus = true;
          }
          else
          {
            pImage.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
            pImage.Focus = false;
          }
          TransformMatrix matrix = GUIGraphicsContext.ControlTransform;
          GUIGraphicsContext.ControlTransform = new TransformMatrix();
          pImage.UpdateVisibility();
          pImage.DoRender(timePassed, currentTime);
          tm = pImage.getTransformMatrix(currentTime);
          GUIGraphicsContext.ControlTransform = matrix;
        }
      }
      else
      {
        if (pItem.HasIconBig)
        {
          pImage = pItem.IconBig;
          if (null == pImage && _sleeper == 0 && !IsAnimating)
          {
            pImage = new GUIImage(0, 0, _thumbNailPositionX - iOverSized + dwPosX,
                                  _thumbNailPositionY - iOverSized + dwPosY, _thumbNailWidth + 2 * iOverSized,
                                  _thumbNailHeight + 2 * iOverSized, pItem.IconImageBig, 0x0);
            pImage.ParentControl = this;
            pImage.KeepAspectRatio = _keepAspectRatio;
            pImage.ZoomFromTop = !pItem.IsFolder && _zoom;
            pImage.ImageAlignment = _imageAlignment;
            pImage.ImageVAlignment = _imageVAlignment;
            pImage.AllocResources();
            pImage.FlipX = _flipX;
            pImage.FlipY = _flipY;
            pImage.DiffuseFileName = _diffuseFileName;
            pImage.SetAnimations(_allThumbAnimations);
            pItem.IconBig = pImage;
            pImage.SetPosition(_thumbNailPositionX + dwPosX - iOverSized, _thumbNailPositionY - iOverSized + dwPosY);
            pImage.DimColor = DimColor;
            pImage.MaskFileName = _textureMask;

            if (itemFocused)
            {
              pImage.ColourDiffuse = 0xffffffff;
              pImage.Focus = Focus;
            }
            else
            {
              pImage.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
              pImage.Focus = false;
            }
            _sleeper += SLEEP_FRAME_COUNT;
          }
          if (null != pImage)
          {
            pImage.ZoomFromTop = !pItem.IsFolder && _zoom;
            pImage.ImageAlignment = _imageAlignment;
            pImage.ImageVAlignment = _imageVAlignment;
            pImage.Width = _thumbNailWidth + 2 * iOverSized;
            pImage.Height = _thumbNailHeight + 2 * iOverSized;
            pImage.SetPosition(_thumbNailPositionX - iOverSized + dwPosX, _thumbNailPositionY - iOverSized + dwPosY);
            pImage.DimColor = DimColor;

            if (itemFocused)
            {
              pImage.ColourDiffuse = 0xffffffff;
            }
            else
            {
              pImage.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
            }
            if (pImage.Focus != itemFocused)
            {
              _imageFolderFocus[itemNumber].Focus = !itemFocused;
              // ensure that _imageFolderFocus is in sync with pImage  }
              _imageFolder[itemNumber].Focus = !itemFocused;
              _frameFocusControl[itemNumber].Focus = !itemFocused;
              _frameControl[itemNumber].Focus = !itemFocused;
            }
            pImage.Focus = itemFocused;


            TransformMatrix matrix = GUIGraphicsContext.ControlTransform;
            GUIGraphicsContext.ControlTransform = new TransformMatrix();

            pImage.UpdateVisibility();
            pImage.DoRender(timePassed, currentTime);
            tm = pImage.getTransformMatrix(currentTime);
            GUIGraphicsContext.ControlTransform = matrix;
          }
        }
      }

      if (bFocus == true && Focus && _listType == GUIListControl.ListType.CONTROL_LIST)
      {
        TransformMatrix matrix = GUIGraphicsContext.ControlTransform;
        GUIGraphicsContext.ControlTransform = new TransformMatrix();
        //doesn't render items when scrolling left if this "if" clause is uncommented - should be fixed later
        if (!_scrollingLeft)
        {
          if (_showFolder)
          {
            _imageFolderFocus[itemNumber].SetPosition(dwPosX, dwPosY);
            _imageFolder[itemNumber].Focus = true;
            _imageFolderFocus[itemNumber].Focus = true;

            if (true == _showTexture)
            {
              _imageFolderFocus[itemNumber].UpdateVisibility();
              _imageFolderFocus[itemNumber].DoRender(timePassed, currentTime);
            }
            for (int i = 0; i < _imageFolderFocus.Count; ++i)
            {
              if (i != itemNumber)
              {
                _imageFolder[i].Focus = false;
                _imageFolderFocus[i].Focus = false;
              }
            }
          }

          if (_showFrame)
          {
            _frameFocusControl[itemNumber].Focus = true;
            _frameFocusControl[itemNumber].SetPosition(dwPosX, dwPosY);
            _frameFocusControl[itemNumber].UpdateVisibility();
            _frameFocusControl[itemNumber].DoRender(timePassed, currentTime);
            for (int i = 0; i < _frameFocusControl.Count; ++i)
            {
              if (i != itemNumber)
              {
                _frameControl[i].Focus = false;
                _frameFocusControl[i].Focus = false;
              }
            }
          }
        }

        if (tm != null)
        {
          GUIGraphicsContext.AddTransform(tm);
        }

        _listLabels[itemNumber].XPosition = dwPosX + _textXOff;
        _listLabels[itemNumber].YPosition = (int)Math.Truncate(fTextPosY + _textYOff);
        _listLabels[itemNumber].Width = _textureWidth;
        _listLabels[itemNumber].Height = _textureHeight;
        _listLabels[itemNumber].TextColor = dwColor;
        _listLabels[itemNumber].Label = pItem.Label;
        _listLabels[itemNumber].AllowScrolling = true;
        _listLabels[itemNumber].Render(timePassed);

        if (tm != null)
        {
          GUIGraphicsContext.RemoveTransform();
        }
        GUIGraphicsContext.ControlTransform = matrix;
      }
      else
      {
        TransformMatrix matrix = GUIGraphicsContext.ControlTransform;
        GUIGraphicsContext.ControlTransform = new TransformMatrix();
        //doesn't render items when scrolling left if this "if" clause is uncommented - should be fixed later
        if (!_scrollingLeft)
        {
          if (_showFolder)
          {
            _imageFolder[itemNumber].SetPosition(dwPosX, dwPosY);
            _imageFolder[itemNumber].Focus = false;
            _imageFolderFocus[itemNumber].Focus = false;
            if (true == _showTexture)
            {
              _imageFolder[itemNumber].UpdateVisibility();
              _imageFolder[itemNumber].DoRender(timePassed, currentTime);
            }
          }

          if (_showFrame)
          {
            _frameControl[itemNumber].Focus = false;
            _frameFocusControl[itemNumber].Focus = false;
            _frameControl[itemNumber].SetPosition(dwPosX, dwPosY);
            _frameControl[itemNumber].UpdateVisibility();
            _frameControl[itemNumber].DoRender(timePassed, currentTime);
          }
        }

        if (tm != null)
        {
          GUIGraphicsContext.AddTransform(tm);
        }
        _listLabels[itemNumber].XPosition = dwPosX + _textXOff;
        _listLabels[itemNumber].YPosition = (int)Math.Truncate(fTextPosY + _textYOff);
        _listLabels[itemNumber].Width = _textureWidth;
        _listLabels[itemNumber].Height = _textureHeight;
        _listLabels[itemNumber].TextColor = dwColor;
        _listLabels[itemNumber].Label = pItem.Label;
        _listLabels[itemNumber].AllowScrolling = false;
        _listLabels[itemNumber].Render(timePassed);
        if (tm != null)
        {
          GUIGraphicsContext.RemoveTransform();
        }
        GUIGraphicsContext.ControlTransform = matrix;
      }
    }
Esempio n. 2
0
    //void SetProperties()

    protected override 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.DisplayName);
          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++;
      }

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

      strLogo = GetChannelLogo(channel.DisplayName);
      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)
      {
        _programs = new List<Program>();

        DateTime dtStart = DateTime.Now;
        dtStart = dtStart.AddDays(-1);

        DateTime dtEnd = dtStart.AddDays(30);

        TvBusinessLayer layer = new TvBusinessLayer();
        _programs = layer.GetPrograms(channel, dtStart, dtEnd);

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

        _recalculateProgramOffset = false;
        bool found = false;
        for (int i = 0; i < _programs.Count; i++)
        {
          Program program = (Program)_programs[i];
          if (program.StartTime <= _viewingTime && program.EndTime >= _viewingTime)
          {
            _programOffset = i;
            found = true;
            break;
          }
        }
        if (!found)
        {
          _programOffset = 0;
        }
      }
      else if (_programOffset < _programs.Count)
      {
        int day = ((Program)_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;

        Program program;
        int offset = _programOffset;
        if (offset + ichan < _programs.Count)
        {
          program = (Program)_programs[offset + ichan];
        }
        else
        {
          // bugfix for 0 items
          if (_programs.Count == 0)
          {
            program = new Program(channel.IdChannel, _viewingTime, _viewingTime, "-", string.Empty, string.Empty,
                                  Program.ProgramState.None,
                                  DateTime.MinValue, string.Empty, string.Empty, string.Empty, string.Empty, -1,
                                  string.Empty, -1);
          }
          else
          {
            program = (Program)_programs[_programs.Count - 1];
            if (program.EndTime.DayOfYear == _viewingTime.DayOfYear)
            {
              program = new Program(channel.IdChannel, program.EndTime, program.EndTime, "-", "-", "-",
                                    Program.ProgramState.None,
                                    DateTime.MinValue, string.Empty, string.Empty, string.Empty, string.Empty, -1,
                                    string.Empty, -1);
            }
            else
            {
              program = new Program(channel.IdChannel, _viewingTime, _viewingTime, "-", "-", "-",
                                    Program.ProgramState.None,
                                    DateTime.MinValue, string.Empty, string.Empty, string.Empty, string.Empty, -1,
                                    string.Empty, -1);
            }
          }
        }

        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.Genre);
          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.Genre);
          img.IsVisible = true;
          img.DoUpdate();
        }
        img.RenderLeft = false;
        img.RenderRight = false;
        img.StretchIfNotRendered = true;

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

        img.Data = program;
        img.ColourDiffuse = GetColorForGenre(program.Genre);
        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 = TVUtil.GetDisplayTitle(program);

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

        if (program.StartTime.DayOfYear != _viewingTime.DayOfYear)
        {
          img.Label1 = String.Format("{0} {1}", Utils.GetShortDayString(program.StartTime),
                                     TVUtil.GetDisplayTitle(program));
        }

        GUILabelControl labelTemplate;
        if (program.IsRunningAt(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 (program.IsRunningAt(dt))
        {
          img.TextColor2 = 0xff101010;
          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);
        }
        imgCh.Label1 = strTimeSingle;
        imgCh.TexutureIcon = "";

        if (program.IsRunningAt(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 (program.Notify)
        {
          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 (bRecording)
        {
          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 (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.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)
            {
              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";
              }
              else
              {
                if (bConflict)
                {
                  img.TexutureIcon = Thumbs.TvConflictRecordingIcon;
                }
                else if (bSeries)
                {
                  img.TexutureIcon = Thumbs.TvRecordingSeriesIcon;
                }
                else
                {
                  img.TexutureIcon = Thumbs.TvRecordingIcon;
                }
              }
            }
          }
        }
      }
    }
Esempio n. 3
0
    public PlaneScene(VMR9Util util)
    {
      //	Log.Info("PlaneScene: ctor()");

      _textureAddress = 0;
      _vmr9Util = util;

      // Number of vertex buffers must be same as numer of segments in non-linear stretch
      _vertexBuffers = new VertexBuffer[nlsSourcePartitioning.Length];
      for (int i = 0; i < _vertexBuffers.Length; i++)
      {
        _vertexBuffers[i] = new VertexBuffer(typeof (CustomVertex.TransformedColoredTextured),
                                             4,
                                             GUIGraphicsContext.DX9Device,
                                             0,
                                             CustomVertex.TransformedColoredTextured.Format,
                                             GUIGraphicsContext.GetTexturePoolType());
      }

      _blackImage = new GUIImage(0);
      _blackImage.SetFileName("black.png");
      _blackImage.AllocResources();

      _cropSettings = new CropSettings();
    }
Esempio n. 4
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();
            }
        }
Esempio n. 5
0
    private void RenderItem(float timePassed, int iButton, bool bFocus, int dwPosX, int dwPosY, GUIListItem pItem,
                            bool buttonOnly)
    {
      if (_listButtons == null)
      {
        return;
      }
      if (iButton < 0 || iButton >= _listButtons.Count)
      {
        return;
      }
      GUIButtonControl btn = _listButtons[iButton];
      if (btn == null)
      {
        return;
      }

      btn.Width = _textureWidth;
      btn.Height = _textureHeight;

      bool clipping = false;
      if (bFocus && Focus)
      {
        Rectangle clipRect = new Rectangle();
        clipRect.X = _positionX - _zoomXPixels / 2;
        clipRect.Y = _positionY - _zoomYPixels / 2;
        clipRect.Width = (_columnCount * _itemWidth) + _zoomXPixels + (_zoomXPixels / 2);
        clipRect.Height = (_rowCount * _itemHeight) + _zoomYPixels + (_zoomYPixels / 2);
        if (clipRect.X < 0)
        {
          clipRect.X = 0;
        }
        if (clipRect.Y < 0)
        {
          clipRect.Y = 0;
        }
        GUIGraphicsContext.BeginClip(clipRect, false);
        clipping = true;
      }

      float fTextPosY = (float)dwPosY + (float)_textureHeight;

      long dwColor = _textColor;
      if (pItem.Selected)
      {
        dwColor = _selectedColor;
      }
      if (pItem.IsPlayed)
      {
        dwColor = _playedColor;
      }
      if (!bFocus && Focus)
      {
        dwColor = Color.FromArgb(_unfocusedAlpha, Color.FromArgb((int)dwColor)).ToArgb();
      }

      if (pItem.IsRemote)
      {
        dwColor = _remoteColor;
        if (pItem.IsDownloading)
        {
          dwColor = _downloadColor;
        }
      }

      if (pItem.IsBdDvdFolder)
      {
        dwColor = _bdDvdDirectoryColor;
      }

      if (!Focus)
      {
        dwColor &= DimColor;
      }

      if (bFocus == true && Focus && m_iSelect == GUIListControl.ListType.CONTROL_LIST)
      {
        if (buttonOnly)
        {
          btn.ColourDiffuse = 0xffffffff;
          btn.Focus = true;
          btn.SetPosition(dwPosX, dwPosY);
          //if (true == _showTexture) btn.Render(timePassed);

          if (clipping)
          {
            GUIGraphicsContext.EndClip();
          }
          return;
        }
        if (fTextPosY >= _positionY && _renderFocusText)
        {
          _listLabels[iButton].XPosition = dwPosX + _textXOff;
          _listLabels[iButton].YPosition = (int)Math.Truncate(fTextPosY + _textYOff + _zoomYPixels);
          _listLabels[iButton].Width = _textureWidth;
          _listLabels[iButton].Height = _textureHeight;
          _listLabels[iButton].TextColor = dwColor;
          _listLabels[iButton].Label = pItem.Label;
          _listLabels[iButton].AllowScrolling = true;
          _listLabels[iButton].Render(timePassed);
        }
      }
      else
      {
        if (buttonOnly)
        {
          btn.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
          if (!btn.Focus)
          {
            btn.SetPosition(dwPosX, dwPosY);
          }
          btn.Focus = false;
          if (!_hideUnfocusTexture)
          {
            btn.Render(timePassed);
          }
          if (_showFrame)
          {
            _frameFocusControl.Focus = btn.Focus;
            _frameFocusControl.SetPosition(btn._positionX, btn._positionY);
            _frameFocusControl.Width = btn.Width;
            _frameFocusControl.Height = btn.Height;
            _frameFocusControl.Render(timePassed);
          }

          if (clipping)
          {
            GUIGraphicsContext.EndClip();
          }
          return;
        }
        if (fTextPosY >= _positionY && _renderUnfocusText)
        {
          _listLabels[iButton].XPosition = dwPosX + _textXOff;
          _listLabels[iButton].YPosition = (int)Math.Truncate(fTextPosY + _textYOff);
          _listLabels[iButton].Width = _textureWidth;
          _listLabels[iButton].Height = _textureHeight;
          _listLabels[iButton].TextColor = dwColor;
          _listLabels[iButton].Label = pItem.Label;
          _listLabels[iButton].AllowScrolling = false;
          _listLabels[iButton].Render(timePassed);
        }
      }

      // Set oversized value
      int iOverSized = 0;
      if (bFocus && Focus && _enableFocusZoom && _zoomXPixels == 0 && _zoomYPixels == 0)
      {
        iOverSized = (_thumbNailWidth + _thumbNailHeight) / THUMBNAIL_OVERSIZED_DIVIDER;
      }

      GUIImage pFocusImage = null;
      if (pItem.HasThumbnail)
      {
        GUIImage pImage = pItem.Thumbnail;
        pFocusImage = pImage;
        if (null == pImage /*&& _sleeper==0 */&& !IsAnimating)
        {
          pImage = new GUIImage(0, 0, _xPositionThumbNail - iOverSized + dwPosX,
                                _yPositionThumbNail - iOverSized + dwPosY, _thumbNailWidth + 2 * iOverSized,
                                _thumbNailHeight + 2 * iOverSized, pItem.ThumbnailImage, 0x0);

          if (pImage != null)
          {
            pImage.ParentControl = this;
            pImage.KeepAspectRatio = _keepAspectRatio;
            pImage.ImageAlignment = Alignment.ALIGN_CENTER;
            pImage.ImageVAlignment = VAlignment.ALIGN_MIDDLE;
            pImage.MaskFileName = _textureMask;
            pImage.ZoomFromTop = !pItem.IsFolder && _zoom;
            pImage.AllocResources();
            pItem.Thumbnail = pImage;
            pImage.SetPosition(_xPositionThumbNail - iOverSized + dwPosX, _yPositionThumbNail - iOverSized + dwPosY);
            pImage.DimColor = DimColor;
            if (bFocus || !Focus)
            {
              pImage.ColourDiffuse = 0xffffffff;
            }
            else
            {
              pImage.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
            }
            if (bFocus && (_zoomXPixels != 0 || _zoomYPixels != 0))
            {
              pImage.Width = _textureWidth + _zoomXPixels;
              pImage.Height = _textureHeight + _zoomYPixels;
              pImage.SetPosition(dwPosX - (_zoomXPixels / 2), dwPosY - (_zoomYPixels / 2));
            }
            pImage.Render(timePassed);
            _sleeper += SLEEP_FRAME_COUNT;
          }
        }
        if (null != pImage)
        {
          if (pImage.TextureHeight == 0 && pImage.TextureWidth == 0)
          {
            pImage.SafeDispose();
            pImage.AllocResources();
          }
          pImage.ZoomFromTop = !pItem.IsFolder && _zoom;
          pImage.Width = _thumbNailWidth + 2 * iOverSized;
          pImage.Height = _thumbNailHeight + 2 * iOverSized;
          pImage.ImageAlignment = Alignment.ALIGN_CENTER;
          pImage.ImageVAlignment = VAlignment.ALIGN_MIDDLE;
          pImage.MaskFileName = _textureMask;
          pImage.SetPosition(_xPositionThumbNail + dwPosX - iOverSized, _yPositionThumbNail - iOverSized + dwPosY);
          pImage.DimColor = DimColor;
          if (bFocus || !Focus)
          {
            pImage.ColourDiffuse = 0xffffffff;
          }
          else
          {
            pImage.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
          }
          if (bFocus && (_zoomXPixels != 0 || _zoomYPixels != 0))
          {
            pImage.Width = _textureWidth + _zoomXPixels;
            pImage.Height = _textureHeight + _zoomYPixels;
            pImage.SetPosition(dwPosX - (_zoomXPixels / 2), dwPosY - (_zoomYPixels / 2));
          }
          pImage.Render(timePassed);
        }
      }
      else
      {
        if (pItem.HasIconBig)
        {
          GUIImage pImage = pItem.IconBig;
          pFocusImage = pImage;
          if (null == pImage /*&& _sleeper==0 */&& !IsAnimating)
          {
            pImage = new GUIImage(0, 0, _xPositionThumbNail - iOverSized + dwPosX,
                                  _yPositionThumbNail - iOverSized + dwPosY, _thumbNailWidth + 2 * iOverSized,
                                  _thumbNailHeight + 2 * iOverSized, pItem.IconImageBig, 0x0);
            pImage.ParentControl = this;
            pImage.KeepAspectRatio = _keepAspectRatio;
            pImage.ImageAlignment = Alignment.ALIGN_CENTER;
            pImage.ImageVAlignment = VAlignment.ALIGN_MIDDLE;
            pImage.MaskFileName = _textureMask;
            pImage.ZoomFromTop = !pItem.IsFolder && _zoom;

            pImage.AllocResources();
            pItem.IconBig = pImage;
            pImage.SetPosition(_xPositionThumbNail + dwPosX - iOverSized, _yPositionThumbNail - iOverSized + dwPosY);
            pImage.DimColor = DimColor;
            if (bFocus || !Focus)
            {
              pImage.ColourDiffuse = 0xffffffff;
            }
            else
            {
              pImage.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
            }
            if (bFocus && (_zoomXPixels != 0 || _zoomYPixels != 0))
            {
              pImage.Width = _textureWidth + _zoomXPixels;
              pImage.Height = _textureHeight + _zoomYPixels;
              pImage.SetPosition(dwPosX - (_zoomXPixels / 2), dwPosY - (_zoomYPixels / 2));
            }
            pImage.Render(timePassed);
            _sleeper += SLEEP_FRAME_COUNT;
          }
          else if (null != pImage)
          {
            if (pImage.TextureHeight == 0 && pImage.TextureWidth == 0)
            {
              pImage.SafeDispose();
              pImage.AllocResources();
            }
            pImage.ZoomFromTop = !pItem.IsFolder && _zoom;
            pImage.ImageAlignment = Alignment.ALIGN_CENTER;
            pImage.ImageVAlignment = VAlignment.ALIGN_MIDDLE;
            pImage.MaskFileName = _textureMask;
            pImage.Width = _thumbNailWidth + 2 * iOverSized;
            pImage.Height = _thumbNailHeight + 2 * iOverSized;
            pImage.SetPosition(_xPositionThumbNail - iOverSized + dwPosX, _yPositionThumbNail - iOverSized + dwPosY);
            pImage.DimColor = DimColor;
            if (bFocus || !Focus)
            {
              pImage.ColourDiffuse = 0xffffffff;
            }
            else
            {
              pImage.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
            }
            if (bFocus && (_zoomXPixels != 0 || _zoomYPixels != 0))
            {
              pImage.Width = _textureWidth + _zoomXPixels;
              pImage.Height = _textureHeight + _zoomYPixels;
              pImage.SetPosition(dwPosX - (_zoomXPixels / 2), dwPosY - (_zoomYPixels / 2));
            }
            pImage.Render(timePassed);
          }
        }
      }
      if (bFocus && Focus)
      {
        btn.Width = _textureWidth + _zoomXPixels;
        btn.Height = _textureHeight + _zoomYPixels;
        btn.SetPosition(dwPosX - (_zoomXPixels / 2), dwPosY - (_zoomYPixels / 2));
        btn.Render(timePassed);
        if (pFocusImage != null/* && _zoomXPixels == 0 && _zoomYPixels == 0*/)
        {
          pFocusImage.ImageAlignment = Alignment.ALIGN_CENTER;
          pFocusImage.ImageVAlignment = VAlignment.ALIGN_MIDDLE;
          pFocusImage.Render(timePassed);
        }
        if (_showFrame)
        {
          //_frameFocusControl.Focus = btn.Focus;
          _frameFocusControl.SetPosition(btn._positionX, btn._positionY);
          _frameFocusControl.Width = btn.Width;
          _frameFocusControl.Height = btn.Height;
          _frameFocusControl.Render(timePassed);
        }
      }
      else
      {
        if (_showFrame)
        {
          //_frameNoFocusControl.Focus = btn.Focus;
          _frameNoFocusControl.SetPosition(dwPosX, dwPosY);
          _frameNoFocusControl.Width = btn.Width + 2 * iOverSized;
          _frameNoFocusControl.Height = btn.Height + 2 * iOverSized;
          _frameNoFocusControl.Render(timePassed);
        }
        btn.Width = _textureWidth;
        btn.Height = _textureHeight;
      }

      if (clipping)
      {
        GUIGraphicsContext.EndClip();
      }
    }
    protected virtual void RenderIcon(float timePassed, int buttonNr, int x, int y, bool gotFocus)
    {
      GUIListItem pItem = _listItems[buttonNr + _offset];

      if (pItem.HasIcon)
      {
        if (MediaPortal.Util.Utils.FileExistsInCache(pItem.ThumbnailImage))
        {
          pItem.IconImage = pItem.ThumbnailImage;
        }
        // show icon
        GUIImage pImage = pItem.Icon;
        if (null == pImage)
        {
          pImage = new GUIImage(0, 0, 0, 0, _imageWidth, _imageHeight, pItem.IconImage, 0x0)
                     {
                       ParentControl = this,
                       KeepAspectRatio = _keepAspectRatio
                     };
          pImage.AllocResources();
          pItem.Icon = pImage;
        }
        if (pImage.TextureHeight == 0 && pImage.TextureWidth == 0)
        {
          pImage.SafeDispose();

          pImage = new GUIImage(0, 0, 0, 0, _imageWidth, _imageHeight, pItem.IconImage, 0x0)
                     {
                       ParentControl = this,
                       KeepAspectRatio = _keepAspectRatio
                     };
          pImage.AllocResources();
          pItem.Icon = pImage;

          //pImage.AllocResources();
        }
        pImage.KeepAspectRatio = _keepAspectRatio;
        pImage.Width = _imageWidth;
        pImage.Height = _imageHeight;
        pImage.SetPosition(x, y);
        if (gotFocus || !Focus)
        {
          pImage.ColourDiffuse = 0xffffffff;
        }
        else
        {
          pImage.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
        }
        if (!pItem.Selected && !gotFocus && _unfocusedAlphaApplyToAll)
        {
          pImage.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
        }
        pImage.DimColor = DimColor;
        pImage.Render(timePassed);
      }
    }
    protected virtual void RenderPinIcon(float timePassed, int buttonNr, int x, int y, bool gotFocus)
    {
      GUIListItem pItem = _listItems[buttonNr + _offset];
      if (pItem.HasPinIcon)
      {
        GUIImage pinImage = pItem.PinIcon;
        if (null == pinImage)
        {
          //pinImage = new GUIImage(0, 0, 0, 0, 0, 0, pItem.PinImage, 0x0);
          pinImage = new GUIImage(0, 0, 0, 0, _widthPinIcon, _heightPinIcon, pItem.PinImage, 0x0)
                       {
                         ParentControl = this,
                         KeepAspectRatio = _keepAspectRatio
                       };
          pinImage.AllocResources();
          pItem.PinIcon = pinImage;
        }
        pinImage.KeepAspectRatio = _keepAspectRatio;
        pinImage.Width = PinIconWidth;
        pinImage.Height = PinIconHeight;


        if (PinIconOffsetY < 0 || PinIconOffsetX < 0)
        {
          pinImage.SetPosition(x + (_width) - (pinImage.TextureWidth + pinImage.TextureWidth / 2),
                               y + (_height / 2) - (pinImage.TextureHeight / 2));
        }
        else
        {
          pinImage.SetPosition(x + PinIconOffsetX, y + PinIconOffsetY);
        }

        if (gotFocus || !Focus)
        {
          pinImage.ColourDiffuse = 0xffffffff;
        }
        else
        {
          pinImage.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
        }

        if (!pItem.Selected && !gotFocus && _unfocusedAlphaApplyToAll)
        {
          pinImage.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
        }
        pinImage.DimColor = DimColor;
        pinImage.Render(timePassed);
      }
    }
Esempio n. 8
0
    /// <summary>
    /// Draws the front of a single item of the cover flow.
    /// </summary>
    /// <param name="timePassed"></param>
    /// <param name="index">The index of the card in the entire set.</param>
    /// <param name="shouldFocus">True if the card should be in focus.</param>
    private void RenderCardFront(float timePassed, int index, bool shouldFocus)
    {
      GUIListItem pItem = _listItems[index];
      GUIImage pCard = null;
      bool itemFocused = (shouldFocus == true);
      uint currentTime = (uint)System.Windows.Media.Animation.AnimationTimer.TickCount;

      if (pItem.HasThumbnail)
      {
        pCard = pItem.Thumbnail;
        if (null == pCard && !IsAnimating)
        {
          pCard = new GUIImage(0, 0,
                               0, 0,
                               _cardWidth, _cardHeight,
                               pItem.ThumbnailImage, 0x0);

          pCard.ParentControl = null; // We want to be able to treat each card as a control.
          pCard.KeepAspectRatio = _keepAspectRatio;
          pCard.ZoomFromTop = !pItem.IsFolder && _zoom;
          pCard.ImageAlignment = _imageAlignment;
          pCard.ImageVAlignment = _imageVAlignment;
          pCard.FlipY = _flipY;
          pCard.DiffuseFileName = _diffuseFilename;
          pCard.MaskFileName = _maskFilename;
          pCard.DimColor = DimColor;
          pCard.AllocResources();

          pItem.Thumbnail = pCard;
        }

        if (null != pCard)
        {
          if (pCard.TextureHeight == 0 && pCard.TextureWidth == 0)
          {
            pCard.SafeDispose();
            pCard.AllocResources();
          }

          if (itemFocused)
          {
            pCard.ColourDiffuse = 0xffffffff;
            pCard.Focus = true;
          }
          else
          {
            pCard.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
            pCard.Focus = false;
          }

          // Ensure our card is setup as we expect because other views (filmstrip) may have changed these values.
          pCard.KeepAspectRatio = _keepAspectRatio;
          pCard.ZoomFromTop = !pItem.IsFolder && _zoom;
          pCard.ImageAlignment = _imageAlignment;
          pCard.ImageVAlignment = _imageVAlignment;
          pCard.FlipY = _flipY;
          pCard.DiffuseFileName = _diffuseFilename;
          pCard.MaskFileName = _maskFilename;
          pCard.DimColor = DimColor;
          pCard.Width = _cardWidth;
          pCard.Height = _cardHeight;

          pCard.UpdateVisibility();
          pCard.Render(timePassed);
        }
      }
      else if (pItem.HasIconBig)
      {
        pCard = pItem.IconBig;
        if (null == pCard && !IsAnimating)
        {
          pCard = new GUIImage(0, 0,
                               0, 0,
                               _cardWidth, _cardHeight,
                               pItem.IconImageBig, 0x0);

          pCard.ParentControl = null; // We want to be able to treat each card as a control.
          pCard.KeepAspectRatio = _keepAspectRatio;
          pCard.ZoomFromTop = !pItem.IsFolder && _zoom;
          pCard.ImageAlignment = _imageAlignment;
          pCard.ImageVAlignment = _imageVAlignment;
          pCard.FlipY = _flipY;
          pCard.DiffuseFileName = _diffuseFilename;
          pCard.MaskFileName = _maskFilename;
          pCard.DimColor = DimColor;
          pCard.AllocResources();

          pItem.IconBig = pCard;
        }
        if (null != pCard)
        {
          if (itemFocused)
          {
            pCard.ColourDiffuse = 0xffffffff;
            pCard.Focus = true;
          }
          else
          {
            pCard.ColourDiffuse = Color.FromArgb(_unfocusedAlpha, Color.White).ToArgb();
            pCard.Focus = false;
          }

          // Ensure our card is setup as we expect because other views (filmstrip) may have changed these values.
          pCard.KeepAspectRatio = _keepAspectRatio;
          pCard.ZoomFromTop = !pItem.IsFolder && _zoom;
          pCard.ImageAlignment = _imageAlignment;
          pCard.ImageVAlignment = _imageVAlignment;
          pCard.FlipY = _flipY;
          pCard.DiffuseFileName = _diffuseFilename;
          pCard.MaskFileName = _maskFilename;
          pCard.DimColor = DimColor;
          pCard.Width = _cardWidth;
          pCard.Height = _cardHeight;

          pCard.UpdateVisibility();
          pCard.Render(timePassed);
        }
      }

      // Render the card frame.
      if (_showFrame)
      {
        // Choose a frame for the card from the collection of frames for rendered cards.
        GUIAnimation frame = (itemFocused ? _frameFocus : _frame[GetNextAvailableFrameIndex()]);
        frame.Focus = itemFocused;
        frame.Width = _frameWidth;
        frame.Height = _frameHeight;
        frame.MaskFileName = _maskFilename;

        // Center the frame over the card.
        int x = Math.Abs(_frameWidth - _cardWidth) / 2;
        int y = Math.Abs(_frameHeight - _cardHeight) / 2;
        if (_frameWidth >= _cardWidth)
        {
          x = -x;
        }
        if (_frameHeight >= _cardHeight)
        {
          y = -y;
        }

        frame.SetPosition(x, y);
        frame.UpdateVisibility();
        frame.Render(timePassed);
      }
    }
Esempio n. 9
0
    public override void AllocResources()
    {
      _fontNamedKey = GUIFontManager.GetFont(_namedKeyFont);
      _fontCharKey = GUIFontManager.GetFont(_charKeyFont);
      _fontSearchText = GUIFontManager.GetFont(_inputTextFont);

      labelBox = new GUIImage(GetID, 1, 0, 0, 10, 10, _labelBoxTexture, 1);
      labelBox.AllocResources();

      label = new GUILabelControl(GetID);
      label.FontName = _labelFont;
      label.SetShadow(_labelShadowAngle, _labelShadowDistance, _labelShadowColor);
      label.AllocResources();

      inputTextBox = new GUIImage(GetID, 1, 0, 0, 10, 10, _inputTextBoxTexture, 1);
      inputTextBox.AllocResources();

      inputText = new GUILabelControl(GetID);
      inputText.FontName = _inputTextFont;
      inputText.SetShadow(_inputTextShadowAngle, _inputTextShadowDistance, _inputTextShadowColor);
      inputText.AllocResources();

      inputTextCaret = new GUILabelControl(GetID);
      inputTextCaret.FontName = _inputTextFont;
      inputTextCaret.SetShadow(_inputTextShadowAngle, _inputTextShadowDistance, _inputTextShadowColor);
      inputTextCaret.AllocResources();

      base.AllocResources();
      _isAllocated = true;
    }
Esempio n. 10
0
    protected void RenderGenreKey()
    {
      GUIImage imgGenreColor = (GUIImage)GetControl((int)Controls.GENRE_COLOR_KEY_PAIR);
      GUIFadeLabel labelGenreName = (GUIFadeLabel)GetControl((int)Controls.GENRE_COLOR_KEY_PAIR + 1);

      MpGenre genreObj = _mpGenres.Find(x => x.Enabled == true);

      // Do not render the key if the template controls are not present or there are no enabled mp genres.
      if (imgGenreColor == null || labelGenreName == null || genreObj == null)
      {
        return;
      }

      // Display the genre key.
      var genreKeys = _genreColorsOnLater.Keys.ToList();
      genreKeys.Sort();
      int xpos, i = 0;
      int xoffset = 0;
      foreach (var genreName in genreKeys)
	    {
        // If the genre is not enabled then skip it.  This can occur if the user desires to have less than the maximum number of MP genres available.
        genreObj = ((List<MpGenre>)_mpGenres).Find(x => x.Name.Equals(genreName));
        if (!genreObj.Enabled)
        {
          continue;
        }

        xpos = imgGenreColor.XPosition + xoffset;

        GUIImage img = GetControl((int)Controls.GENRE_COLOR_KEY_PAIR + (2 * i)) as GUIImage;
        if (img == null)
        {
          img = new GUIImage(GetID, (int)Controls.GENRE_COLOR_KEY_PAIR + (2 * i), xpos, imgGenreColor.YPosition, imgGenreColor.Width,
                             imgGenreColor.Height, imgGenreColor.FileName, 0x0);
          img.AllocResources();
          GUIControl cntl = (GUIControl)img;
          Add(ref cntl);
        }
        img.IsVisible = true;
        img.ColourDiffuse = _genreColorsOnLater[genreName];
        img.OverlayFileName = imgGenreColor.OverlayFileName;
        img.SetPosition(xpos, imgGenreColor.YPosition);
        img.DoUpdate();

        GUIFadeLabel label = GetControl(((int)Controls.GENRE_COLOR_KEY_PAIR + 1) + (2 * i)) as GUIFadeLabel;
        if (label == null)
        {
          label = new GUIFadeLabel(GetID, ((int)Controls.GENRE_COLOR_KEY_PAIR + 1) + (2 * i), 0, 0, labelGenreName.Width,
                                   labelGenreName.Height, labelGenreName.FontName,
                                   labelGenreName.TextColor, labelGenreName.TextAlignment, labelGenreName.TextVAlignment,
                                   labelGenreName.ShadowAngle, labelGenreName.ShadowDistance, labelGenreName.ShadowColor,
                                   string.Empty);

          label.AllocResources();
          GUIControl cntl = (GUIControl)label;
          this.Add(ref cntl);
        }
        label.Label = genreName;
        label.SetPosition(xpos + imgGenreColor.Width + 10, labelGenreName.YPosition);
        label.ScrollStartDelay = labelGenreName.ScrollStartDelay;
        label.IsVisible = true;

        // Compute position of the next key.
        int w = label.Width;
        if (label.TextWidth < label.Width)
        {
          w = label.TextWidth;
        }

        xoffset += (int)(imgGenreColor.Width * 2.3 + w);
        i++;
      }
    }
Esempio n. 11
0
    public override void AllocResources()
    {
      base.AllocResources();

      m_imgFocus = new GUIImage(GetID, GetID * 10, _positionX, _positionY, this.Width, this.Height,
                                "icon_empty_focus.png",
                                0xFFFFFFFF);
      m_imgFocus.AllocResources();
      m_imgNoFocus = new GUIImage(GetID, GetID * 100, _positionX, _positionY, this.Width, this.Height,
                                  "icon_empty_nofocus.png", 0xFFFFFFFF);
      m_imgNoFocus.AllocResources();
      for (int i = 0; i < 9; i++)
      {
        m_imgOverlay[i] = new GUIImage(GetID, GetID * 1000 + i, _positionX, _positionY, this.Width, this.Height,
                                       string.Format("icon_numberplace_overlay_{0}.png", i + 1), 0xFFFFFFFF);
        m_imgOverlay[i].AllocResources();
      }

      m_label = new GUILabelControl(GetID, GetID * 1000, _positionX, _positionY, this.Width, this.Height, this.FontName,
                                    string.Empty, 0xFFFFFFFF, Alignment.ALIGN_CENTER, VAlignment.ALIGN_MIDDLE, false,
                                    _shadowAngle, _shadowDistance, _shadowColor);
      _colorOverlay = new GUIImage(GetID, GetID * 10, _positionX, _positionY, this.Width, this.Height,
                                   "icon_numberplace_colouroverlay.png", 0xFFFFFFFF);
      _colorOverlay.AllocResources();
    }
    protected void RenderGenreKey()
    {
      GUIImage imgGenreColor = (GUIImage)GetControl((int)Controls.GENRE_COLOR_KEY_PAIR);
      GUIFadeLabel labelGenreName = (GUIFadeLabel)GetControl((int)Controls.GENRE_COLOR_KEY_PAIR + 1);

      // Do not render the key if not required or the template controls are not present or are specified as not visible.
      if (imgGenreColor == null || labelGenreName == null || !imgGenreColor.Visible)
      {
        return;
      }

      int xpos, i = 0;
      int xoffset = 0;

      var genreKeys = _genreColorsOnLater.Keys.ToList();
      genreKeys.Sort();

      // Loop through genre names.
      foreach (var genreName in genreKeys)
	    {
        xpos = imgGenreColor.XPosition + xoffset;

        GUIImage img = GetControl((int)Controls.GENRE_COLOR_KEY_PAIR + (2 * i)) as GUIImage;
        if (img == null)
        {
          img = new GUIImage(GetID, (int)Controls.GENRE_COLOR_KEY_PAIR + (2 * i), xpos, imgGenreColor.YPosition, imgGenreColor.Width,
                             imgGenreColor.Height, imgGenreColor.FileName, 0x0);
          img.AllocResources();
          GUIControl cntl = (GUIControl)img;
          Add(ref cntl);
        }
        img.IsVisible = true;
        img.ColourDiffuse = _genreColorsOnLater[genreName];
        img.OverlayFileName = imgGenreColor.OverlayFileName;
        img.SetPosition(xpos, imgGenreColor.YPosition);
        img.DoUpdate();

        GUIFadeLabel label = GetControl(((int)Controls.GENRE_COLOR_KEY_PAIR + 1) + (2 * i)) as GUIFadeLabel;
        if (label == null)
        {
          label = new GUIFadeLabel(GetID, ((int)Controls.GENRE_COLOR_KEY_PAIR + 1) + (2 * i), 0, 0, labelGenreName.Width,
                                   labelGenreName.Height, labelGenreName.FontName,
                                   labelGenreName.TextColor, labelGenreName.TextAlignment, labelGenreName.TextVAlignment,
                                   labelGenreName.ShadowAngle, labelGenreName.ShadowDistance, labelGenreName.ShadowColor,
                                   string.Empty);

          label.AllocResources();
          GUIControl cntl = (GUIControl)label;
          this.Add(ref cntl);
        }
        label.Label = genreName;
        label.SetPosition(xpos + imgGenreColor.Width + 10, labelGenreName.YPosition);
        label.ScrollStartDelay = labelGenreName.ScrollStartDelay;
        label.IsVisible = true;

        // Compute position of the next key.
        int w = label.Width;
        if (label.TextWidth < label.Width)
        {
          w = label.TextWidth;
        }

        xoffset += (int)(imgGenreColor.Width * 2.3 + w);
        i++;
      }
    }