private void FindPageNo() { int pageNo = PreviewPages.FindPage(Offset.Y) + 1; if (!PreviewPages.IsSameRow(pageNo - 1, PageNo - 1)) { SetPageNo(pageNo, false); } }
protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (Disabled) { return; } int pageNo = PreviewPages.FindPage(Offset.X + e.X, Offset.Y + e.Y); ReportPage page = PreparedPages.GetCachedPage(pageNo); Rectangle pageBounds = PreviewPages.GetPageBounds(pageNo); SetPageNo(pageNo + 1, false); Cursor = curHandMove; FLastMousePoint = e.Location; // reset page's NeedRefresh flag page.NeedRefresh = false; page.NeedModify = false; // generate mousedown event if (FActiveObject != null) { FActiveObject.OnMouseDown(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)); } // reset search highlight if (SearchInfo != null && SearchInfo.Visible) { SearchInfo.Visible = false; Refresh(); } // modify and refresh the page if requested in the object's script if (page.NeedModify) { PreparedPages.ModifyPage(pageNo, page); } if (page.NeedRefresh) { Refresh(); } }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); if (Disabled) { return; } Cursor = curHand; // find object under mouse to invoke its PreviewClick event int pageNo = PreviewPages.FindPage(Offset.X + e.X, Offset.Y + e.Y); ReportPage page = PreparedPages.GetCachedPage(pageNo); Rectangle pageBounds = PreviewPages.GetPageBounds(pageNo); // reset NeedRefresh flag page.NeedRefresh = false; page.NeedModify = false; Report.NeedRefresh = false; // generate mouseup event if (FActiveObject != null) { FActiveObject.OnMouseUp(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)); Hyperlink hyperlink = FActiveObject.Hyperlink; switch (hyperlink.Kind) { case HyperlinkKind.URL: try { Process.Start(hyperlink.Value); } catch { } break; case HyperlinkKind.PageNumber: PageNo = int.Parse(hyperlink.Value); break; case HyperlinkKind.Bookmark: Bookmarks.BookmarkItem bookmark = PreparedPages.Bookmarks.Find(hyperlink.Value); if (bookmark != null) { PositionTo(bookmark.PageNo + 1, new PointF(0, bookmark.OffsetY)); } break; case HyperlinkKind.DetailReport: // if detail report name is empty, refresh this report if (String.IsNullOrEmpty(hyperlink.DetailReportName)) { hyperlink.SetParameters(Report); Report.NeedRefresh = true; } else { // open a new report. check if such tab is opened already if (!Preview.SwitchToTab(hyperlink.Value)) { FLocked = true; try { using (Report report = hyperlink.GetReport(true)) { report.Prepare(); Preview.AddPreviewTab(report.PreparedPages, hyperlink.Value); report.SetPreparedPages(null); } } finally { FLocked = false; } } } break; case HyperlinkKind.DetailPage: ReportPage reportPage = Report.FindObject(hyperlink.DetailPageName) as ReportPage; if (reportPage != null) { hyperlink.SetParameters(Report); // check if such tab is opened already if (!Preview.SwitchToTab(hyperlink.Value)) { FLocked = true; Preview.Lock(); PreparedPages pages = new PreparedPages(Report); try { Report.SetPreparedPages(pages); Report.PreparePage(reportPage); } finally { FLocked = false; Preview.Unlock(); Preview.AddPreviewTab(pages, hyperlink.Value); } } } break; } FActiveObject.OnClick(EventArgs.Empty); } // modify and refresh the page if requested in the object's script if (page.NeedModify) { PreparedPages.ModifyPage(pageNo, page); } if (page.NeedRefresh) { Refresh(); } if (Report.NeedRefresh) { bool saveShowProgress = Config.ReportSettings.ShowProgress; Config.ReportSettings.ShowProgress = false; RefreshReport(); Config.ReportSettings.ShowProgress = saveShowProgress; } }
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(); } }