/// <summary> /// Renders the text /// </summary> /// <param name="graph">Graphics</param> /// <param name="Item">Item number</param> /// <param name="fPosX">X Position</param> /// <param name="fPosY">Y Position</param> /// <param name="fMaxWidth">Width</param> /// <param name="dwTextColor">Text Color</param> /// <param name="strTextToRender">Text to render</param> private void RenderText(Graphics graph, int Item, float fPosX, float fPosY, float fMaxWidth, long dwTextColor, string strTextToRender) { if (_labelControls1 == null) { return; } if (Item < 0 || Item >= _labelControls1.Count) { return; } ListLabelElement label = _labelControls1[Item]; if (label == null) { return; } SizeF stringSize = label.GetStringSize(graph); if (_list.TextAlignment == GUIControl.Alignment.ALIGN_RIGHT && stringSize.Width < fMaxWidth) { label.XPosition = fPosX + fMaxWidth; label.YPosition = fPosY; } else { label.XPosition = fPosX; label.YPosition = fPosY; } label.Brush = new SolidBrush(GetColor(dwTextColor)); label.Label = strTextToRender; label.Width = fMaxWidth; label.Alignment = stringSize.Width < fMaxWidth ? _list.TextAlignment : GUIControl.Alignment.ALIGN_LEFT; label.Font = getFont(_list.FontName); label.DrawElement(graph); }
/// <summary> /// Renders the label /// </summary> /// <param name="graph">Graphics</param> /// <param name="buttonNr">Number of the button</param> /// <param name="dwPosX">X Position</param> /// <param name="dwPosY">Y Position</param> private void RenderLabel(Graphics graph, int buttonNr, int dwPosX, int dwPosY) { GUIListItem pItem = _listItems[buttonNr + _offset]; long dwColor; if (pItem.Shaded) { dwColor = _list.ShadedColor; } if (pItem.Selected) { dwColor = _list.SelectedColor; } dwPosX += _list.TextOffsetX; int dMaxWidth = (_list.Width - _list.TextOffsetX - _list.ImageWidth - GUIGraphicsContext.ScaleHorizontal(20)); if ((_list.TextVisible2 && pItem.Label2.Length > 0) && (_list.TextOffsetY == _list.TextOffsetY2)) { dwColor = _list.TextColor2; if (pItem.Selected) { dwColor = _list.SelectedColor2; } if (pItem.IsPlayed) { dwColor = _list.PlayedColor; } if (pItem.IsRemote) { dwColor = _list.RemoteColor; if (pItem.IsDownloading) { dwColor = _list.DownloadColor; } } int xpos = dwPosX; int ypos = dwPosY; if (0 == _list.TextOffsetX2) { xpos = _list.XPosition + _list.Width - GUIGraphicsContext.ScaleHorizontal(16); } else { xpos = _list.XPosition + _list.TextOffsetX2; } if ((_labelControls2 != null) && (buttonNr >= 0) && (buttonNr < _labelControls2.Count)) { ListLabelElement label2 = _labelControls2[buttonNr]; if (label2 != null) { label2.XPosition = xpos; label2.YPosition = ypos + GUIGraphicsContext.ScaleVertical(2) + _list.TextOffsetY2; label2.Label = pItem.Label2; label2.Alignment = GUIControl.Alignment.ALIGN_RIGHT; label2.Font = getFont(_list.FontName2); SizeF stringSize = label2.GetStringSize(graph); dMaxWidth = (int)label2.XPosition - dwPosX - (int)stringSize.Width - GUIGraphicsContext.ScaleHorizontal(20); } } } _textLine = pItem.Label; if (_list.TextVisible1) { dwColor = _list.TextColor; if (pItem.Selected) { dwColor = _list.SelectedColor; } if (pItem.IsPlayed) { dwColor = _list.PlayedColor; } if (pItem.IsRemote) { dwColor = _list.RemoteColor; if (pItem.IsDownloading) { dwColor = _list.DownloadColor; } } RenderText(graph, buttonNr, (float)dwPosX, (float)dwPosY + GUIGraphicsContext.ScaleVertical(2) + _list.TextOffsetY, (float)dMaxWidth, dwColor, _textLine); } if (pItem.Label2.Length > 0) { dwColor = _list.TextColor2; if (pItem.Selected) { dwColor = _list.SelectedColor2; } if (pItem.IsPlayed) { dwColor = _list.PlayedColor; } if (pItem.IsRemote) { dwColor = _list.RemoteColor; if (pItem.IsDownloading) { dwColor = _list.DownloadColor; } } if (0 == _list.TextOffsetX2) { dwPosX = _list.XPosition + _list.Width - GUIGraphicsContext.ScaleHorizontal(16); } else { dwPosX = _list.XPosition + _list.TextOffsetX2; } _textLine = pItem.Label2; if (_list.TextVisible2 && (_labelControls2 != null) && (buttonNr >= 0) && (buttonNr < _labelControls2.Count)) { ListLabelElement label2 = _labelControls2[buttonNr]; if (label2 != null) { label2.XPosition = dwPosX - GUIGraphicsContext.ScaleHorizontal(6); label2.YPosition = dwPosY + GUIGraphicsContext.ScaleVertical(2) + _list.TextOffsetY2; label2.Label = _textLine; label2.Alignment = GUIControl.Alignment.ALIGN_RIGHT; label2.Font = getFont(_list.FontName2); label2.DrawElement(graph); label2 = null; } } } if (pItem.Label3.Length > 0) { dwColor = _list.TextColor3; if (pItem.Selected) { dwColor = _list.SelectedColor3; } if (pItem.IsPlayed) { dwColor = _list.PlayedColor; } if (pItem.IsRemote) { dwColor = _list.RemoteColor; if (pItem.IsDownloading) { dwColor = _list.DownloadColor; } } if (0 == _list.TextColor3) { dwPosX = _list.XPosition + _list.TextOffsetX; } else { dwPosX = _list.XPosition + _list.TextOffsetX3; } int ypos = dwPosY; if (0 == _list.TextOffsetY3) { ypos += _list.TextOffsetY2; } else { ypos += _list.TextOffsetY3; } if (_list.TextVisible3 && (_labelControls3 != null) && (buttonNr >= 0) && (buttonNr < _labelControls3.Count)) { ListLabelElement label3 = _labelControls3[buttonNr]; if (label3 != null) { label3.XPosition = dwPosX; label3.YPosition = ypos; label3.Label = pItem.Label3; label3.Alignment = GUIControl.Alignment.ALIGN_LEFT; label3.Font = getFont(_list.Font3); label3.Width = (_list.Width - _list.TextOffsetX - _list.ImageWidth - GUIGraphicsContext.ScaleHorizontal(34)); label3.DrawElement(graph); } } } }