예제 #1
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            if (Disabled)
            {
                return;
            }

            // find an object under mouse
            int                 pageNo     = PreviewPages.FindPage(Offset.X + e.X, Offset.Y + e.Y);
            ReportPage          page       = PreparedPages.GetCachedPage(pageNo);
            Rectangle           pageBounds = PreviewPages.GetPageBounds(pageNo);
            ReportComponentBase obj        = page.HitTest(new PointF((Offset.X + e.X - pageBounds.X) / Zoom,
                                                                     (Offset.Y + e.Y - pageBounds.Y) / Zoom));

            // reset page's NeedRefresh flag
            page.NeedRefresh = false;

            // generate mouse enter, mouseleave events
            if (obj != FActiveObject)
            {
                if (FActiveObject != null)
                {
                    FActiveObject.OnMouseLeave(EventArgs.Empty);
                }
                if (obj != null)
                {
                    obj.OnMouseEnter(EventArgs.Empty);
                }
            }
            FActiveObject = obj;

            // generate mousemove event
            if (FActiveObject != null)
            {
                FActiveObject.OnMouseMove(new MouseEventArgs(e.Button, e.Clicks,
                                                             (int)Math.Round((Offset.X + e.X - pageBounds.X) / Zoom - page.LeftMargin * Units.Millimeters - FActiveObject.AbsLeft),
                                                             (int)Math.Round((Offset.Y + e.Y - pageBounds.Y) / Zoom - page.TopMargin * Units.Millimeters - FActiveObject.AbsTop),
                                                             e.Delta));
            }

            string url    = "";
            Cursor cursor = Cursors.Default;

            if (obj != null)
            {
                cursor = obj.Cursor;
                url    = obj.Hyperlink.Value;
            }
            Cursor = cursor == Cursors.Default ? (e.Button == MouseButtons.Left ? curHandMove : curHand) : cursor;
            Preview.UpdateUrl(url);

            if (e.Button == MouseButtons.Left)
            {
                Offset          = new Point(Offset.X - (e.X - FLastMousePoint.X), Offset.Y - (e.Y - FLastMousePoint.Y));
                FLastMousePoint = e.Location;
            }

            // refresh page if requested in the object's script
            if (page.NeedRefresh)
            {
                Refresh();
            }
        }