本文整理汇总了C#中System.Windows.Forms.ListView.PointToClient方法的典型用法代码示例。如果您正苦于以下问题:C# ListView.PointToClient方法的具体用法?C# ListView.PointToClient怎么用?C# ListView.PointToClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ListView
的用法示例。
在下文中一共展示了ListView.PointToClient方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getItemUnderMouse
/// <summary>
/// Returns the item in the given ListView under the cursor.
/// </summary>
private ListViewItem getItemUnderMouse( ListView list, int x, int y )
{
// Get the coordinates relative to the control.
Point localPoint = list.PointToClient( new Point( x, y ) );
return list.GetItemAt( localPoint.X, localPoint.Y );
}
示例2: BeginDrag
public void BeginDrag( ListView curListView, Point curPos, ListView targetListView )
{
if( Region != null )
Region.Dispose( );
if( BackgroundImage != null )
BackgroundImage.Dispose( );
DragListViewRect = CalculateApproximateRect( curListView );
DragListView = curListView;
DropListView = targetListView;
Size = new Size( DragListViewRect.Width, DragListViewRect.Height );
Opacity = 0.5;
DragOffset = DragListView.PointToClient( curPos );
DragOffset.X *= -1;
DragOffset.Y *= -1;
DragOffset.Offset( DragListViewRect.X, DragListViewRect.Y ); // リストビューの隠れている箇所のぶんのオフセット
Location = new Point(
curPos.X + DragOffset.X,
curPos.Y + DragOffset.Y
);
IntPtr coord = Api.SendMessage( DragListView.Handle, (uint)LVM.GETITEMSPACING, 0, 0 );
int horizontal = (int)Api.LOWORD( coord );
int vertical = (int)Api.HIWORD( coord );
Rectangle padding = new Rectangle(
( horizontal - DragListView.LargeImageList.ImageSize.Width ) / 2,
0, //( vertical - DragListView.LargeImageList.ImageSize.Height ) / 2,
( horizontal - DragListView.LargeImageList.ImageSize.Width ),
0 //( vertical - DragListView.LargeImageList.ImageSize.Height )
);
// 上に切れたアイテムをドラッグすると透明が描画されない
BackgroundImage = new Bitmap( Size.Width, Size.Height );
GraphicsPath path = new GraphicsPath( );
using( Graphics gfx = Graphics.FromImage( BackgroundImage ) )
{
var brush = new SolidBrush(DragListView.ForeColor);
foreach( int index in DragListView.SelectedIndices )
{
var rcIcon = DragListView.GetItemRect( index, ItemBoundsPortion.Entire );
rcIcon.Offset( -DragListViewRect.X, -DragListViewRect.Y );
rcIcon.Offset( padding.X, padding.Y );
rcIcon.Width -= padding.Width;
rcIcon.Height -= padding.Height;
gfx.DrawImage( DragListView.LargeImageList.Images[ index ], rcIcon.Left, rcIcon.Top );
var rcText = DragListView.GetItemRect( index, ItemBoundsPortion.Label );
rcText.Offset( -DragListViewRect.X, -DragListViewRect.Y );
rcText.Offset( 0 /*padding.X*/, padding.Y );
rcText.Width -= padding.Width;
rcText.Height -= padding.Height;
gfx.DrawString(
DragListView.Items[ index ].Text,
DragListView.Font, brush,
rcText.Left, rcText.Top
);
path.AddRectangle( rcIcon );
//path.AddRectangle( rcText );
}
}
Region = new Region( path );
Show( );
}
示例3: GetListViewItemAt
private ListViewItem GetListViewItemAt(ListView listView, Point pos)
{
// Returns the location of the mouse pointer in the ListView control.
Point cp = listView.PointToClient(pos);
// Obtain the item that is located at the specified location of the mouse pointer.
return listView.GetItemAt(cp.X, cp.Y);
}