Пример #1
0
        private void DrawBorder(PageItem pi, Graphics g, RectangleF r)
        {
            if (r.Height <= 0 || r.Width <= 0)      // no bounding box to use
            {
                return;
            }

            StyleInfo si = pi.SI;

            DrawLine(si.BColorTop, si.BStyleTop, si.BWidthTop, g, r.X, r.Y, r.Right, r.Y);

            DrawLine(si.BColorRight, si.BStyleRight, si.BWidthRight, g, r.Right, r.Y, r.Right, r.Bottom);

            DrawLine(si.BColorLeft, si.BStyleLeft, si.BWidthLeft, g, r.X, r.Y, r.X, r.Bottom);

            DrawLine(si.BColorBottom, si.BStyleBottom, si.BWidthBottom, g, r.X, r.Bottom, r.Right, r.Bottom);

            return;
        }
Пример #2
0
        private void AddObjectInternal(PageItem pi)
        {
            pi.Page       = this;
            pi.ItemNumber = _items.Count;
            if (_items.Count == 0)
            {
                _lastZIndex = pi.ZIndex;
            }
            else if (_lastZIndex != pi.ZIndex)
            {
                _needSort = true;
            }

            // adjust the page item locations
            pi.X += _xOffset;
            pi.Y += _yOffset;
            if (pi is PageLine)
            {
                PageLine pl = pi as PageLine;
                pl.X2 += _xOffset;
                pl.Y2 += _yOffset;
            }
            else if (pi is PagePolygon)
            {
                PagePolygon pp = pi as PagePolygon;
                for (int i = 0; i < pp.Points.Length; i++)
                {
                    pp.Points[i].X += _xOffset;
                    pp.Points[i].Y += _yOffset;
                }
            }
            else if (pi is PageCurve)
            {
                PageCurve pc = pi as PageCurve;
                for (int i = 0; i < pc.Points.Length; i++)
                {
                    pc.Points[i].X += _xOffset;
                    pc.Points[i].Y += _yOffset;
                }
            }
        }
Пример #3
0
 internal HitListEntry(PagePolygon pp, float x, float y, PageDrawing pd)
 {
     pi = pp;
     poly = new PointF[pp.Points.Length];
     for (int i = 0; i < pp.Points.Length; i++)
     {
         poly[i].X = pd.PixelsX(pp.Points[i].X + x);
         poly[i].Y = pd.PixelsY(pp.Points[i].Y + y);
     }
     rect = RectangleF.Empty;
 }
Пример #4
0
 internal HitListEntry(RectangleF r, PageItem pitem)
 {
     rect = r;
     pi = pitem;
     poly = null;
 }
Пример #5
0
        public void FindNext()
        {
            if (_Viewer == null)
                throw new ApplicationException("Viewer property must be set prior to issuing FindNext.");

            if (tbFind.Text.Length == 0)    // must have something to find
                return;

            RdlViewerFinds findOptions =
                ckMatchCase.Checked ?
                RdlViewerFinds.MatchCase :
                RdlViewerFinds.None;

            bool begin = position == null;
            position = _Viewer.Find(tbFind.Text, position, findOptions);
            if (position == null)
            {
                if (!begin)     // if we didn't start from beginning already; try from beginning
                    position = _Viewer.Find(tbFind.Text, position, findOptions);

                lStatus.Text = position == null ?
                    "Phrase not found" : "Reached end of report, continued from top";

                _Viewer.HighlightPageItem = position;
                if (position != null)
                    _Viewer.ScrollToPageItem(position);
            }
            else
            {
                lStatus.Text = "";
                _Viewer.HighlightPageItem = position;
                _Viewer.ScrollToPageItem(position);
            }
        }
Пример #6
0
 private void tbFind_TextChanged(object sender, EventArgs e)
 {
     lStatus.Text = "";
     position = null;        // reset position when edit changes?? todo not really
     _Viewer.HighlightText = tbFind.Text;
     ckHighlightAll.Enabled = bFindNext.Enabled = bFindPrevious.Enabled =
             tbFind.Text.Length > 0;
     if (tbFind.Text.Length > 0)
         FindNext();
 }
Пример #7
0
 private void RdlViewerFind_VisibleChanged(object sender, EventArgs e)
 {
     lStatus.Text = "";
     if (this.Visible)
     {
         _Viewer.HighlightText = tbFind.Text;
         tbFind.Focus();
         FindNext();         // and go find the contents of the textbox
     }
     else
     {   // turn off any highlighting when find control not visible
         _Viewer.HighlightPageItem = position = null;
         _Viewer.HighlightText = null;
         _Viewer.HighlightAll = false;
         ckHighlightAll.Checked = false;
     }
 }
Пример #8
0
 public void AddObject(PageItem pi)
 {
     AddObjectInternal(pi);
     _items.Add(pi);
 }
Пример #9
0
        private static int ComparePageItemByPageXY(PageItem pi1, PageItem pi2)
        {
            if (pi1.Page.Count != pi2.Page.Count)
                return pi1.Page.Count - pi2.Page.Count;

            if (pi1.Y != pi2.Y)
            {
                return Convert.ToInt32((pi1.Y - pi2.Y) * 1000);
            }
            return Convert.ToInt32((pi1.X - pi2.X) * 1000);
        }
Пример #10
0
 public void AddObject(PageItem pi)
 {
     AddObjectInternal(pi);
     _items.Add(pi);
 }
Пример #11
0
        internal void SetPagePositionAndStyle(Report rpt, PageItem pi, Row row)
        {
            WorkClass wc = GetWC(rpt);
            pi.X = GetOffsetCalc(rpt) + LeftCalc(rpt);
            if (this._TC != null)
            {	// must be part of a table
                Table t = _TC.OwnerTable;
                int colindex = _TC.ColIndex;

                // Calculate width: add up all columns within the column span
                float width=0;
                TableColumn tc;
                for (int ci=colindex; ci < colindex + _TC.ColSpan; ci++)
                {
                    tc = (TableColumn) (t.TableColumns.Items[ci]);
                    width += tc.Width.Points;
                }
                pi.W = width;
                pi.Y = 0;

                TableRow tr = (TableRow) (_TC.Parent.Parent);
                pi.H = tr.HeightCalc(rpt);	// this is a cached item; note tr.HeightOfRow must already be called on row
            }
            else if (wc.MC != null)
            {	// must be part of a matrix
                pi.W = wc.MC.Width;
                pi.Y = 0;
                pi.H = wc.MC.Height;
            }
            else if (pi is PageLine)
            {   // don't really handle if line is part of table???  TODO
                PageLine pl = (PageLine) pi;
                if (Top != null)
                    pl.Y = this.Gap(rpt);		 //  y will get adjusted when pageitem added to page
                float y2 = pl.Y;
                if (Height != null)
                    y2 += Height.Points;
                pl.Y2 = y2;
                pl.X2 = pl.X;
                if (Width != null)
                    pl.X2 += Width.Points;
            }
            else
            {	// not part of a table or matrix
                if (Top != null)
                    pi.Y = this.Gap(rpt);		 //  y will get adjusted when pageitem added to page
                if (Height != null)
                    pi.H = Height.Points;
                else
                    pi.H = this.HeightOrOwnerHeight;
                if (Width != null)
                    pi.W = Width.Points;
                else
                    pi.W = this.WidthOrOwnerWidth(rpt);
            }
            if (Style != null)
                pi.SI = Style.GetStyleInfo(rpt, row);
            else
                pi.SI = new StyleInfo();	// this will just default everything

            pi.ZIndex = this.ZIndex;        // retain the zindex of the object

            // Catch any action needed
            if (this._Action != null)
            {
                pi.BookmarkLink = _Action.BookmarkLinkValue(rpt, row);
                pi.HyperLink = _Action.HyperLinkValue(rpt, row);
            }

            if (this._Bookmark != null)
                pi.Bookmark = _Bookmark.EvaluateString(rpt, row);

            if (this._ToolTip != null)
                pi.Tooltip = _ToolTip.EvaluateString(rpt, row);
        }
Пример #12
0
        public void ScrollToPageItem(PageItem pi)
        {
            LoadPageIfNeeded();
            if (_pgs == null || _pgs.PageCount <= 0)    // nothing to scroll to
                return;

            int sPage = 0;
            int sItem = 0;
            int itemVerticalOffset = 0;
            int itemHorzOffset = 0;
            int height = 0;
            int width = 0;
            if (pi != null)
            {
                sPage = pi.Page.PageNumber-1;
                sItem = pi.ItemNumber;
                RectangleF rect = new RectangleF(PixelsX(pi.X + _leftMargin),
                    PixelsY(pi.Y),
                    PixelsX(pi.W),
                    PixelsY(pi.H));
                itemVerticalOffset = (int) (rect.Top);
                itemHorzOffset = (int)rect.Left;
                width = (int)rect.Width;
                height = (int) (rect.Height);
            }

            // set the vertical scroll
            int scroll = (int)((double)_vScroll.Maximum * sPage / _pgs.PageCount) + itemVerticalOffset;

            // do we need to scroll vertically?
            if (!(_vScroll.Value <= scroll && _vScroll.Value + _DrawPanel.Height/this.Zoom >= scroll + height))
            {   // item isn't on visible part of window; force scroll
                _vScroll.Value = Math.Min(scroll, Math.Max(0,_vScroll.Maximum - _DrawPanel.Height));
                SetScrollControlsV();
                ScrollEventArgs sa = new ScrollEventArgs(ScrollEventType.ThumbPosition, _vScroll.Maximum + 1); // position is intentionally wrong
                VerticalScroll(_vScroll, sa);
            }

            // set the horizontal scroll
            scroll = itemHorzOffset;

            // do we need to scroll horizontally?
            if (!(_hScroll.Value <= scroll && _hScroll.Value + _DrawPanel.Width / this.Zoom >= scroll + width))
            {   // item isn't on visible part of window; force scroll
                _hScroll.Value = Math.Min(scroll, Math.Max(0, _hScroll.Maximum-_DrawPanel.Width));
                SetScrollControlsH();
                ScrollEventArgs sa = new ScrollEventArgs(ScrollEventType.ThumbPosition, _hScroll.Maximum + 1); // position is intentionally wrong
                HorizontalScroll(_hScroll, sa);
            }
        }
Пример #13
0
        /// <summary>
        /// Find locates the next string after the passed location.  Use ScrollToPageItem to then
        /// reposition the Viewer on that item
        /// </summary>
        /// <param name="search">Text to search for</param>
        /// <param name="position">PageItem after which to start search.  null starts at beginning</param>
        /// <param name="options">Multiple options can be or'ed together.</param>
        /// <returns>null if not found</returns>
        public PageItem Find(string search, PageItem position, RdlViewerFinds options)
        {
            LoadPageIfNeeded();

            if (_pgs == null || _pgs.Count == 0)       // no report nothing to find
                return null;

            // initialize the loop direction and starting point
            int increment;
            int sPage;
            int sItem;
            if (((options & RdlViewerFinds.Backward) == RdlViewerFinds.Backward))
            {   // set to backward direction
                increment = -1;                 // go backwards
                sPage = _pgs.PageCount - 1;     // start at last page
                sItem = _pgs[sPage].Count - 1;  // start at bottom of last page
            }
            else
            {   // set to forward direction
                increment = 1;
                sPage = 0;
                sItem = 0;
            }

            bool bFirst = true;
            if (position != null)
            {
                sPage = position.Page.PageNumber - 1;   // start on same page as current
                sItem = position.ItemNumber + increment;  //   but on the item after/before the current one
            }

            if (!((options & RdlViewerFinds.MatchCase) == RdlViewerFinds.MatchCase))
                search = search.ToLower();          // should use Culture!!! todo

            PageItem found = null;
            for (int pi = sPage; pi < _pgs.Count && found == null && pi >= 0; pi = pi + increment)
            {
                Page p = _pgs[pi];
                if (bFirst)         // The first time sItem is already set
                    bFirst = false;
                else
                {
                    if (increment < 0)  // we're going backwards?
                        sItem = p.Count - 1;    // yes, start at bottom of page
                    else
                        sItem = 0;              // no, start at top of page
                }
                for (int pii = sItem; pii < p.Count && found == null && pii >= 0; pii = pii + increment)
                {
                    PageText pt = p[pii] as PageText;
                    if (pt == null)
                        continue;

                    if ((options & RdlViewerFinds.MatchCase) == RdlViewerFinds.MatchCase)
                    {
                        if (pt.Text.Contains(search))
                            found = pt;
                    }
                    else
                    {
                        if (pt.Text.ToLower().Contains(search))
                            found = pt;
                    }
                }
            }

            return found;
        }
Пример #14
0
        internal void SetPagePositionAndStyle(Report rpt, PageItem pi, Row row)
        {
            WorkClass wc = GetWC(rpt);

            pi.X = GetOffsetCalc(rpt) + LeftCalc(rpt);
            if (this._TC != null)
            {                   // must be part of a table
                Table t        = _TC.OwnerTable;
                int   colindex = _TC.ColIndex;

                // Calculate width: add up all columns within the column span
                float       width = 0;
                TableColumn tc;
                for (int ci = colindex; ci < colindex + _TC.ColSpan; ci++)
                {
                    tc     = (TableColumn)(t.TableColumns.Items[ci]);
                    width += tc.Width.Points;
                }
                pi.W = width;
                pi.Y = 0;

                TableRow tr = (TableRow)(_TC.Parent.Parent);
                pi.H = tr.HeightCalc(rpt);                      // this is a cached item; note tr.HeightOfRow must already be called on row
            }
            else if (wc.MC != null)
            {                   // must be part of a matrix
                pi.W = wc.MC.Width;
                pi.Y = 0;
                pi.H = wc.MC.Height;
            }
            else if (pi is PageLine)
            {   // don't really handle if line is part of table???  TODO
                PageLine pl = (PageLine)pi;
                if (Top != null)
                {
                    pl.Y = this.Gap(rpt);                //  y will get adjusted when pageitem added to page
                }
                float y2 = pl.Y;
                if (Height != null)
                {
                    y2 += Height.Points;
                }
                pl.Y2 = y2;
                pl.X2 = pl.X;
                if (Width != null)
                {
                    pl.X2 += Width.Points;
                }
            }
            else
            {   // not part of a table or matrix
                if (Top != null)
                {
                    pi.Y = this.Gap(rpt);                //  y will get adjusted when pageitem added to page
                }
                if (Height != null)
                {
                    pi.H = Height.Points;
                }
                else
                {
                    pi.H = this.HeightOrOwnerHeight;
                }
                if (Width != null)
                {
                    pi.W = Width.Points;
                }
                else
                {
                    pi.W = this.WidthOrOwnerWidth(rpt);
                }
            }
            if (Style != null)
            {
                pi.SI = Style.GetStyleInfo(rpt, row);
            }
            else
            {
                pi.SI = new StyleInfo();    // this will just default everything
            }
            pi.ZIndex = this.ZIndex;        // retain the zindex of the object

            // Catch any action needed
            if (this._Action != null)
            {
                pi.BookmarkLink = _Action.BookmarkLinkValue(rpt, row);
                pi.HyperLink    = _Action.HyperLinkValue(rpt, row);
            }

            if (this._Bookmark != null)
            {
                pi.Bookmark = _Bookmark.EvaluateString(rpt, row);
            }

            if (this._ToolTip != null)
            {
                pi.Tooltip = _ToolTip.EvaluateString(rpt, row);
            }
        }
Пример #15
0
        /// <summary>
        /// Draw- simple draw of an entire page.  Useful when printing or creating an image.
        /// </summary>
        /// <param name="g"></param>
        /// <param name="page"></param>
        /// <param name="clipRectangle"></param>
        public void Draw(Graphics g, int page, System.Drawing.Rectangle clipRectangle, bool drawBackground, PointF pageOffset)
        {
            DpiX = g.DpiX;			 // this can change (e.g. printing graphics context)
            DpiY = g.DpiY;
            _HighlightText = null;
            _HighlightItem = null;
            _HighlightAll = false;
            _HighlightCaseSensitive = false;

            //			g.InterpolationMode = InterpolationMode.HighQualityBilinear;	// try to unfuzz charts
            g.PageUnit = GraphicsUnit.Pixel;
            g.ScaleTransform(1, 1);

            if (!pageOffset.IsEmpty)    // used when correcting for non-printable area on paper
            {
                g.TranslateTransform(pageOffset.X, pageOffset.Y);
            }

            _left = 0;
            _top = 0;
            _hScroll = 0;
            _vScroll = 0;

            RectangleF r = new RectangleF(clipRectangle.X, clipRectangle.Y,
                                            clipRectangle.Width, clipRectangle.Height);

            if (drawBackground)
                g.FillRectangle(Brushes.White, PixelsX(_left), PixelsY(_top),
                    PixelsX(_pgs.PageWidth), PixelsY(_pgs.PageHeight));

            ProcessPage(g, _pgs[page], r, false);
        }
Пример #16
0
 public void InsertObject(PageItem pi)
 {
     AddObjectInternal(pi);
     _items.Insert(0, pi);
 }
Пример #17
0
        /// <summary>
        /// Draw: accounting for scrolling and zoom factors
        /// </summary>
        /// <param name="g"></param>
        /// <param name="zoom"></param>
        /// <param name="leftOffset"></param>
        /// <param name="pageGap"></param>
        /// <param name="hScroll"></param>
        /// <param name="vScroll"></param>
        /// <param name="clipRectangle"></param>
        public void Draw(Graphics g, float zoom, float leftOffset, float pageGap,
            float hScroll, float vScroll,
            System.Drawing.Rectangle clipRectangle,
            PageItem highLightItem,
            string highLight, bool highLightCaseSensitive, bool highLightAll)
        {
            // init for mouse handling
            _HitList.Clear();			// remove all items from list
            _LastZoom = zoom;
            _HighlightItem = highLightItem;
            _HighlightText = highLight;
            _HighlightCaseSensitive = highLightCaseSensitive;
            _HighlightAll = highLightAll;

            if (_pgs == null)
            {	// No pages; means nothing to draw
                g.FillRectangle(Brushes.White, clipRectangle);
                return;
            }

            g.PageUnit = GraphicsUnit.Pixel;
            g.ScaleTransform(zoom, zoom);
            DpiX = g.DpiX;
            DpiY = g.DpiY;

            // Zoom affects how much will show on the screen.  Adjust our perceived clipping rectangle
            //  to account for it.
            RectangleF r;
            r = new RectangleF((clipRectangle.X) / zoom, (clipRectangle.Y) / zoom,
                (clipRectangle.Width) / zoom, (clipRectangle.Height) / zoom);

            // Calculate the top of the page
            int fpage = (int)(vScroll / (_pgs.PageHeight + pageGap));
            int lpage = (int)((vScroll + r.Height) / (_pgs.PageHeight + pageGap)) + 1;
            if (fpage >= _pgs.PageCount)
                return;
            if (lpage >= _pgs.PageCount)
                lpage = _pgs.PageCount - 1;

            _hScroll = hScroll;
            _left = leftOffset;
            _top = pageGap;
            // Loop thru the visible pages
            for (int p = fpage; p <= lpage; p++)
            {
                _vScroll = vScroll - p * (_pgs.PageHeight + pageGap);

                System.Drawing.Rectangle pr =
                    new System.Drawing.Rectangle((int)PixelsX(_left - _hScroll), (int)PixelsY(_top - _vScroll),
                                                    (int)PixelsX(_pgs.PageWidth), (int)PixelsY(_pgs.PageHeight));
                g.FillRectangle(Brushes.White, pr);

                ProcessPage(g, _pgs[p], r, true);

                // Draw the page outline
                using (Pen pn = new Pen(Brushes.Black, 1))
                {
                    int z3 = Math.Min((int)(3f / zoom), 3);
                    if (z3 <= 0)
                        z3 = 1;
                    int z4 = Math.Min((int)(4f / zoom), 4);
                    if (z4 <= 0)
                        z4 = 1;
                    g.DrawRectangle(pn, pr);					// outline of page
                    g.FillRectangle(Brushes.Black,
                        pr.X + pr.Width, pr.Y + z3, z3, pr.Height);		// right side of page
                    g.FillRectangle(Brushes.Black,
                        pr.X + z3, pr.Y + pr.Height, pr.Width, z4);		// bottom of page
                }
            }
        }
Пример #18
0
        private void AddObjectInternal(PageItem pi)
        {
            pi.Page = this;
            pi.ItemNumber = _items.Count;
            if (_items.Count == 0)
                _lastZIndex = pi.ZIndex;
            else if (_lastZIndex != pi.ZIndex)
                _needSort = true;

            // adjust the page item locations
            pi.X += _xOffset;
            pi.Y += _yOffset;
            if (pi is PageLine)
            {
                PageLine pl = pi as PageLine;
                pl.X2 += _xOffset;
                pl.Y2 += _yOffset;
            }
            else if (pi is PagePolygon)
            {
                PagePolygon pp = pi as PagePolygon;
                for (int i = 0; i < pp.Points.Length; i++ )
                {
                    pp.Points[i].X += _xOffset;
                    pp.Points[i].Y += _yOffset;
                }
            }
            else if (pi is PageCurve)
            {
                PageCurve pc = pi as PageCurve;
                for (int i = 0; i < pc.Points.Length; i++)
                {
                    pc.Points[i].X += _xOffset;
                    pc.Points[i].Y += _yOffset;
                }
            }
        }
Пример #19
0
        private void DrawBorder(PageItem pi, Graphics g, RectangleF r)
        {
            if (pi.GetType().Name.Equals("PagePie")) return;
            if (r.Height <= 0 || r.Width <= 0)		// no bounding box to use
                return;

            StyleInfo si = pi.SI;

            DrawLine(si.BColorTop, si.BStyleTop, si.BWidthTop, g, r.X, r.Y, r.Right, r.Y);

            DrawLine(si.BColorRight, si.BStyleRight, si.BWidthRight, g, r.Right, r.Y, r.Right, r.Bottom);

            DrawLine(si.BColorLeft, si.BStyleLeft, si.BWidthLeft, g, r.X, r.Y, r.X, r.Bottom);

            DrawLine(si.BColorBottom, si.BStyleBottom, si.BWidthBottom, g, r.X, r.Bottom, r.Right, r.Bottom);

            return;
        }
Пример #20
0
 public void InsertObject(PageItem pi)
 {
     AddObjectInternal(pi);
     _items.Insert(0, pi);
 }