Example #1
0
        public void DisplayImages()
        {
            if (PagePlotModel == null)
            {
                return;
            }

            foreach (var s in PagePlotModel.Series.Where(s => (string)s.Tag == "image").ToList())
            {
                PagePlotModel.Series.Remove(s);
            }

            foreach (var block in _pdfPageModel.GetImages())
            {
                var series1 = new LineSeries {
                    Tag = "image", Title = "image", LineStyle = LineStyle.Solid, Color = OxyColors.YellowGreen
                };
                var bbox = block.Bounds;
                series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.BottomLeft));
                series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.BottomRight));
                series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.TopRight));
                series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.TopLeft));
                series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.BottomLeft));
                PagePlotModel.Series.Add(series1);
            }

            PagePlotModel.InvalidatePlot(true);
        }
Example #2
0
        public void DisplayTextBlocks()
        {
            if (PagePlotModel == null)
            {
                return;
            }

            foreach (var s in PagePlotModel.Series.Where(s => (string)s.Tag == "textblock").ToList())
            {
                PagePlotModel.Series.Remove(s);
            }

            foreach (var block in _pdfPageModel.GetTextBlocks())
            {
                var series1 = new LineSeries {
                    Tag = "textblock", Title = GetShorterText(block.Text), LineStyle = LineStyle.Solid, Color = OxyColors.Brown
                };
                var bbox = block.BoundingBox;
                series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.BottomLeft));
                series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.BottomRight));
                series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.TopRight));
                series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.TopLeft));
                series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.BottomLeft));
                PagePlotModel.Series.Add(series1);
            }

            PagePlotModel.InvalidatePlot(true);
        }
Example #3
0
        public void DisplayLetters()
        {
            if (PagePlotModel == null)
            {
                return;
            }

            foreach (var s in PagePlotModel.Series.Where(s => (string)s.Tag == "letter").ToList())
            {
                PagePlotModel.Series.Remove(s);
            }

            foreach (var letter in _pdfPageModel.GetLetters())
            {
                var series1 = new LineSeries {
                    Tag = "letter", Title = GetShorterText(letter.Value), LineStyle = LineStyle.Solid, Color = OxyColors.Blue
                };
                var bbox = letter.GlyphRectangle;
                series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.BottomLeft));
                series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.BottomRight));
                series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.TopRight));
                series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.TopLeft));
                series1.Points.Add(PdfDocumentModel.ToDataPoint(bbox.BottomLeft));
                PagePlotModel.Series.Add(series1);
            }

            PagePlotModel.InvalidatePlot(true);
        }
Example #4
0
 public void ShowPagePlotModel()
 {
     if (_currentSeries != null)
     {
         _currentSeries.ToList().ForEach(s => PagePlotModel.Series.Add(s));
         PagePlotModel.InvalidatePlot(true);
         this.RaisePropertyChanged(nameof(PagePlotModel));
     }
 }
Example #5
0
        public void HideImages()
        {
            if (PagePlotModel == null)
            {
                return;
            }

            foreach (var s in PagePlotModel.Series.Where(s => (string)s.Tag == "image").ToList())
            {
                PagePlotModel.Series.Remove(s);
            }

            PagePlotModel.InvalidatePlot(true);
        }
Example #6
0
        public void DisplayPaths()
        {
            if (PagePlotModel == null)
            {
                return;
            }

            foreach (var s in PagePlotModel.Series.Where(s => (string)s.Tag == "pdfpath").ToList())
            {
                PagePlotModel.Series.Remove(s);
            }

            foreach (var path in _pdfPageModel.GetPdfPaths())
            {
                foreach (var sp in path)
                {
                    string title = ("path: " + (path.IsStroked ? "stroked " + (path.StrokeColor?.ToRGBValues()).ToString() : "") +
                                    (path.IsFilled ? "filled " + (path.FillColor?.ToRGBValues()).ToString() : "") +
                                    (path.IsClipping ? "clipping" : "")
                                    ).Trim();
                    var series1 = new LineSeries {
                        Tag = "pdfpath", Title = title, LineStyle = LineStyle.Solid, Color = OxyColors.Yellow
                    };

                    PdfPoint first = PdfPoint.Origin;
                    foreach (var c in sp.Commands)
                    {
                        if (c is Move m)
                        {
                            first = m.Location;
                            series1.Points.Add(PdfDocumentModel.ToDataPoint(first));
                        }
                        else if (c is Line l)
                        {
                            series1.Points.Add(PdfDocumentModel.ToDataPoint(l.From));
                            series1.Points.Add(PdfDocumentModel.ToDataPoint(l.To));
                        }
                        else if (c is BezierCurve bc)
                        {
                            var lines = bc.ToLines(10).ToList();
                            for (int i = 0; i < lines.Count; i++)
                            {
                                series1.Points.Add(PdfDocumentModel.ToDataPoint(lines[i].From));
                                series1.Points.Add(PdfDocumentModel.ToDataPoint(lines[i].To));
                            }
                        }
                        else if (c is Close)
                        {
                            series1.Points.Add(PdfDocumentModel.ToDataPoint(first));
                        }
                        else
                        {
                            throw new ArgumentException();
                        }
                    }

                    PagePlotModel.Series.Add(series1);
                }
            }

            PagePlotModel.InvalidatePlot(true);
        }