///
/// Copyright © 2003-2008 JetBrains s.r.o.
/// You may distribute under the terms of the GNU General Public License, as published by the Free Software Foundation, version 2 (see License.txt in the repository root folder).
///
using System;
using System.Collections;
using System.Drawing;
namespace JetBrains.JetListViewLibrary
{
public class JetListViewColumnCollection: IDisposable, IEnumerable
{
private ArrayList _items;
private JetListView _ownerControl;
private IControlPainter _controlPainter;
private Font _font;
private int _batchUpdateCount;
internal JetListViewColumnCollection()
{
_items = new ArrayList();
}
public IEnumerator GetEnumerator()
{
return _items.GetEnumerator();
}
public void Dispose()
{
Clear();
}
internal JetListView OwnerControl
{
get { return _ownerControl; }
set { _ownerControl = value; }
}
public IControlPainter ControlPainter
{
get { return _controlPainter; }
set { _controlPainter = value; }
}
public Font Font
{
get { return _font; }
set { _font = value; }
}
///
/// Occurs when a column is added to the collection.
///
public event ColumnEventHandler ColumnAdded;
///
/// Occurs when a column is removed from the collection.
///
public event ColumnEventHandler ColumnRemoved;
public event EventHandler BatchUpdateStarted;
public event EventHandler BatchUpdated;
public JetListViewColumn this[int index]
{
get
{
return (JetListViewColumn) _items [index];
}
set
{
_items [index] = value;
}
}
public int Count
{
get { return _items.Count; }
}
public void Insert( int index, JetListViewColumn value )
{
value.Owner = this;
_items.Insert( index, value );
OnColumnAdded( value );
}
public void Remove( JetListViewColumn value )
{
_items.Remove( value );
OnColumnRemoved( value );
value.Dispose();
}
///
///
///
///
///
public bool Contains( JetListViewColumn value )
{
return _items.Contains( value );
}
///
///
///
///
///
public int IndexOf( JetListViewColumn value )
{
return _items.IndexOf( value );
}
///
/// Adds the specified column to the list.
///
/// The column to add.
/// The index of the added column.
public int Add( JetListViewColumn value )
{
int result = _items.Add( value );
value.Owner = this;
OnColumnAdded( value );
return result;
}
public void AddRange( JetListViewColumn[] values )
{
foreach( JetListViewColumn col in values )
{
_items.Add( col );
col.Owner = this;
OnColumnAdded( col );
}
}
private void OnColumnAdded( JetListViewColumn value )
{
if ( ColumnAdded != null )
{
ColumnAdded( this, new ColumnEventArgs( value ) );
}
}
///
/// Removes all columns from the collection.
///
public void Clear()
{
for( int i=0; i 0; }
}
}
}