Example #1
0
        override protected void OnMouseDown(MouseEventArgs mea)
        {
            base.OnMouseDown(mea);                              // allow base to process first

            HitListEntry hle = this.GetHitListEntry(mea);

            SetHitListCursor(hle);                              // set the cursor based on the hit list entry

            if (mea.Button != MouseButtons.Left || hle == null)
            {
                return;
            }

            if (hle.pi.HyperLink != null)
            {
                try
                {
                    System.Diagnostics.Process.Start(hle.pi.HyperLink);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format("Unable to link to {0}{1}{2}",
                                                  hle.pi.HyperLink, Environment.NewLine, ex.Message), "HyperLink Error");
                }
            }
        }
Example #2
0
        override protected void OnMouseMove(MouseEventArgs mea)
        {
            Cursor c = Cursors.Default;

            HitListEntry hle = this.GetHitListEntry(mea);

            SetHitListCursor(hle);
            SetHitListTooltip(hle);
            return;
        }
Example #3
0
 private void SetHitListTooltip(HitListEntry hle)
 {
     if (hle == null || hle.pi.Tooltip == null)
     {
         _tt.Active = false;
     }
     else
     {
         _tt.SetToolTip(this, hle.pi.Tooltip);
         _tt.Active = true;
     }
 }
Example #4
0
        private void SetHitListCursor(HitListEntry hle)
        {
            Cursor c = Cursors.Default;

            if (hle == null)
            {
            }
            else if (hle.pi.HyperLink != null || hle.pi.BookmarkLink != null)
            {
                c = Cursors.Hand;
            }

            if (Cursor.Current != c)
            {
                Cursor.Current = c;
            }
        }
Example #5
0
        override protected void OnMouseDown(MouseEventArgs mea)
        {
            base.OnMouseDown(mea);                              // allow base to process first
            _MousePosition = new Point(mea.X, mea.Y);

            if (MouseDownRubberBand(mea))
            {
                return;
            }

            HitListEntry hle = this.GetHitListEntry(mea);

            SetHitListCursor(hle);                              // set the cursor based on the hit list entry

            if (mea.Button != MouseButtons.Left || hle == null)
            {
                return;
            }

            if (hle.pi.HyperLink != null)
            {
                RdlViewer rv      = this.Parent as RdlViewer;
                bool      bInvoke = true;
                if (rv != null)
                {
                    HyperlinkEventArgs hlea = new HyperlinkEventArgs(hle.pi.HyperLink);
                    rv.InvokeHyperlink(hlea);     // reset any mousemove
                    bInvoke = !hlea.Cancel;
                }
                try
                {
                    if (bInvoke)
                    {
                        System.Diagnostics.Process.Start(hle.pi.HyperLink);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format("Unable to link to {0}{1}{2}",
                                                  hle.pi.HyperLink, Environment.NewLine, ex.Message), "HyperLink Error");
                }
            }
        }
        private void SetItemsHitArea()
        {
            float XAdditional = GetLeftAreaPosition();
            float YAdditional = rep_padding;

            hitList.Clear();
            foreach (PageItem pi in pages)
            {
                if (pi is PageTextHtml)                     // PageTextHtml is actually a composite object (just like a page)
                {
                    Rectangle hr = new Rectangle(PixelsX(pi.X * scale) + XAdditional, PixelsY(pi.Y * scale) + YAdditional,
                                                 PixelsX(pi.W * scale), PixelsY(pi.H * scale));
                    hitList.Add(new HitListEntry(hr, pi));
                    continue;
                }

                Rectangle rect = new Rectangle(PixelsX(pi.X * scale) + XAdditional, PixelsY(pi.Y * scale) + YAdditional,
                                               PixelsX(pi.W * scale), PixelsY(pi.H * scale));

                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, XAdditional, YAdditional, this);
                    }
                    else
                    {
                        hle = new HitListEntry(rect, pi);
                    }
                    hitList.Add(hle);
                }
            }
        }
Example #7
0
 private void SetHitListTooltip(HitListEntry hle)
 {
     if (hle == null || hle.pi.Tooltip == null)
         _tt.Active = false;
     else
     {
         _tt.SetToolTip(this, hle.pi.Tooltip);
         _tt.Active = true;
     }
 }
Example #8
0
        private void SetHitListCursor(HitListEntry hle)
        {
            Cursor c = Cursors.Default;
            if (hle == null)
            { }
            else if (hle.pi.HyperLink != null || hle.pi.BookmarkLink != null)
                c = Cursors.Hand;

            if (this.Cursor != c)
                this.Cursor = c;
        }
Example #9
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);
            }
        }
Example #11
0
        override protected void OnMouseMove(MouseEventArgs mea)
        {
            if (SelectTool)
            {   // When selection we skip other cursor processing
                if (this.Cursor != Cursors.Cross)
                {
                    this.Cursor = Cursors.Cross;
                }

                if (!_bHaveMouse)
                {
                    return;
                }

                Point newMousePosition = new Point(mea.X, mea.Y);

                // we're rubber banding
                // If we drew previously; we'll draw again to remove old rectangle
                if (this._ptRBLast.X != -1)
                {
                    this.RubberBand(this._ptRBOriginal, _ptRBLast);
                }
                _MousePosition = newMousePosition;
                // Update last point;  but don't rubber band outside our client area
                if (newMousePosition.X < 0)
                {
                    newMousePosition.X = 0;
                }
                if (newMousePosition.X > this.Width)
                {
                    newMousePosition.X = this.Width;
                }
                if (newMousePosition.Y < 0)
                {
                    newMousePosition.Y = 0;
                }
                if (newMousePosition.Y > this.Height)
                {
                    newMousePosition.Y = this.Height;
                }
                _ptRBLast = newMousePosition;
                if (_ptRBLast.X < 0)
                {
                    _ptRBLast.X = 0;
                }
                if (_ptRBLast.Y < 0)
                {
                    _ptRBLast.Y = 0;
                }
                // Draw new lines.
                this.RubberBand(_ptRBOriginal, newMousePosition);
                this.Cursor = Cursors.Cross;            // use cross hair to indicate drawing
                return;
            }

            HitListEntry hle = this.GetHitListEntry(mea);

            SetHitListCursor(hle);
            SetHitListTooltip(hle);
            return;
        }