GetItemRect() public method

public GetItemRect ( int index ) : Rectangle
index int
return System.Drawing.Rectangle
示例#1
0
        /// <summary>
        /// Définit le texte du tooltip en fonction de la couleur de la ligne
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnMouseMoveColor(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            Point point = new Point(e.X, e.Y);

            for (int i = 0; i < listViewAffectedUsersWithProfile.Items.Count; i++)
            {
                if (listViewAffectedUsersWithProfile.GetItemRect(i).Contains(point))
                {
                    if (((AccountMgmt.DataAccess.OracleProfile)m_listOracleProfile.ListOracleProfile[i]).Color == "vert")
                    {
                        toolTipColor.SetToolTip(listViewAffectedUsersWithProfile, "MOU Profile Oracle déjà affecté + aucun autre MOU Profile Oracle possible différent de 'DEFAULT'");
                    }
                    if (((AccountMgmt.DataAccess.OracleProfile)m_listOracleProfile.ListOracleProfile[i]).Color == "jaune")
                    {
                        toolTipColor.SetToolTip(listViewAffectedUsersWithProfile, "MOU Profile Oracle déjà affecté + autre MOU Profile Oracle possible différent de 'DEFAULT'");
                    }
                    if (((AccountMgmt.DataAccess.OracleProfile)m_listOracleProfile.ListOracleProfile[i]).Color == "orange")
                    {
                        toolTipColor.SetToolTip(listViewAffectedUsersWithProfile, "MOU Profile Oracle pas affecté + aucun autre MOU Profile Oracle possible différent de 'DEFAULT'");
                    }
                    if (((AccountMgmt.DataAccess.OracleProfile)m_listOracleProfile.ListOracleProfile[i]).Color == "rouge")
                    {
                        toolTipColor.SetToolTip(listViewAffectedUsersWithProfile, "MOU Profile Oracle pas affecté + autre MOU Profile Oracle possible différent de 'DEFAULT'");
                    }

                    i = listViewAffectedUsersWithProfile.Items.Count;
                }
            }
        }
示例#2
0
		public void GetItemRectTest ()
		{
			ListView mylistview = new ListView ();
			mylistview.Items.Add ("Item 1");
			mylistview.Items.Add ("Item 2");
			Rectangle r = mylistview.GetItemRect (1);
			Assert.AreEqual (0, r.Top, "#35a");
			Assert.IsTrue (r.Bottom > 0, "#35b");
			Assert.IsTrue (r.Right > 0, "#35c");
			Assert.IsTrue (r.Left > 0, "#35d");
			Assert.IsTrue (r.Height > 0, "#35e");
			Assert.IsTrue (r.Width > 0, "#35f");
		}
        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( );
        }