Beispiel #1
0
        public GridLayer(RenderElement owner, int nColumns, int nRows, CellSizeStyle cellSizeStyle)
            : base(owner)
        {
            this.cellSizeStyle = cellSizeStyle;
            this.gridTable = new GridTable();
            gridRows = gridTable.Rows;
            gridCols = gridTable.Columns;
            int columnWidth = owner.Width;
            if (nColumns > 0)
            {
                columnWidth = columnWidth / nColumns;
                uniformCellWidth = columnWidth;
                if (columnWidth < 1)
                {
                    columnWidth = 1;
                }
            }

            //------------------------------------------------------------             
            int cx = 0;
            for (int c = 0; c < nColumns; c++)
            {
                GridColumn col = new GridColumn(columnWidth);
                col.Width = columnWidth;
                col.Left = cx;
                cx += columnWidth;
                gridCols.Add(col);
            }
            //------------------------------------------------------------

            if (nRows > 0)
            {
                int rowHeight = owner.Height / nRows;
                int cy = 0;
                for (int r = 0; r < nRows; r++)
                {
                    var row = new GridRow(rowHeight);
                    gridRows.Add(row);
                    row.Height = rowHeight;
                    row.Top = cy;
                    cy += rowHeight;
                }
                uniformCellHeight = rowHeight;
            }
            //------------------------------------------------------------
        }
Beispiel #2
0
 public void BuildGrid(int ncols, int nrows, CellSizeStyle cellSizeStyle)
 {
     this.cellSizeStyle = cellSizeStyle;
     //1. create cols
     var cols = gridTable.Columns;
     for (int n = 0; n < ncols; ++n)
     {
         //create with defatul width
         GridColumn col = new GridColumn(1);
         cols.Add(col);
     }
     //2. create rows
     var rows = gridTable.Rows;
     for (int n = 0; n < nrows; ++n)
     {
         rows.Add(new GridRow(1));
     }
 }
Beispiel #3
0
            public void MoveColumnAfter(GridColumn tobeMovedColumn, GridColumn afterColumn)
            {
                //---------------------------------------------------------

                int toTargetColumnIndex = afterColumn.ColumnIndex;
                if (tobeMovedColumn.ColumnIndex < toTargetColumnIndex)
                {
                    toTargetColumnIndex -= 1;
                }
                cols.RemoveAt(tobeMovedColumn.ColumnIndex);
                cols.Insert(afterColumn.ColumnIndex, tobeMovedColumn);
                UpdateColumnIndex(Math.Min(afterColumn.ColumnIndex, toTargetColumnIndex));
                this.OwnerInvalidateGraphicAndStartBubbleUp();
            }
Beispiel #4
0
            public void Insert(int index, GridColumn coldef)
            {
                cols.Insert(index, coldef);
                int j = cols.Count;
                for (int i = index + 1; i < j; i++)
                {
                    cols[i].ColumnIndex = i;
                }


                foreach (GridRow rowdef in this.table.GetRowIter())
                {
                    coldef.CreateGridItemForRow(rowdef);
                }
                //--------------------------------------------
                //                ContentArrangementVisitor contArrVisitor = new ContentArrangementVisitor(ownerGridLayer);
                //#if DEBUG
                //                //contArrVisitor.dbug_StartLayoutTrace("GridColumnCollection::Insert");
                //                contArrVisitor.dbug_StartLayoutTrace(dbugVisualElementLayoutMsg.GridColumnCollection_Insert);
                //#endif

                InvalidateGraphicAndStartBubbleUp();
                //OwnerGridLayer.OwnerInvalidateGraphicAndStartBubbleUp();


                //#if DEBUG
                //                contArrVisitor.dbug_EndLayoutTrace();
                //#endif
                //--------------------------------------------
            }
Beispiel #5
0
            public void Add(GridColumn newColumnDef)
            {
                int j = cols.Count;
                if (j == 0)
                {
                    newColumnDef.Left = 0;
                    newColumnDef.ColumnIndex = 0;
                }
                else
                {
                    newColumnDef.Left = cols[j - 1].Right + 1;
                    newColumnDef.ColumnIndex = j;
                }
                newColumnDef.SetParentColumnCollection(this);
                cols.Add(newColumnDef);
#if DEBUG
                //contArrVisitor.dbug_StartLayoutTrace("GridCollection::Add(GridColumn)");
#endif

                InvalidateGraphicAndStartBubbleUp();
#if DEBUG
                //contArrVisitor.dbug_EndLayoutTrace();
#endif

                //--------------------------------------------
            }
Beispiel #6
0
 internal GridCell(GridColumn column, GridRow row)
 {
     this.row = row;
     this.column = column;
 }
Beispiel #7
0
        static void ReCalculateColumnSize(GridColumn col)
        {
            int j = col.CellCount;
            if (j > 0)
            {
                col.DesiredHeight = 0;
                bool firstFoundContentCell = false;
                int local_desired_width = 0;
                for (int i = 0; i < j; i++)
                {
                    GridCell cell = col.GetCell(i);
                    ReCalculateContentSize(cell);
                    int cellDesiredWidth = col.Width;
                    int cellDesiredHeight = cell.Height;
                    var content = cell.ContentElement as RenderElement;
                    if (content != null)
                    {
                        if (content.Width > cellDesiredWidth)
                        {
                            cellDesiredWidth = content.Width;
                        }
                        if (content.Height > cellDesiredHeight)
                        {
                            cellDesiredHeight = content.Height;
                        }
                    }

                    col.DesiredHeight += cellDesiredHeight;
                    if (!firstFoundContentCell)
                    {
                        firstFoundContentCell = cell.HasContent;
                    }
                    if (cellDesiredWidth > local_desired_width)
                    {
                        if (firstFoundContentCell)
                        {
                            if (cell.HasContent)
                            {
                                local_desired_width = cellDesiredWidth;
                            }
                        }
                        else
                        {
                            local_desired_width = cellDesiredWidth;
                        }
                    }
                }
                col.CalculatedWidth = local_desired_width;
            }
            else
            {
                col.CalculatedWidth = col.Width;
            }
        }
Beispiel #8
0
 public void MoveColumnAfter(GridColumn tobeMoveColumn, GridColumn afterColumn)
 {
     this.gridCols.MoveColumnAfter(tobeMoveColumn, afterColumn);
     this.OwnerInvalidateGraphic();
 }
Beispiel #9
0
 public void InsertColumn(int index, GridColumn col)
 {
     gridCols.Insert(index, col);
 }
Beispiel #10
0
 public void AddColumn(GridColumn col)
 {
     gridCols.Add(col);
 }
Beispiel #11
0
 public void ChangeColumnWidth(GridColumn targetGridColumn, int newWidth)
 {
     targetGridColumn.Width = newWidth;
     GridColumn prevColumn = targetGridColumn;
     GridColumn currentColumn = targetGridColumn.NextColumn;
     while (currentColumn != null)
     {
         currentColumn.Left = prevColumn.Right;
         prevColumn = currentColumn;
         currentColumn = currentColumn.NextColumn;
     }
 }
Beispiel #12
0
        static void SetLeftAndPerformArrange(GridColumn col, int left)
        {
            int prevWidth = col.Width;
            if (!col.HasCustomSize)
            {
                col.Width = col.CalculatedWidth;
            }
            col.Left = left;
            int j = col.CellCount;
            int dW = col.Width;
            for (int i = 0; i < j; ++i)
            {
                var content = col.GetCell(i).ContentElement as RenderElement;
                if (content != null)
                {
                    //RenderElement.DirectSetVisualElementWidth(content, dW);
                    //if (content.IsVisualContainerBase)
                    //{

                    //    ArtVisualContainerBase vscont = (ArtVisualContainerBase)content;
                    //    vscont.InvalidateContentArrangementFromContainerSizeChanged();
                    //    vscont.TopDownReArrangeContentIfNeed(vinv);
                    //} 
                }
            }
        }