Ejemplo n.º 1
0
        public static Table ReportTable(IWidget parent, int countLines, int x, int y, int firstWidth = 200)
        {
            var rv   = new Table(parent);
            var line = new TableLine(rv, 22);

            const int kWidth = 320;

            line.AddColumn(firstWidth, null, Align.Left, 21, Palette.Black, new GfxPoint(4, 4));
            line.AddColumn(kWidth - firstWidth, null, Align.Left, 21, Palette.Black, new GfxPoint(4, 4));
            rv.SetBackground(null, Palette.TextArea.Background);
            rv.SetBorder(1, Palette.DarkGray);



            rv.AddLine(line);
            for (var i = 0; i < countLines - 1; i++)
            {
                rv.AddLine(new TableLine(line));
            }

            rv.Move(x, y);


            return(rv);
        }
Ejemplo n.º 2
0
        private void ScVxDate_SizeChanged(object sender, SizeF oldSize)
        {
            RectangleF rect = new RectangleF(0, 0, Width, Height);

            mainTable = new Table(rect, 1, 2);

            TableLine tableLine = new TableLine(LineDir.VERTICAL);

            tableLine.lineComputeMode = LineComputeMode.PERCENTAGE;

            tableLine.computeParam = 0.85f;
            mainTable.SetLineArea(0, tableLine);

            tableLine.computeParam = 0.15f;
            mainTable.SetLineArea(1, tableLine);

            mainTable.ComputeLinesArea(LineDir.VERTICAL);

            //
            rect          = mainTable.GetCellContentRect(0, 0);
            textBox.Width = rect.Width - 10;

            float x = rect.Width / 2 - textBox.Width / 2;
            float y = rect.Height / 2 - textBox.Height / 2;

            textBox.Location = new PointF(x, y);

            //
            rect            = mainTable.GetCellContentRect(0, 1);
            search.Width    = rect.Width;
            search.Height   = rect.Height;
            search.Location = new PointF(rect.X, rect.Y);
        }
Ejemplo n.º 3
0
        public static TableLine InputArea(IWidget parent, string label, int x, int y, int width = 440, int height = 30)
        {
            var rv = new TableLine(parent, height);

            rv.AddColumn(width, null, Align.Left, 20, Palette.Black, new GfxPoint(5, 5));

            //var outline = VGPath.OpenVGPath();
            //VGU.vguRoundRect(outline, 0, 0, width, height, 5, 5);
            //rv.AddVGPath(new VGPath(outline, new VGSolidColor(Palette.LightGrey), new VGSolidColor(Palette.TextArea.Background)));

            rv.Move(x, y);

            var hitLabel = new TextArea(rv, 0, 0, rv.Width, rv.Height);

            hitLabel.SetAlign(Align.Left, new GfxPoint(5, 5));
            hitLabel.SetFont(Palette.DarkSlateGray, 20);
            hitLabel.Text = label;

            rv.OnPaint += caller =>
            {
                if (string.IsNullOrEmpty(rv.Text[0].Text))
                {
                    hitLabel.Show();
                }
                else
                {
                    hitLabel.Hide();
                }
            };


            return(rv);
        }
Ejemplo n.º 4
0
        void ReCreateTable()
        {
            RectangleF r = new RectangleF(0, 0, Width, Height);

            mainTable = new Table(r, 1, 1);
            mainTable.SetDefaultCellMargin(margin);

            contentTable = new Table(mainTable.GetCellContentRect(0, 0), 3, 1);

            TableLine tableLine = new TableLine(LineDir.HORIZONTAL);

            tableLine.lineComputeMode = LineComputeMode.ABSOLUTE;

            tableLine.computeParam = 20;
            contentTable.SetLineArea(0, tableLine);

            tableLine.computeParam = 40;
            contentTable.SetLineArea(2, tableLine);

            tableLine.lineComputeMode = LineComputeMode.PERCENTAGE;
            tableLine.computeParam    = 1f;
            contentTable.SetLineArea(1, tableLine);

            contentTable.ComputeLinesArea(LineDir.HORIZONTAL);
        }
Ejemplo n.º 5
0
        public List(IWidget parent, int countLines, int x, int y, int firstWidth = 200) : base(parent)
        {
            mCountOfVisibleLines = countLines;

            var line = new TableLine(this, 22);

            Resize(320, 0);
            //Width = 320;

            line.AddColumn(firstWidth, null, Align.Left, 21, Palette.White, new GfxPoint(4, 4));
            line.AddColumn(Width - firstWidth, null, Align.Left, 21, Palette.White, new GfxPoint(4, 4));
            SetBackground(Palette.LightSkyBlue, new Color(0x121212FF));//Palette.TextArea.Background);
            SetBorder(1, Palette.DarkGray);

            AddLine(line);
            for (var i = 0; i < countLines - 1; i++)
            {
                AddLine(new TableLine(line));
            }

            base.Move(x, y);

            OnIndexChange += s =>
            {
                ActiveLine = GetLineById(mCountOfVisibleLines - (mDataIndex % mCountOfVisibleLines) - 1);
            };

            Init();
        }
Ejemplo n.º 6
0
        public void TestErrorAddTextChunkIntTextChunk()
        {
            TableLine   line     = new TableLine();
            TextElement tElement = new TextElement(new PdfRectangle(), UtilsForTesting.HELVETICA_BOLD, 10, "testTabula3", 5, 0);
            TextChunk   tChunk   = new TextChunk(tElement);

            Assert.Throws <ArgumentException>(() => line.AddTextChunk(-1, tChunk));
        }
Ejemplo n.º 7
0
        public void ReCreateTable()
        {
            RectangleF rect = new RectangleF(0, 0, Width, Height);

            mainTable = new Table(rect, 1, 1);

            float hPaddingLen;
            float vPaddingLen;

            if (isPaddingPercentage)
            {
                hPaddingLen = hPadding * Width;
                vPaddingLen = vPadding * Height;
            }
            else
            {
                hPaddingLen = hPadding;
                vPaddingLen = vPadding;
            }


            Margin defaultCellMargin = new Margin(hPaddingLen, vPaddingLen, hPaddingLen, vPaddingLen);

            mainTable.SetDefaultCellMargin(defaultCellMargin);


            //
            contentTable = new Table(mainTable.GetCellContentRect(0, 0), 1, 2);
            TableLine tableLine = new TableLine(LineDir.VERTICAL);

            tableLine.lineComputeMode = LineComputeMode.PERCENTAGE;

            tableLine.computeParam = splitValue;
            contentTable.SetLineArea(0, tableLine);

            tableLine.computeParam = 1 - splitValue;
            contentTable.SetLineArea(1, tableLine);

            contentTable.ComputeLinesArea(LineDir.VERTICAL);


            //
            txtTable = new Table(contentTable.GetCellContentRect(0, 1), TxtRowCount, 1);

            tableLine = new TableLine(LineDir.HORIZONTAL);
            tableLine.lineComputeMode = LineComputeMode.PERCENTAGE;
            int i = 0;

            foreach (ScTxtInfo txtInfo in rowTextInfoList)
            {
                tableLine.computeParam = rowTextInfoList[i].lineHeight;
                txtTable.SetLineArea(i, tableLine);
                i++;
            }

            txtTable.ComputeLinesArea(LineDir.HORIZONTAL);
        }
Ejemplo n.º 8
0
        public void TestAddTextChunkIntTextChunk()
        {
            TableLine line = new TableLine();

            TextElement tElement = new TextElement(new PdfRectangle(), UtilsForTesting.HELVETICA_BOLD, 10, "testTabula2", 5, 0);
            TextChunk   tChunk   = new TextChunk(tElement);

            line.AddTextChunk(3, tChunk);
            Assert.Equal("testTabula2", line.TextElements[3].GetText());
        }
Ejemplo n.º 9
0
        public void TestToString()
        {
            TableLine line = new TableLine();

            TextElement tElement = new TextElement(new PdfRectangle(), UtilsForTesting.HELVETICA_BOLD, 10, "test", 5, 0);
            TextChunk   tChunk   = new TextChunk(tElement);

            line.AddTextChunk(0, tChunk);
            line.AddTextChunk(0, tChunk);
            Assert.Equal("Tabula.TableLine[left=0.00,bottom=0.00,right=0.00,top=0.00,chunks='testtest', ]", line.ToString());
            //Assert.Equal("technology.tabula.Line[x=0.0,y=0.0,w=0.0,h=0.0,bottom=0.000000,right=0.000000,chunks='testtest', ]", line.ToString());
        }
Ejemplo n.º 10
0
        public void TestSetTextElements()
        {
            TableLine line = new TableLine();

            TextElement      tElement = new TextElement(new PdfRectangle(), UtilsForTesting.HELVETICA_BOLD, 10, "testTabula1", 5, 0);
            TextChunk        tChunk   = new TextChunk(tElement);
            List <TextChunk> tList    = new List <TextChunk>
            {
                tChunk
            };

            line.SetTextElements(tList);

            Assert.Equal("testTabula1", line.TextElements[0].GetText());
        }
Ejemplo n.º 11
0
        public static TableLine DateTime(IWidget parent, int x, int y)
        {
            const int kHeight = 40;

            var rv = new TableLine(parent, kHeight);

            rv.AddColumn(35, null, Align.Center, 40, Palette.Black, new GfxPoint(5, 5)); // hour
            rv.AddColumn(15, null, Align.Center, 40, Palette.Black, new GfxPoint(5, 5)); // :
            rv.AddColumn(35, null, Align.Center, 40, Palette.Black, new GfxPoint(5, 5)); // minute
            rv.AddColumn(0, null, Align.Center, 40, Palette.Black, new GfxPoint(5, 5));  // :
            rv.AddColumn(0, null, Align.Center, 40, Palette.Black, new GfxPoint(5, 5));  // seconds
            rv.AddColumn(20, null, Align.Center, 40, Palette.Black, new GfxPoint(5, 5)); // " - "

            rv.AddColumn(35, null, Align.Center, 40, Palette.Black, new GfxPoint(5, 5)); // day
            rv.AddColumn(15, null, Align.Center, 40, Palette.Black, new GfxPoint(5, 5)); // "/"
            rv.AddColumn(35, null, Align.Center, 40, Palette.Black, new GfxPoint(5, 5)); // month
            rv.AddColumn(15, null, Align.Center, 40, Palette.Black, new GfxPoint(5, 5)); // "/"
            rv.AddColumn(80, null, Align.Center, 40, Palette.Black, new GfxPoint(5, 5)); // year

            //rv.AddColumn(30, null, Align.Center, 20, Palette.Black, new GfxPoint(5, 5)); // seconds

            var outline = VGPath.OpenVGPath();

            VGU.vguRoundRect(outline, 0, 0, rv.Width, kHeight, 5, 5);

            rv.AddVGPath(new VGPath(outline, new VGSolidColor(Palette.LightGrey), new VGSolidColor(Palette.TextArea.Background)));
            rv.Move(x, y);

            {
                rv.Text[0].Text = "09";
                rv.Text[1].Text = ":";
                rv.Text[2].Text = "00";
                rv.Text[3].Text = ":";
                rv.Text[4].Text = "00";
                rv.Text[5].Text = " - ";


                rv.Text[6].Text  = "01";
                rv.Text[7].Text  = "/";
                rv.Text[8].Text  = "03";
                rv.Text[9].Text  = "/";
                rv.Text[10].Text = "2014";
                //rv.Text[0].Text = ":";
                //rv.Text[0].Text = "14";
            }

            return(rv);
        }
Ejemplo n.º 12
0
        void CreateTable()
        {
            RectangleF r = new RectangleF(0, 0, Width, Height);

            mainTable = new Table(r, 2, 1);

            TableLine tableLine = new TableLine(LineDir.HORIZONTAL);

            tableLine.lineComputeMode = LineComputeMode.PERCENTAGE;

            tableLine.computeParam = 0.8f;
            mainTable.SetLineArea(0, tableLine);

            tableLine.computeParam = 0.2f;
            mainTable.SetLineArea(1, tableLine);

            mainTable.ComputeLinesArea(LineDir.HORIZONTAL);

            //
            infoTable = new Table(mainTable.GetCellContentRect(0, 0), 1, 3);

            Margin margin = new Margin(10, 20, 10, 20);

            infoTable.SetCellMargin(0, 0, margin);
            infoTable.SetCellMargin(0, 2, margin);

            margin = new Margin(20, 0, 20, 0);
            infoTable.SetCellMargin(0, 1, margin);

            //
            detailTable = new Table(infoTable.GetCellContentRect(0, 1), 2, 1);

            tableLine = new TableLine(LineDir.HORIZONTAL);
            tableLine.lineComputeMode = LineComputeMode.PERCENTAGE;

            tableLine.computeParam = 0.3f;
            detailTable.SetLineArea(0, tableLine);

            tableLine.computeParam = 0.7f;
            detailTable.SetLineArea(1, tableLine);

            detailTable.ComputeLinesArea(LineDir.HORIZONTAL);
        }
Ejemplo n.º 13
0
        static void IndividualTask1()
        {
            List <TableLine> table = new List <TableLine>()
            {
                new TableLine("Большой Лебовски", "Коэн И., Коэн Дж", 1998, 'К'),
                new TableLine("Геркулес", "Маскер Дж.", 1997, 'А'),
                new TableLine("Ноттинг-хилл", "Мишелл Р.", 1999, 'М'),
                new TableLine("Большой Лебовски", "Коэн И., Коэн Дж", 1998, 'К')
            };

            PrintTable(table);

            bool flag = true;

            do
            {
                Console.Clear();
                PrintTable(table);
                Console.WriteLine("Добавить запись? Y(y) - Да; N(n) - Нет");
                char key = Console.ReadKey().KeyChar;
                if (key == 'n' || key == 'N')
                {
                    flag = false;
                    break;
                }


                TableLine tableLine = new TableLine();
                Console.WriteLine("\nДобавление фильма:");
                Console.WriteLine("Введите название фильма:");
                tableLine.FilmName = Console.ReadLine();
                Console.WriteLine("Введите название режисера:");
                tableLine.Producer = Console.ReadLine();
                Console.WriteLine("Введите год выпуска:");
                tableLine.PublicationDate = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Введите тип:");
                tableLine.Type = Console.ReadKey().KeyChar;

                table.Add(tableLine);
            } while (flag);
        }
Ejemplo n.º 14
0
        void CreateViewLayoutTable(int itemCount)
        {
            float w = (itemWidth + itemMargin.left + itemMargin.right) * colItemCount;

            rowItemCount = itemCount / colItemCount;

            int m = itemCount % colItemCount;

            if (m > 0)
            {
                rowItemCount--;
            }
            float contentHeight = rowItemCount * (itemHeight + itemMargin.top + itemMargin.bottom);
            float viewHeight    = headerHeight + contentViewHeight;

            viewLayoutTable = new TableEx(2, 1);
            viewLayoutTable.SetTablePosition(0, 0);
            viewLayoutTable.SetTableSize(w, viewHeight);

            TableLine tableLine = new TableLine(LineDir.HORIZONTAL);

            tableLine.lineComputeMode = LineComputeMode.ABSOLUTE;

            tableLine.computeParam = headerHeight;
            viewLayoutTable.SetLineArea(0, tableLine);

            tableLine.computeParam = contentViewHeight;
            viewLayoutTable.SetLineArea(1, tableLine);

            //
            itemContentLayoutTable = headerLayoutTable = new TableEx(0, headerNames.Count());
            itemContentLayoutTable.SetTableSize(w, headerHeight);
            viewLayoutTable.AddCellChildTable(0, 0, headerLayoutTable);


            //
            SetTableData();

            viewLayoutTable.ReLayout();
        }
Ejemplo n.º 15
0
        private void ScVxSearchAndTitle_SizeChanged(object sender, SizeF oldSize)
        {
            RectangleF rect = new RectangleF(130, 18, Width - 150, Height - 40);

            mainTable = new Table(rect, 2, 1);

            TableLine tableLine = new TableLine(LineDir.HORIZONTAL);

            tableLine.lineComputeMode = LineComputeMode.PERCENTAGE;

            tableLine.computeParam = 0.4f;
            mainTable.SetLineArea(0, tableLine);

            tableLine.computeParam = 0.6f;
            mainTable.SetLineArea(1, tableLine);

            mainTable.ComputeLinesArea(LineDir.HORIZONTAL);

            rect            = mainTable.GetCellContentRect(1, 0);
            search.Width    = rect.Width;
            search.Height   = rect.Height;
            search.Location = new PointF(rect.X, rect.Y);
        }
Ejemplo n.º 16
0
        private void ScVxDate_SizeChanged(object sender, SizeF oldSize)
        {
            RectangleF rect = new RectangleF(0, 0, Width, Height);

            mainTable = new Table(rect, 1, 3);

            TableLine tableLine = new TableLine(LineDir.VERTICAL);

            tableLine.lineComputeMode = LineComputeMode.PERCENTAGE;

            tableLine.computeParam = 0.4f;
            mainTable.SetLineArea(0, tableLine);

            tableLine.computeParam = 0.25f;
            mainTable.SetLineArea(1, tableLine);

            tableLine.computeParam = 0.35f;
            mainTable.SetLineArea(2, tableLine);
            mainTable.ComputeLinesArea(LineDir.VERTICAL);

            dateAnim.Stop();
            dateAnim.Start();
        }
Ejemplo n.º 17
0
        public void ReCreateTable()
        {
            float      space = spaceLayer.Location.Y;
            RectangleF rect  = new RectangleF(0, 5, spaceLayer.Width, spaceLayer.Height - 10);

            mainTable = new Table(rect, 1, 3);

            TableLine tableLine = new TableLine(LineDir.VERTICAL);

            tableLine.lineComputeMode = LineComputeMode.ABSOLUTE;

            tableLine.computeParam = 5;
            mainTable.SetLineArea(0, tableLine);

            tableLine.computeParam = spaceLayer.Height + space - 15;
            mainTable.SetLineArea(1, tableLine);

            tableLine.computeParam = spaceLayer.Width - (spaceLayer.Height + space - 15) - 5;
            mainTable.SetLineArea(2, tableLine);
            mainTable.ComputeLinesArea(LineDir.VERTICAL);

            //
            txtTable = new Table(mainTable.GetCellContentRect(0, 2), TxtRowCount, 1);
        }
Ejemplo n.º 18
0
        private void ScVxTipsProgressBar_SizeChanged(object sender, SizeF oldSize)
        {
            //
            float tipsRowHeight = Height * tipsRowHeightRatio;
            float barRowHeight  = Height * barRowHeightRatio;

            RectangleF rect = new RectangleF(0, 0, Width, Height);

            mainTable = new Table(rect, 3, 1);

            Margin margin = new Margin(0, 5, 0, 5);

            mainTable.SetCellMargin(0, 0, margin);
            mainTable.SetCellMargin(2, 0, margin);

            TableLine tableLine = new TableLine(LineDir.HORIZONTAL);

            tableLine.lineComputeMode = LineComputeMode.ABSOLUTE;

            tableLine.computeParam = tipsRowHeight;
            mainTable.SetLineArea(0, tableLine);

            tableLine.computeParam = barRowHeight;
            mainTable.SetLineArea(1, tableLine);

            tableLine.computeParam = Height - tipsRowHeight - barRowHeight;
            mainTable.SetLineArea(2, tableLine);

            mainTable.ComputeLinesArea(LineDir.HORIZONTAL);


            RectangleF tipsRowRect = mainTable.GetCellContentRect(0, 0);
            RectangleF barRowRect  = mainTable.GetCellContentRect(1, 0);
            RectangleF numRowRect  = mainTable.GetCellContentRect(2, 0);

            progressBar.BarHeight = barHeight;
            progressBar.Height    = barRowHeight;
            progressBar.Location  = new PointF(barRowRect.X, barRowRect.Y);


            //
            RectangleF[]        progressNodeRects = progressBar.progressNodeRects;
            List <ScVxPageTips> tipsList          = new List <ScVxPageTips>();
            List <RectangleF>   numRectList       = new List <RectangleF>();
            ScVxPageTips        tips;
            RectangleF          r;
            float x;

            string[] nodeNames = progressBar.progressNodeNames;



            for (int i = 0; i < progressNodeRects.Count(); i++)
            {
                r = progressNodeRects[i];
                x = r.X + r.Width / 2 - tipsWidth / 2;

                tips                = new ScVxPageTips();
                tips.txt            = nodeNames[i];
                tips.triWidthScale  = 4f;
                tips.triHeightScale = 5f;
                tips.bgColor        = Color.Black;
                tips.txtColor       = Color.White;
                tips.isDisplaySide  = true;
                tips.alpha          = 0;

                tips.Width    = tipsWidth;
                tips.Height   = tipsRowRect.Height;
                tips.Location = new PointF(x, tipsRowRect.Y);


                Add(tips);
                tipsList.Add(tips);

                //
                x = r.X + r.Width / 2 - r.Width;
                RectangleF r2 = new RectangleF(x, numRowRect.Y, r.Width * 2, numRowRect.Height);
                numRectList.Add(r2);
            }

            tipsSet          = tipsList.ToArray();
            progressNumRects = numRectList.ToArray();

            //
        }
Ejemplo n.º 19
0
        private void ScVxMainBox_SizeChanged(object sender, SizeF oldSize)
        {
            //
            titleLayer.Width    = Width;
            titleLayer.Height   = 100;
            titleLayer.Location = new PointF(0, 0);

            //
            RectangleF rect = new RectangleF(0, 0, titleLayer.Width, titleLayer.Height);

            titleTable = new Table(rect, 1, 4);

            TableLine tableLine = new TableLine(LineDir.VERTICAL);

            tableLine.lineComputeMode = LineComputeMode.ABSOLUTE;

            tableLine.computeParam = 200f;
            titleTable.SetLineArea(0, tableLine);
            titleTable.SetLineArea(1, tableLine);

            tableLine.computeParam = 400f;
            titleTable.SetLineArea(3, tableLine);

            TableLine tableLine2 = new TableLine(LineDir.VERTICAL);

            tableLine.lineComputeMode = LineComputeMode.PERCENTAGE;

            tableLine2.computeParam = 1.0f;
            titleTable.SetLineArea(2, tableLine2);
            titleTable.ComputeLinesArea(LineDir.VERTICAL);


            if (titleLeftLayer != null)
            {
                rect = titleTable.GetCellContentRect(0, 0);

                titleLeftLayer.Width    = rect.Width;
                titleLeftLayer.Height   = rect.Height;
                titleLeftLayer.Location = new PointF(rect.X, rect.Y);
            }

            if (titleLeftLayer2 != null)
            {
                rect = titleTable.GetCellContentRect(0, 1);

                titleLeftLayer2.Width    = rect.Width;
                titleLeftLayer2.Height   = rect.Height;
                titleLeftLayer2.Location = new PointF(rect.X, rect.Y);
            }

            if (titleMiddleLayer != null)
            {
                rect = titleTable.GetCellContentRect(0, 2);

                titleMiddleLayer.Width    = rect.Width;
                titleMiddleLayer.Height   = rect.Height;
                titleMiddleLayer.Location = new PointF(rect.X, rect.Y);
            }

            if (titleRightLayer != null)
            {
                rect = titleTable.GetCellContentRect(0, 3);

                titleRightLayer.Width    = rect.Width;
                titleRightLayer.Height   = rect.Height;
                titleRightLayer.Location = new PointF(rect.X, rect.Y);
            }


            //
            contentLayer.Width    = Width;
            contentLayer.Height   = Height - titleLayer.Height;
            contentLayer.Location = new PointF(0, titleLayer.Location.Y + titleLayer.Height);

            //
            dateLayer.Width  = 250;
            dateLayer.Height = 30;

            float y = contentLayer.Location.Y - dateLayer.Height / 2;
            float x = 30;

            dateLayer.Location = new PointF(x, y);

            if (contentLayer.controls.Count > 0)
            {
                ScLayer cLayer = contentLayer.controls[0];
                cLayer.Width    = contentLayer.Width - 40;
                cLayer.Height   = contentLayer.Height - 10;
                cLayer.Location = new PointF(20, 0);
            }


            if (dateLayer.controls.Count > 0)
            {
                ScLayer dLayer = dateLayer.controls[0];
                dLayer.Width    = dateLayer.Width;
                dLayer.Height   = dateLayer.Height;
                dLayer.Location = new PointF(0, 0);
            }


            //
            drakLayer.Width  = Width;
            drakLayer.Height = Height;
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Extracts the tables in the page.
        /// </summary>
        /// <param name="page">The page where to extract the tables.</param>
        public List <Table> Extract(PageArea page)
        {
            List <TextElement> textElements = page.GetText();

            if (textElements.Count == 0)
            {
                return(new Table[] { Table.EMPTY }.ToList());
            }

            List <TextChunk> textChunks = this.verticalRulings == null?TextElement.MergeWords(page.GetText()) : TextElement.MergeWords(page.GetText(), this.verticalRulings);

            List <TableLine> lines = TextChunk.GroupByLines(textChunks);

            List <double> columns;

            if (this.verticalRulings != null)
            {
                // added by bobld: clipping verticalRulings because testExtractColumnsCorrectly2() fails
                var clippedVerticalRulings = Ruling.CropRulingsToArea(this.verticalRulings, page.BoundingBox);
                clippedVerticalRulings.Sort(new VerticalRulingComparer());
                columns = new List <double>(clippedVerticalRulings.Count);
                foreach (Ruling vr in clippedVerticalRulings)
                {
                    columns.Add(vr.Left);
                }

                /*
                 * this.verticalRulings.Sort(new VerticalRulingComparer());
                 * columns = new List<double>(this.verticalRulings.Count);
                 * foreach (Ruling vr in this.verticalRulings)
                 * {
                 *  columns.Add(vr.getLeft());
                 * }
                 */
            }
            else
            {
                columns = ColumnPositions(lines);
            }

            // added by bobld: remove duplicates because testExtractColumnsCorrectly2() fails,
            // why do we need it here and not in the java version??
            columns = columns.Distinct().ToList();

            Table table = new Table(this);

            table.SetRect(page.BoundingBox);

            for (int i = 0; i < lines.Count; i++)
            {
                TableLine        line     = lines[i];
                List <TextChunk> elements = line.TextElements.ToList();

                elements.Sort(new TextChunkComparer());

                foreach (TextChunk tc in elements)
                {
                    if (tc.IsSameChar(TableLine.WHITE_SPACE_CHARS))
                    {
                        continue;
                    }

                    int  j     = 0;
                    bool found = false;
                    for (; j < columns.Count; j++)
                    {
                        if (tc.Left <= columns[j])
                        {
                            found = true;
                            break;
                        }
                    }

                    table.Add(new Cell(tc), i, found ? j : columns.Count);
                }
            }

            return(new Table[] { table }.ToList());
        }
Ejemplo n.º 21
0
        public static Window ShowWindow()
        {
            var window = new Window("show", kWidth, kHeight)
            {
                Description = "Шеф-повар \"Сибовар\""
            };

            var line = new TableLine(25);

            line.AddColumn(80);
            line.AddColumn(80);
            line.AddColumn(70);

            line.Text[0].Text = "HgjloGreen";
            line.Text[0].SetFont(Palette.Lime, 20);
            line.Text[0].SetAlign(Align.Left, new GfxPoint(0, 3));
            line.Text[1].Text = "HelloRed";
            line.Text[1].SetFont(Palette.Red, 15);
            line.Text[1].SetAlign(Align.Center);
            line.Text[2].Text = "HgelloBlue";
            line.Text[2].SetFont(Palette.PaleTurquoise, 30);
            line.Text[2].SetAlign(Align.Left, new GfxPoint(0, 4));

            line.Name = "line";


            var table = new Table(window)
            {
                Name = "table"
            };

            table.Move(10, 50);
            table.AddLine(new TableLine(line));
            table.AddLine(new TableLine(line));
            table.AddLine(new TableLine(line));
            table.SetBackground(Palette.Red, Palette.White);
            table.SetBorder(1, Palette.Lime);
            table.OnPress += caller =>
            {
                var rv = table.GetLineByCell(caller);
                if (rv == null)
                {
                    return;
                }

                table.ActiveLine   = rv;
                window.Description = rv.Name;
            };


            var text = new TextArea(window, 10, 180, 325, 50);

            text.SetFont("i260c", Palette.PaleTurquoise, 50);
            text.Text = "0123456789:";

            text.OnPress += caller => window.Description = "Text.Pressed";

            var bar = new ProgressBar(window, 40, 30, 200, 15, 15)
            {
                Percent = 10, Status = { Text = "hello" }
            };

            bar.Status.SetAlign(Align.Center, new GfxPoint(3, 3));
            bar.Status.SetFont(Palette.White, 14);
            bar.Rotate(70);

            text.OnRelease += caller =>
            {
                window.Description = "Text.Released";
                //mApplication.SetFocusedWindow("1");
                line.Move(line.X - 3, line.Y - 3);
                table.ActiveLine = null;
                bar.Percent     -= 1;
            };

            window.OnPaint += delegate { Debug.Print(DateTime.Now.ToString("HH:mm:ss") + ":\tHome update"); };

            var activePath = VG.vgCreatePath(0, VGPathDatatype.VG_PATH_DATATYPE_S_16, 1, 0, 0, 0, VGPathCapabilities.VG_PATH_CAPABILITY_ALL);

            VGU.vguRoundRect(activePath, 0, 0, 60, 100, 20, 20);

            var normalPath = VG.vgCreatePath(0, VGPathDatatype.VG_PATH_DATATYPE_S_16, 1, 0, 0, 0, VGPathCapabilities.VG_PATH_CAPABILITY_ALL);

            VGU.vguRoundRect(normalPath, 0, 0, 100, 50, 20, 20);
            VGU.vguRoundRect(normalPath, 10, 50, 80, 70, 20, 20);



            var activeButton = new VGSolidColor(new Color(0xFF0000FF));
            //var normalButton = new VGSolidColor(new Color(0x00FF00FF));
            var normalButton = new VGLinearGradient(0, 0, 100, 120);

            normalButton.AddColor(0, new Color(0xFF0000FF));
            normalButton.AddColor(100, new Color(0x00FF00FF));

            var button = new Button(window, new VGPath(activePath, null, activeButton), new VGPath(normalPath, null, normalButton));

            button.IsCached = true;
            button.Move(250, 50);
            button.OnPress += delegate { Console.WriteLine("button.OnPress"); };


            var image = new Image(window, 25, 10);

            image.Load("splash.raw");
            image.Scale(0.5f, 0.5f);
            image.RotateCenter = new GfxPoint(image.Width / 2, image.Height / 2);
            //image.Hide();

            window.OnPaint += caller =>
            {
                image.Rotate(mImageRotate);
                mImageRotate += 5;
            };

            var graphicArea = new GraphicArea(window, 200, 200);

            graphicArea.Move(70, 20);
            graphicArea.Background = new Color(0xF0F0F0FF);


            graphicArea.Grid   = new VGPath(activePath, activeButton, null);
            graphicArea.Arrows = new VGPath(normalPath, new VGSolidColor(Palette.PaleTurquoise), null);

            var graphicData1 = new GraphicsData
            {
                Data =
                    new byte[]
                {
                    0, 15, 25, 50, 40, 35, 12, 10, 15, 17, 30, 32, 35, 35, 35, 35, 35, 40,
                    45, 57, 25, 23, 20, 18, 12, 12, 12, 30, 32, 35, 35, 35, 35, 35, 40, 45
                }
            };

            var graphicData2 = new GraphicsData(graphicData1)
            {
                Color = Palette.Lime, Position = new GfxPoint(10, 10)
            };

            graphicArea.AddGrapic(graphicData1);
            graphicArea.AddGrapic(graphicData2);

            return(window);
        }
Ejemplo n.º 22
0
        private void Init(int x, int y)
        {
            InitBackground();

            mPaint = VG.vgCreatePaint();
            VG.vgSetParameterfv(mPaint, (int)VGPaintParamType.VG_PAINT_COLOR, 4, (new Color(0xEDAB18ff)).Value);

            AddVGPath(new VGPath(mPath, new VGSolidColor(new Color(0xD1D3D4FF)), new VGSolidColor(new Color(0x2c2d2eff)))
            {
                StrokeWidth = 0.5f
            });

            var       divideLines = VGPath.OpenVGPath();
            const int kBiasY      = 44;

            VGU.vguLine(divideLines, 0, 3 * kBiasY, Width - 30, 3 * kBiasY);
            VGU.vguLine(divideLines, 0, 2 * kBiasY, Width - 30, 2 * kBiasY);
            VGU.vguLine(divideLines, 0, kBiasY, Width - 30, kBiasY);
            VGU.vguLine(divideLines, 0, 0, Width - 30, 0);
            var lines = new VGPath(divideLines, new VGSolidColor(new Color(0xD1D3D4FF)), null)
            {
                StrokeWidth = 0.5f
            };

            lines.Move(15, kBiasY);
            AddVGPath(lines);

            const int kBiasX  = 47;
            const int kBiasX0 = 60;

            Text.Label(this, "T, ⁰C", 16, kBiasX0, kBiasY * 4, kBiasX, 18);
            Text.Label(this, "I, A", 16, kBiasX0 + kBiasX, kBiasY * 4, kBiasX, 18);
            Text.Label(this, "U, B", 16, kBiasX0 + 2 * kBiasX, kBiasY * 4, kBiasX, 18);
            Text.Label(this, "F, Гц", 16, kBiasX0 + 3 * kBiasX, kBiasY * 4, kBiasX, 18);
            Text.Label(this, "об/мин", 16, kBiasX0 + 4 * kBiasX, kBiasY * 4, kBiasX, 18);

            //Text.Label(this, "ПЧН #1\\nПЧН #2\\nПЧН #3\\nПЧН #4", 18, 15, 22, kBiasX0 - 15, kBiasY, Align.Left);

            mTable     = new Table(this);
            mTableLine = new TableLine(kBiasY / 2);
            mTableLine.AddColumn(kBiasX0 - 15, null, Align.Center, 17, Palette.White, new GfxPoint(0, 3));
            //mTableLine.Text[0].Text = "ПЧН #4";
            mTableLine.AddColumn(kBiasX, null, Align.Center, 17, Palette.White, new GfxPoint(0, 3));
            mTableLine.AddColumn(kBiasX, null, Align.Center, 17, Palette.White, new GfxPoint(0, 3));
            mTableLine.AddColumn(kBiasX, null, Align.Center, 17, Palette.White, new GfxPoint(0, 3));
            mTableLine.AddColumn(kBiasX, null, Align.Center, 17, Palette.White, new GfxPoint(0, 3));
            mTableLine.AddColumn(kBiasX, null, Align.Center, 17, Palette.White, new GfxPoint(0, 3));

            mTableStatusLine = new TableLine(kBiasY / 2);
            mTableStatusLine.AddColumn(kBiasX0 - 15, null, Align.Center, 16, new Color(0xD1D3D4FF), new GfxPoint(0, 5));
            mTableStatusLine.Text[0].Text = "статус:";
            mTableStatusLine.AddColumn(kBiasX * 5, null, Align.Center, 17, Palette.White, new GfxPoint(0, 3));

            mTable.AddLine(mTableStatusLine);
            mTable.AddLine(mTableLine);

            mTable.AddLine(new TableLine(mTableStatusLine));
            mTable.AddLine(new TableLine(mTableLine));

            mTable.AddLine(new TableLine(mTableStatusLine));
            mTable.AddLine(new TableLine(mTableLine));

            mTable.AddLine(new TableLine(mTableStatusLine));
            mTable.AddLine(new TableLine(mTableLine));

            //mTable.SetBorder(1, Palette.Lime); // for debug
            mTable.Move(15, 0);

            mTable.GetCellById(7, 0).Text = "Uz 2";
            mTable.GetCellById(5, 0).Text = "Uz 3";
            mTable.GetCellById(3, 0).Text = "Uz 4";
            mTable.GetCellById(1, 0).Text = "Uz 5";


            #region temperature
            mReciever.GetSignal("uz.2.temperature").OnUpdate += sensor => mTable.GetCellById(7, 1).Text = string.Format("{0}", sensor.Value);
            mReciever.GetSignal("uz.3.temperature").OnUpdate += sensor =>
            {
                mTable.GetCellById(5, 1).Text = string.Format("{0}", sensor.Value);
            };
            mReciever.GetSignal("uz.4.temperature").OnUpdate += sensor => mTable.GetCellById(3, 1).Text = string.Format("{0}", sensor.Value);
            mReciever.GetSignal("uz.5.temperature").OnUpdate += sensor => mTable.GetCellById(1, 1).Text = string.Format("{0}", sensor.Value);
            mTable.GetCellById(7, 1).Text = "-";
            mTable.GetCellById(5, 1).Text = "-";
            mTable.GetCellById(3, 1).Text = "-";
            mTable.GetCellById(1, 1).Text = "-";
            #endregion

            #region current
            mReciever.GetSignal("uz.2.current").OnUpdate += sensor => mTable.GetCellById(7, 2).Text = string.Format("{0}", sensor.Value);
            mReciever.GetSignal("uz.3.current").OnUpdate += sensor => mTable.GetCellById(5, 2).Text = string.Format("{0}", sensor.Value);
            mReciever.GetSignal("uz.4.current").OnUpdate += sensor => mTable.GetCellById(3, 2).Text = string.Format("{0}", sensor.Value);
            mReciever.GetSignal("uz.5.current").OnUpdate += sensor => mTable.GetCellById(1, 2).Text = string.Format("{0}", sensor.Value);
            mTable.GetCellById(7, 2).Text = "-";
            mTable.GetCellById(5, 2).Text = "-";
            mTable.GetCellById(3, 2).Text = "-";
            mTable.GetCellById(1, 2).Text = "-";
            #endregion

            #region voltage
            mReciever.GetSignal("uz.2.voltage").OnUpdate += sensor => mTable.GetCellById(7, 3).Text = string.Format("{0}", sensor.Value);
            mReciever.GetSignal("uz.3.voltage").OnUpdate += sensor => mTable.GetCellById(5, 3).Text = string.Format("{0}", sensor.Value);
            mReciever.GetSignal("uz.4.voltage").OnUpdate += sensor => mTable.GetCellById(3, 3).Text = string.Format("{0}", sensor.Value);
            mReciever.GetSignal("uz.5.voltage").OnUpdate += sensor => mTable.GetCellById(1, 3).Text = string.Format("{0}", sensor.Value);
            mTable.GetCellById(7, 3).Text = "-";
            mTable.GetCellById(5, 3).Text = "-";
            mTable.GetCellById(3, 3).Text = "-";
            mTable.GetCellById(1, 3).Text = "-";
            #endregion

            // TODO: привязать к реальным значениям
            #region freq
            mReciever.GetSignal("uz.2.frequency").OnUpdate += sensor => mTable.GetCellById(7, 4).Text = string.Format("{0:F2}", sensor.Value / 100);
            mReciever.GetSignal("uz.3.frequency").OnUpdate += sensor => mTable.GetCellById(5, 4).Text = string.Format("{0:F2}", sensor.Value / 100);
            mReciever.GetSignal("uz.4.frequency").OnUpdate += sensor => mTable.GetCellById(3, 4).Text = string.Format("{0:F2}", sensor.Value / 100);
            mReciever.GetSignal("uz.5.frequency").OnUpdate += sensor => mTable.GetCellById(1, 4).Text = string.Format("{0:F2}", sensor.Value / 100);
            mTable.GetCellById(7, 4).Text = "-";
            mTable.GetCellById(5, 4).Text = "-";
            mTable.GetCellById(3, 4).Text = "-";
            mTable.GetCellById(1, 4).Text = "-";
            #endregion

            #region rpm - энкодера нет физически
            //mReciever.GetSignal("uz.2.speed").OnUpdate += sensor => mTable.GetCellById(7, 5).Text = string.Format("{0}", sensor.Value);
            //mReciever.GetSignal("uz.3.speed").OnUpdate += sensor => mTable.GetCellById(5, 5).Text = string.Format("{0}", sensor.Value);
            //mReciever.GetSignal("uz.4.speed").OnUpdate += sensor => mTable.GetCellById(3, 5).Text = string.Format("{0}", sensor.Value);
            //mReciever.GetSignal("uz.5.speed").OnUpdate += sensor => mTable.GetCellById(1, 5).Text = string.Format("{0}", sensor.Value);
            mTable.GetCellById(7, 5).Text = "-";
            mTable.GetCellById(5, 5).Text = "-";
            mTable.GetCellById(3, 5).Text = "-";
            mTable.GetCellById(1, 5).Text = "-";
            #endregion

            // TODO: по значению
            #region status

            /*
             * mReciever.GetSignal("uz.2.error").OnUpdate += sensor => mTable.GetCellById(7, 5).Text = string.Format("0x{0:X4}", sensor.Value);
             * mReciever.GetSignal("uz.3.error").OnUpdate += sensor => mTable.GetCellById(5, 5).Text = string.Format("0x{0:X4}", sensor.Value);
             * mReciever.GetSignal("uz.4.error").OnUpdate += sensor => mTable.GetCellById(3, 5).Text = string.Format("0x{0:X4}", sensor.Value);
             * mReciever.GetSignal("uz.5.error").OnUpdate += sensor => mTable.GetCellById(1, 5).Text = string.Format("0x{0:X4}", sensor.Value);
             */

            mReciever.GetSignal("uz.2.error").OnUpdate += sensor =>
            {
                mTable.GetCellById(6, 1).SetFont(sensor.Value > 0
                                                                                                            ? Palette.Red
                                                                                                            : Palette.White);
                mTable.GetCellById(6, 1).Text = string.Format("{0}", sensor.Value);
            };
            mReciever.GetSignal("uz.3.error").OnUpdate += sensor =>
            {
                mTable.GetCellById(4, 1).SetFont(sensor.Value > 0
                                                                                                            ? Palette.Red
                                                                                                            : Palette.White);
                mTable.GetCellById(4, 1).Text = string.Format("{0}", sensor.Value);
            };
            mReciever.GetSignal("uz.4.error").OnUpdate += sensor =>
            {
                mTable.GetCellById(2, 1).SetFont(sensor.Value > 0
                                                                                                            ? Palette.Red
                                                                                                            : Palette.White);
                mTable.GetCellById(2, 1).Text = string.Format("{0}", sensor.Value);
            };
            mReciever.GetSignal("uz.5.error").OnUpdate += sensor =>
            {
                mTable.GetCellById(0, 1).SetFont(sensor.Value > 0
                                                                                                            ? Palette.Red
                                                                                                            : Palette.White);
                mTable.GetCellById(0, 1).Text = string.Format("{0}", sensor.Value);
            };

            mTable.GetCellById(6, 1).Text = "6:1";
            mTable.GetCellById(4, 1).Text = "4:1";
            mTable.GetCellById(2, 1).Text = "2:1";
            mTable.GetCellById(0, 1).Text = "0:1";
            #endregion

            //mReciever.GetSignal("").OnUpdate += sensor => mTable.GetCellById(0, 0).Text = string.Format("{0}", sensor.Value);


            Move(x, y);
        }
Ejemplo n.º 23
0
        public void ReCreateTable()
        {
            int        n    = 1;
            RectangleF rect = new RectangleF(0, 0, Width, Height);

            mainTable = new Table(rect, 1, 1);

            Margin defaultCellMargin = new Margin(hPadding, vPadding, hPadding, vPadding);

            mainTable.SetDefaultCellMargin(defaultCellMargin);

            if (isHorLayout == false)
            {
                if (isShowFieldTitle)
                {
                    n = 2;
                }
                //
                txtTable = new Table(mainTable.GetCellContentRect(0, 0), TxtRowCount, n);

                for (int j = 0; j < TxtRowCount; j++)
                {
                    int    m      = 0;
                    Margin margin = new Margin(20, 0, 0, 0);

                    if (n == 2)
                    {
                        m = 1;
                    }

                    txtTable.SetCellMargin(j, m, margin);
                }


                TableLine tableLine = new TableLine(LineDir.HORIZONTAL);
                tableLine.lineComputeMode = LineComputeMode.PERCENTAGE;
                int i = 0;

                foreach (ScTxtInfo txtInfo in rowTextInfoList)
                {
                    tableLine.computeParam = rowTextInfoList[i].lineHeight;
                    txtTable.SetLineArea(i, tableLine);
                    i++;
                }

                txtTable.ComputeLinesArea(LineDir.HORIZONTAL);


                if (isShowFieldTitle)
                {
                    //
                    tableLine = new TableLine(LineDir.VERTICAL);
                    tableLine.lineComputeMode = LineComputeMode.PERCENTAGE;

                    tableLine.computeParam = titleRatio;
                    txtTable.SetLineArea(0, tableLine);

                    tableLine.computeParam = 1 - titleRatio;
                    txtTable.SetLineArea(1, tableLine);

                    txtTable.ComputeLinesArea(LineDir.VERTICAL);
                }
            }
            else
            {
                if (isShowFieldTitle)
                {
                    n = 2;
                }

                txtTable = new Table(mainTable.GetCellContentRect(0, 0), n, TxtRowCount);

                TableLine tableLine = new TableLine(LineDir.VERTICAL);
                tableLine.lineComputeMode = LineComputeMode.PERCENTAGE;
                int i = 0;

                foreach (ScTxtInfo txtInfo in rowTextInfoList)
                {
                    tableLine.computeParam = rowTextInfoList[i].lineHeight;
                    txtTable.SetLineArea(i, tableLine);
                    i++;
                }

                txtTable.ComputeLinesArea(LineDir.VERTICAL);


                if (isShowFieldTitle)
                {
                    //
                    tableLine = new TableLine(LineDir.HORIZONTAL);
                    tableLine.lineComputeMode = LineComputeMode.PERCENTAGE;

                    tableLine.computeParam = titleRatio;
                    txtTable.SetLineArea(0, tableLine);

                    tableLine.computeParam = 1 - titleRatio;
                    txtTable.SetLineArea(1, tableLine);

                    txtTable.ComputeLinesArea(LineDir.HORIZONTAL);
                }
            }
        }
Ejemplo n.º 24
0
        public static TableLine DateTime(IWidget parent, int x, int y)
        {
            const int kHeight = 30;

            var rv = new TableLine(parent, kHeight);

            rv.AddColumn(25, null, Align.Center, 20, Palette.Black, new GfxPoint(5, 5)); // hour
            rv.AddColumn(10, null, Align.Center, 20, Palette.Black, new GfxPoint(5, 5)); // :
            rv.AddColumn(25, null, Align.Center, 20, Palette.Black, new GfxPoint(5, 5)); // minute
            rv.AddColumn(0, null, Align.Center, 20, Palette.Black, new GfxPoint(5, 5));  // :
            rv.AddColumn(0, null, Align.Center, 20, Palette.Black, new GfxPoint(5, 5));  // seconds
            rv.AddColumn(15, null, Align.Center, 20, Palette.Black, new GfxPoint(5, 5)); // " - "

            rv.AddColumn(25, null, Align.Center, 20, Palette.Black, new GfxPoint(5, 5)); // day
            rv.AddColumn(10, null, Align.Center, 20, Palette.Black, new GfxPoint(5, 5)); // "/"
            rv.AddColumn(25, null, Align.Center, 20, Palette.Black, new GfxPoint(5, 5)); // month
            rv.AddColumn(10, null, Align.Center, 20, Palette.Black, new GfxPoint(5, 5)); // "/"
            rv.AddColumn(55, null, Align.Center, 20, Palette.Black, new GfxPoint(5, 5)); // year

            //rv.AddColumn(30, null, Align.Center, 20, Palette.Black, new GfxPoint(5, 5)); // seconds

            //var outline = VGPath.OpenVGPath();
            //VGU.vguRoundRect(outline, 0, 0, rv.Width, kHeight, 5, 5);
            //rv.AddVGPath(new VGPath(outline, new VGSolidColor(Palette.LightGrey), new VGSolidColor(Palette.TextArea.Background)));

            rv.Move(x, y);

            foreach (var label in rv.Text)
            {
                label.SetFont(Palette.Black, 25);
                label.SetAlign(Align.Center);
            }

            //rv.OnShow += caller =>
            {
                rv.Text[0].Text = "09";
                rv.Text[1].Text = ":";
                rv.Text[2].Text = "00";
                rv.Text[3].Text = ":";
                rv.Text[4].Text = "00";
                rv.Text[5].Text = " - ";


                rv.Text[6].Text  = "01";
                rv.Text[7].Text  = "/";
                rv.Text[8].Text  = "03";
                rv.Text[9].Text  = "/";
                rv.Text[10].Text = "2014";
                //rv.Text[0].Text = ":";
                //rv.Text[0].Text = "14";
            }



            rv.OnPress += caller =>
            {
                var cell = caller as TextArea;
                if (cell != null)
                {
                    cell.SetFont(Palette.Red);
                }
            };

            return(rv);
        }
Ejemplo n.º 25
0
        private TableRectangle getTableFromText(List <TableLine> lines, List <TextEdge> relevantEdges, int relevantEdgeCount, List <Ruling> horizontalRulings)
        {
            TableRectangle table = new TableRectangle();

            TableLine prevRow       = null;
            TableLine firstTableRow = null;
            TableLine lastTableRow  = null;

            int    tableSpaceCount = 0;
            double totalRowSpacing = 0;

            // go through the lines and find the ones that have the correct count of the relevant edges
            foreach (TableLine textRow in lines)
            {
                int numRelevantEdges = 0;

                if (firstTableRow != null && tableSpaceCount > 0)
                {
                    // check to make sure this text row is within a line or so of the other lines already added
                    // if it's not, we should stop the table here
                    double tableLineThreshold = (totalRowSpacing / tableSpaceCount) * 2.5;
                    double lineDistance       = prevRow.Bottom - textRow.Bottom; // bobld: textRow.Top - prevRow.Top

                    System.Diagnostics.Debug.Assert(lineDistance >= 0);

                    if (lineDistance > tableLineThreshold)
                    {
                        lastTableRow = prevRow;
                        break;
                    }
                }

                // for larger tables, be a little lenient on the number of relevant rows the text intersects
                // for smaller tables, not so much - otherwise we'll end up treating paragraphs as tables too
                int relativeEdgeDifferenceThreshold = 1;
                if (relevantEdgeCount <= 3)
                {
                    relativeEdgeDifferenceThreshold = 0;
                }

                foreach (TextEdge edge in relevantEdges)
                {
                    if (textRow.IntersectsLine(edge.Line))
                    {
                        numRelevantEdges++;
                    }
                }

                // see if we have a candidate text row
                if (numRelevantEdges >= (relevantEdgeCount - relativeEdgeDifferenceThreshold))
                {
                    // keep track of table row spacing
                    if (prevRow != null && firstTableRow != null)
                    {
                        tableSpaceCount++;
                        totalRowSpacing += prevRow.Bottom - textRow.Bottom; // bobld: textRow.Top - prevRow.Top
                    }

                    // row is part of a table
                    if (table.Area == 0)
                    {
                        firstTableRow = textRow;
                        table.SetRect(textRow);
                    }
                    else
                    {
                        table.SetLeft(Math.Min(table.Left, textRow.Left));
                        table.SetBottom(Math.Min(table.Bottom, textRow.Bottom)); // bobld: Max
                        table.SetRight(Math.Max(table.Right, textRow.Right));
                    }
                }
                else
                {
                    // no dice
                    // if we're at the end of the table, save the last row
                    if (firstTableRow != null && lastTableRow == null)
                    {
                        lastTableRow = prevRow;
                    }
                }

                prevRow = textRow;
            }

            // if we don't have a table now, we won't after the next step either
            if (table.Area == 0)
            {
                return(null);
            }

            if (lastTableRow == null)
            {
                // takes care of one-row tables or tables that end at the bottom of a page
                lastTableRow = prevRow;
            }

            // use the average row height and nearby horizontal lines to extend the table area
            double avgRowHeight;

            if (tableSpaceCount > 0)
            {
                System.Diagnostics.Debug.Assert(totalRowSpacing >= 0);
                avgRowHeight = totalRowSpacing / tableSpaceCount;
            }
            else
            {
                avgRowHeight = lastTableRow.Height;
            }

            double rowHeightThreshold = avgRowHeight * 1.5;

            // check lines after the bottom of the table
            //foreach (Ruling ruling in sortedHorizontalRulings) //Line2D.Float
            for (int i = horizontalRulings.Count - 1; i >= 0; i--) // reverse order
            {
                var ruling = horizontalRulings[i];
                if (ruling.Y1 > table.Bottom) // bobld: <
                {
                    continue;
                }

                double distanceFromTable = table.Bottom - ruling.Y2; // bobld: Y1
                System.Diagnostics.Debug.Assert(distanceFromTable >= 0);
                if (distanceFromTable <= rowHeightThreshold)
                {
                    // use this ruling to help define the table
                    table.SetBottom(Math.Min(table.Bottom, ruling.Y2));  // bobld: Max Y1
                    table.SetLeft(Math.Min(table.Left, ruling.X1));
                    table.SetRight(Math.Max(table.Right, ruling.X2));
                }
                else
                {
                    // no use checking any further
                    break;
                }
            }

            // do the same for lines at the top, but make the threshold greater since table headings tend to be
            // larger to fit up to three-ish rows of text (at least but we don't want to grab too much)
            rowHeightThreshold = avgRowHeight * 3.8;

            //for (int i = horizontalRulings.Count - 1; i >= 0; i--)
            for (int i = 0; i < horizontalRulings.Count; i++)
            {
                Ruling ruling = horizontalRulings[i];

                if (ruling.Y1 < table.Top) //bobld: >
                {
                    continue;
                }

                double distanceFromTable = ruling.Y1 - table.Top; // bobld: table.Top - ruling.Y1
                System.Diagnostics.Debug.Assert(distanceFromTable >= 0);
                if (distanceFromTable <= rowHeightThreshold)
                {
                    table.SetTop(Math.Max(table.Top, ruling.Y2));  // bobld: Min Y1
                    table.SetLeft(Math.Min(table.Left, ruling.X1));
                    table.SetRight(Math.Max(table.Right, ruling.X2));
                }
                else
                {
                    break;
                }
            }

            // add a bit of padding since the halved horizontal lines are a little fuzzy anyways
            table.SetTop(Math.Ceiling(table.Top) + TABLE_PADDING_AMOUNT);       // bobld: Floor -
            table.SetBottom(Math.Floor(table.Bottom) - TABLE_PADDING_AMOUNT);   // bobld: Ceiling +
            table.SetLeft(Math.Floor(table.Left) - TABLE_PADDING_AMOUNT);
            table.SetRight(Math.Ceiling(table.Right) + TABLE_PADDING_AMOUNT);

            return(table);
        }