GdPicture.NET.14
GdPicture14 Namespace / GdViewer Class / GetRectWidthOnViewer Method
Example





In This Topic
GetRectWidthOnViewer Method (GdViewer)
In This Topic
Returns the width, in pixels, of the rectangle of area selection, related to the document displayed in the GdViewer control. The resulting value corresponds to the viewer area. You can determine, if the rectangle of selection is currently defined and drawn within the control, using the IsRect method.
Syntax
'Declaration
 
Public Function GetRectWidthOnViewer() As Integer
public int GetRectWidthOnViewer()
public function GetRectWidthOnViewer(): Integer; 
public function GetRectWidthOnViewer() : int;
public: int GetRectWidthOnViewer(); 
public:
int GetRectWidthOnViewer(); 

Return Value

The width, in pixels, of the rectangle of area selection, related to the viewer area.
Remarks
Be aware that you are allowed to define only one rectangle of selection within the GdViewer control. 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 this value is related to the viewer area.

Example
How to compare the width of the rectangle of selection related to the document pages area with the width related to the viewer area.
'We assume that the GdViewer1 control has been properly integrated
'and your document has been properly displayed as well.
GdViewer1.RectBorderColor = GdViewer1.ARGB(255, 69, 0)
GdViewer1.RectBorderSize = 2
'You can change the zoom mode here.
GdViewer1.ZoomMode = GdPicture14.ViewerZoomMode.ZoomModeToViewer
'Setting the rectangle of selection.
Dim left As Integer = 0, top As Integer = 0, width As Integer = 0, height As Integer = 0
GdViewer1.GetDisplayedArea(left, top, width, height)
GdViewer1.SetRectCoordinatesOnDocument(left, top, width, height)
'Finding coordinates to compare.
Dim widthViewer As Integer = GdViewer1.GetRectWidthOnDocument()
Dim widthDoc As Integer = GdViewer1.GetRectWidthOnViewer()
MessageBox.Show("The width on the viewer is " + widthViewer + " pixels." + vbCrLf +
                "The width on the document's page is " + widthDoc + " pixels.", "GdViewer.GetRectWidthOnViewer")
//We assume that the GdViewer1 control has been properly integrated
//and your document has been properly displayed as well.
GdViewer1.RectBorderColor = GdViewer1.ARGB(255, 69, 0);
GdViewer1.RectBorderSize = 2;
//You can change the zoom mode here.
GdViewer1.ZoomMode = GdPicture14.ViewerZoomMode.ZoomModeToViewer;
//Setting the rectangle of selection.
int left = 0, top = 0, width = 0, height = 0;
GdViewer1.GetDisplayedArea(ref left, ref top, ref width, ref height);
GdViewer1.SetRectCoordinatesOnDocument(left, top, width, height);
//Finding coordinates to compare.
int widthViewer = GdViewer1.GetRectWidthOnDocument();
int widthDoc = GdViewer1.GetRectWidthOnViewer();
MessageBox.Show("The width on the viewer is " + widthViewer + " pixels.\nThe width on the document's page is " + widthDoc + " pixels.", "GdViewer.GetRectWidthOnViewer");
See Also