private void DrawCellDrag(PaintEventArgs e) { if (DraggingCell != null) { var text = ""; int offsetX = 0; int offsetY = 0; if (QueryItemText != null) { QueryItemText(DraggingCell.RowIndex.Value, DraggingCell.Column, out text, ref offsetX, ref offsetY); } Color bgColor = _backColor; if (QueryItemBkColor != null) { QueryItemBkColor(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 DrawColumnText(PaintEventArgs e, List <RollColumn> visibleColumns) { if (HorizontalOrientation) { int start = -VBar.Value; Gdi.PrepDrawString(RotatedFont, _foreColor); foreach (var column in visibleColumns) { var point = new Point(CellWidthPadding, start + CellHeightPadding); if (IsHoveringOnColumnCell && column == CurrentCell.Column) { Gdi.PrepDrawString(NormalFont, SystemColors.HighlightText); Gdi.DrawString(column.Text, point); Gdi.PrepDrawString(NormalFont, _foreColor); } else { Gdi.DrawString(column.Text, point); } start += CellHeight; } } else { //zeromus test //Gdi.PrepDrawString(NormalFont, _foreColor); Gdi.PrepDrawString(RotatedFont, _foreColor); foreach (var column in visibleColumns) { var point = new Point(column.Left.Value + 2 * CellWidthPadding - HBar.Value, CellHeightPadding); // TODO: fix this CellPadding issue (2 * CellPadding vs just CellPadding) if (IsHoveringOnColumnCell && column == CurrentCell.Column) { //zeromus test //Gdi.PrepDrawString(NormalFont, SystemColors.HighlightText); Gdi.PrepDrawString(RotatedFont, SystemColors.HighlightText); Gdi.DrawString(column.Text, point); //zeromus test //Gdi.PrepDrawString(NormalFont, _foreColor); Gdi.PrepDrawString(RotatedFont, _foreColor); } else { Gdi.DrawString(column.Text, point); } } } }
private void DrawTitle(Rectangle rectangle, ChartProperty property) { IQuote cQuote = __cBars.Quotes; IInstrumentSettings cSettings = __cBars.Info; InstrumentDataRequest cRequest = __cBars.Request; Resolution cResolution = cRequest.Resolution; string sTitle = string.Format("{0} {1} ({2}{3}) #{4} {5}", (cQuote == null) ? cRequest.Symbol : cQuote.SymbolId, (cQuote == null) ? cSettings.ASymbolInfo2.SymbolName : cQuote.SymbolName, cResolution.Size, cResolution.Type.ToString(), cSettings.Category.ToString(), cRequest.Exchange); IntPtr cOldFont = __cGDI.SelectFont(property.TitleFont); __cGDI.DrawString(sTitle, property.ForeColor, 5, rectangle.Top + 2); __cGDI.RemoveObject(__cGDI.SelectFont(cOldFont)); }
private void DrawTradeInfo(ITrade trade, AxisX axisX, ChartProperty property, IntPtr font, Rectangle4 layerRect, int top) { ITradeOrder cEntry = trade.EntryOrder; Point cPoint1 = new Point(axisX.ConvertBarNumberToWidth(cEntry.BarNumber).CenterPoint, top + this.AxisY.ConvertValueToHeight(cEntry.Price)); __cGDI.DrawString("▸", property.TradeSymbolColor, cPoint1.X - 7, cPoint1.Y - 7); DrawTradeName(cEntry.Name, font, property.ForeColor, cPoint1, true); ITradeOrder cExit = trade.ExitOrder; if (cExit != null) { Point cPoint2 = new Point(axisX.ConvertBarNumberToWidth(cExit.BarNumber).CenterPoint, top + this.AxisY.ConvertValueToHeight(cExit.Price)); __cGDI.DrawString("◂", property.TradeSymbolColor, cPoint2.X + 1, cPoint2.Y - 7); DrawTradeName(cExit.Name, font, property.ForeColor, cPoint2, false); if (Boundary.BoundFix(ref cPoint1, ref cPoint2, layerRect)) { __cGDI.DrawLine(cPoint1.X, cPoint1.Y, cPoint2.X, cPoint2.Y); } } }
private void DrawColumnDrag(PaintEventArgs e) { if (_columnDown != null && _currentX.HasValue && _currentY.HasValue && IsHoveringOnColumnCell) { int x1 = _currentX.Value - (_columnDown.Width.Value / 2); int y1 = _currentY.Value - (CellHeight / 2); int x2 = x1 + _columnDown.Width.Value; int y2 = y1 + CellHeight; Gdi.SetSolidPen(_backColor); Gdi.DrawRectangle(x1, y1, x2, y2); Gdi.PrepDrawString(NormalFont, _foreColor); Gdi.DrawString(_columnDown.Text, new Point(x1 + CellWidthPadding, y1 + CellHeightPadding)); } }
private void DrawData(PaintEventArgs e, List <RollColumn> visibleColumns) { if (QueryItemText != null) { if (HorizontalOrientation) { int startRow = FirstVisibleRow; int range = Math.Min(LastVisibleRow, RowCount - 1) - startRow + 1; Gdi.PrepDrawString(NormalFont, _foreColor); for (int i = 0, f = 0; f < range; i++, f++) { f += lagFrames[i]; int LastVisible = LastVisibleColumnIndex; for (int j = FirstVisibleColumn; j <= LastVisible; j++) { Bitmap image = null; int x = 0; int y = 0; int bitmapOffsetX = 0; int bitmapOffsetY = 0; if (QueryItemIcon != null) { QueryItemIcon(f + startRow, visibleColumns[j], ref image, ref bitmapOffsetX, ref bitmapOffsetY); } if (image != null) { x = RowsToPixels(i) + CellWidthPadding + bitmapOffsetX; y = (j * CellHeight) + (CellHeightPadding * 2) + bitmapOffsetY; Gdi.DrawBitmap(image, new Point(x, y), true); } string text; int strOffsetX = 0; int strOffsetY = 0; QueryItemText(f + startRow, visibleColumns[j], out text, ref strOffsetX, ref strOffsetY); // Center Text x = RowsToPixels(i) + (CellWidth - text.Length * _charSize.Width) / 2; y = (j * CellHeight) + CellHeightPadding - VBar.Value; var point = new Point(x + strOffsetX, y + strOffsetY); var rePrep = false; if (j == 1) { if (SelectedItems.Contains(new Cell { Column = visibleColumns[j], RowIndex = i + startRow })) { Gdi.PrepDrawString(RotatedFont, SystemColors.HighlightText); rePrep = true; } else if (j == 1) { //1. not sure about this; 2. repreps may be excess, but if we render one column at a time, we do need to change back after rendering the header rePrep = true; Gdi.PrepDrawString(RotatedFont, _foreColor); } } if (!string.IsNullOrWhiteSpace(text)) { Gdi.DrawString(text, point); } if (rePrep) { Gdi.PrepDrawString(NormalFont, _foreColor); } } } } else { int startRow = FirstVisibleRow; int range = Math.Min(LastVisibleRow, RowCount - 1) - startRow + 1; Gdi.PrepDrawString(NormalFont, _foreColor); int xPadding = CellWidthPadding + 1 - HBar.Value; for (int i = 0, f = 0; f < range; i++, f++) // Vertical { f += lagFrames[i]; int LastVisible = LastVisibleColumnIndex; for (int j = FirstVisibleColumn; j <= LastVisible; j++) // Horizontal { RollColumn col = visibleColumns[j]; string text; int strOffsetX = 0; int strOffsetY = 0; Point point = new Point(col.Left.Value + xPadding, RowsToPixels(i) + CellHeightPadding); Bitmap image = null; int bitmapOffsetX = 0; int bitmapOffsetY = 0; if (QueryItemIcon != null) { QueryItemIcon(f + startRow, visibleColumns[j], ref image, ref bitmapOffsetX, ref bitmapOffsetY); } if (image != null) { Gdi.DrawBitmap(image, new Point(point.X + bitmapOffsetX, point.Y + bitmapOffsetY + CellHeightPadding), true); } QueryItemText(f + startRow, visibleColumns[j], out text, ref strOffsetX, ref strOffsetY); bool rePrep = false; if (SelectedItems.Contains(new Cell { Column = visibleColumns[j], RowIndex = f + startRow })) { Gdi.PrepDrawString(NormalFont, SystemColors.HighlightText); rePrep = true; } if (!string.IsNullOrWhiteSpace(text)) { Gdi.DrawString(text, new Point(point.X + strOffsetX, point.Y + strOffsetY)); } if (rePrep) { Gdi.PrepDrawString(NormalFont, _foreColor); } } } } } }
private void DrawTextObject(Layer layer, TextObject textObject, ChartProperty property, bool useROP) { AxisX cAxisX = layer.AxisX; AxisY cAxisY = layer.AxisY; Rectangle cRectY = cAxisY.AxisRectangle; int iOldBackground = 0; IntPtr iOldFont = IntPtr.Zero; bool bUseBG = textObject.BGColor != property.BackgroundColor; bool bUseFont = textObject.FontName != property.TextFont.Name || textObject.Size != property.TextFont.Size; if (bUseBG) { iOldBackground = __cGDI.SelectBackground(textObject.BGColor); } else { iOldBackground = __cGDI.SelectTransparent(); } if (bUseFont) { iOldFont = __cGDI.SelectFont(new Font(textObject.FontName, textObject.Size, textObject.Style)); } int iX = 0, iY = 0; ChartPoint cPoint = textObject.Location; bool bAbsolute = textObject.AbsolutePosition; if (bAbsolute) { iY = cRectY.Y + (int)cPoint.Price; iX = cPoint.BarNumber.Value; } else { iY = cRectY.Y + cAxisY.ConvertValueToHeight(cPoint.Price) + 1; AxisXUnit cUnit = cAxisX.ConvertBarNumberToWidth(cPoint.BarNumber.Value); Size cSize = __cGDI.MeasureString(textObject.Text); iY = CalculateYFromStyle(iY, cSize, textObject.VStyle); iX = CalculateXFromStyle(cUnit.CenterPoint, cSize, textObject.HStyle); } Rectangle cLayerRect = layer.LayerRectangleWithoutAxisY; if (useROP || bAbsolute) { __cGDI.BeginRopDraw(); __cGDI.DrawRopString(textObject.Text, textObject.Color, iX, iY); __cGDI.EndRopDraw(); } else { __cGDI.DrawString(textObject.Text, textObject.Color, iX, iY); } if (bUseFont) { __cGDI.RemoveObject(__cGDI.SelectFont(iOldFont)); } if (bUseBG) { __cGDI.SelectBackground(iOldBackground); } else { __cGDI.ClearTransparent(iOldBackground); } }