OffsetCanvasOrigin() public méthode

public OffsetCanvasOrigin ( int dx, int dy ) : void
dx int
dy int
Résultat void
 public sealed override void CustomDrawToThisCanvas(Canvas canvas, Rectangle updateArea)
 {
     canvas.OffsetCanvasOrigin(-myviewportX, -myviewportY);
     updateArea.Offset(myviewportX, myviewportY);
     this.DrawBoxContent(canvas, updateArea);
     canvas.OffsetCanvasOrigin(myviewportX, myviewportY);
     updateArea.Offset(-myviewportX, -myviewportY);
 }
        public override void DrawChildContent(Canvas canvasPage, Rectangle updateArea)
        {
            if ((layerFlags & IS_LAYER_HIDDEN) != 0)
            {
                return;
            }

            this.BeginDrawingChildContent();
            foreach (RenderElement child in this.GetDrawingIter())
            {
                if (child.IntersectsWith(ref updateArea))
                {
                    int x = child.X;
                    int y = child.Y;
                    canvasPage.OffsetCanvasOrigin(x, y);
                    updateArea.Offset(-x, -y);
                    child.DrawToThisCanvas(canvasPage, updateArea);
                    canvasPage.OffsetCanvasOrigin(-x, -y);
                    updateArea.Offset(x, y);
                }
            }

            this.FinishDrawingChildContent();
        }
Exemple #3
0
        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();
        }