Queries the specified location to determine if the point is over a RasterImageListItem.
public RasterImageListItem HitTest(int x,int y)
Public Function HitTest( _ByVal x As Integer, _ByVal y As Integer _) As Leadtools.Winforms.RasterImageListItem
public:Leadtools.Winforms.RasterImageListItem^ HitTest(int x,int y)
x
The horizontal position of the coordinate in client coordinates.
y
The vertical position of the coordinate in client coordinates.
An RasterImageListItem object under the given location, or null (Nothing in VB) if no RasterImageListItem is under the location.
This example will create and populate a RasterImageList control, and then performs hittesting when the user right clicks on the control and shows the item information.
using Leadtools.WinForms;using Leadtools;using Leadtools.Codecs;using Leadtools.Drawing;class MyForm4 : Form{RasterImageList imageList;RasterCodecs codecs;public MyForm4(string title){Text = title;// Set the size of the formSize = new Size(400, 200);// Create a new RasterImageList controlimageList = new RasterImageList();imageList.Dock = DockStyle.Fill;imageList.SelectionMode = RasterImageListSelectionMode.Single;imageList.Size = Size;Controls.Add(imageList);imageList.BringToFront();codecs = new RasterCodecs();// Create three itemsstring imagesPath = LEAD_VARS.ImagesDir;for (int i = 0; i < 3; i++){// Load the imageint index = i + 1;string imageFileName = Path.Combine(imagesPath, @"ImageProcessingDemo\Image" + index.ToString() + ".cmp");RasterImage image = codecs.Load(imageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1);RasterImageListItem item = new RasterImageListItem(image, 1, "Item" + index.ToString());// Select the first itemif (i == 0)item.Selected = true;// Add the item to the image listimageList.Items.Add(item);}// Add a handler to the MouseDown eventimageList.MouseDown += new MouseEventHandler(rasterImageList_MouseDown);// Add the RasterImageList to the control collection.Controls.Add(imageList);}private void rasterImageList_MouseDown(object sender, MouseEventArgs e){// Check for right button clicksif (e.Button == MouseButtons.Right){// Check if any item is under the cursor poisitionRasterImageList imageList = sender as RasterImageList;RasterImageListItem item = imageList.HitTest(e.X, e.Y);if (item != null){// Yes, show the item text in a message boxMessageBox.Show(this, item.Text);}}}}public void RasterImageList_HitTest(string title){MyForm4 form = new MyForm4(title);form.ShowDialog();}static class LEAD_VARS{public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";}
Imports Leadtools.WinFormsImports LeadtoolsImports Leadtools.CodecsImports Leadtools.DrawingPrivate Class MyForm4 : Inherits FormPrivate imageList As RasterImageListPrivate codecs As RasterCodecsPublic Sub New(ByVal title As String)Text = title' Set the size of the formSize = New Size(400, 200)' Create a new RasterImageList controlimageList = New RasterImageList()imageList.Dock = DockStyle.FillimageList.SelectionMode = RasterImageListSelectionMode.SingleimageList.Size = SizeControls.Add(imageList)imageList.BringToFront()codecs = New RasterCodecs()' Create three itemsDim imagesPath As String = LEAD_VARS.ImagesDirFor i As Integer = 0 To 2' Load the imageDim index As Integer = i + 1Dim imageFileName As String = Path.Combine(imagesPath, "ImageProcessingDemo\Image" & index.ToString() & ".cmp")Dim image As RasterImage = codecs.Load(imageFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1)Dim item As RasterImageListItem = New RasterImageListItem(image, 1, "Item" & index.ToString())' Select the first itemIf i = 0 Thenitem.Selected = TrueEnd If' Add the item to the image listimageList.Items.Add(item)Next i' Add a handler to the MouseDown eventAddHandler imageList.MouseDown, AddressOf rasterImageList_MouseDown' Add the RasterImageList to the control collection.Controls.Add(imageList)End SubPrivate Sub rasterImageList_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs)' Check for right button clicksIf e.Button = Windows.Forms.MouseButtons.Right Then' Check if any item is under the cursor poisitionDim imageList As RasterImageList = CType(IIf(TypeOf sender Is RasterImageList, sender, Nothing), RasterImageList)Dim item As RasterImageListItem = imageList.HitTest(e.X, e.Y)If Not item Is Nothing Then' Yes, show the item text in a message boxMessageBox.Show(Me, item.Text)End IfEnd IfEnd SubEnd ClassPublic Sub RasterImageList_HitTest(ByVal title As String)Dim form As MyForm4 = New MyForm4(title)form.ShowDialog()End SubPublic NotInheritable Class LEAD_VARSPublic Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"End Class
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
