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)
44 public int Add (TableLayoutStyle style)
46 return ((IList)this).Add (style);
51 foreach (TableLayoutStyle style in al)
55 table.PerformLayout ();
59 get { return al.Count; }
62 public void RemoveAt (int index)
64 ((TableLayoutStyle)al[index]).Owner = null;
67 table.PerformLayout ();
72 // The IList methods will later be implemeneted, this is to get us started
74 int IList.Add (object style)
76 TableLayoutStyle layoutStyle = (TableLayoutStyle) style;
77 if (layoutStyle.Owner != null)
78 throw new ArgumentException ("Style is already owned");
80 layoutStyle.Owner = table;
81 int result = al.Add (layoutStyle);
84 table.PerformLayout ();
89 bool IList.Contains (object style)
91 return al.Contains ((TableLayoutStyle) style);
94 int IList.IndexOf (object style)
96 return al.IndexOf ((TableLayoutStyle) style);
99 void IList.Insert (int index, object style)
101 if (((TableLayoutStyle)style).Owner != null)
102 throw new ArgumentException ("Style is already owned");
103 ((TableLayoutStyle)style).Owner = table;
104 al.Insert (index, (TableLayoutStyle) style);
106 table.PerformLayout ();
109 void IList.Remove (object style)
111 ((TableLayoutStyle)style).Owner = null;
112 al.Remove ((TableLayoutStyle) style);
114 table.PerformLayout ();
117 bool IList.IsFixedSize {
119 return al.IsFixedSize;
123 bool IList.IsReadOnly {
125 return al.IsReadOnly;
129 object IList.this [int index] {
134 if (((TableLayoutStyle)value).Owner != null)
135 throw new ArgumentException ("Style is already owned");
136 ((TableLayoutStyle)value).Owner = table;
139 table.PerformLayout ();
144 #region ICollection methods
145 void ICollection.CopyTo (Array array, int startIndex)
147 al.CopyTo (array, startIndex);
150 object ICollection.SyncRoot {
156 bool ICollection.IsSynchronized {
158 return al.IsSynchronized;
163 #region IEnumerable methods
164 IEnumerator IEnumerable.GetEnumerator ()
166 return al.GetEnumerator ();
169 public TableLayoutStyle this [int index] {
171 return (TableLayoutStyle) ((IList)this)[index];
175 ((IList)this)[index] = value;