/// <summary> /// Draw the entity. /// </summary> /// <param name="spriteBatch">Sprite batch to draw on.</param> override protected void DrawEntity(SpriteBatch spriteBatch) { // if size changed, update paragraphs list if ((_prevSize.Y != _destRectInternal.Size.Y) || _hadResizeWhileNotVisible) { OnResize(); } // store last known size _prevSize = _destRectInternal.Size; // call base draw function to draw the panel part base.DrawEntity(spriteBatch); // update paragraphs list values for (int i = 0; i < _paragraphs.Count; ++i) { // if paragraph is within items range: int item_index = i + (int)_scrollbar.Value; if (item_index < _list.Count) { // set paragraph text, make visible, and remove background. _paragraphs[i].Text = _list[item_index]; _paragraphs[i].Background = null; _paragraphs[i].Visible = true; // set locked state bool isLocked = false; LockedItems.TryGetValue(item_index, out isLocked); _paragraphs[i].Locked = isLocked; } // if paragraph out of range (eg more paragraphs than list items), make this paragraph invisible. else { _paragraphs[i].Visible = false; _paragraphs[i].Text = string.Empty; } } // highlight the currently selected item paragraph (eg the paragraph that represent the selected value, if currently visible) int selectedParagraphIndex = _index; if (selectedParagraphIndex != -1) { int i = selectedParagraphIndex - _scrollbar.Value; if (i >= 0 && i < _paragraphs.Count) { // add background to selected paragraph Paragraph paragraph = _paragraphs[i]; Rectangle destRect = paragraph.GetActualDestRect(); Vector2 size = new Vector2(0, destRect.Height * 1.35f / UserInterface.Active.GlobalScale); paragraph.State = EntityState.MouseDown; paragraph.Padding = new Vector2(-Padding.X, 0); paragraph.CalcDestRect(); paragraph.CalcInternalRect(); ColoredRectangle selectMark = new ColoredRectangle(GetActiveStyle("SelectedHighlightColor").asColor, size, Anchor.TopCenter, new Vector2(0, -4)); paragraph.Background = selectMark; } } }