예제 #1
0
        /// <summary>
        /// Removes the given columns.
        /// </summary>
        /// <param name="columns">Indexes of the columns to remove.</param>
        public void RemoveColumns(IEnumerable <int> columns)
        {
            A.Table     tbl     = this.slideTemplate.FindTable(this.tblId);
            A.TableGrid tblGrid = tbl.TableGrid;

            // Remove the latest columns first
            IEnumerable <int> columnsSorted = from column in columns
                                              orderby column descending
                                              select column;

            int tblRowsCount = RowsCount(tbl);

            foreach (int column in columnsSorted)
            {
                for (int row = 0; row < tblRowsCount; row++)
                {
                    A.TableRow tr = GetRow(tbl, row);

                    // Remove the column from the row
                    A.TableCell tc = GetCell(tr, column);
                    tc.Remove();
                }

                // Remove the column from TableGrid
                A.GridColumn gridCol = tblGrid.Descendants <A.GridColumn>().ElementAt(column);
                gridCol.Remove();
            }

            this.slideTemplate.Save();
        }
예제 #2
0
        private static void AddNewGridColumn(OXD.TableGrid tableGrid, OXD.TableRow headerRow, OXD.TableRow contentRow)
        {
            var columns = tableGrid.Descendants <OXD.GridColumn>();

            if (null != columns && columns.Any())
            {
                var    headerLastCell  = headerRow.Descendants <OXD.TableCell>().Last();
                var    contentLastCell = contentRow.Descendants <OXD.TableCell>().Last();
                double tableWidth      = columns.Sum(_ => Convert.ToInt32(_.Width.Value));
                var    newColWidth     = Math.Floor(tableWidth / columns.Count());
                foreach (var col in columns)
                {
                    col.Width = col.Width > 0 ? Convert.ToInt64(Math.Floor((tableWidth - newColWidth) / (tableWidth / col.Width))) : 0;
                }
                tableGrid.InsertAfter <OXD.GridColumn>(new OXD.GridColumn()
                {
                    Width = Convert.ToInt64(newColWidth)
                }, columns.Last());
                headerRow.InsertAfter <OXD.TableCell>((OXD.TableCell)headerLastCell.CloneNode(true), headerLastCell);
                contentRow.InsertAfter <OXD.TableCell>((OXD.TableCell)contentLastCell.CloneNode(true), contentLastCell);
            }
        }
예제 #3
0
        private static void RemoveLastGridColumn(OXD.TableGrid tableGrid)
        {
            var lastColumn = tableGrid.Descendants <OXD.GridColumn>().Last();

            tableGrid.RemoveChild <OXD.GridColumn>(lastColumn);
        }