Hi Hristo,
Thank you for reply me back. I'm using GetLocationFromViewPoint method in MouseDown and MouseUp events to draw rectangles on a Pdf file. Then I'm saving those coordinates in a separate file. When I' m redrawing the rectangle again on the same Pdf it it not correctly drawing on the locations it draws earlier. I assume it is because of the gap between the RadPdfViewerElement and the RadFixedPageElement. I need to to get the extract position to draw the rectangle in correct position.
Here is my code I'm using to get the coordinates in MouseUp and MouseDown events.
private void radPdfVwr_MouseDown(object sender, MouseEventArgs e)
{
if ((radPdfVwr.ElementTree.GetElementAtPoint(((MouseEventArgs)e).Location)).GetType().Name == typeof(RadFixedPageElement).Name)
{
if (isMouseDwnClked == true)
return;
currentPos = startPos = e.Location;
drawing = true;
Point currentPos1 = new Point(e.X, e.Y);
currentPos1 = new Point(currentPos.X + this.radPdfVwr.PdfViewerElement.HScrollBar.Value, currentPos.Y + this.radPdfVwr.PdfViewerElement.VScrollBar.Value);
Graphics formGraphics = this.CreateGraphics();
Telerik.Windows.Pdf.Documents.Fixed.Model.RadFixedPage page;
this.radPdfVwr.PdfViewerElement.GetLocationFromViewPoint(currentPos1, out page, out down);
_top = Math.Round(((down.Y / formGraphics.DpiY) * 25.4), 2);
_left = Math.Round(((down.X / formGraphics.DpiX) * 25.4), 2);
}
}
private void radPdfVwr_MouseUp(object sender, MouseEventArgs e)
{
if ((radPdfVwr.ElementTree.GetElementAtPoint(((MouseEventArgs)e).Location)) != null)
{
if ((radPdfVwr.ElementTree.GetElementAtPoint(((MouseEventArgs)e).Location)).GetType().Name == typeof(RadFixedPageElement).Name)
{
if (isMouseUpClked == true && rectanglesList.Count > 0)
return;
if (drawing)
{
drawing = false;
var rc = GetRectangle();
if (rc.Width > 0 && rc.Height > 0)
rectanglesList.Add(rc);
radPdfVwr.Invalidate();
}
Point currentPos = new Point(e.X, e.Y);
currentPos = new Point(currentPos.X + this.radPdfVwr.PdfViewerElement.HScrollBar.Value, currentPos.Y + this.radPdfVwr.PdfViewerElement.VScrollBar.Value);
Graphics formGraphics = this.CreateGraphics();
Telerik.Windows.Pdf.Documents.Fixed.Model.RadFixedPage page;
Point pointLoc;
Point x;
this.radPdfVwr.PdfViewerElement.GetLocationFromViewPoint(currentPos, out page, out pointLoc);
_height = Math.Round((((pointLoc.Y - down.Y) / formGraphics.DpiY) * 25.4), 2);
_width = Math.Round((((pointLoc.X - down.X) / formGraphics.DpiX) * 25.4), 2);
}
}