当前位置: 首页>>代码示例>>C#>>正文


C# ListView.PointToClient方法代码示例

本文整理汇总了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 );
        }
开发者ID:phillco,项目名称:LANdrop,代码行数:10,代码来源:MainForm.cs

示例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( );
        }
开发者ID:sato1043,项目名称:SAITextureChanger,代码行数:77,代码来源:DragImagesForm.cs

示例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);
        }
开发者ID:timmersuk,项目名称:KSP-Mod-Admin-aOS,代码行数:8,代码来源:frmColumnSelection.cs


注:本文中的System.Windows.Forms.ListView.PointToClient方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。