[ToolboxItem(false)]
[DesignTimeVisible(false)]
[DefaultProperty("Header")]
+ [TypeConverter (typeof (ListViewGroupConverter))]
public sealed class ListViewGroup : ISerializable
{
- private string header = string.Empty;
+ internal string header = string.Empty;
private string name = null;
private HorizontalAlignment header_alignment = HorizontalAlignment.Left;
private ListView list_view_owner = null;
private ListView.ListViewItemCollection items = null;
private object tag = null;
- private Point location = Point.Empty;
+ private Rectangle header_bounds = Rectangle.Empty;
+ internal int starting_row; // At which row the group starts
+ internal int rows;
+ internal int current_item; // Current item when doing layout
+ internal Point items_area_location;
+ bool is_default_group;
+ int item_count; // Used by default group to store item count
#region ListViewGroup constructors
public ListView.ListViewItemCollection Items {
get {
if (items == null)
- items = new ListView.ListViewItemCollection(list_view_owner);
+ items = new ListView.ListViewItemCollection (list_view_owner, this);
return items;
}
internal ListView ListViewOwner {
get { return list_view_owner; }
- set { list_view_owner = value; }
+ set {
+ list_view_owner = value;
+ if (!is_default_group)
+ items.Owner = value;
+ }
+ }
+
+ internal Rectangle HeaderBounds {
+ get {
+ Rectangle retval = header_bounds;
+ retval.X -= list_view_owner.h_marker;
+ retval.Y -= list_view_owner.v_marker;
+ return retval;
+ }
+ set {
+ if (list_view_owner != null)
+ list_view_owner.item_control.Invalidate (HeaderBounds);
+
+ header_bounds = value;
+
+ if (list_view_owner != null)
+ list_view_owner.item_control.Invalidate (HeaderBounds);
+
+ }
+ }
+
+ internal bool IsDefault {
+ get {
+ return is_default_group;
+ }
+ set {
+ is_default_group = value;
+ }
}
- internal Point Location {
- get { return location; }
- set { location = value; }
+ internal int ItemCount {
+ get {
+ return is_default_group ? item_count : items.Count;
+ }
+ set {
+ if (!is_default_group)
+ throw new InvalidOperationException ("ItemCount cannot be set for non-default groups.");
+
+ item_count = value;
+ }
}
[Browsable(true)]
#region ISerializable Members
- public void GetObjectData(SerializationInfo info, StreamingContext context)
+ void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("Header", header);
info.AddValue("Name", name);
#endregion
}
+
+ internal class ListViewGroupConverter : TypeConverter
+ {
+ public override bool GetStandardValuesSupported (ITypeDescriptorContext context)
+ {
+ return true;
+ }
+
+ // Weird
+ public override StandardValuesCollection GetStandardValues (ITypeDescriptorContext context)
+ {
+ return new StandardValuesCollection (new object [] {});
+ }
+ }
}
#endif