internal HitListEntry(PagePolygon pp, float x, float y, ReportArea ra)
 {
     pi   = pp;
     poly = new System.Drawing.PointF[pp.Points.Length];
     for (int i = 0; i < pp.Points.Length; i++)
     {
         poly[i].X = ra.PixelsX(pp.Points[i].X + x);
         poly[i].Y = ra.PixelsY(pp.Points[i].Y + y);
     }
     rect = new Rectangle(0, 0, 0, 0);
 }
Exemple #2
0
 /// <summary>
 /// This class represents an entry into the hit list, the list containing the items that have been "hit" or selected.
 /// </summary>
 public HitListEntry(PagePolygon pp, float x, float y, Canvas pd)
 {
     pi   = pp;
     poly = new PointF[pp.Points.Length];
     for (int i = 0; i < pp.Points.Length; i++)
     {
         poly[i].X = Measurement.PixelsFromPoints(pp.Points[i].X + x, pd.Properties.Dpi.X);
         poly[i].Y = Measurement.PixelsFromPoints(pp.Points[i].Y + y, pd.Properties.Dpi.Y);
     }
     rect = RectangleF.Empty;
 }
        private void DrawPolygon(PagePolygon pp, StringBuilder sb)
        {
            StyleInfo si = pp.SI;

            sb.Append("<Polygon Points=\"");
            foreach (PointF p in pp.Points)
            {
                sb.AppendFormat("{0}, {1} ", PixelsX(p.X + si.PaddingLeft), PixelsY(p.Y + si.PaddingTop));
            }
            sb.Append("\">");
            sb.Append("<Polygon.Fill>");
            DrawBackground(sb, si);
            sb.Append("</Polygon.Fill>");
            sb.Append("</Polygon>");
        }
Exemple #4
0
        private void FillPolygon(PagePolygon pp, Graphics g, RectangleF r)
        {
            StyleInfo si = pp.SI;

            PointF[] tmp = new PointF[pp.Points.Length];
            if (!si.BackgroundColor.IsEmpty)
            //RectangleF(PixelsX(pi.X + _left - _hScroll), PixelsY(pi.Y + _top - _vScroll),
            //                                                                    PixelsX(pi.W), PixelsY(pi.H))
            {
                for (int i = 0; i < pp.Points.Length; i++)
                {
                    tmp[i].X = PixelsX(pp.Points[i].X + _left - _hScroll);
                    tmp[i].Y = PixelsY(pp.Points[i].Y + _top - _vScroll);
                }
                g.FillPolygon(new SolidBrush(si.BackgroundColor), tmp);
            }
        }
        private static void FillPolygon(PagePolygon pp, Graphics g, RectangleF r, CanvasProperties cp)
        {
            StyleInfo si = pp.SI;

            PointF[] tmp = new PointF[pp.Points.Length];
            if (!si.BackgroundColor.IsEmpty)
            //RectangleF(PixelsX(pi.X + _left - _hScroll), PixelsY(pi.Y + _top - _vScroll),
            //                                                                    PixelsX(pi.W), PixelsY(pi.H))
            {
                for (int i = 0; i < pp.Points.Length; i++)
                {
                    tmp[i] = Measurement.PixelsFromPoints(pp.Points[i].X + cp.Left - cp.Scroll.X,
                                                          pp.Points[i].Y + cp.Top - cp.Scroll.Y,
                                                          cp.Dpi);
                }
                g.FillPolygon(new SolidBrush(si.BackgroundColor), tmp);
            }
        }
Exemple #6
0
        // render all the objects in a page (or any composite object
        private void ProcessPage(System.Drawing.Graphics g, IEnumerable p)
        {
            // TODO: (Peter) Support can grow and can shrink
            foreach (PageItem pi in p)
            {
                if (pi is PageTextHtml)
                {       // PageTextHtml is actually a composite object (just like a page)
                    ProcessHtml(pi as PageTextHtml, g);
                    continue;
                }

                if (pi is PageLine)
                {
                    PageLine pl = pi as PageLine;
                    DrawLine(pl.SI.BColorLeft, pl.SI.BStyleLeft, pl.SI.BWidthLeft,
                             g, PixelsX(pl.X + _left - _hScroll), PixelsY(pl.Y + _top - _vScroll),
                             PixelsX(pl.X2 + _left - _hScroll), PixelsY(pl.Y2 + _top - _vScroll));
                    continue;
                }


                RectangleF rect = new RectangleF(PixelsX(pi.X + _left - _hScroll), PixelsY(pi.Y + _top - _vScroll),
                                                 PixelsX(pi.W), PixelsY(pi.H));


                if ((pi is PagePolygon) || (pi is PageCurve))
                { // intentionally empty; polygon's rectangles aren't calculated
                }

                if (pi.SI.BackgroundImage != null)
                {       // put out any background image
                    PageImage i = pi.SI.BackgroundImage;
                    DrawImageBackground(i, pi.SI, g, rect);
                }

                if (pi is PageText)
                {
                    // TODO: enable can shrink, can grow
                    // 2005 spec file, page 9, in the text box has
                    // CanGrow and CanShrink
                    PageText pt = pi as PageText;
                    DrawString(pt, g, rect);
                }
                else if (pi is PageImage)
                {
                    PageImage i = pi as PageImage;
                    DrawImage(i, g, rect);
                }
                else if (pi is PageRectangle)
                {
                    this.DrawBackground(g, rect, pi.SI);
                }
                else if (pi is PageEllipse)
                {
                    PageEllipse pe = pi as PageEllipse;
                    DrawEllipse(pe, g, rect);
                }
                else if (pi is PagePie)
                {
                    PagePie pp = pi as PagePie;
                    DrawPie(pp, g, rect);
                }
                else if (pi is PagePolygon)
                {
                    PagePolygon ppo = pi as PagePolygon;
                    FillPolygon(ppo, g, rect);
                }
                else if (pi is PageCurve)
                {
                    PageCurve pc = pi as PageCurve;
                    DrawCurve(pc.SI.BColorLeft, pc.SI.BStyleLeft, pc.SI.BWidthLeft,
                              g, pc.Points, pc.Offset, pc.Tension);
                }


                DrawBorder(pi, g, rect);
            }

            // TO: convert System.Drawing.Graphics to Xwt.Drawing.Context and draw it to this.g

            Bitmap bm = new Bitmap(600, 600);

            g.DrawImage(bm, 600, 600);

            System.IO.MemoryStream s = new System.IO.MemoryStream();
            gImg.Save(s, System.Drawing.Imaging.ImageFormat.Png);
            gImg.Save("test.png", System.Drawing.Imaging.ImageFormat.Png);
            // Xwt.Drawing.Image img = Xwt.Drawing.Image.FromStream(s);
            Xwt.Drawing.Image img = Xwt.Drawing.Image.FromFile("test.png");

            xwtContext.DrawImage(img, new Xwt.Rectangle(0, 0, 600, 600), new Xwt.Rectangle(0, 0, 600, 600));
            //Xwt.Drawing.TextLayout layout = new Xwt.Drawing.TextLayout(xwtContext);
            //layout.Font = xwtContext.Font;
            //layout.Text = "Test";
            //xwtContext.DrawTextLayout(layout, 2, 4);
        }
        // render all the objects in a page (or any composite object
        private void ProcessPage(StringBuilder sb, IEnumerable p, Rectangle offset)
        {
            foreach (PageItem pi in p)
            {
                if (pi is PageTextHtml)
                {       // PageTextHtml is actually a composite object (just like a page)
                    ProcessHtml(pi as PageTextHtml, sb, new Rectangle(PixelsX(pi.X), PixelsY(pi.Y), PixelsX(pi.W), PixelsY(pi.H)));
                    continue;
                }

                if (pi is PageLine)
                {
                    PageLine pl = pi as PageLine;
                    DrawLine(pl.SI.BColorLeft, pl.SI.BStyleLeft, PixelsX(pl.SI.BWidthLeft),
                             sb, PixelsX(pl.X), PixelsY(pl.Y),
                             PixelsX(pl.X2), PixelsY(pl.Y2));
                    continue;
                }

                Rectangle rect = new Rectangle(PixelsX(pi.X), PixelsY(pi.Y),
                                               PixelsX(pi.W), PixelsY(pi.H));

                if (pi.SI.BackgroundImage != null)
                {       // put out any background image
                    PageImage i = pi.SI.BackgroundImage;
                    DrawImageBackground(i, pi.SI, sb, rect);
                }

                if (pi is PageText)
                {
                    PageText pt = pi as PageText;
                    DrawString(pt, sb, rect);
                }
                else if (pi is PageImage)
                {
                    PageImage i = pi as PageImage;
                    DrawImage(i, sb, rect);
                }
                else if (pi is PageRectangle)
                {
                    this.DrawRectangle(pi as PageRectangle, sb, rect);
                }
                else if (pi is PageEllipse)
                {
                    PageEllipse pe = pi as PageEllipse;
                    DrawEllipse(pe, sb, rect);
                }
                else if (pi is PagePie)
                {
                    PagePie pp = pi as PagePie;
                    // DrawPie(pp, g, rect);
                }
                else if (pi is PagePolygon)
                {
                    PagePolygon ppo = pi as PagePolygon;
                    DrawPolygon(ppo, sb);
                }

                DrawBorder(pi, sb, rect);
            }
        }
Exemple #8
0
        // render all the objects in a page (or any composite object
        private void ProcessPage(Graphics g, IEnumerable p, RectangleF clipRect, bool bHitList)
        {
            // TODO: (Peter) Support can grow and can shrink
            foreach (PageItem pi in p)
            {
                //if (pi is PageTextHtml)
                //{	// PageTextHtml is actually a composite object (just like a page)
                //    if (SelectTool && bHitList)
                //    {
                //        RectangleF hr = new RectangleF(PixelsX(pi.X + _left - _hScroll), PixelsY(pi.Y + _top - _vScroll),
                //                                                            PixelsX(pi.W), PixelsY(pi.H));
                //        _HitList.Add(new HitListEntry(hr, pi));
                //    }
                //    ProcessHtml(pi as PageTextHtml, g, clipRect, bHitList);
                //    continue;
                //}

                if (pi is PageLine)
                {
                    PageLine pl = pi as PageLine;
                    DrawLine(pl.SI.BColorLeft, pl.SI.BStyleLeft, pl.SI.BWidthLeft,
                             g, PixelsX(pl.X + _left - _hScroll), PixelsY(pl.Y + _top - _vScroll),
                             PixelsX(pl.X2 + _left - _hScroll), PixelsY(pl.Y2 + _top - _vScroll));
                    continue;
                }


                RectangleF rect = new RectangleF(PixelsX(pi.X + _left - _hScroll), PixelsY(pi.Y + _top - _vScroll),
                                                 PixelsX(pi.W), PixelsY(pi.H));

                // Maintain the hit list
                //if (bHitList)
                //{
                //    if (SelectTool)
                //    {   // we need all PageText and PageImage items that have been displayed
                //        if (pi is PageText || pi is PageImage)
                //        {
                //            _HitList.Add(new HitListEntry(rect, pi));
                //        }
                //    }
                //    // Only care about items with links and tips
                //    else if (pi.HyperLink != null || pi.BookmarkLink != null || pi.Tooltip != null)
                //    {
                //        HitListEntry hle;
                //        if (pi is PagePolygon)
                //            hle = new HitListEntry(pi as PagePolygon, _left - _hScroll, _top - _vScroll, this);
                //        else
                //            hle = new HitListEntry(rect, pi);
                //        _HitList.Add(hle);
                //    }
                //}

                if ((pi is PagePolygon) || (pi is PageCurve))
                { // intentionally empty; polygon's rectangles aren't calculated
                }
                else if (!rect.IntersectsWith(clipRect))
                {
                    continue;
                }

                if (pi.SI.BackgroundImage != null)
                {       // put out any background image
                    PageImage i = pi.SI.BackgroundImage;
                    DrawImageBackground(i, pi.SI, g, rect);
                }

                if (pi is PageText)
                {
                    // TODO: enable can shrink, can grow
                    // 2005 spec file, page 9, in the text box has
                    // CanGrow and CanShrink
                    PageText pt = pi as PageText;
                    DrawString(pt, g, rect);
                }
                else if (pi is PageImage)
                {
                    PageImage i = pi as PageImage;
                    DrawImage(i, g, rect);
                }
                else if (pi is PageRectangle)
                {
                    this.DrawBackground(g, rect, pi.SI);
                }
                else if (pi is PageEllipse)
                {
                    PageEllipse pe = pi as PageEllipse;
                    DrawEllipse(pe, g, rect);
                }
                else if (pi is PagePie)
                {
                    PagePie pp = pi as PagePie;
                    DrawPie(pp, g, rect);
                }
                else if (pi is PagePolygon)
                {
                    PagePolygon ppo = pi as PagePolygon;
                    FillPolygon(ppo, g, rect);
                }
                else if (pi is PageCurve)
                {
                    PageCurve pc = pi as PageCurve;
                    DrawCurve(pc.SI.BColorLeft, pc.SI.BStyleLeft, pc.SI.BWidthLeft,
                              g, pc.Points, pc.Offset, pc.Tension);
                }


                DrawBorder(pi, g, rect);
            }
        }
        /// <summary>
        /// Renders all the objects in a Page or composite object.
        /// </summary>
        private static void ProcessPage(Graphics g, IEnumerable p, RectangleF clipRect, bool bHitList, CanvasProperties cp, ref PageItemManager cpim)
        {
            foreach (PageItem pi in p)
            {
                if (pi is PageTextHtml)
                {       // PageTextHtml is actually a composite object (just like a page)
                    if (cpim.SelectToolEnabled && bHitList)
                    {
                        RectangleF hr = new RectangleF(
                            Measurement.PixelsFromPoints(pi.X + cp.Left - cp.Scroll.X, cp.Dpi.X),
                            Measurement.PixelsFromPoints(pi.Y + cp.Scroll.X - cp.Scroll.Y, cp.Dpi.Y),
                            Measurement.PixelsFromPoints(pi.W, cp.Dpi.X),
                            Measurement.PixelsFromPoints(pi.H, cp.Dpi.Y));

                        cpim.HitList.Add(new HitListEntry(hr, pi));
                    }
                    ProcessHtml(pi as PageTextHtml, g, clipRect, bHitList, cp, ref cpim);
                    continue;
                }

                if (pi is PageLine)
                {
                    PageLine pl = pi as PageLine;
                    CanvasPainter.DrawLine(
                        pl.SI.BColorLeft,
                        pl.SI.BStyleLeft,
                        pl.SI.BWidthLeft,
                        g,
                        Measurement.PixelsFromPoints(pl.X + cp.Left - cp.Scroll.X, cp.Dpi.X),
                        Measurement.PixelsFromPoints(pl.Y + cp.Top - cp.Scroll.Y, cp.Dpi.Y),
                        Measurement.PixelsFromPoints(pl.X2 + cp.Left - cp.Scroll.X, cp.Dpi.X),
                        Measurement.PixelsFromPoints(pl.Y2 + cp.Top - cp.Scroll.Y, cp.Dpi.Y));
                    continue;
                }


                RectangleF rect = new RectangleF(
                    Measurement.PixelsFromPoints(pi.X + cp.Left - cp.Scroll.X, cp.Dpi.X),
                    Measurement.PixelsFromPoints(pi.Y + cp.Top - cp.Scroll.Y, cp.Dpi.Y),
                    Measurement.PixelsFromPoints(pi.W, cp.Dpi.X),
                    Measurement.PixelsFromPoints(pi.H, cp.Dpi.Y));

                // Maintain the hit list
                if (bHitList)
                {
                    if (cpim.SelectToolEnabled)
                    {   // we need all PageText and PageImage items that have been displayed
                        if (pi is PageText || pi is PageImage)
                        {
                            cpim.HitList.Add(new HitListEntry(rect, pi));
                        }
                    }
                    // Only care about items with links and tips
                    else if (pi.HyperLink != null || pi.BookmarkLink != null || pi.Tooltip != null)
                    {
                        HitListEntry hle;
                        if (pi is PagePolygon)
                        {
                            hle = new HitListEntry(pi as PagePolygon, cp.Left - cp.Scroll.X, cp.Top - cp.Scroll.Y, ((Canvas)cp.Parent));
                        }
                        else
                        {
                            hle = new HitListEntry(rect, pi);
                        }
                        cpim.HitList.Add(hle);
                    }
                }

                if ((pi is PagePolygon) || (pi is PageCurve))
                { // intentionally empty; polygon's rectangles aren't calculated
                }
                else if (!rect.IntersectsWith(clipRect))
                {
                    continue;
                }

                if (pi.SI.BackgroundImage != null)
                {       // put out any background image
                    PageImage i = pi.SI.BackgroundImage;
                    CanvasPainter.DrawImageBackground(i, pi.SI, g, rect);
                }

                if (pi is PageText)
                {
                    PageText pt = pi as PageText;
                    CanvasPainter.DrawString(pt, g, rect, cp, cpim);
                }
                else if (pi is PageImage)
                {
                    PageImage i = pi as PageImage;
                    CanvasPainter.DrawImage(i, g, rect, cp, cpim);
                }
                else if (pi is PageRectangle)
                {
                    CanvasPainter.DrawBackground(g, rect, pi.SI);
                }
                else if (pi is PageEllipse)
                {
                    PageEllipse pe = pi as PageEllipse;
                    CanvasPainter.DrawEllipse(pe, g, rect);
                }
                else if (pi is PagePie)
                {
                    PagePie pp = pi as PagePie;
                    CanvasPainter.DrawPie(pp, g, rect);
                }
                else if (pi is PagePolygon)
                {
                    PagePolygon ppo = pi as PagePolygon;
                    CanvasPainter.FillPolygon(ppo, g, rect, cp);
                }
                else if (pi is PageCurve)
                {
                    PageCurve pc = pi as PageCurve;
                    CanvasPainter.DrawCurve(pc.SI.BColorLeft, pc.SI.BStyleLeft, pc.SI.BWidthLeft,
                                            g, pc.Points, pc.Offset, pc.Tension, cp);
                }


                CanvasPainter.DrawBorder(pi, g, rect);
            }
        }
Exemple #10
0
        // render all the objects in a page (or any composite object
        private void ProcessPage(System.Drawing.Graphics g, IEnumerable p)
        {
            // TODO: (Peter) Support can grow and can shrink
            foreach (PageItem pi in p)
            {
                if (pi is PageTextHtml)
                {       // PageTextHtml is actually a composite object (just like a page)
                    ProcessHtml(pi as PageTextHtml, g);
                    continue;
                }

                if (pi is PageLine)
                {
                    PageLine pl = pi as PageLine;
                    DrawLine(pl.SI.BColorLeft, pl.SI.BStyleLeft, pl.SI.BWidthLeft,
                             g, PixelsX(pl.X + _left - _hScroll), PixelsY(pl.Y + _top - _vScroll),
                             PixelsX(pl.X2 + _left - _hScroll), PixelsY(pl.Y2 + _top - _vScroll));
                    continue;
                }


                RectangleF rect = new RectangleF(PixelsX(pi.X + _left - _hScroll), PixelsY(pi.Y + _top - _vScroll),
                                                 PixelsX(pi.W), PixelsY(pi.H));


                if ((pi is PagePolygon) || (pi is PageCurve))
                { // intentionally empty; polygon's rectangles aren't calculated
                }

                if (pi.SI.BackgroundImage != null)
                {       // put out any background image
                    PageImage i = pi.SI.BackgroundImage;
                    DrawImageBackground(i, pi.SI, g, rect);
                }

                if (pi is PageText)
                {
                    // TODO: enable can shrink, can grow
                    // 2005 spec file, page 9, in the text box has
                    // CanGrow and CanShrink
                    PageText pt = pi as PageText;
                    DrawString(pt, g, rect);
                }
                else if (pi is PageImage)
                {
                    PageImage i = pi as PageImage;
                    DrawImage(i, g, rect);
                }
                else if (pi is PageRectangle)
                {
                    this.DrawBackground(g, rect, pi.SI);
                }
                else if (pi is PageEllipse)
                {
                    PageEllipse pe = pi as PageEllipse;
                    DrawEllipse(pe, g, rect);
                }
                else if (pi is PagePie)
                {
                    PagePie pp = pi as PagePie;
                    DrawPie(pp, g, rect);
                }
                else if (pi is PagePolygon)
                {
                    PagePolygon ppo = pi as PagePolygon;
                    FillPolygon(ppo, g, rect);
                }
                else if (pi is PageCurve)
                {
                    PageCurve pc = pi as PageCurve;
                    DrawCurve(pc.SI.BColorLeft, pc.SI.BStyleLeft, pc.SI.BWidthLeft,
                              g, pc.Points, pc.Offset, pc.Tension);
                }


                DrawBorder(pi, g, rect);
            }

            // TO: convert System.Drawing.Graphics to Xwt.Drawing.Context and draw it to this.g

            Bitmap bm = new Bitmap(gImg.Width, gImg.Height);

            g.DrawImage(bm, gImg.Width, gImg.Height);


            // Xwt.Drawing.Image.FromStream does not work.  It crashes with both wpf and gtk
            // As a work around save the image to a temporary file and load it into xwt using the
            // FromFile method.

            System.IO.MemoryStream s = new System.IO.MemoryStream();
            gImg.Save(s, System.Drawing.Imaging.ImageFormat.Png);
            string fileName = System.IO.Path.GetTempFileName();

            gImg.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);

            // Xwt.Drawing.Image img = Xwt.Drawing.Image.FromStream(s);

            Xwt.Drawing.Image img = Xwt.Drawing.Image.FromFile(fileName);
            xwtContext.DrawImage(img, new Xwt.Rectangle(0, 0, gImg.Width, gImg.Height), new Xwt.Rectangle(0, 0, gImg.Width, gImg.Height));
            img.Dispose();
            System.IO.File.Delete(fileName);
        }