public abstract DrawLine ( float x1, float y1, float x2, float y2 ) : void | ||
x1 | float | |
y1 | float | |
x2 | float | |
y2 | float | |
Résultat | void |
internal void PaintDecoration(Canvas g, RectangleF rectangle, bool isFirst, bool isLast) { float y = 0f; switch (this.TextDecoration) { default: return; case Css.CssTextDecoration.Underline: { //TODO: correct this ... //var h = g.MeasureString(" ", ActualFont).Height; //float desc = FontsUtils.GetDescentPx(ActualFont); //y = (float)Math.Round(rectangle.Top + h - desc + 0.5); RequestFont afont = ResolvedFont; //PixelFarm.Drawing.Fonts.ActualFont ff = afont.ActualFont; var h = afont.SizeInPixels; float desc = (float)afont.DescentInPixels;// fontInfo.DescentPx; y = (float)Math.Round(rectangle.Top + h - desc); } break; case Css.CssTextDecoration.LineThrough: { y = rectangle.Top + rectangle.Height / 2f; } break; case Css.CssTextDecoration.Overline: { y = rectangle.Top; } break; } //y -= ActualPaddingBottom - ActualBorderBottomWidth; y -= (ActualPaddingBottom + ActualBorderBottomWidth); float x1 = rectangle.X; if (isFirst) { x1 += ActualPaddingLeft + ActualBorderLeftWidth; } float x2 = rectangle.Right; if (isLast) { x2 -= ActualPaddingRight + ActualBorderRightWidth; } var prevColor = g.StrokeColor; g.StrokeColor = ActualColor; g.DrawLine(x1, y, x2, y); g.StrokeColor = prevColor; }
public override void DrawChildContent(Canvas canvas, Rectangle updateArea) { //GridCell leftTopGridItem = GetGridItemByPosition(updateArea.Left, updateArea.Top); //if (leftTopGridItem == null) //{ // return; //} //GridCell rightBottomGridItem = GetGridItemByPosition(updateArea.Right, updateArea.Bottom); //if (rightBottomGridItem == null) //{ // return; //} //TODO: temp fixed, review here again, GridCell leftTopGridItem = this.GetCell(0, 0); if (leftTopGridItem == null) { return; } GridCell rightBottomGridItem = this.GetCell(this.RowCount - 1, this.ColumnCount - 1); if (rightBottomGridItem == null) { return; } this.BeginDrawingChildContent(); GridColumn startColumn = leftTopGridItem.column; GridColumn currentColumn = startColumn; GridRow startRow = leftTopGridItem.row; GridColumn stopColumn = rightBottomGridItem.column.NextColumn; GridRow stopRow = rightBottomGridItem.row.NextRow; int startRowId = startRow.RowIndex; int stopRowId = 0; if (stopRow == null) { stopRowId = gridRows.Count; } else { stopRowId = stopRow.RowIndex; } int n = 0; var prevColor = canvas.StrokeColor; canvas.StrokeColor = Color.Gray; //canvas.DrawLine(0, 0, 100, 100); //canvas.DrawLine(0, 100, 100, 0); //if (startRowId > 0) //{ // Console.WriteLine(startRowId); //} //canvas.DrawRectangle(Color.Red, updateArea.Left, updateArea.Top, updateArea.Width, updateArea.Height); do { GridCell startGridItemInColumn = currentColumn.GetCell(startRowId); GridCell stopGridItemInColumn = currentColumn.GetCell(stopRowId - 1); //draw vertical line canvas.DrawLine( startGridItemInColumn.Right, startGridItemInColumn.Y, stopGridItemInColumn.Right, stopGridItemInColumn.Bottom); if (n == 0) { //draw horizontal line int horizontalLineWidth = rightBottomGridItem.Right - startGridItemInColumn.X; for (int i = startRowId; i < stopRowId; i++) { GridCell gridItem = currentColumn.GetCell(i); int x = gridItem.X; int gBottom = gridItem.Bottom; canvas.DrawLine( x, gBottom, x + horizontalLineWidth, gBottom); } n = 1; } currentColumn = currentColumn.NextColumn; } while (currentColumn != stopColumn); canvas.StrokeColor = prevColor; currentColumn = startColumn; //---------------------------------------------------------------------------- do { for (int i = startRowId; i < stopRowId; i++) { GridCell gridItem = currentColumn.GetCell(i); if (gridItem != null && gridItem.HasContent) { int x = gridItem.X; int y = gridItem.Y; canvas.OffsetCanvasOrigin(x, y); updateArea.Offset(-x, -y); var renderContent = gridItem.ContentElement as RenderElement; if (renderContent != null) { if (canvas.PushClipAreaRect(gridItem.Width, gridItem.Height, ref updateArea)) { renderContent.DrawToThisCanvas(canvas, updateArea); } canvas.PopClipAreaRect(); } canvas.OffsetCanvasOrigin(-x, -y); updateArea.Offset(x, y); } #if DEBUG else { canvas.DrawText(new char[] { '.' }, gridItem.X, gridItem.Y); } #endif } currentColumn = currentColumn.NextColumn; } while (currentColumn != stopColumn); this.FinishDrawingChildContent(); }