Esempio n. 1
0
        private static T FindBlock <T>(BlockCollection blocks, TextPointer position) where T : Block
        {
            T     result = null;
            Block block  = blocks.FirstOrDefault(x => x.ContentStart.CompareTo(position) == -1 && x.ContentEnd.CompareTo(position) == 1);

            if (block is T)
            {
                result = (T)block;
            }
            else if (block is Table)
            {
                Table table = (Table)block;
                foreach (TableRowGroup rowGroup in table.RowGroups)
                {
                    foreach (TableRow row in rowGroup.Rows)
                    {
                        foreach (TableCell cell in row.Cells)
                        {
                            result = FindBlock <T>(cell.Blocks, position);
                            if (result != null)
                            {
                                return(result);
                            }
                        }
                    }
                }
            }

            return(result);
        }