1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 // Miguel de Icaza (miguel@gnome.org)
24 // Copyright 2004-2006 Novell, Inc.
28 using System.ComponentModel;
29 using System.Collections;
30 using System.Windows.Forms.Layout;
32 namespace System.Windows.Forms {
33 [Editor ("System.Windows.Forms.Design.StyleCollectionEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
34 public abstract class TableLayoutStyleCollection : IList, ICollection, IEnumerable
36 ArrayList al = new ArrayList ();
37 TableLayoutPanel table;
39 internal TableLayoutStyleCollection (TableLayoutPanel table)
42 throw new ArgumentNullException("table");
47 public int Add (TableLayoutStyle style)
49 return ((IList)this).Add (style);
54 foreach (TableLayoutStyle style in al)
57 table.PerformLayout ();
61 get { return al.Count; }
64 public void RemoveAt (int index)
66 ((TableLayoutStyle)al[index]).Owner = null;
68 table.PerformLayout ();
73 // The IList methods will later be implemeneted, this is to get us started
75 int IList.Add (object style)
77 TableLayoutStyle layoutStyle = (TableLayoutStyle) style;
78 if (layoutStyle.Owner != null)
79 throw new ArgumentException ("Style is already owned");
81 layoutStyle.Owner = table;
82 int result = al.Add (layoutStyle);
85 table.PerformLayout ();
90 bool IList.Contains (object style)
92 return al.Contains ((TableLayoutStyle) style);
95 int IList.IndexOf (object style)
97 return al.IndexOf ((TableLayoutStyle) style);
100 void IList.Insert (int index, object style)
102 if (((TableLayoutStyle)style).Owner != null)
103 throw new ArgumentException ("Style is already owned");
104 ((TableLayoutStyle)style).Owner = table;
105 al.Insert (index, (TableLayoutStyle) style);
106 table.PerformLayout ();
109 void IList.Remove (object style)
111 ((TableLayoutStyle)style).Owner = null;
112 al.Remove ((TableLayoutStyle) style);
113 table.PerformLayout ();
116 bool IList.IsFixedSize {
118 return al.IsFixedSize;
122 bool IList.IsReadOnly {
124 return al.IsReadOnly;
128 object IList.this [int index] {
133 if (((TableLayoutStyle)value).Owner != null)
134 throw new ArgumentException ("Style is already owned");
135 ((TableLayoutStyle)value).Owner = table;
137 table.PerformLayout ();
142 #region ICollection methods
143 void ICollection.CopyTo (Array array, int startIndex)
145 al.CopyTo (array, startIndex);
148 object ICollection.SyncRoot {
154 bool ICollection.IsSynchronized {
156 return al.IsSynchronized;
161 #region IEnumerable methods
162 IEnumerator IEnumerable.GetEnumerator ()
164 return al.GetEnumerator ();
167 public TableLayoutStyle this [int index] {
169 return (TableLayoutStyle) ((IList)this)[index];
173 ((IList)this)[index] = value;