Dispose ();
}
}
+
+ [ListBindable (false)]
#if NET_2_0
[ComVisible (false)]
+ public class ControlCollection : Layout.ArrangedElementCollection, IList, ICollection, ICloneable, IEnumerable {
#else
[DesignerSerializer("System.Windows.Forms.Design.ControlCollectionCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
-#endif
- [ListBindable(false)]
public class ControlCollection : IList, ICollection, ICloneable, IEnumerable {
+#endif
#region ControlCollection Local Variables
+#if !NET_2_0
ArrayList list;
+#endif
ArrayList impl_list;
Control[] all_controls;
Control owner;
#region ControlCollection Public Constructor
public ControlCollection(Control owner) {
this.owner=owner;
+#if !NET_2_0
this.list=new ArrayList();
+#endif
}
#endregion
}
+#if !NET_2_0
public int Count {
get { return list.Count; }
}
+#endif
#if NET_2_0
bool IList.IsReadOnly
}
}
+#if NET_2_0
+ public Control Owner { get { return this.owner; } }
+
+ public virtual Control this[string key] {
+ get {
+ int index = IndexOfKey (key);
+
+ if (index >= 0)
+ return this[index];
+
+ return null;
+ }
+ }
+
+ new
+#endif
public virtual Control this[int index] {
get {
if (index < 0 || index >= list.Count) {
}
return (Control)list[index];
}
+
+
}
#endregion // ControlCollection Public Instance Properties
- #region ControlCollection Private Instance Methods
+ #region ControlCollection Instance Methods
public virtual void Add (Control value)
{
if (value == null)
}
}
+#if NET_2_0
+ new
+#endif
public virtual void Clear ()
{
all_controls = null;
return Contains (value) || ImplicitContains (value);
}
+#if NET_2_0
+ public virtual bool ContainsKey (string key)
+ {
+ return IndexOfKey (key) >= 0;
+ }
+#endif
+
void ICollection.CopyTo (Array array, int index)
{
CopyTo (array, index);
}
+#if !NET_2_0
public void CopyTo (Array array, int index)
{
list.CopyTo(array, index);
}
-#if !NET_2_0
public override bool Equals (object other)
{
if (other is ControlCollection && (((ControlCollection)other).owner==this.owner)) {
}
#endif
+#if NET_2_0
+ // LAMESPEC: MSDN says AE, MS implementation throws ANE
+ public Control[] Find (string key, bool searchAllChildren)
+ {
+ if (string.IsNullOrEmpty (key))
+ throw new ArgumentNullException ("key");
+
+ ArrayList al = new ArrayList ();
+
+ foreach (Control c in list) {
+ if (c.Name.Equals (key, StringComparison.CurrentCultureIgnoreCase))
+ al.Add (c);
+
+ if (searchAllChildren)
+ al.AddRange (c.Controls.Find (key, true));
+ }
+
+ return (Control[])al.ToArray (typeof (Control));
+ }
+#endif
+
public int GetChildIndex(Control child) {
return GetChildIndex(child, false);
}
}
#if NET_2_0
- public virtual IEnumerator
+ public override IEnumerator
#else
public IEnumerator
#endif
return list.IndexOf(control);
}
+#if NET_2_0
+ public virtual int IndexOfKey (string key)
+ {
+ if (string.IsNullOrEmpty (key))
+ return -1;
+
+ for (int i = 0; i < list.Count; i++)
+ if (((Control)list[i]).Name.Equals (key, StringComparison.CurrentCultureIgnoreCase))
+ return i;
+
+ return -1;
+ }
+#endif
+
public virtual void Remove(Control value)
{
if (value == null)
owner.UpdateChildrenZOrder ();
}
+#if NET_2_0
+ new
+#endif
public void RemoveAt(int index)
{
if (index < 0 || index >= list.Count) {
}
#if NET_2_0
+ public virtual void RemoveByKey (string key)
+ {
+ int index = IndexOfKey (key);
+
+ if (index >= 0)
+ RemoveAt (index);
+ }
+
public virtual void
#else
public void
tab_stop = true;
ime_mode = ImeMode.Inherit;
- layout_engine = this.LayoutEngine;
- if (layout_engine == null)
- layout_engine = new Layout.DefaultLayout ();
#if NET_2_0
backgroundimage_layout = ImageLayout.Tile;
use_compatible_text_rendering = Application.use_compatible_text_rendering;
child_controls = CreateControlsInstance();
client_size = new Size(DefaultSize.Width, DefaultSize.Height);
client_rect = new Rectangle(0, 0, DefaultSize.Width, DefaultSize.Height);
- XplatUI.CalculateWindowRect(ref client_rect, CreateParams.Style, CreateParams.ExStyle, null, out bounds);
+ bounds.Size = SizeFromClientSize (client_size);
+
if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) == 0) {
bounds.X=-1;
bounds.Y=-1;
border_style = value;
if (IsHandleCreated) {
- XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
- Refresh();
+ XplatUI.SetBorderStyle (window.Handle, (FormBorderStyle)border_style);
+ RecreateHandle ();
+ Refresh ();
}
}
}
public virtual
#endif
Layout.LayoutEngine LayoutEngine {
- get { return new Layout.DefaultLayout (); }
- }
+ get {
+ if (layout_engine == null)
+ layout_engine = new Layout.DefaultLayout ();
+ return layout_engine;
+ }
+ }
[EditorBrowsable(EditorBrowsableState.Always)]
[Browsable(false)]
// Perform all Dock and Anchor calculations
try {
- layout_engine.Layout(this, levent);
-
- // Let everyone know
OnLayout(levent);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void SetClientSizeCore(int x, int y) {
- // Calculate the actual window size from the client size (it usually stays the same or grows)
- Rectangle ClientRect;
- Rectangle WindowRect;
- CreateParams cp;
-
- ClientRect = new Rectangle(0, 0, x, y);
- cp = this.CreateParams;
-
- if (XplatUI.CalculateWindowRect(ref ClientRect, cp.Style, cp.ExStyle, null, out WindowRect)==false) {
- return;
- }
-
- SetBounds(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
+ Size NewSize = SizeFromClientSize (new Size (x, y));
+
+ if (NewSize != Size.Empty)
+ SetBounds (bounds.X, bounds.Y, NewSize.Width, NewSize.Height, BoundsSpecified.Size);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
}
}
}
-
+
+#if NET_2_0
+ protected
+#else
+ internal
+#endif
+ virtual Size SizeFromClientSize (Size clientSize)
+ {
+ Rectangle ClientRect;
+ Rectangle WindowRect;
+ CreateParams cp;
+
+ ClientRect = new Rectangle (0, 0, clientSize.Width, clientSize.Height);
+ cp = this.CreateParams;
+
+ if (XplatUI.CalculateWindowRect (ref ClientRect, cp.Style, cp.ExStyle, null, out WindowRect))
+ return new Size (WindowRect.Width, WindowRect.Height);
+
+ return Size.Empty;
+ }
+
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected void UpdateBounds() {
int x;
#region OnXXX methods
#if NET_2_0
- [EditorBrowsable (EditorBrowsableState.Advanced)]
protected virtual void OnAutoSizeChanged (EventArgs e)
{
EventHandler eh = (EventHandler)(Events[AutoSizeChangedEvent]);
LayoutEventHandler eh = (LayoutEventHandler)(Events [LayoutEvent]);
if (eh != null)
eh (this, levent);
+
+ LayoutEngine.Layout (this, levent);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
}
#if NET_2_0
- [EditorBrowsable (EditorBrowsableState.Advanced)]
protected virtual void OnMarginChanged (EventArgs e)
{
EventHandler eh = (EventHandler)(Events[MarginChangedEvent]);