GdPicture.NET Reference Guide
GetRectCoordinatesOnViewerPixel Method
Example 





GdPicture14.WPF Namespace > GdViewer Class : GetRectCoordinatesOnViewerPixel Method
Output parameter. The horizontal (X) coordinate (0-based) of the top left point, in pixels, of the rectangle of selection, related to the viewer area.
Output parameter. The vertical (Y) coordinate (0-based) of the top left point, in pixels, of the rectangle of selection, related to the viewer area.
Output parameter. The width, in pixels, of the rectangle of selection.
Output parameter. The height, in pixels, of the rectangle of selection.
Gets data of the currently defined rectangle of area selection refering to the displayed viewer area. This method gets the rectangle's coordinates and dimensions, in pixels, which determine the rectangle of selection related to the document displayed in the GdViewer control. The resulting values correspond to the actual viewer area.

Be aware that the rectangle of selection always relates to the displayed document. You can find out, if this rectangle is defined and drawn, using the IsRect method.

Syntax
'Declaration
 
Public Sub GetRectCoordinatesOnViewerPixel( _
   ByRef Left As Double, _
   ByRef Top As Double, _
   ByRef Width As Double, _
   ByRef Height As Double _
) 
public void GetRectCoordinatesOnViewerPixel( 
   ref double Left,
   ref double Top,
   ref double Width,
   ref double Height
)
public procedure GetRectCoordinatesOnViewerPixel( 
   var  Left: Double;
   var  Top: Double;
   var  Width: Double;
   var  Height: Double
); 
public function GetRectCoordinatesOnViewerPixel( 
   Left : double,
   Top : double,
   Width : double,
   Height : double
);
public: void GetRectCoordinatesOnViewerPixel( 
   ref double Left,
   ref double Top,
   ref double Width,
   ref double Height
) 
public:
void GetRectCoordinatesOnViewerPixel( 
   double% Left,
   double% Top,
   double% Width,
   double% Height
) 

Parameters

Left
Output parameter. The horizontal (X) coordinate (0-based) of the top left point, in pixels, of the rectangle of selection, related to the viewer area.
Top
Output parameter. The vertical (Y) coordinate (0-based) of the top left point, in pixels, of the rectangle of selection, related to the viewer area.
Width
Output parameter. The width, in pixels, of the rectangle of selection.
Height
Output parameter. The height, in pixels, of the rectangle of selection.
Remarks
Be aware that you are allowed to define only one rectangle of selection within the current viewer. Likewise, this rectangle always relates to the currently displayed document, meaning that without displaying some document you cannot get valid rectangle's data.

Just to remind you, that all coordinates are 0-based with the origin being in the top left corner in the viewer area.

Example
How to translate the rectangle's coordinates related to the document to the coordinates related to the viewer.
'We assume that the GdViewer1 control has been properly integrated
'and your document has been properly displayed as well.
Dim left1 As Double = 0, top1 As Double = 0, width1 As Double = 0, height1 As Double = 0
Dim left2 As Double = 0, top2 As Double = 0, width2 As Double = 0, height2 As Double = 0
GdViewer1.RectBorderColor = Color.FromArgb(255, 255, 69, 0)
GdViewer1.RectBorderSize = 2
GdViewer1.GetDisplayedArea(left1, top1, width1, height1)
GdViewer1.SetRectCoordinatesOnDocumentPixel(left1, top1, width1, height1)
GdViewer1.GetRectCoordinatesOnViewerPixel(left2, top2, width2, height2)
MessageBox.Show("The displayed area of the document: " + left1 + ", " + top1 + " w=" + width1 + ", h=" + height1 + vbCrLf +
                "The rectangle of selection (viewer-related): " + left2 + ", " + top2 + " w=" + width2 + ", h=" + height2, "GdViewer.GetRectCoordinatesOnViewerPixel")
//We assume that the GdViewer1 control has been properly integrated
//and your document has been properly displayed as well.
double left1 = 0, top1 = 0, width1 = 0, height1 = 0;
double left2 = 0, top2 = 0, width2 = 0, height2 = 0;
            
GdViewer1.RectBorderColor = Color.FromArgb(255, 255, 69, 0);
GdViewer1.RectBorderSize = 2;
GdViewer1.GetDisplayedArea(ref left1, ref top1, ref width1, ref height1);
GdViewer1.SetRectCoordinatesOnDocumentPixel(left1, top1, width1, height1);
GdViewer1.GetRectCoordinatesOnViewerPixel(ref left2, ref top2, ref width2, ref height2);
MessageBox.Show("The displayed area of the document: " + left1 + ", " + top1 + " w=" + width1 + ", h=" + height1 +
                "\nThe rectangle of selection (viewer-related): " + left2 + ", " + top2 + " w=" + width2 + ", h=" + height2, "GdViewer.GetRectCoordinatesOnViewerPixel");
See Also

Reference

GdViewer Class
GdViewer Members
SetRectCoordinatesOnDocumentInch Method
GetRectCoordinatesOnDocumentPixel Method
SetRectCoordinatesOnViewerPixel Method
IsRect Method
ClearRect Method
CenterOnRect Method
RectBorderSize Property