Contains(X: Integer, Y: Integer): Boolean;
Contains(X: integer, Y: integer): boolean;
X. The X coordinate of the point.
Y. The Y coordinate of the point.
The Contains method checks if the integer rectangle contains the point.
Available method values:
True. If the point with X and Y coordinates is contained in integer rectangle.
False. If point with X and Y coordinates is not contained in integer rectangle.
Executing the example requires:
A form with a button with the Button1 identifier, the TabSheetBox and UiTabSheet components with the TabSheetBox1 and UiTabSheet1 corresponding identifiers. For TabSheetBox select a component with the UiTabSheet1 identifier in the Source (UiSourse for Fore.NET) property.
Bitmap file C:\1.bmp.
Add links to the Drawing, Forms, MathFin, Report, Tab, UI system assemblies.
The example is a handler of the OnClick event for the Button1 component.
Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
Obj: ITabObject;
Tab: ITabSheet;
Rect: IGxRect;
X, Y: Integer;
Begin
// Create a new rectangle with specified sizes
Rect := New GxRect.Create(0, 0, 50, 45);
Tab := UiTabSheet1.TabSheet;
// Add an image to the created rectangle
Obj := Tab.Objects.Add("PrxPicture", Rect.ToRectF);
(Obj As IPrxPicture).Image := GxImage.FromFile("c:\1.bmp");
// Set point with random coordinates
X := Math.RandBetweenI(0, 70);
Y := Math.RandBetweenI(0, 70);
// Check that point enters to the rectangle
If Rect.Contains(X, Y) Then
WinApplication.InformationBox("Yes");
Else
WinApplication.InformationBox("No");
End If;
End Sub Button1OnClick;
Imports Prognoz.Platform.Interop.Drawing;
Imports Prognoz.Platform.Interop.MathFin;
Imports Prognoz.Platform.Interop.Forms;
Imports Prognoz.Platform.Interop.Report;
Imports Prognoz.Platform.Interop.Tab;
Imports Prognoz.Platform.Interop.Ui;
…
Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Var
Obj: ITabObject;
Tab: ITabSheet;
Rect: GxRect = New GxRectClass();
S: string;
X, Y: integer;
Math: MathClass = New MathClass();
Image: GxImageClass_2 = New GxImageClass_2();
WinAppCls: WinApplicationClass = New WinApplicationClassClass();
Begin
// Create a new rectangle with specified sizes
Rect.Create(0, 0, 50, 45);
Tab := UiTabSheetNet1.TabSheetUi.TabSheet;
// Add an image to the created rectangle
Obj := Tab.Objects.Add("PrxPicture", Rect.ToRectF());
Image.CreateFromFile("c:\1.bmp");
(Obj As IPrxPicture).Image := Image;
// Set point with random coordinates
X := Math.RandBetweenI(0, 70);
Y := Math.RandBetweenI(0, 70);
// Check that point enters to the rectangle
If Rect.Contains(X, Y) Then
WinAppCls.InformationBox("Yes", New IWin32WindowForeAdapter(Self));
Else
WinAppCls.InformationBox("No", New IWin32WindowForeAdapter(Self));
End If;
End Sub;
After executing the example clicking the Button1 button creates an image in the regular report. The image source is the 1.bmp file. The information window contains Yes if the point with the random coordinates is included to the rectangle that bounds the image.
See also: