private void DrawCellDrag(List <RollColumn> visibleColumns) { if (_draggingCell != null && _draggingCell.RowIndex.HasValue && _draggingCell.Column.Width.HasValue && _currentX.HasValue && _currentY.HasValue) { var text = ""; int offsetX = 0; int offsetY = 0; QueryItemText?.Invoke(_draggingCell.RowIndex.Value, _draggingCell.Column, out text, ref offsetX, ref offsetY); Color bgColor = _backColor; QueryItemBkColor?.Invoke(_draggingCell.RowIndex.Value, _draggingCell.Column, ref bgColor); int columnHeight = CellHeight; if (HorizontalOrientation) { int columnIndex = visibleColumns.IndexOf(_draggingCell.Column); columnHeight = GetHColHeight(columnIndex); } int x1 = _currentX.Value - (_draggingCell.Column.Width.Value / 2); int y1 = _currentY.Value - (columnHeight / 2); int x2 = x1 + _draggingCell.Column.Width.Value; int y2 = y1 + columnHeight; _renderer.SetBrush(bgColor); _renderer.FillRectangle(x1, y1, x2 - x1, y2 - y1); _renderer.PrepDrawString(_font, _foreColor); _renderer.DrawString(text, new Point(x1 + CellWidthPadding + offsetX, y1 + CellHeightPadding + offsetY)); } }
private void DrawColumnDrag(PaintEventArgs e) { if (_draggingCell != null) { var text = ""; int offsetX = 0; int offsetY = 0; QueryItemText?.Invoke(_draggingCell.RowIndex.Value, _columns.IndexOf(_draggingCell.Column), out text); QueryItemTextAdvanced?.Invoke(_draggingCell.RowIndex.Value, _draggingCell.Column, out text, ref offsetX, ref offsetY); Color bgColor = ColumnHeaderBackgroundColor; QueryItemBkColor?.Invoke(_draggingCell.RowIndex.Value, _draggingCell.Column, ref bgColor); int x1 = _currentX.Value - (_draggingCell.Column.Width.Value / 2); int y1 = _currentY.Value - (CellHeight / 2); int x2 = x1 + _draggingCell.Column.Width.Value; int y2 = y1 + CellHeight; sBrush = new SolidBrush(bgColor); e.Graphics.FillRectangle(sBrush, x1, y1, x2 - x1, y2 - y1); sBrush = new SolidBrush(ColumnHeaderFontColor); e.Graphics.DrawString(text, ColumnHeaderFont, sBrush, (PointF)(new Point(x1 + CellWidthPadding + offsetX, y1 + CellHeightPadding + offsetY))); } }
// Calls QueryItemBkColor callback for all visible cells and fills in the background of those cells. private void DoBackGroundCallback(List <RollColumn> visibleColumns) { int startIndex = FirstVisibleRow; int range = Math.Min(LastVisibleRow, RowCount - 1) - startIndex + 1; int lastVisibleColumn = LastVisibleColumn; int firstVisibleColumn = FirstVisibleColumn; // Prevent exceptions with small TAStudio windows if (firstVisibleColumn < 0) { return; } for (int i = 0, f = 0; f < range; i++, f++) { f += _lagFrames[i]; Color rowColor = Color.White; QueryRowBkColor?.Invoke(f + startIndex, ref rowColor); for (int j = firstVisibleColumn; j <= lastVisibleColumn; j++) { Color itemColor = Color.White; QueryItemBkColor?.Invoke(f + startIndex, visibleColumns[j], ref itemColor); if (itemColor == Color.White) { itemColor = rowColor; } else if (itemColor.A != 255 && itemColor.A != 0) { float alpha = (float)itemColor.A / 255; itemColor = Color.FromArgb(rowColor.R - (int)((rowColor.R - itemColor.R) * alpha), rowColor.G - (int)((rowColor.G - itemColor.G) * alpha), rowColor.B - (int)((rowColor.B - itemColor.B) * alpha)); } if (itemColor != Color.White) // An easy optimization, don't draw unless the user specified something other than the default { var cell = new Cell { Column = visibleColumns[j], RowIndex = i }; DrawCellBG(itemColor, cell, visibleColumns); } } } }
private void DoSelectionBG(PaintEventArgs e, List <RollColumn> visibleColumns) { // SuuperW: This allows user to see other colors in selected frames. Color rowColor = Color.White; int _lastVisibleRow = LastVisibleRow; int lastRow = -1; foreach (Cell cell in _selectedItems) { if (cell.RowIndex > _lastVisibleRow || cell.RowIndex < FirstVisibleRow || !VisibleColumns.Contains(cell.Column)) { continue; } Cell relativeCell = new Cell { RowIndex = cell.RowIndex - FirstVisibleRow, Column = cell.Column, }; relativeCell.RowIndex -= CountLagFramesAbsolute(relativeCell.RowIndex.Value); if (QueryRowBkColor != null && lastRow != cell.RowIndex.Value) { QueryRowBkColor(cell.RowIndex.Value, ref rowColor); lastRow = cell.RowIndex.Value; } Color cellColor = rowColor; QueryItemBkColor?.Invoke(cell.RowIndex.Value, cell.Column, ref cellColor); // Alpha layering for cell before selection float alpha = (float)cellColor.A / 255; if (cellColor.A != 255 && cellColor.A != 0) { cellColor = Color.FromArgb(rowColor.R - (int)((rowColor.R - cellColor.R) * alpha), rowColor.G - (int)((rowColor.G - cellColor.G) * alpha), rowColor.B - (int)((rowColor.B - cellColor.B) * alpha)); } // Alpha layering for selection alpha = 0.33f; cellColor = Color.FromArgb(cellColor.R - (int)((cellColor.R - SystemColors.Highlight.R) * alpha), cellColor.G - (int)((cellColor.G - SystemColors.Highlight.G) * alpha), cellColor.B - (int)((cellColor.B - SystemColors.Highlight.B) * alpha)); DrawCellBG(cellColor, relativeCell, visibleColumns); } }
private void DoSelectionBG(List <RollColumn> visibleColumns, Rectangle rect) { Color rowColor = Color.White; var visibleRows = FirstVisibleRow.RangeTo(LastVisibleRow); int lastRow = -1; foreach (Cell cell in _selectedItems) { if (!cell.RowIndex.HasValue || !visibleRows.Contains(cell.RowIndex.Value) || !VisibleColumns.Contains(cell.Column)) { continue; } Cell relativeCell = new Cell { RowIndex = cell.RowIndex - visibleRows.Start, Column = cell.Column, }; relativeCell.RowIndex -= CountLagFramesAbsolute(relativeCell.RowIndex.Value); if (QueryRowBkColor != null && lastRow != cell.RowIndex.Value) { QueryRowBkColor(cell.RowIndex.Value, ref rowColor); lastRow = cell.RowIndex.Value; } Color cellColor = rowColor; QueryItemBkColor?.Invoke(cell.RowIndex.Value, cell.Column, ref cellColor); // Alpha layering for cell before selection float alpha = (float)cellColor.A / 255; if (cellColor.A != 255 && cellColor.A != 0) { cellColor = Color.FromArgb(rowColor.R - (int)((rowColor.R - cellColor.R) * alpha), rowColor.G - (int)((rowColor.G - cellColor.G) * alpha), rowColor.B - (int)((rowColor.B - cellColor.B) * alpha)); } // Alpha layering for selection alpha = 0.33f; cellColor = Color.FromArgb(cellColor.R - (int)((cellColor.R - SystemColors.Highlight.R) * alpha), cellColor.G - (int)((cellColor.G - SystemColors.Highlight.G) * alpha), cellColor.B - (int)((cellColor.B - SystemColors.Highlight.B) * alpha)); DrawCellBG(cellColor, relativeCell, visibleColumns, rect); } }
// Calls QueryItemBkColor callback for all visible cells and fills in the background of those cells. private void DoBackGroundCallback(List <RollColumn> visibleColumns, Rectangle rect, int firstVisibleRow, int lastVisibleRow) { if (!visibleColumns.Any()) { return; } int startIndex = firstVisibleRow; int range = Math.Min(lastVisibleRow, RowCount - 1) - startIndex + 1; for (int i = 0, f = 0; f < range; i++, f++) { f += _lagFrames[i]; Color rowColor = Color.White; QueryRowBkColor?.Invoke(f + startIndex, ref rowColor); foreach (var column in visibleColumns) { Color itemColor = Color.White; QueryItemBkColor?.Invoke(f + startIndex, column, ref itemColor); if (itemColor == Color.White) { itemColor = rowColor; } else if (itemColor.A != 255 && itemColor.A != 0) { float alpha = (float)itemColor.A / 255; itemColor = Color.FromArgb(rowColor.R - (int)((rowColor.R - itemColor.R) * alpha), rowColor.G - (int)((rowColor.G - itemColor.G) * alpha), rowColor.B - (int)((rowColor.B - itemColor.B) * alpha)); } if (itemColor != Color.White) // An easy optimization, don't draw unless the user specified something other than the default { var cell = new Cell { Column = column, RowIndex = i }; DrawCellBG(itemColor, cell, visibleColumns, rect); } } } }
private void DrawCellDrag(PaintEventArgs e) { if (_draggingCell != null) { var text = ""; int offsetX = 0; int offsetY = 0; QueryItemText?.Invoke(_draggingCell.RowIndex.Value, _draggingCell.Column, out text, ref offsetX, ref offsetY); Color bgColor = _backColor; QueryItemBkColor?.Invoke(_draggingCell.RowIndex.Value, _draggingCell.Column, ref bgColor); int x1 = _currentX.Value - (_draggingCell.Column.Width.Value / 2); int y1 = _currentY.Value - (CellHeight / 2); int x2 = x1 + _draggingCell.Column.Width.Value; int y2 = y1 + CellHeight; _gdi.SetBrush(bgColor); _gdi.FillRectangle(x1, y1, x2 - x1, y2 - y1); _gdi.PrepDrawString(_normalFont, _foreColor); _gdi.DrawString(text, new Point(x1 + CellWidthPadding + offsetX, y1 + CellHeightPadding + offsetY)); } }
private void GDIP_DrawCellDrag(PaintEventArgs e) { if (_draggingCell != null) { var text = ""; int offsetX = 0; int offsetY = 0; QueryItemText?.Invoke(_draggingCell.RowIndex.Value, _draggingCell.Column, out text, ref offsetX, ref offsetY); Color bgColor = _backColor; QueryItemBkColor?.Invoke(_draggingCell.RowIndex.Value, _draggingCell.Column, ref bgColor); int x1 = _currentX.Value - (_draggingCell.Column.Width.Value / 2); int y1 = _currentY.Value - (CellHeight / 2); int x2 = x1 + _draggingCell.Column.Width.Value; int y2 = y1 + CellHeight; sBrush = new SolidBrush(bgColor); e.Graphics.FillRectangle(sBrush, x1, y1, x2 - x1, y2 - y1); sBrush = new SolidBrush(_foreColor); //e.Graphics.DrawString(text, _commonFont, sBrush, (PointF)(new Point(x1 + CellWidthPadding + offsetX, y1 + CellHeightPadding + offsetY))); GDIP_DrawString(e, text, _commonFont, new Point(x1 + CellWidthPadding + offsetX, y1 + CellHeightPadding + offsetY), _foreColor); } }