OnCacheVirtualItems() protected méthode

protected OnCacheVirtualItems ( CacheVirtualItemsEventArgs e ) : void
e CacheVirtualItemsEventArgs
Résultat void
Exemple #1
0
		// Drawing
		public override void DrawListViewItems (Graphics dc, Rectangle clip, ListView control)
		{
			bool details = control.View == View.Details;
			int first = control.FirstVisibleIndex;	
			int lastvisibleindex = control.LastVisibleIndex;

#if NET_2_0
			if (control.VirtualMode)
				control.OnCacheVirtualItems (new CacheVirtualItemsEventArgs (first, lastvisibleindex));
#endif

			for (int i = first; i <= lastvisibleindex; i++) {					
				ListViewItem item = control.GetItemAtDisplayIndex (i);
				if (clip.IntersectsWith (item.Bounds)) {
#if NET_2_0
					bool owner_draw = false;
					if (control.OwnerDraw)
						owner_draw = DrawListViewItemOwnerDraw (dc, item, i);
					if (!owner_draw)
#endif
					{
						DrawListViewItem (dc, control, item);
						if (control.View == View.Details)
							DrawListViewSubItems (dc, control, item);
					}
				}
			}	

#if NET_2_0
			if (control.UsingGroups) {
				// Use InternalCount instead of Count to take into account Default Group as needed
				for (int i = 0; i < control.Groups.InternalCount; i++) {
					ListViewGroup group = control.Groups.GetInternalGroup (i);
					if (group.ItemCount > 0 && clip.IntersectsWith (group.HeaderBounds))
						DrawListViewGroupHeader (dc, control, group);
				}
			}

			ListViewInsertionMark insertion_mark = control.InsertionMark;
			int insertion_mark_index = insertion_mark.Index;
			if (Application.VisualStylesEnabled && insertion_mark.Bounds != Rectangle.Empty &&
					(control.View != View.Details && control.View != View.List) &&
					insertion_mark_index > -1 && insertion_mark_index < control.Items.Count) {

				Brush brush = ResPool.GetSolidBrush (insertion_mark.Color);
				dc.FillRectangle (brush, insertion_mark.Line);
				dc.FillPolygon (brush, insertion_mark.TopTriangle);
				dc.FillPolygon (brush, insertion_mark.BottomTriangle);
			}
#endif
			
			// draw the gridlines
#if NET_2_0
			if (details && control.GridLines && !control.UsingGroups) {
#else
			if (details && control.GridLines) {
#endif
				Size control_size = control.ClientSize;
				int top = (control.HeaderStyle == ColumnHeaderStyle.None) ?
					0 : control.header_control.Height;

				// draw vertical gridlines
				foreach (ColumnHeader col in control.Columns) {
					int column_right = col.Rect.Right - control.h_marker;
					dc.DrawLine (SystemPens.Control,
						     column_right, top,
						     column_right, control_size.Height);
				}

				// draw horizontal gridlines
				int item_height = control.ItemSize.Height;
				if (item_height == 0)
					item_height =  control.Font.Height + 2;

				int y = top + item_height - (control.v_marker % item_height); // scroll bar offset
				while (y < control_size.Height) {
					dc.DrawLine (SystemPens.Control, 0, y, control_size.Width, y);
					y += item_height;
				}
			}			
			
			// Draw corner between the two scrollbars
			if (control.h_scroll.Visible == true && control.v_scroll.Visible == true) {
				Rectangle rect = new Rectangle ();
				rect.X = control.h_scroll.Location.X + control.h_scroll.Width;
				rect.Width = control.v_scroll.Width;
				rect.Y = control.v_scroll.Location.Y + control.v_scroll.Height;
				rect.Height = control.h_scroll.Height;
				dc.FillRectangle (SystemBrushes.Control, rect);
			}

			Rectangle box_select_rect = control.item_control.BoxSelectRectangle;
			if (!box_select_rect.Size.IsEmpty)
				dc.DrawRectangle (ResPool.GetDashPen (ColorControlText, DashStyle.Dot), box_select_rect);

		}