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++; } }
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); } }
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++; } }