Ejemplo n.º 1
0
 /// <summary>
 /// Creates the element and retrieves all information from the control
 /// </summary>
 /// <param name="control">GUIControl</param>
 public FadeLabelElement(GUIControl control)
     : base(control)
 {
     _label = control as GUIFadeLabel;
       if (_label != null)
       {
     _font = GetFont(_label.FontName);
     _brush = new SolidBrush(GetColor(_label.TextColor));
     _labelString = _label.Label;
       }
 }
    /*public GUIFilmstripControl(int dwParentID, int dwControlId, int dwPosX, int dwPosY, int dwWidth, int dwHeight, 
      string strFontName, 
      string strImageIcon, 
      string strImageIconFocus, 
      int dwitemWidth, int dwitemHeight, 
      int dwSpinWidth, int dwSpinHeight, 
      string strUp, string strDown, 
      string strUpFocus, string strDownFocus, 
      long dwSpinColor, int dwSpinX, int dwSpinY, 
      string strFont, long dwTextColor, long dwSelectedColor, 
      string strScrollbarBackground, string strScrollbarTop, string strScrollbarBottom)
      : base(dwParentID, dwControlId, dwPosX, dwPosY, dwWidth, dwHeight)
    {
    }*/

    /// <summary> 
    /// This function is called after all of the XmlSkinnable fields have been filled
    /// with appropriate data.
    /// Use this to do any construction work other than simple data member assignments,
    /// for example, initializing new reference types, extra calculations, etc..
    /// </summary>
    public override void FinalizeConstruction()
    {
      base.FinalizeConstruction();
      if (_positionY > _positionY && _spinControlPositionY < _positionY + _height)
      {
        _spinControlPositionY = _positionY + _height;
      }
      for (int i = 0; i < 30; ++i)
      {
        GUIAnimation anim = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _itemWidth,
                                                 _itemHeight, _imageFolderName);
        anim.ParentControl = this;
        anim.DimColor = DimColor;
        anim.FlipX = _flipX;
        anim.FlipY = _flipY;
        anim.DiffuseFileName = _diffuseFileName;
        anim.MaskFileName = _imageFolderMask;
        //anim.SetAnimations(ThumbAnimations);
        _imageFolder.Add(anim);

        anim = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _itemWidth, _itemHeight,
                                    _imageFolderNameFocus);
        anim.ParentControl = this;
        anim.DimColor = DimColor;
        anim.FlipX = _flipX;
        anim.FlipY = _flipY;
        anim.DiffuseFileName = _diffuseFileName;
        anim.MaskFileName = _imageFolderFocusMask;
        //anim.SetAnimations(ThumbAnimations);
        _imageFolderFocus.Add(anim);

        anim = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _itemWidth, _itemHeight,
                                    _frameName);
        anim.ParentControl = this;
        anim.DimColor = DimColor;
        //anim.FlipX = _flipX;
        //anim.FlipY = _flipY;
        anim.DiffuseFileName = _diffuseFileName;
        anim.MaskFileName = _frameMask;
        //anim.SetAnimations(ThumbAnimations);
        _frameControl.Add(anim);

        anim = LoadAnimationControl(_parentControlId, _controlId, _positionX, _positionY, _itemWidth, _itemHeight,
                                    _frameFocusName);
        anim.ParentControl = this;
        anim.DimColor = DimColor;
        //anim.FlipX = _flipX;
        //anim.FlipY = _flipY;
        anim.DiffuseFileName = _diffuseFileName;
        anim.MaskFileName = _frameFocusMask;
        //anim.SetAnimations(ThumbAnimations);
        _frameFocusControl.Add(anim);

        // for label
        GUIFadeLabel fadelabel = new GUIFadeLabel(_parentControlId, _controlId, _positionX, _positionY, _textureWidth,
                                                  _textureHeight, _fontName, _textColor, Alignment.ALIGN_LEFT,
                                                  VAlignment.ALIGN_TOP, 0, 0, 0, " | ");
        fadelabel.ParentControl = this;
        fadelabel.AllowScrolling = false;
        fadelabel.DimColor = DimColor;
        //fadelabel.AllowFadeIn = false;
        _listLabels.Add(fadelabel);
      }

      _upDownControl = new GUISpinControl(_controlId, 0, _spinControlPositionX, _spinControlPositionY, _spinControlWidth,
                                          _spinControlHeight, _upTextureName, _downTextureName, _upTextureNameFocus,
                                          _downTextureNameFocus, _fontName, _spinControlColor,
                                          GUISpinControl.SpinType.SPIN_CONTROL_TYPE_INT, _spinControlAlignment);
      _upDownControl.ParentControl = this;
      _upDownControl.DimColor = DimColor;

      _font = GUIFontManager.GetFont(_fontName);



      // Create the horizontal scrollbar.
      int scrollbarWidth = _scrollbarWidth;
      int scrollbarHeight = _scrollbarHeight;
      GUIGraphicsContext.ScaleHorizontal(ref scrollbarWidth);
      GUIGraphicsContext.ScaleVertical(ref scrollbarHeight);
      int scrollbarPosX = _positionX + (_width / 2) - (scrollbarWidth / 2);

      _horizontalScrollbar = new GUIHorizontalScrollbar(_controlId, 0,
                                                        scrollbarPosX, _positionY + _scrollbarOffsetY,
                                                        scrollbarWidth, scrollbarHeight,
                                                        _scrollbarBackgroundName, _scrollbarLeftName,
                                                        _scrollbarRightName);
      _horizontalScrollbar.ParentControl = this;
      _horizontalScrollbar.DimColor = DimColor;


      _upDownControl.Orientation = eOrientation.Horizontal;
      _upDownControl.SetReverse(true);

      _imageBackground = LoadAnimationControl(0, 0, _backGroundPositionX, _backGroundPositionY, _backGroundWidth,
                                              _backGroundHeight, _backgroundTextureName);
      _imageBackground.ParentControl = this;
      _imageBackground.DimColor = DimColor;

      _imageInfo = new GUIImage(0, 0, _infoImagePositionX, _infoImagePositionY, _infoImageWidth, _infoImageHeight,
                                _infoImageName, 0);
      _imageInfo.ParentControl = this;
      _imageInfo.Filtering = true;
      _imageInfo.KeepAspectRatio = true;
      _imageInfo.ImageAlignment = Alignment.ALIGN_CENTER;
      _imageInfo.ImageVAlignment = VAlignment.ALIGN_MIDDLE;
      _imageInfo.HorizontalAlignment = MediaPortal.Drawing.HorizontalAlignment.Center;
      _imageInfo.VerticalAlignment = MediaPortal.Drawing.VerticalAlignment.Center;
      _imageInfo.DimColor = DimColor;
      _imageInfo.FlipX = _flipInfoImageX;
      _imageInfo.FlipY = _flipInfoImageY;
      _imageInfo.DiffuseFileName = _diffuseInfoImageFileName;
      _imageInfo.MaskFileName = _infoImageMask;

      SetThumbDimensionsLow(_thumbNailPositionX, _thumbNailPositionY, _thumbNailWidth, _thumbNailHeight);
      SetTextureDimensions(_textureWidth, _textureHeight);
    }
Ejemplo n.º 3
0
    private void Calculate()
    {
      float fWidth = 0, fHeight = 0;

      // height of 1 item = folder image height + text row height + space in between
      _font.GetTextExtent("y", ref fWidth, ref fHeight);

      fWidth = (float)_itemWidth;
      fHeight = (float)_itemHeight;
      float fTotalHeight = (float)(_height - 5);
      _rowCount = (int)(fTotalHeight / fHeight);
      _columnCount = (int)(_width / fWidth);

      int iItemsPerPage = _rowCount * _columnCount;
      int iPages = iItemsPerPage == 0 ? 0 : _listItems.Count / iItemsPerPage;
      if (iItemsPerPage != 0)
      {
        if ((_listItems.Count % iItemsPerPage) != 0)
        {
          iPages++;
        }
      }
      _controlUpDown.SetRange(1, iPages);
      _controlUpDown.Value = 1;

      // Dispose used buttoncontrols
      if (_listButtons != null)
      {
        for (int i = 0; i < _listButtons.Count; ++i)
        {
          GUIButtonControl cntl = _listButtons[i];
          cntl.SafeDispose();
        }
      }
      _listButtons = null;

      if (_listLabels != null)
      {
        for (int i = 0; i < _listLabels.Count; ++i)
        {
          GUIFadeLabel cntl = _listLabels[i];
          cntl.SafeDispose();
        }
      }
      _listLabels = null;

      // Create new buttoncontrols
      _listButtons = new List<GUIButtonControl>();
      _listLabels = new List<GUIFadeLabel>();
      for (int i = 0; i < _columnCount * _rowCount; ++i)
      {
        GUIButtonControl btn = new GUIButtonControl(_parentControlId, _controlId, _positionX, _positionY, _textureWidth,
                                                    _textureHeight, _imageFolderNameFocus, _imageFolderName,
                                                    _shadowAngle, _shadowDistance, _shadowColor);
        btn.ParentControl = this;
        btn.SetFocusedTextureMask(_textureMask);
        btn.SetNonFocusedTextureMask(_textureMask);
        btn.SetHoverTextureMask(_textureMask);
        btn.AllocResources();

        _listButtons.Add(btn);

        GUIFadeLabel fadelabel = new GUIFadeLabel(_parentControlId, _controlId, _positionX, _positionY, _textureWidth,
                                                  _textureHeight, _fontName, _textColor, Alignment.ALIGN_LEFT,
                                                  VAlignment.ALIGN_TOP, _shadowAngle, _shadowDistance, _shadowColor,
                                                  " | ");
        fadelabel.DimColor = DimColor;
        fadelabel.ParentControl = this;
        fadelabel.AllowScrolling = false;
        //fadelabel.AllowFadeIn = false;
        fadelabel.AllocResources();

        _listLabels.Add(fadelabel);
      }
    }
Ejemplo n.º 4
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++;
      }
    }
    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++;
      }
    }