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


C# ListViewItem.GetBounds方法代码示例

本文整理汇总了C#中System.Windows.Forms.ListViewItem.GetBounds方法的典型用法代码示例。如果您正苦于以下问题:C# ListViewItem.GetBounds方法的具体用法?C# ListViewItem.GetBounds怎么用?C# ListViewItem.GetBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.ListViewItem的用法示例。


在下文中一共展示了ListViewItem.GetBounds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetSubItemBounds

		protected Rectangle GetSubItemBounds(ListViewItem Item, int SubItem)
		{
			Rectangle subItemRect = Rectangle.Empty;

			if (Item == null)
				throw new ArgumentNullException("Item");

			int[] order = GetColumnOrder();
			if (order == null) // No Columns
				return subItemRect;

			if (SubItem >= order.Length)
				throw new IndexOutOfRangeException("SubItem "+SubItem+" out of range");

			// Retrieve the bounds of the entire ListViewItem (all subitems)
			Rectangle lviBounds = Item.GetBounds(ItemBoundsPortion.Entire);
			int	subItemX = lviBounds.Left;

			// Calculate the X position of the SubItem.
			// Because the columns can be reordered we have to use Columns[order[i]] instead of Columns[i] !
			ColumnHeader col;
			int i;
			for (i=0; i<order.Length; i++)
			{
				col = this.Columns[order[i]];
				if (col.Index == SubItem)
					break;
				subItemX += col.Width;
			}
 
			subItemRect	= new Rectangle(subItemX, lviBounds.Top, this.Columns[order[i]].Width, lviBounds.Height);

			return subItemRect;
		}
开发者ID:CaineQT,项目名称:hookme,代码行数:34,代码来源:ListViewEx.cs

示例2: GetSubItemBounds

        public Rectangle GetSubItemBounds(ListViewItem lvi, int subItemIndex)
        {
            Rectangle lviBounds = lvi.GetBounds(ItemBoundsPortion.Entire);

            int subItemX = lviBounds.Left;

            for (int i = 0; i < GetNameColumnIndex(); i++)
                subItemX += this.listView.Columns[i].Width;

            Rectangle rect = new Rectangle();
            rect.Y = lviBounds.Top;
            rect.X = subItemX + lvi.GetBounds(ItemBoundsPortion.Icon).Width + 4;	// magic number for making the textbox appear just to the right of the icon

            rect.Size = new Size(GetSelectedItemNameTextWidth(), lvi.GetBounds(ItemBoundsPortion.Entire).Height);

            return rect;
        }
开发者ID:almx,项目名称:ExRep,代码行数:17,代码来源:ExRepListViewControl_SubItemTextEditing.cs

示例3: GetIconsSpacerBounds

		private static Rectangle GetIconsSpacerBounds(ListViewItem item)
		{
			if (item == null)
				return Rectangle.Empty;
			var xPosition = item.Bounds.X;
			for (var i = 1; i < item.SubItems.Count; i++)
			{
				var iPos = item.SubItems[i].Bounds.X + item.SubItems[i].Bounds.Width;
				if (item.Position.X > iPos && xPosition < iPos)
					xPosition = iPos;
			}
			var iconBounds = item.GetBounds(ItemBoundsPortion.Icon);
			var labelBounds = item.GetBounds(ItemBoundsPortion.Label);
			var width = iconBounds.X - xPosition + iconBounds.Width + (labelBounds.Width < 0 ? labelBounds.Width : 0);
			return new Rectangle(xPosition, item.Bounds.Y, width, item.Bounds.Height);
		}
开发者ID:TargetProcess,项目名称:Tp.Integration.Ide.VisualStudio,代码行数:16,代码来源:ListViewEx.cs

示例4: GetSubItemBounds

        /// <summary>
        /// Get bounds for a SubItem
        /// </summary>
        /// <param name="Item">Target ListViewItem</param>
        /// <param name="SubItem">Target SubItem index</param>
        /// <returns>Bounds of SubItem (relative to ListView)</returns>
        public Rectangle GetSubItemBounds(ListViewItem Item, int SubItem)
        {
            int[] order = GetColumnOrder();

            Rectangle subItemRect = Rectangle.Empty;
            if (SubItem >= order.Length)
                throw new IndexOutOfRangeException("SubItem " + SubItem + " out of range");

            if (Item == null)
                throw new ArgumentNullException("Item");

            Rectangle lviBounds = Item.GetBounds(ItemBoundsPortion.Entire);
            int subItemX = lviBounds.Left;

            ColumnHeader col;
            int i;
            for (i = 0; i < order.Length; i++)
            {
                col = this.Columns[order[i]];
                if (col.Index == SubItem)
                    break;
                subItemX += col.Width;
            }
            subItemRect = new Rectangle(subItemX, lviBounds.Top, this.Columns[order[i]].Width, lviBounds.Height);
            return subItemRect;
        }
开发者ID:xescrp,项目名称:breinstormin,代码行数:32,代码来源:ListViewEx.cs

示例5: GetSubItemAt

        /// <summary>
        /// Find ListViewItem and SubItem Index at position (x,y)
        /// </summary>
        /// <param name="x">relative to ListView</param>
        /// <param name="y">relative to ListView</param>
        /// <param name="item">Item at position (x,y)</param>
        /// <returns>SubItem index</returns>
        public int GetSubItemAt(int x, int y, out ListViewItem item)
        {
            item = GetItemAt(x, y);

            if (item != null)
            {
                int[] order = GetColumnOrder();

                Rectangle lviBounds = item.GetBounds(ItemBoundsPortion.Entire);
                int subItemX = lviBounds.Left;
                foreach (int t in order)
                {
                    ColumnHeader h = Columns[t];
                    if (x < subItemX + h.Width)
                    {
                        return h.Index;
                    }
                    subItemX += h.Width;
                }
            }

            return -1;
        }
开发者ID:Maximus325,项目名称:ShareX,代码行数:30,代码来源:ListViewEx.cs

示例6: BeginEdit

			internal void BeginEdit (ListViewItem item)
			{
				if (edit_item != null)
					EndEdit (edit_item);
				
				if (edit_text_box == null) {
					edit_text_box = new ListViewLabelEditTextBox ();
					edit_text_box.BorderStyle = BorderStyle.FixedSingle;
					edit_text_box.EditingCancelled += new EventHandler (LabelEditCancelled);
					edit_text_box.EditingFinished += new EventHandler (LabelEditFinished);
					edit_text_box.TextChanged += new EventHandler (LabelTextChanged);
					edit_text_box.Visible = false;
					Controls.Add (edit_text_box);
				}
				
				item.EnsureVisible();
				
				edit_text_box.Reset ();
				
				switch (owner.view) {
					case View.List:
					case View.SmallIcon:
					case View.Details:
						edit_text_box.TextAlign = HorizontalAlignment.Left;
						edit_text_box.Bounds = item.GetBounds (ItemBoundsPortion.Label);
						SizeF sizef = TextRenderer.MeasureString (item.Text, item.Font);
						edit_text_box.Width = (int)sizef.Width + 4;
						edit_text_box.MaxWidth = owner.ClientRectangle.Width - edit_text_box.Bounds.X;
						edit_text_box.WordWrap = false;
						edit_text_box.Multiline = false;
						break;
					case View.LargeIcon:
						edit_text_box.TextAlign = HorizontalAlignment.Center;
						edit_text_box.Bounds = item.GetBounds (ItemBoundsPortion.Label);
						sizef = TextRenderer.MeasureString (item.Text, item.Font);
						edit_text_box.Width = (int)sizef.Width + 4;
						edit_text_box.MaxWidth = item.GetBounds(ItemBoundsPortion.Entire).Width;
						edit_text_box.MaxHeight = owner.ClientRectangle.Height - edit_text_box.Bounds.Y;
						edit_text_box.WordWrap = true;
						edit_text_box.Multiline = true;
						break;
				}

				edit_item = item;

				edit_text_box.Text = item.Text;
				edit_text_box.Font = item.Font;
				edit_text_box.Visible = true;
				edit_text_box.Focus ();
				edit_text_box.SelectAll ();

				edit_args = new LabelEditEventArgs (owner.Items.IndexOf (edit_item));
				owner.OnBeforeLabelEdit (edit_args);

				if (edit_args.CancelEdit)
					EndEdit (item);
			}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:57,代码来源:ListView.cs

示例7: DrawListViewSubItems

		protected virtual void DrawListViewSubItems (Graphics dc, ListView control, ListViewItem item)
		{
			int columns_count = control.Columns.Count;
			int count = Math.Min (item.SubItems.Count, columns_count);
			// 0th item already done (in this case)
			for (int i = 1; i < count; i++)
				DrawListViewSubItem (dc, control, item, i);

			// Fill in selection for remaining columns if Column.Count > SubItems.Count
			Rectangle sub_item_rect = item.GetBounds (ItemBoundsPortion.Label);
			if (item.Selected && (control.Focused || !control.HideSelection) && control.FullRowSelect) {
				for (int index = count; index < columns_count; index++) {
					ColumnHeader col = control.Columns [index];
					sub_item_rect.X = col.Rect.X - control.h_marker;
					sub_item_rect.Width = col.Wd;
					dc.FillRectangle (control.Focused ? SystemBrushes.Highlight : SystemBrushes.Control, 
							sub_item_rect);
				}
			}
		}
开发者ID:ngraziano,项目名称:mono,代码行数:20,代码来源:ThemeWin32Classic.cs

示例8: GetSubItemBounds

        public Rectangle GetSubItemBounds(ListViewItem item, int subItem)
        {
            int[] order = GetColumnOrder();

            if (subItem >= order.Length) {
                throw new IndexOutOfRangeException("SubItem '" + subItem + "' is out of range.");
            }

            if (item == null) {
                throw new ArgumentNullException("item");
            }

            Rectangle itemBounds = item.GetBounds(ItemBoundsPortion.Entire);

            int subItemX = itemBounds.Left;
            for (int i = 0; i < order.Length; i++) {
                ColumnHeader col = Columns[order[i]];
                if (col.Index == subItem) {
                    return new Rectangle(subItemX, itemBounds.Top, col.Width, itemBounds.Height);
                }
                subItemX += col.Width;
            }

            return Rectangle.Empty;
        }
开发者ID:JuliaABurch,项目名称:Treefrog,代码行数:25,代码来源:EditableListView.cs

示例9: GetSubItemAt

 public int GetSubItemAt(int x, int y, out ListViewItem item)
 {
     item = base.GetItemAt(x, y);
     if (item != null)
     {
         int[] columnOrder = this.GetColumnOrder();
         int left = item.GetBounds(ItemBoundsPortion.Entire).Left;
         for (int i = 0; i < columnOrder.Length; i++)
         {
             ColumnHeader header = base.Columns[columnOrder[i]];
             if (x < (left + header.Width))
             {
                 return header.Index;
             }
             left += header.Width;
         }
     }
     return -1;
 }
开发者ID:christoyer,项目名称:SuiteCRM-Outlook-Plugin,代码行数:19,代码来源:ListViewEx.cs

示例10: HitImageTestAt

            private bool HitImageTestAt(Point p, ListViewItem item)
            {
                Rectangle rcItem = item.GetBounds(ItemBoundsPortion.Entire);
                GraphicsUnit units = GraphicsUnit.Point;
                if (item.ImageList != null)
                {
                    Image img = item.ImageList.Images[0];
                    RectangleF rcImageF = img.GetBounds(ref units);
                    Rectangle rcImage = Rectangle.Round(rcImageF);

                    rcImage.Width += item.IndentCount + item.Position.X;
                    p.Offset(rcItem.Left, -rcItem.Top);

                    if (rcImage.Contains(p))
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
                return false;
            }
开发者ID:unforgiven512,项目名称:kpenhancedlistview,代码行数:24,代码来源:InlineEditing.cs

示例11: DrawListViewItem

		// draws the ListViewItem of the given index
		protected override void DrawListViewItem( Graphics dc, ListView control, ListViewItem item ) {				
			Rectangle rect_checkrect = item.CheckRectReal;
			Rectangle rect_iconrect = item.GetBounds( ItemBoundsPortion.Icon );
			Rectangle full_rect = item.GetBounds( ItemBoundsPortion.Entire );
			Rectangle text_rect = item.GetBounds( ItemBoundsPortion.Label );			
			
			if ( control.CheckBoxes ) {
				if ( control.StateImageList == null ) {
					// Make sure we've got at least a line width of 1
					int check_wd = Math.Max( 3, rect_checkrect.Width / 6 );
					int scale = Math.Max( 1, rect_checkrect.Width / 12 );
					
					// set the checkbox background
					dc.FillRectangle( this.ResPool.GetSolidBrush( this.ColorWindow ),
							 rect_checkrect );
					// define a rectangle inside the border area
					Rectangle rect = new Rectangle( rect_checkrect.X + 2,
								       rect_checkrect.Y + 2,
								       rect_checkrect.Width - 4,
								       rect_checkrect.Height - 4 );
					Pen pen = new Pen( this.ColorWindowText, 2 );
					dc.DrawRectangle( pen, rect );
					
					// Need to draw a check-mark
					if ( item.Checked ) {
						pen.Width = 1;
						// adjustments to get the check-mark at the right place
						rect.X ++; rect.Y ++;
						// following logic is taken from DrawFrameControl method
						for ( int i = 0; i < check_wd; i++ ) {
							dc.DrawLine( pen, rect.Left + check_wd / 2,
								    rect.Top + check_wd + i,
								    rect.Left + check_wd / 2 + 2 * scale,
								    rect.Top + check_wd + 2 * scale + i );
							dc.DrawLine( pen,
								    rect.Left + check_wd / 2 + 2 * scale,
								    rect.Top + check_wd + 2 * scale + i,
								    rect.Left + check_wd / 2 + 6 * scale,
								    rect.Top + check_wd - 2 * scale + i );
						}
					}
				} else {
					if ( item.Checked && control.StateImageList.Images.Count > 1 )
						control.StateImageList.Draw( dc,
									    rect_checkrect.Location, 1 );
					else if ( ! item.Checked && control.StateImageList.Images.Count > 0 )
						control.StateImageList.Draw( dc,
									    rect_checkrect.Location, 0 );
				}
			}
			
			// Item is drawn as a special case, as it is not just text
			if ( control.View == View.LargeIcon ) {
				if ( item.ImageIndex > -1 &&
				    control.LargeImageList != null &&
				    item.ImageIndex < control.LargeImageList.Images.Count ) {
					// center image
					Point image_location = rect_iconrect.Location;
					Image image = control.LargeImageList.Images[ item.ImageIndex ];
					if ( image.Width < rect_iconrect.Width ) {
						int icon_rect_middle = rect_iconrect.Width / 2;
						int image_middle = image.Width / 2;
						image_location.X = image_location.X + icon_rect_middle - image_middle;
					}
					control.LargeImageList.Draw( dc, image_location,
								    item.ImageIndex );
				}
			} else {
				if ( item.ImageIndex > -1 &&
				    control.SmallImageList != null &&
				    item.ImageIndex < control.SmallImageList.Images.Count )
					control.SmallImageList.Draw( dc, rect_iconrect.Location,
								    item.ImageIndex );
			}
			
			// draw the item text			
			// format for the item text
			StringFormat format = new StringFormat( );
			format.LineAlignment = StringAlignment.Center;
			if ( control.View == View.LargeIcon )
				format.Alignment = StringAlignment.Center; 
			else
				format.Alignment = StringAlignment.Near;
			
			if ( !control.LabelWrap )
				format.FormatFlags = StringFormatFlags.NoWrap;
			
			if ( item.Selected ) {
				if ( control.View == View.Details ) {
					if ( control.FullRowSelect ) {
						// fill the entire rect excluding the checkbox						
						full_rect.Location = item.GetBounds (ItemBoundsPortion.Label).Location;
						dc.FillRectangle( this.ResPool.GetSolidBrush
								 ( this.ColorHighlight ), full_rect );
					} else {
						Size text_size = Size.Ceiling( dc.MeasureString( item.Text,
												item.Font ) );
						text_rect.Width = text_size.Width;
						dc.FillRectangle( this.ResPool.GetSolidBrush
//.........这里部分代码省略.........
开发者ID:stabbylambda,项目名称:mono,代码行数:101,代码来源:ThemeClearlooks.cs

示例12: GetSubItemBounds

        /// <summary>
        /// Retrieve the bounds of a ListViewSubItem
        /// </summary>
        /// <param name="item">The Item containing the SubItem</param>
        /// <param name="subItemIndex">Index of the SubItem</param>
        /// <returns>Subitem's bounds</returns>
        protected Rectangle GetSubItemBounds(ListViewItem item, int subItemIndex)
        {
            Rectangle subItemRect = Rectangle.Empty;

            if (item == null)
            {
                throw new ArgumentNullException("Item", "The list view item cannot be null");
            }

            int[] listColumns = GetCurrentColumnOrder();

            if (listColumns != null)
            {
                if (subItemIndex >= listColumns.Length)
                {
                    throw new IndexOutOfRangeException("Index " + subItemIndex + " is out of range of the columns in the listview");
                }

                // Retrieve the bounds of the entire ListViewItem (all subitems)
                Rectangle itemBounds = item.GetBounds(ItemBoundsPortion.Entire);

                // Calculate the X position of the SubItem.
                // Because the columns may be reordered we have
                //to use Columns[listColumns[index]] instead of Columns[index]
                int subItemX = itemBounds.Left;
                int index = 0;

                for (; index < listColumns.Length; index++)
                {
                    ColumnHeader column = this.Columns[listColumns[index]];

                    if (column.Index == subItemIndex)
                    {
                        break;
                    }

                    subItemX += column.Width;
                }

                subItemRect = new Rectangle(subItemX, itemBounds.Top, this.Columns[listColumns[index]].Width, itemBounds.Height);
            }

            return subItemRect;
        }
开发者ID:tuvoksg1,项目名称:Coding-Challenge,代码行数:50,代码来源:IrisListView.cs

示例13: GetSubItemBounds

    /// <summary>Calculates the boundaries of a cell in the list view</summary>
    /// <param name="item">Item in the list view from which to calculate the cell</param>
    /// <param name="subItem">Index der cell whose boundaries to calculate</param>
    /// <returns>The boundaries of the specified list view cell</returns>
    /// <exception cref="IndexOutOfRangeException">
    ///   When the specified sub item index is not in the range of valid sub items
    /// </exception>
    protected Rectangle GetSubItemBounds(ListViewItem item, int subItem) {
      int[] order = GetColumnOrder();
      if(order == null) // No Columns
        return Rectangle.Empty;

      if(subItem >= order.Length)
        throw new IndexOutOfRangeException("SubItem " + subItem + " out of range");

      // Determine the border of the entire ListViewItem, including all sub items
      Rectangle itemBounds = item.GetBounds(ItemBoundsPortion.Entire);
      int subItemX = itemBounds.Left;

      // Find the horizontal position of the sub item. Because the column order can vary,
      // we need to use Columns[order[i]] instead of simply doing Columns[i] here!
      ColumnHeader columnHeader;
      int i;
      for(i = 0; i < order.Length; ++i) {
        columnHeader = this.Columns[order[i]];
        if(columnHeader.Index == subItem)
          break;

        subItemX += columnHeader.Width;
      }

      return new Rectangle(
        subItemX, itemBounds.Top, this.Columns[order[i]].Width, itemBounds.Height
      );
    }
开发者ID:pr0gramm3r1,项目名称:AngryTanks,代码行数:35,代码来源:ContainerListView.cs

示例14: DrawListViewItem

        private void DrawListViewItem(Graphics g, ListViewItem item, ColumnHeader header, Font font, Color color, ListViewItemStates state)
        {
            bool hasImage = HasImage(item);
            // Draw Image if any
            if (hasImage && (header == null || header.Width > 4))
            {
                Rectangle rImage = item.GetBounds(ItemBoundsPortion.Icon);
                int index = item.ImageIndex;
                if (index < 0)
                    index = item.ImageList.Images.IndexOfKey(item.ImageKey);
                if (this.View != View.Details && this.View != View.List && this.StateImageList != null)
                    rImage.X += this.StateImageList.ImageSize.Width + 3;
                else if (this.View == View.SmallIcon && this.CheckBoxes && this.Groups.Count == 0)
                    rImage.X += this.SmallImageList.ImageSize.Width;
                else if (this.View == View.LargeIcon && (item.ImageList.ImageSize.Width < rImage.Width || item.ImageList.ImageSize.Height < rImage.Height))
                {
                    if (item.ImageList.ImageSize.Width < rImage.Width)
                        rImage.X += (rImage.Width - item.ImageList.ImageSize.Width) / 2;
                    if (item.ImageList.ImageSize.Height < rImage.Height)
                        rImage.Y += (rImage.Height - item.ImageList.ImageSize.Height) / 2;
                }

                Region oldClip = null;
                if (header != null && header.Width < rImage.Width)
                {
                    Rectangle rClip = rImage;
                    rClip.Width = header.Width;
                    oldClip = g.Clip;
                    g.SetClip(rClip);
                }
                if (rImage.Width > 2)
                {
                    g.DrawImage(item.ImageList.Images[index], rImage.Location); // item.ImageList.Draw(g, rImage.Location, index);
                }

                if (oldClip != null) g.Clip = oldClip;
            }

            // Draw text
            Rectangle rText = item.GetBounds(ItemBoundsPortion.Label);
            if (rText.Width > 2)
            {
                // Draw the item text for views other than the Details view.
                eTextFormat flags = eTextFormat.Left | eTextFormat.SingleLine | eTextFormat.NoPrefix;
                if (this.View == View.Tile && item.SubItems.Count > 1)
                    flags |= eTextFormat.Top;
                else
                    flags |= eTextFormat.VerticalCenter;
                if (this.View == View.LargeIcon)
                {
                    flags = eTextFormat.HorizontalCenter | eTextFormat.WordBreak | eTextFormat.EndEllipsis | eTextFormat.NoClipping;
                }
                else if (this.View == View.Details && header != null)
                {
                    flags |= eTextFormat.EndEllipsis;
                    if (header.TextAlign == HorizontalAlignment.Center)
                        flags |= eTextFormat.HorizontalCenter;
                    else if (header.TextAlign == HorizontalAlignment.Right)
                        flags |= eTextFormat.Right;

                    rText.X += 2;
                }
                else if (this.View == View.List || this.View == View.SmallIcon)
                    rText.X += 2;
                if (!BarFunctions.IsVista) rText.Inflate(0, 1);
                TextDrawing.DrawString(g, item.Text, font, color, rText, flags);

                if (this.View == View.Tile && item.SubItems.Count > 1)
                {
                    Size sz = TextDrawing.MeasureString(g, item.Text, font);
                    rText.Y += sz.Height;
                    rText.Height -= sz.Height;
                    Color c1 = item.SubItems[1].ForeColor;
                    if (!c1.IsEmpty && c1 != color)
                        color = c1;
                    else
                        color = SystemColors.ControlDarkDark;
                    TextDrawing.DrawString(g, item.SubItems[1].Text, font, color, rText, flags);
                }
            }

            if (this.View == View.Details || this.StateImageList != null)
            {
                if (this.StateImageList != null)
                {
                    if (item.StateImageIndex >= 0 && item.StateImageIndex < this.StateImageList.Images.Count)
                    {
                        Rectangle r = item.GetBounds(ItemBoundsPortion.Icon);
                        if (this.View == View.Details || this.View == View.List)
                            r.X -= 19;
                        else if (this.View == View.LargeIcon && r.Width > this.StateImageList.ImageSize.Width)
                        {
                            r.X += (r.Width - this.StateImageList.ImageSize.Width) / 2;
                            r.Y++;
                        }
                        else if (this.View == View.Tile && r.Height > this.StateImageList.ImageSize.Height)
                        {
                            r.Y += (r.Height - this.StateImageList.ImageSize.Height) / 2;
                            r.X++;
                        }
//.........这里部分代码省略.........
开发者ID:huamanhtuyen,项目名称:VNACCS,代码行数:101,代码来源:ListViewEx.cs

示例15: DrawItemBackground

        private void DrawItemBackground(Graphics g, Rectangle r, ListViewItem item, ListViewItemStates state)
        {
            if (!this.Enabled) return;
            // Bug fix in ListView for this specific state
            if (state == 0 && item.Selected && this.View == View.Details && this.FullRowSelect && this.Focused)
                r.X++;

            if (!item.BackColor.IsEmpty)
            {
                using (SolidBrush brush = new SolidBrush(item.BackColor))
                {
                    g.FillRectangle(brush, r);
                }
            }
            bool selected = IsInState(state, ListViewItemStates.Selected) || state == 0 && item.Selected;
            if (selected)
            {
                Office2007ListViewColorTable ct = GetColorTable();
                // Draw the background for selected item.
                r.Height--;
                r.Width--;
                using (Pen pen = new Pen(ct.SelectionBorder))
                    g.DrawRectangle(pen, r);
                r.Height++;
                r.Width++;
                Rectangle ir = new Rectangle(r.X, r.Y + 1, r.Width, r.Height - 2);
                DisplayHelp.FillRectangle(g, ir, ct.SelectionBackground);
            }
            else if (IsInState(state, ListViewItemStates.Hot) && this.HotTracking)
            {
                Office2007Renderer rnd = this.GetRenderer() as Office2007Renderer;
                Office2007ButtonItemPainter.PaintBackground(g, rnd.ColorTable.ButtonItemColors[0].MouseOver, r, RoundRectangleShapeDescriptor.RectangleShape);
            }

            if (IsInState(state, ListViewItemStates.Focused) && (!IsInState(state, ListViewItemStates.Hot) && this.View != View.LargeIcon || selected))
            {
                Rectangle rFocus = item.Bounds;
                if (this.View == View.Details && !this.FullRowSelect || this.View == View.List)
                    rFocus = item.GetBounds(ItemBoundsPortion.Label);
                else if (this.View == View.Details && this.FullRowSelect)
                    rFocus = r;
                else if (this.View == View.SmallIcon)
                    rFocus = r;

                if (selected)
                {
                    rFocus.Y++;
                    rFocus.Height -= 2;
                }

                DrawFocusRectangle(g, rFocus, item);
            }
            else if (selected && this.View == View.Details && this.FullRowSelect && this.Focused) // Bug fix in ListView for this specific state
            {
                Rectangle rFocus = r;
                rFocus.Y++;
                rFocus.Height -= 2;
                Region oldClip = g.Clip;
                Rectangle rClip = rFocus;
                rClip.Width--;
                g.SetClip(rClip);
                DrawFocusRectangle(g, rFocus, item);
                g.Clip = oldClip;
            }
        }
开发者ID:huamanhtuyen,项目名称:VNACCS,代码行数:65,代码来源:ListViewEx.cs


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