/// <summary> /// 画行 /// </summary> /// <param name="graphics"></param> /// <param name="headerFormat"></param> /// <param name="titleFormat"></param> /// <param name="row"></param> /// <param name="range"></param> /// <param name="rowRect"></param> protected virtual void DrawRow(Graphics graphics, StringFormat headerFormat, StringFormat titleFormat, GanttChartViewRow row, RectangleF range, RectangleF rowRect) { graphics.SetClip(range); var drawY = rowRect.Y + RowSpacing; var drawHeight = rowRect.Height - RowSpacing * 2; if (drawHeight > (_ContentControl.Height - ColumnHeight) / 4) { drawY = Math.Max(rowRect.Y, ColumnHeight); drawHeight = Math.Min(rowRect.Bottom - RowSpacing, _ContentControl.Height) - drawY; } graphics.DrawString(row.Title, RowHeaderTextFont, this.Brushes.RowHeaderTextBrush, new RectangleF(rowRect.X + RowSpacing, drawY, RowHeaderWidth - RowSpacing * 2, drawHeight), headerFormat); graphics.ResetClip(); if (row.Items != null) { var items = row.Items.OrderBy(r => r.StartTime); foreach (var item in items) { if (item.Left + item.Width - _HScrollBar.Value > RowHeaderWidth) { if (item.Left - _HScrollBar.Value < range.Right) { DrawItem(graphics, titleFormat, item, new RectangleF(RowHeaderWidth + 1, rowRect.Y + 1, rowRect.Width - RowHeaderWidth - 2, rowRect.Height - 2)); } } } } graphics.SetClip(range); graphics.DrawLine(this.Brushes.GridPen, 0, row.Bottom - _VScrollBar.Value, rowRect.Width, row.Bottom - _VScrollBar.Value); if (_SelectionRow == row && IsShowSelectionBorder) { var selectionRect = new Rectangle(1, row.Top + 1, (int)(range.Width - 3), (int)(row.Bottom - row.Top - 2)); graphics.DrawRectangle(this.Brushes.RowSelectionBorderPen, selectionRect); } graphics.ResetClip(); }
/// <summary> /// 初始化 /// </summary> /// <param name="row"></param> public GanttChartRowSelectedEventArgs(GanttChartViewRow row) { Row = row; }