Esempio n. 1
0
 private IEnumerable<WtRow> SplitRow(WtRow tRow, int rowCount)
 {
     var rows = new List<WtRow> {tRow};
     for (var i = 1; i < rowCount; i++)
     {
         var row = InsertRowAfter(tRow);
         row.Width = tRow.Width;
         row.Height = tRow.Height;
         rows.Add(row);
     }
     return rows;
 }
Esempio n. 2
0
 private void CreateRows(int rowCount, int colCount)
 {
     for (var i = 0; i < rowCount; i++)
     {
         var row = new WtRow() { OwnerTable = this };
         for (var j = 0; j < colCount; j++)
         {
             var cell = row.CreateCells();
             cell.Width = row.Width/colCount;
             cell.Height = row.Height;
             row.Add(cell);
         }
         Rows.Add(row);
         row.SetCellsRelation();
         //this.Height += row.Height;
     }
 }
Esempio n. 3
0
        private List<WtCell> SplitCell(int rowCount, int colCount, WtRow wtRow, WtCell cell)
        {
            var tempWidth = cell.Width / colCount;
            var lastWidth = cell.Width - tempWidth*(colCount - 1);

            var cells = new List<WtCell>();
            WtCell tempCell = null;
            for (var i = 0; i < colCount; i++)
            {
                if (i == 0)
                {
                    cell.Width = tempWidth;
                    tempCell = cell;
                }
                else
                {
                    tempCell = wtRow.InsertCellAfter(tempCell);
                    tempCell.Width = i < colCount - 1 ? tempWidth : lastWidth;
                    tempCell.Height = cell.Height;
                }
                cells.Add(tempCell);
            }
            wtRow.SetCellProperty();
            return cells;
        }
Esempio n. 4
0
        public DTable Xml2Object(XmlElement xmlElement)
        {
            if (!"table".Equals(xmlElement.Name)) return this;

            Width = Convert.ToInt32(xmlElement.GetAttribute("width"));
            Height = Convert.ToInt32(xmlElement.GetAttribute("height"));

            var rowElements = xmlElement.ChildNodes;
            foreach (XmlNode rowNode in rowElements)
            {
                if (!"tRow".Equals(rowNode.Name)) continue;
                var rowElement = (XmlElement) rowNode;
                var row = new WtRow
                    {
                        Width = Convert.ToInt32(rowElement.GetAttribute("width")),
                        Height = Convert.ToInt32(rowElement.GetAttribute("height")),
                        OwnerTable = this
                    };

                var cellElements = rowElement.ChildNodes;
                foreach (XmlNode cellNode in cellElements)
                {
                    if(!"tCell".Equals(cellNode.Name)) continue;
                    var cellElement = (XmlElement) cellNode;
                    var cell = new WtCell
                        {
                            OwnerTable = this,
                            OwnerRow = row,
                            OwnerDocument = {Context = OwnerDocument.Context}
                        };
                    cell.Xml2Object(cellElement);
                    row.Add(cell);
                }
                row.SetCellsRelation();
                Rows.Add(row);
            }
            SetRowsRelation();
            return this;
        }
Esempio n. 5
0
        public void RemoveRow(WtRow tRow)
        {
            if (!Rows.Contains(tRow)) return;

            if (tRow.PreDocRow != null)
            {
                tRow.PreDocRow.NextDocRow = tRow.NextDocRow;
            }

            if (tRow.NextDocRow != null)
            {
                tRow.NextDocRow.PreDocRow = tRow.PreDocRow;
            }

            Rows.Remove(tRow);
        }
Esempio n. 6
0
 public WtRow LocateCurrentRow(int x, int y)
 {
     foreach (var wtRow in Rows)
     {
         if (x > wtRow.X && x <= wtRow.X + wtRow.Width
             && y > wtRow.Y && y <= wtRow.Y + wtRow.Height)
         {
             CurrentRow = wtRow;
             wtRow.LocateCurrentCell(x, y);
             break;
         }
     }
     return CurrentRow;
 }
Esempio n. 7
0
        public WtRow InsertRowBefore(WtRow tRow)
        {
            var index = Rows.IndexOf(tRow);
            if (index < 0) return null;

            var row = new WtRow() { OwnerTable = this, Width = tRow.Width };

            Rows.Insert(index, row);

            if (index - 1 >= 0)
            {
                Rows[index - 1].NextDocRow = row;
                row.PreDocRow = Rows[index - 1];
            }

            if (index + 1 < Rows.Count)
            {
                Rows[index + 1].PreDocRow = row;
                row.NextDocRow = Rows[index + 1];
            }

            return row;
        }
Esempio n. 8
0
        public WtRow InsertRowAfter(WtRow tRow)
        {
            var index = Rows.IndexOf(tRow);
            if (index < 0) return null;

            var row = new WtRow() {OwnerTable = this, Width = tRow.Width};

            Rows.Insert(index + 1, row);

            Rows[index].NextDocRow = row;
            row.PreDocRow = Rows[index];

            if (index + 2 < Rows.Count)
            {
                Rows[index + 2].PreDocRow = row;
                row.NextDocRow = Rows[index + 2];
            }

            return row;
        }