//
// System.Windows.Forms.ListViewItem.cs
//
// Author:
// stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
// Dennis Hayes (dennish@Raytek.com)
// Implemented by Jordi Mas i Hernāndez (jmas@softcatala.org)
//
// (C) 2002/3 Ximian, Inc
//
using System.Runtime.Serialization;
using System.Drawing;
using System.Collections;
using System.Runtime.InteropServices;
namespace System.Windows.Forms
{
//
//
[Serializable]
public class ListViewItem : ICloneable, ISerializable
{
private ListView container = null;
private string text;
private ListViewSubItemCollection colSubItem = null;
private int index;
private bool bSelected = false;
private bool useItemStyleForSubItems = true;
private bool bChecked = false;
private bool bFocused = false;
private Color backColor = SystemColors.Window;
private Color foreColor = SystemColors.WindowText;
private object tag = null;
//
// --- Constructor
//
protected void CommonConstructor(){
colSubItem = new ListViewSubItemCollection(this);
}
public ListViewItem(){
CommonConstructor();
}
public ListViewItem(string str) {
Console.WriteLine("ListViewItem.ListViewItem str");
CommonConstructor();
text = str;
}
public ListViewItem(string[] strings){ // An array of strings that represent the subitems of the new item.
Console.WriteLine("ListView.ListView strings");
CommonConstructor();
if (strings.Length>0)
text = strings[0];
if (strings.Length>1)
{
for (int i=1; i0)
text = strings[0];
if (strings.Length>1)
{
for (int i=1; i0){
text = strings[0];
BackColor = bColor;
ForeColor = fColor;
}
if (strings.Length>1){
ListViewSubItem subItem;
for (int i=1; i
//
[Serializable]
public class ListViewSubItemCollection : IList, ICollection, IEnumerable
{
private ArrayList collection = new ArrayList();
private ListViewItem owner = null;
//
// --- Constructor
//
public ListViewSubItemCollection(ListViewItem item) {
owner = item;
}
//
// --- Public Properties
//
public int Count {
get { return collection.Count; }
}
public bool IsReadOnly
{
get { return collection.IsReadOnly; }
}
public ListViewSubItem this[int index]
{
get {
if (index<0 || index>=Count) throw new ArgumentOutOfRangeException();
return (ListViewSubItem) collection[index];
}
set {
if (index<0 || index>=Count) throw new ArgumentOutOfRangeException();
collection[index] = value;
}
}
/// --- ICollection properties ---
bool IList.IsFixedSize
{
get { return collection.IsFixedSize; }
}
object IList.this[int index]
{
get { return collection[index]; }
set { collection[index] = value; }
}
object ICollection.SyncRoot
{
get { return collection.SyncRoot; }
}
bool ICollection.IsSynchronized
{
get { return collection.IsSynchronized; }
}
//
// --- Public Methods
//
public ListViewSubItem Add(ListViewItem.ListViewSubItem item)
{
if (item.ListViewItem==null) item.ListViewItem = owner;
int nIdx = collection.Add(item);
return (ListViewSubItem)collection[nIdx];
}
public ListViewSubItem Add(string text)
{
ListViewItem.ListViewSubItem item = new ListViewSubItem(owner, text);
return Add(item);
}
public ListViewSubItem Add(string text,Color fColor,Color bColor,Font font)
{
ListViewSubItem item = new ListViewSubItem(owner, text);
item.ForeColor = fColor;
item.BackColor = bColor;
return Add(item);
}
public void AddRange(ListViewItem.ListViewSubItem[] values) {
for (int i=0; i
//
public class ListViewSubItem
{
private string sText;
private ListViewItem owner = null;
private Color backColor = SystemColors.Window;
private Color foreColor = SystemColors.WindowText;
private Font font;
internal ListViewItem ListViewItem{
get{return owner;}
set{owner=value;}
}
//
// --- Constructor
//
public ListViewSubItem(){
}
public ListViewSubItem(ListViewItem item, string str){
owner = item;
sText = str;
}
public ListViewSubItem(ListViewItem item, string str, Color foreClr, Color backClr, Font fnt){
owner = item;
sText = str;
BackColor = backClr;
ForeColor = foreClr;
font = fnt;
}
//
// --- Public Properties
//
public Color BackColor {
get {return backColor;}
set {backColor = value;}
}
public Font Font {
get {return font;}
set {font = value;}
}
public Color ForeColor {
get {return foreColor;}
set {foreColor = value;}
}
public string Text {
get {return sText;}
set {sText=value;}
}
//
// --- Public Methods
//
[MonoTODO]
public override bool Equals(object obj)
{
//FIXME:
return base.Equals(obj);
}
[MonoTODO]
public override int GetHashCode() {
//FIXME add our proprities
return base.GetHashCode();
}
[MonoTODO]
public void ResetStyle()
{
//FIXME:
}
[MonoTODO]
public override string ToString()
{
//FIXME:
return base.ToString();
}
}
}
}