2 // System.Windows.Forms.ListBox.cs
5 // stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
6 // Dennis Hayes (dennish@Raytek.com)
7 // Alexandre Pigolkine (pigolkine@gmx.de)
9 // (C) 2002/3 Ximian, Inc
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System
.Collections
;
34 using System
.Runtime
.InteropServices
;
36 namespace System
.Windows
.Forms
{
41 public class ListBox
: ListControl
{
48 SubClassWndProc_
= true;
49 BorderStyle_
= BorderStyle
.Fixed3D
;
50 BackColor
= SystemColors
.Window
;
51 controlStyles_
|= ControlStyles
.AllPaintingInWmPaint
;
55 // --- Protected Fields
57 internal int ColumnWidth_
= 0; // The columns will have default width
58 internal bool IntegralHeight_
= true;
59 internal ListBox
.ObjectCollection Items_
= null;
60 internal ListBox
.SelectedIndexCollection SelectedIndices_
= null;
61 internal ListBox
.SelectedObjectCollection SelectedObjects_
= null;
62 internal DrawMode DrawMode_
= DrawMode
.Normal
;
63 internal bool UseTabStops_
= false;
64 internal bool MultiColumn_
= false;
65 int selectedIndex
= -1;
66 internal bool Sorted_
= false;
67 internal int prevSelectedIndex
= -1;
68 internal BorderStyle BorderStyle_
;
73 public const int DefaultItemHeight
= 13;//correct
74 public const int NoMatches
= -1 ;//correct
78 // --- Public Properties
81 public override Color ForeColor
{
84 return base.ForeColor
;
88 base.ForeColor
= value;
93 public override Color BackColor
{
96 return base.BackColor
;
100 base.BackColor
= value;
104 public override Image BackgroundImage
{
107 return base.BackgroundImage
;
111 base.BackgroundImage
= value;
115 public BorderStyle BorderStyle
{
120 if( BorderStyle_
!= value) {
121 BorderStyle_
= value;
122 if( IsHandleCreated
) {
130 public int HorizontalExtent
{
132 throw new NotImplementedException ();
138 public bool MultiColumn
{
143 if( MultiColumn_
!= value) {
144 MultiColumn_
= value;
151 public override RightToLeft RightToLeft
{
154 return base.RightToLeft
;
158 base.RightToLeft
= value;
162 public bool ScrollAlwaysVisible
{
164 throw new NotImplementedException ();
172 public bool HorizontalScrollbar
{
174 throw new NotImplementedException ();
182 public int PreferredHeight
{
184 throw new NotImplementedException ();
189 public override int SelectedIndex
{
191 if( IsHandleCreated
) {
192 return Win32
.SendMessage(Handle
, (int)ListBoxMessages
.LB_GETCURSEL
, 0, 0);
195 return selectedIndex
;
199 prevSelectedIndex
= selectedIndex
;
200 if( selectedIndex
!= value) {
201 //FIXME: set exception parameters
202 selectedIndex
= value;
203 if( IsHandleCreated
) {
204 Win32
.SendMessage(Handle
, (int)ListBoxMessages
.LB_SETCURSEL
, selectedIndex
, 0);
206 OnSelectedIndexChanged(new EventArgs());
212 public ListBox
.SelectedIndexCollection SelectedIndices
{
214 if( SelectedIndices_
== null) {
215 SelectedIndices_
= new ListBox
.SelectedIndexCollection(this);
217 return SelectedIndices_
;
221 public object SelectedItem
{
223 throw new NotImplementedException ();
230 public ListBox
.SelectedObjectCollection SelectedItems
{
232 if( SelectedObjects_
== null) {
233 SelectedObjects_
= new ListBox
.SelectedObjectCollection(this);
235 return SelectedObjects_
;
239 public virtual SelectionMode SelectionMode
{
241 throw new NotImplementedException ();
253 if( Sorted_
!= value){
256 Items_
.SwitchToSortedStyle();
258 object[] items = new object[Items.Count];
259 Items.CopyTo(items, 0);
261 Items.AddRange(items);
268 public override string Text
{
277 public int TopIndex
{
279 throw new NotImplementedException ();
286 public bool UseTabStops
{
291 UseTabStops_
= value;
296 public virtual DrawMode DrawMode
{
302 // FIXME: change styles of Windows control/ recreate control
306 public int ColumnWidth
{
311 ColumnWidth_
= value;
316 public virtual int ItemHeight
{
318 throw new NotImplementedException ();
324 public bool IntegralHeight
{
326 return IntegralHeight_
;
329 IntegralHeight_
= value;
333 public ListBox
.ObjectCollection Items
{
335 if( Items_
== null) {
336 Items_
= CreateItemCollection();
342 internal virtual void OnObjectCollectionChanged() {
343 SelectedIndices_
= null;
347 // --- Public Methods
350 public void BeginUpdate() {
354 public void ClearSelected() {
358 public void EndUpdate() {
362 public int FindString(string s
) {
363 throw new NotImplementedException ();
366 public int FindString(string s
, int startIndex
) {
367 throw new NotImplementedException ();
370 public int FindStringExact(string s
) {
371 throw new NotImplementedException ();
374 public int FindStringExact(string s
, int startIndex
) {
375 throw new NotImplementedException ();
378 public int GetItemHeight(int index
) {
379 throw new NotImplementedException ();
382 public Rectangle
GetItemRectangle(int index
) {
383 throw new NotImplementedException ();
386 public bool GetSelected(int index
) {
387 throw new NotImplementedException ();
390 public int IndexFromPoint(Point p
) {
391 throw new NotImplementedException ();
394 public int IndexFromPoint(int x
, int y
) {
395 throw new NotImplementedException ();
398 public void SetSelected(int index
, bool value) {
402 public override string ToString() {
404 return base.ToString();
411 public event DrawItemEventHandler DrawItem
;
413 public event MeasureItemEventHandler MeasureItem
;
414 public event EventHandler SelectedIndexChanged
;
416 // --- Protected Properties
419 protected override CreateParams CreateParams
{
421 CreateParams createParams
= base.CreateParams
;
422 createParams
.ClassName
= "LISTBOX";
423 createParams
.ExStyle
= (int)WindowExStyles
.WS_EX_CLIENTEDGE
;
424 createParams
.Style
= (int) (
425 WindowStyles
.WS_CHILD
|
426 WindowStyles
.WS_VISIBLE
|
427 WindowStyles
.WS_CLIPSIBLINGS
);
428 createParams
.Style
|= (int) (ListBoxStyles
.LBS_NOTIFY
|
429 ListBoxStyles
.LBS_HASSTRINGS
);
430 if( !IntegralHeight_
) {
431 createParams
.Style
|= (int)ListBoxStyles
.LBS_NOINTEGRALHEIGHT
;
434 createParams
.Style
|= (int)ListBoxStyles
.LBS_USETABSTOPS
;
437 case DrawMode
.OwnerDrawFixed
:
438 createParams
.Style
|= (int)ListBoxStyles
.LBS_OWNERDRAWFIXED
;
440 case DrawMode
.OwnerDrawVariable
:
441 createParams
.Style
|= (int)ListBoxStyles
.LBS_OWNERDRAWVARIABLE
;
445 createParams
.Style
|= (int)ListBoxStyles
.LBS_MULTICOLUMN
| (int)WindowStyles
.WS_HSCROLL
;
448 createParams
.Style
|= (int)WindowStyles
.WS_VSCROLL
;
455 protected override Size DefaultSize
{
457 return new Size(120,95);
462 // --- Protected Methods
466 protected virtual void AddItemsCore(object [] value) {
471 protected virtual ObjectCollection
CreateItemCollection() {
472 return new ListBox
.ObjectCollection( this);
476 protected override void OnChangeUICues(UICuesEventArgs e
) {
478 base.OnChangeUICues(e
);
481 protected override void OnDataSourceChanged(EventArgs e
) {
483 base.OnDataSourceChanged(e
);
486 protected override void OnDisplayMemberChanged(EventArgs e
) {
488 base.OnDisplayMemberChanged(e
);
492 protected virtual void OnDrawItem(DrawItemEventArgs e
) {
493 if( DrawItem
!= null) {
499 protected override void OnFontChanged(EventArgs e
) {
501 base.OnFontChanged(e
);
504 protected override void OnHandleCreated(EventArgs e
) {
506 base.OnHandleCreated(e
);
507 if( Items_
!= null) {
508 Items_
.PopulateControl();
510 if( ColumnWidth_
!= 0 && MultiColumn_
) {
511 Win32
.SendMessage( Handle
, (int)ListBoxMessages
.LB_SETCOLUMNWIDTH
, ColumnWidth_
, 0);
516 protected override void OnHandleDestroyed(EventArgs e
) {
518 base.OnHandleDestroyed(e
);
522 protected virtual void OnMeasureItem(MeasureItemEventArgs e
) {
523 if( MeasureItem
!= null) {
524 MeasureItem(this, e
);
529 protected override void OnParentChanged(EventArgs e
) {
531 base.OnParentChanged(e
);
534 protected override void OnResize(EventArgs e
) {
539 protected override void OnSelectedIndexChanged(EventArgs e
) {
541 base.OnSelectedIndexChanged(e
);
542 if( SelectedIndexChanged
!= null) {
543 SelectedIndexChanged(this, e
);
548 protected override void OnSelectedValueChanged(EventArgs e
) {
550 base.OnSelectedValueChanged(e
);
553 protected override void RefreshItem(int index
) {
557 public override void Refresh() { // .NET V1.1 Beta
562 protected override void SetBoundsCore( int x
, int y
, int width
, int height
, BoundsSpecified specified
) {
564 base.SetBoundsCore(x
, y
, width
, height
, specified
);
568 protected override void SetItemCore (int index
, object value) {
572 protected override void SetItemsCore (IList
value){
576 protected virtual void Sort() {
580 protected virtual void WmReflectCommand(ref Message m
){
581 throw new NotImplementedException ();
585 protected override void WndProc(ref Message m
) {
586 switch ((Msg
) m
.Msg
) {
587 case Msg
.WM_MEASUREITEM
: {
588 MEASUREITEMSTRUCT mis
= new MEASUREITEMSTRUCT();
589 mis
= (MEASUREITEMSTRUCT
)Marshal
.PtrToStructure(m
.LParam
, mis
.GetType());
590 MeasureItemEventArgs args
= new MeasureItemEventArgs(CreateGraphics(),mis
.itemID
);
591 args
.ItemHeight
= mis
.itemHeight
;
592 args
.ItemWidth
= mis
.itemWidth
;
593 OnMeasureItem( args
);
594 mis
.itemHeight
= args
.ItemHeight
;
595 mis
.itemWidth
= args
.ItemWidth
;
596 Marshal
.StructureToPtr(mis
, m
.LParam
, false);
597 m
.Result
= (IntPtr
)1;
600 case Msg
.WM_DRAWITEM
: {
601 DRAWITEMSTRUCT dis
= new DRAWITEMSTRUCT();
602 dis
= (DRAWITEMSTRUCT
)Marshal
.PtrToStructure(m
.LParam
, dis
.GetType());
603 Rectangle rect
= new Rectangle(dis
.rcItem
.left
, dis
.rcItem
.top
, dis
.rcItem
.right
- dis
.rcItem
.left
, dis
.rcItem
.bottom
- dis
.rcItem
.top
);
604 DrawItemEventArgs args
= new DrawItemEventArgs(Graphics
.FromHdc(dis
.hDC
), Font
,
605 rect
, dis
.itemID
, (DrawItemState
)dis
.itemState
);
607 //Marshal.StructureToPtr(dis, m.LParam, false);
608 m
.Result
= (IntPtr
)1;
612 switch(m
.HiWordWParam
) {
613 case (uint)ListBoxNotifications
.LBN_SELCHANGE
:
614 SelectedIndex
= Win32
.SendMessage(Handle
, (int)ListBoxMessages
.LB_GETCURSEL
, 0, 0);
615 m
.Result
= IntPtr
.Zero
;
616 CallControlWndProc(ref m
);
619 CallControlWndProc(ref m
);
631 // This is a subclass
634 public class SelectedObjectCollection
: IList
, ICollection
, IEnumerable
{
636 ArrayList collection_
;
642 public SelectedObjectCollection(ListBox owner
) {
644 collection_
= owner_
.Items
.CreateSelectedObjectsList();
648 // --- Public Properties
653 return collection_
.Count
;
657 public bool IsReadOnly
{
663 public object this[int index
] {
665 return collection_
[index
];
673 // --- Public Methods
676 public bool Contains(object selectedObject
) {
677 return collection_
.Contains(selectedObject
);;
680 public void CopyTo(Array dest
, int index
) {
681 collection_
.CopyTo(dest
, index
);
684 public override bool Equals(object obj
) {
686 return base.Equals(obj
);
689 public override int GetHashCode() {
690 //FIXME add our proprities
691 return base.GetHashCode();
694 public IEnumerator
GetEnumerator() {
695 return collection_
.GetEnumerator();
698 public int IndexOf(object selectedObject
) {
699 return collection_
.IndexOf(selectedObject
);
702 /// IList Interface implmentation.
704 bool IList
.IsReadOnly
{
706 // We allow addition, removeal, and editing of items after creation of the list.
710 bool IList
.IsFixedSize
{
712 // We allow addition and removeal of items after creation of the list.
719 object IList
.this[int index
]{
721 throw new NotImplementedException ();
724 throw new NotImplementedException ();
735 int IList
.Add( object value){
736 throw new NotImplementedException ();
740 bool IList
.Contains( object value){
741 throw new NotImplementedException ();
745 int IList
.IndexOf( object value){
746 throw new NotImplementedException ();
750 void IList
.Insert(int index
, object value){
755 void IList
.Remove( object value){
760 void IList
.RemoveAt( int index
){
763 // End of IList interface
765 /// ICollection Interface implmentation.
767 int ICollection
.Count
{
769 throw new NotImplementedException ();
772 bool ICollection
.IsSynchronized
{
774 throw new NotImplementedException ();
777 object ICollection
.SyncRoot
{
779 throw new NotImplementedException ();
782 void ICollection
.CopyTo(Array array
, int index
){
783 throw new NotImplementedException ();
785 // End Of ICollection
791 public class ObjectCollection
: IList
, ICollection
{
793 internal class ListBoxItem
{
794 public object theData_
= null;
795 public string dataRepresentation_
= String
.Empty
;
796 // FIXME: change those fields to flags
797 //public bool wasSorted_ = false;
798 //public bool wasAddedToControl_ = false;
799 public bool IsAddedToControl_
= false;
800 public bool Selected_
= false;
801 public bool Checked_
= false;
803 public ListBoxItem( object data
, string representation
) {
805 dataRepresentation_
= representation
;
809 internal class ListItemRepresentationComparer
: IComparer
{
810 public ListItemRepresentationComparer() {
813 public int Compare(object x
, object y
) {
814 ListBoxItem left
= x
as ListBoxItem
;
815 ListBoxItem right
= y
as ListBoxItem
;
816 if( left
== null || right
== null) {
817 throw new ArgumentException();
819 return left
.dataRepresentation_
.CompareTo(right
.dataRepresentation_
);
823 internal class ListItemDataComparer : IComparer {
824 public ListItemDataComparer() {
827 public int Compare(object x, object y) {
828 ListBoxItem left = x as ListBoxItem;
829 ListBoxItem right = y as ListBoxItem;
830 if( left == null || right == null) {
831 throw new ArgumentException();
833 return left.theData_.CompareTo(right.dataRepresentation_);
837 internal ArrayList
CreateSelectedIndicesList() {
838 ArrayList result
= new ArrayList();
839 int ordinalNumber
= 0;
840 foreach( ListBoxItem lbi
in items_
) {
842 result
.Add(ordinalNumber
);
849 internal ArrayList
CreateSelectedObjectsList() {
850 ArrayList result
= new ArrayList();
851 foreach( ListBoxItem lbi
in items_
) {
853 result
.Add(lbi
.theData_
);
859 internal ArrayList
CreateCheckedIndexList() {
860 ArrayList result
= new ArrayList();
861 int ordinalNumber
= 0;
862 foreach( ListBoxItem lbi
in items_
) {
864 result
.Add(ordinalNumber
);
871 internal ArrayList
CreateCheckedItemList() {
872 ArrayList result
= new ArrayList();
873 foreach( ListBoxItem lbi
in items_
) {
875 result
.Add(lbi
.theData_
);
881 internal ListBoxItem
getItemAt(int index
) {
882 return (ListBoxItem
)items_
[index
];
885 internal void SwitchToSortedStyle() {
886 if( owner_
.IsHandleCreated
) {
887 Win32
.SendMessage(owner_
.Handle
, (int)ListBoxMessages
.LB_RESETCONTENT
, 0, 0);
889 items_
.Sort(new ListItemRepresentationComparer());
890 if( owner_
.IsHandleCreated
) {
891 foreach( ListBoxItem lbi
in items_
) {
892 Win32
.SendMessage(owner_
.Handle
, (int)ListBoxMessages
.LB_ADDSTRING
, 0, lbi
.dataRepresentation_
);
895 owner_
.OnObjectCollectionChanged();
898 internal void PopulateControl() {
899 foreach( ListBoxItem lbi
in items_
) {
900 Win32
.SendMessage(owner_
.Handle
, (int)ListBoxMessages
.LB_ADDSTRING
, 0, lbi
.dataRepresentation_
);
901 lbi
.IsAddedToControl_
= true;
905 internal void DumpItems() {
906 int ordinalNumber
= 0;
907 foreach( ListBoxItem lbi
in items_
) {
908 Console
.WriteLine("ListBoxItem {0} order {1} checked {2}", lbi
.dataRepresentation_
,
909 ordinalNumber
, lbi
.Checked_
);
914 internal class ListBoxItemEnumerator
: IEnumerator
{
915 private IEnumerator containerEnum_
= null;
917 public ListBoxItemEnumerator( IEnumerator containerEnum
) {
918 containerEnum_
= containerEnum
;
921 public object Current
{
923 return ((ListBoxItem
)containerEnum_
.Current
).theData_
;
927 public bool MoveNext() {
928 return containerEnum_
.MoveNext();
931 public void Reset() {
932 containerEnum_
.Reset();
937 protected ListBox owner_
= null;
938 protected ArrayList items_
= new ArrayList(); // has ListBoxItem
944 public ObjectCollection(ListBox box
) {
948 public ObjectCollection(ListBox box
, object[] objs
) {
954 // --- Public Properties
963 public bool IsReadOnly
{
965 // FIXME: Is it always not ReadOnly
970 public virtual object this[int index
] {
972 return ((ListBoxItem
)items_
[index
]).theData_
;
975 ((ListBoxItem
)items_
[index
]).theData_
= value;
976 // FIXME: assing representation and sort if needed
981 // --- Public Methods
984 public int Add(object item
) {
985 string representation
= owner_
.getDisplayMemberOfObj(item
);
986 ListBoxItem newItem
= new ListBoxItem(item
, representation
);
987 int result
= items_
.Add(newItem
);
989 items_
.Sort(new ListItemRepresentationComparer());
990 result
= items_
.BinarySearch(newItem
);
991 if( owner_
.IsHandleCreated
) {
992 Win32
.SendMessage(owner_
.Handle
, (int)ListBoxMessages
.LB_INSERTSTRING
, result
, representation
);
994 owner_
.OnObjectCollectionChanged();
997 if( owner_
.IsHandleCreated
) {
998 Win32
.SendMessage(owner_
.Handle
, (int)ListBoxMessages
.LB_ADDSTRING
, 0, representation
);
1001 newItem
.IsAddedToControl_
= true;
1006 public void AddRange(object[] items
) {
1007 if( items
== null) throw new ArgumentException();
1008 ListBoxItem
[] newItems
= new ListBoxItem
[items
.Length
];
1010 foreach( object obj
in items
) {
1011 newItems
[idx
] = new ListBoxItem(obj
, owner_
.getDisplayMemberOfObj(obj
));
1014 items_
.AddRange(newItems
);
1015 if( owner_
.Sorted
) {
1016 items_
.Sort(new ListItemRepresentationComparer());
1017 if( owner_
.IsHandleCreated
) {
1019 foreach( ListBoxItem lbi
in items_
) {
1020 if(!lbi
.IsAddedToControl_
){
1021 Win32
.SendMessage(owner_
.Handle
, (int)ListBoxMessages
.LB_INSERTSTRING
, index
, lbi
.dataRepresentation_
);
1026 owner_
.OnObjectCollectionChanged();
1029 if( owner_
.IsHandleCreated
) {
1030 foreach(ListBoxItem lbi
in newItems
) {
1031 Win32
.SendMessage(owner_
.Handle
, (int)ListBoxMessages
.LB_ADDSTRING
, 0, lbi
.dataRepresentation_
);
1032 lbi
.IsAddedToControl_
= true;
1036 // FIXME: Add items to control
1039 public void AddRange(ListBox
.ObjectCollection collection
) {
1043 public void Clear() {
1046 if( owner_
.IsHandleCreated
) {
1047 Win32
.SendMessage(owner_
.Handle
, (int)ListBoxMessages
.LB_RESETCONTENT
, 0, 0);
1049 owner_
.OnObjectCollectionChanged();
1052 public bool Contains(object value) {
1053 // FIXME: determine whether some of ListBoxItem has value as theData_
1054 foreach( ListBoxItem lbi
in items_
) {
1055 if( lbi
.theData_
== value) {
1062 public void CopyTo(object[] dest
, int arrayIndex
) {
1063 // FIXME: copy theData_ from ListBoxItem, not the ListBoxItems
1064 items_
.CopyTo(dest
, arrayIndex
);
1067 public override bool Equals(object obj
) {
1069 return base.Equals(obj
);
1072 public override int GetHashCode() {
1073 //FIXME add our proprities
1074 return base.GetHashCode();
1077 public IEnumerator
GetEnumerator() {
1078 return new ListBoxItemEnumerator(items_
.GetEnumerator());
1081 public int IndexOf(object val
) {
1082 // FIXME: find ListBoxItem object which has the val as theData_
1085 foreach( ListBoxItem lbi
in items_
) {
1086 if( lbi
.theData_
== val
) {
1095 public void Insert(int index
, object item
) {
1099 public void Remove(object val
) {
1100 // FIXME: use some sort of Comparer ?
1102 foreach(ListBoxItem lbi
in items_
) {
1103 if( lbi
.theData_
== val
) {
1111 public void RemoveAt(int index
) {
1112 if( index
< 0 || index
>= items_
.Count
) {
1113 //FIXME: set exception parameters
1114 throw new ArgumentOutOfRangeException();
1116 items_
.RemoveAt(index
);
1117 if( owner_
.IsHandleCreated
) {
1118 Win32
.SendMessage( owner_
.Handle
, (int)ListBoxMessages
.LB_DELETESTRING
, index
, 0);
1120 owner_
.OnObjectCollectionChanged();
1123 /// IList Interface implmentation.
1125 bool IList
.IsReadOnly
{
1127 // We allow addition, removeal, and editing of items after creation of the list.
1131 bool IList
.IsFixedSize
{
1133 // We allow addition and removeal of items after creation of the list.
1140 object IList
.this[int index
]{
1142 throw new NotImplementedException ();
1145 throw new NotImplementedException ();
1156 int IList
.Add( object value){
1157 throw new NotImplementedException ();
1161 bool IList
.Contains( object value){
1162 throw new NotImplementedException ();
1166 int IList
.IndexOf( object value){
1167 throw new NotImplementedException ();
1171 void IList
.Insert(int index
, object value){
1176 void IList
.Remove( object value){
1181 void IList
.RemoveAt( int index
){
1184 // End of IList interface
1186 /// ICollection Interface implmentation.
1188 int ICollection
.Count
{
1190 throw new NotImplementedException ();
1193 bool ICollection
.IsSynchronized
{
1195 throw new NotImplementedException ();
1198 object ICollection
.SyncRoot
{
1200 throw new NotImplementedException ();
1203 void ICollection
.CopyTo(Array array
, int index
){
1204 throw new NotImplementedException ();
1206 // End Of ICollection
1212 public class SelectedIndexCollection
: IList
, ICollection
, IEnumerable
{
1214 ArrayList collection_
;
1221 public SelectedIndexCollection(ListBox owner
) {
1223 collection_
= owner_
.Items
.CreateSelectedIndicesList();
1227 // --- Public Properties
1232 return collection_
.Count
;
1236 public bool IsReadOnly
{
1242 public int this[int index
] {
1244 return (int)collection_
[index
];
1249 // --- Public Methods
1252 public bool Contains(int selectedIndex
) {
1253 return collection_
.Contains(selectedIndex
);
1256 public void CopyTo(Array dest
, int index
) {
1257 collection_
.CopyTo(dest
, index
);
1260 public override bool Equals(object obj
) {
1262 return base.Equals(obj
);
1265 public override int GetHashCode() {
1266 //FIXME add our proprities
1267 return base.GetHashCode();
1270 public IEnumerator
GetEnumerator() {
1271 return collection_
.GetEnumerator();
1274 /// IList Interface implmentation.
1276 bool IList
.IsReadOnly
{
1278 // We allow addition, removeal, and editing of items after creation of the list.
1282 bool IList
.IsFixedSize
{
1284 // We allow addition and removeal of items after creation of the list.
1290 object IList
.this[int index
]{
1292 throw new NotImplementedException ();
1305 int IList
.Add( object value){
1306 throw new NotImplementedException ();
1310 bool IList
.Contains( object value){
1311 throw new NotImplementedException ();
1315 int IList
.IndexOf( object value){
1316 throw new NotImplementedException ();
1320 void IList
.Insert(int index
, object value){
1325 void IList
.Remove( object value){
1330 void IList
.RemoveAt( int index
){
1331 throw new NotImplementedException ();
1333 // End of IList interface
1335 /// ICollection Interface implmentation.
1337 int ICollection
.Count
{
1339 throw new NotImplementedException ();
1342 bool ICollection
.IsSynchronized
{
1344 throw new NotImplementedException ();
1347 object ICollection
.SyncRoot
{
1349 throw new NotImplementedException ();
1352 void ICollection
.CopyTo(Array array
, int index
){
1353 throw new NotImplementedException ();
1355 // End Of ICollection