public override void Draw(SpriteBatch spriteBatch) { // TODO: Add your drawing code here var binding = FormCollection.Graphics.GraphicsDevice.GetRenderTargets(); Render(FormCollection.Graphics.GraphicsDevice); if (binding.Length > 0) { FormCollection.Graphics.GraphicsDevice.SetRenderTarget(binding[0].RenderTarget as RenderTarget2D); } FormCollection.Graphics.GraphicsDevice.Clear(Color.Transparent); if (!multiline) { DrawMonoline(spriteBatch); } else { DrawMultiline(spriteBatch); } //Adjust render source rectangle depending on scrollbars visibility if (vscrollbar != null && vscrollbar.Max > 0) { sRect.Width = (int)Width - 14; } else { sRect.Width = (int)Width - 2; } if (hscrollbar != null && hscrollbar.Max > 0) { sRect.Height = (int)Height - 14; } else { sRect.Height = (int)Height - 2; } dRect.X = (int)Position.X; dRect.Y = (int)Position.Y; dRect.Width = sRect.Width; dRect.Height = sRect.Height; spriteBatch.Draw(capturedTexture, dRect, sRect, Color.White); if (vscrollbar != null && vscrollbar.Max > 0) { vscrollbar.Draw(spriteBatch); } if (hscrollbar != null && hscrollbar.Max > 0) { hscrollbar.Draw(spriteBatch); } }
private void DrawScrollbar(SpriteBatch spriteBatch) { vscrollbar.Max = (int)System.Math.Max(0, items.Count - visibleItems); if (vscrollbar.Value > vscrollbar.Max) { vscrollbar.Value = vscrollbar.Max; } if (vscrollbar.Max > 0) { vscrollbar.Draw(spriteBatch); if (hscrollbar != null) { hscrollbar.Width = Width - 14; UpdateHScrollbar(); } } else if (hscrollbar != null) { hscrollbar.Width = Width - 2; UpdateHScrollbar(); } if (horizontalScrollbar && hscrollbar != null && hscrollbar.Max > 0) { vscrollbar.Height = Height - 12; hscrollbar.Max = hScrollWidth; hscrollbar.Draw(spriteBatch); visibleItems = (int)System.Math.Ceiling(Height / Font.LineSpacing) - 1; } else if ((hscrollbar == null || hscrollbar.Max == 0) && vscrollbar.Height != Height - 2) { vscrollbar.Height = Height - 2; visibleItems += 1; } }
private void DrawScrollbars(SpriteBatch spriteBatch) { int totalWidth = 0; if (columnHeader.Count > 0) { for (int i = 0; i < columnHeader.Count; i++) { totalWidth += (int)columnHeader[i].Width; } } if (!isResizing) { if (vScrollbar.Max == 0) { hScrollbar.Max = totalWidth - area.Width; } else { hScrollbar.Max = totalWidth - (area.Width - 12); } } hScrollbar.Step = System.Math.Max(1, hScrollbar.Max / 15); if (hScrollbar.Max > 0) { if (vScrollbar.Max > 0 && hScrollbar.Width != Width - 14) { hScrollbar.Width = Width - 14; } else if (vScrollbar.Max == 0 && hScrollbar.Width != Width - 2) { hScrollbar.Width = Width - 2; } hScrollbar.Draw(spriteBatch); } int rowCount = item.GetLength(0); if (rowCount > VisibleItems) { vScrollbar.Max = rowCount - VisibleItems; } else { vScrollbar.Max = 0; } if (vScrollbar.Max > 0) { if (hScrollbar.Max > 0 && vScrollbar.Height != Height - 14) { vScrollbar.Height = Height - 14; } else if (hScrollbar.Max == 0 && vScrollbar.Height != Height - 2) { vScrollbar.Height = Height - 2; } vScrollbar.Draw(spriteBatch); } }