/// <summary>Draw grid lines in client area.</summary> /// <param name="rowsDC">Graphics dc.</param> /// <param name="vPanelScrollBar">The v Panel Scroll Bar.</param> /// <param name="hPanelScrollBar">The h Panel Scroll Bar.</param> /// <param name="listView">The list View.</param> public static void DrawGridLines(Graphics rowsDC, ManagedVScrollBar vPanelScrollBar, ManagedHScrollBar hPanelScrollBar, VisualListView listView) { ConsoleEx.WriteDebug("ListViewRenderer::DrawGridLines"); int _yCursor = listView.RowsInnerClientRect.Y; using (Pen _gridPen = new Pen(listView.GridColor)) { // Determine the grid line style. if (listView.GridLineStyle == GridLineStyle.Dashed) { _gridPen.DashStyle = DashStyle.Dash; } else if (listView.GridLineStyle == GridLineStyle.Solid) { _gridPen.DashStyle = DashStyle.Solid; } else { _gridPen.DashStyle = DashStyle.Solid; } // Draw horizontal grid lines. if ((listView.GridLines == GridLines.Both) || (listView.GridLines == GridLines.Horizontal)) { int _rowsToDraw = listView.RowsVisible + 1; if (listView.GridTypes == GridTypes.Exists) { if (listView.RowsVisible > listView.Count) { _rowsToDraw = listView.Count; } } for (var _item = 0; _item < _rowsToDraw; _item++) { _yCursor += listView.ItemHeight; // Draw horizontal line. rowsDC.DrawLine(_gridPen, 0, _yCursor, listView.RowsInnerClientRect.Width, _yCursor); } } // Draw vertical grid lines. if ((listView.GridLines == GridLines.Both) || (listView.GridLines == GridLines.Vertical)) { int _xCursor = -hPanelScrollBar.Value; for (var column = 0; column < listView.Columns.Count; column++) { _xCursor += listView.Columns[column].Width; // Draw vertical line. rowsDC.DrawLine(_gridPen, _xCursor + 1, listView.RowsInnerClientRect.Y, _xCursor + 1, listView.RowsInnerClientRect.Bottom); // draw vertical line } } } }
/// <summary>Draw grid lines in client area.</summary> /// <param name="rowsDC">Graphics dc.</param> /// <param name="vPanelScrollBar">The v Panel Scroll Bar.</param> /// <param name="hPanelScrollBar">The h Panel Scroll Bar.</param> /// <param name="listView">The list View.</param> public static void DrawGridLines(Graphics rowsDC, ManagedVScrollBar vPanelScrollBar, ManagedHScrollBar hPanelScrollBar, VisualListViewEx listView) { DebugTraceManager.WriteDebug("ListViewRenderer::DrawGridLines", DebugTraceManager.DebugOutput.TraceListener); // int _startItem = vPanelScrollBar.Value; // int _yCursor = rect.Y; int _yCursor = listView.RowsInnerClientRect.Y; using (Pen _gridPen = new Pen(listView.GridColor)) { if (listView.GridLineStyle == GridLineStyle.Dashed) { _gridPen.DashStyle = DashStyle.Dash; } else if (listView.GridLineStyle == GridLineStyle.Solid) { _gridPen.DashStyle = DashStyle.Solid; } else { _gridPen.DashStyle = DashStyle.Solid; } if ((listView.GridLines == GridLines.Both) || (listView.GridLines == GridLines.Horizontal)) { int _rowsToDraw = listView.VisibleRowsCount + 1; if (listView.GridTypes == GridTypes.Exists) { if (listView.VisibleRowsCount > listView.Count) { _rowsToDraw = listView.Count; } } for (var _item = 0; _item < _rowsToDraw; _item++) { _yCursor += listView.ItemHeight; // draw horizontal line rowsDC.DrawLine(_gridPen, 0, _yCursor, listView.RowsInnerClientRect.Width, _yCursor); } } if ((listView.GridLines == GridLines.Both) || (listView.GridLines == GridLines.Vertical)) { int _xCursor = -hPanelScrollBar.Value; for (var column = 0; column < listView.Columns.Count; column++) { _xCursor += listView.Columns[column].Width; rowsDC.DrawLine(_gridPen, _xCursor + 1, listView.RowsInnerClientRect.Y, _xCursor + 1, listView.RowsInnerClientRect.Bottom); // draw vertical line } } } }
/// <summary>Draw client rows of list control.</summary> /// <param name="graphicsRows">The graphics row.</param> /// <param name="listView">The list View.</param> /// <param name="backColor">The back Color.</param> /// <param name="vPanelScrollBar">The v Panel Scroll Bar.</param> /// <param name="hPanelScrollBar">The h Panel Scroll Bar.</param> /// <param name="_newLiveControls">The new Live Controls.</param> /// <param name="_liveControls">The live Controls.</param> /// <param name="checkBoxSize">The check Box Size.</param> public static void DrawRows(Graphics graphicsRows, VisualListView listView, Color backColor, ManagedVScrollBar vPanelScrollBar, ManagedHScrollBar hPanelScrollBar, ArrayList _newLiveControls, ArrayList _liveControls, int checkBoxSize) { ConsoleEx.WriteDebug("ListViewRenderer::DrawRows"); using (SolidBrush _clientRowsViewBrush = new SolidBrush(backColor)) { graphicsRows.FillRectangle(_clientRowsViewBrush, listView.RowsClientRectangle); } // Draw background image. if (listView.BackgroundImage != null) { if (listView.BackgroundStretchToFit) { graphicsRows.DrawImage(listView.BackgroundImage, listView.RowsInnerClientRect.X, listView.RowsInnerClientRect.Y, listView.RowsInnerClientRect.Width, listView.RowsInnerClientRect.Height); } else { graphicsRows.DrawImage(listView.BackgroundImage, listView.RowsInnerClientRect.X, listView.RowsInnerClientRect.Y); } } // Determine start item based on whether or not we have a vertical scrollbar present. Which item to start with in this visible view. int _startItem; if (vPanelScrollBar.Visible) { _startItem = vPanelScrollBar.Value; } else { _startItem = 0; } Rectangle _rectangleRow = listView.RowsRectangle; _rectangleRow.Height = listView.ItemHeight; // Draw rows. for (var item = 0; (item < listView.RowsVisible + 1) && (item + _startItem < listView.Items.Count); item++) { DrawRow(graphicsRows, _rectangleRow, listView.Items[item + _startItem], item + _startItem, listView, hPanelScrollBar, _newLiveControls, _liveControls, checkBoxSize); _rectangleRow.Y += listView.ItemHeight; } if (listView.GridLineStyle != GridLineStyle.None) { // TODO: DrawGridLines also vertical when sub-items exist. DrawGridLines(graphicsRows, vPanelScrollBar, hPanelScrollBar, listView); } // Draw hot tracking column overlay. if (listView.HoverColumnTracking && (listView.HoverColumnIndex != -1) && (listView.HoverColumnIndex < listView.Columns.Count)) { int _xCursor = -hPanelScrollBar.Value; for (var _columnIndex = 0; _columnIndex < listView.HoverColumnIndex; _columnIndex++) { _xCursor += listView.Columns[_columnIndex].Width; } using (Brush hotBrush = new SolidBrush(Color.FromArgb(75, listView.HoverTrackingColor.R, listView.HoverTrackingColor.G, listView.HoverTrackingColor.B))) { graphicsRows.FillRectangle(hotBrush, _xCursor, listView.RowsInnerClientRect.Y, listView.Columns[listView.HoverColumnIndex].Width + 1, listView.RowsInnerClientRect.Height - 1); } } }
/// <summary>Draw client rows of list control.</summary> /// <param name="graphicsRows">The graphics row.</param> /// <param name="listView">The list View.</param> /// <param name="vPanelScrollBar">The v Panel Scroll Bar.</param> /// <param name="hPanelScrollBar">The h Panel Scroll Bar.</param> /// <param name="_newLiveControls">The new Live Controls.</param> /// <param name="_liveControls">The live Controls.</param> /// <param name="checkBoxSize">The check Box Size.</param> public static void DrawRows(Graphics graphicsRows, VisualListViewEx listView, ManagedVScrollBar vPanelScrollBar, ManagedHScrollBar hPanelScrollBar, ArrayList _newLiveControls, ArrayList _liveControls, int checkBoxSize) { DebugTraceManager.WriteDebug("ListViewRenderer::DrawRows", DebugTraceManager.DebugOutput.TraceListener); SolidBrush brush = new SolidBrush(listView.BackColor); graphicsRows.FillRectangle(brush, listView.RowsClientRect); brush.Dispose(); // if they have a background image, then display it if (listView.BackgroundImage != null) { if (listView.BackgroundStretchToFit) { graphicsRows.DrawImage(listView.BackgroundImage, listView.RowsInnerClientRect.X, listView.RowsInnerClientRect.Y, listView.RowsInnerClientRect.Width, listView.RowsInnerClientRect.Height); } else { graphicsRows.DrawImage(listView.BackgroundImage, listView.RowsInnerClientRect.X, listView.RowsInnerClientRect.Y); } } // determine start item based on whether or not we have a vertical scrollbar present int nStartItem; // which item to start with in this visible pane if (vPanelScrollBar.Visible) { nStartItem = vPanelScrollBar.Value; } else { nStartItem = 0; } Rectangle rectRow = listView.RowsRect; rectRow.Height = listView.ItemHeight; /* Draw Rows */ for (var item = 0; (item < listView.VisibleRowsCount + 1) && (item + nStartItem < listView.Items.Count); item++) { DrawRow(graphicsRows, rectRow, listView.Items[item + nStartItem], item + nStartItem, listView, hPanelScrollBar, _newLiveControls, _liveControls, checkBoxSize); rectRow.Y += listView.ItemHeight; } if (listView.GridLineStyle != GridLineStyle.None) { DrawGridLines(graphicsRows, vPanelScrollBar, hPanelScrollBar, listView); } // draw hot tracking column overlay if (listView.HotColumnTracking && (listView.HotColumnIndex != -1) && (listView.HotColumnIndex < listView.Columns.Count)) { int nXCursor = -hPanelScrollBar.Value; for (int nColumnIndex = 0; nColumnIndex < listView.HotColumnIndex; nColumnIndex++) { nXCursor += listView.Columns[nColumnIndex].Width; } using (Brush hotBrush = new SolidBrush(Color.FromArgb(75, listView.HotTrackingColor.R, listView.HotTrackingColor.G, listView.HotTrackingColor.B))) { graphicsRows.FillRectangle(hotBrush, nXCursor, listView.RowsInnerClientRect.Y, listView.Columns[listView.HotColumnIndex].Width + 1, listView.RowsInnerClientRect.Height - 1); } } }