// Authors:
// Jonathan Pobst (monkey@jpobst.com)
//
-#if NET_2_0
+
using System.Drawing;
using System.ComponentModel;
if (c == null)
throw new ArgumentNullException ("c");
+ this.RightToLeft = RightToLeft.No;
this.control = c;
this.control_align = ContentAlignment.MiddleCenter;
+ this.control.TabStop = false;
+ this.control.Resize += ControlResizeHandler;
+ this.Size = DefaultSize;
this.OnSubscribeControlEvents (this.control);
}
get { return control.CanSelect; }
}
+ [DefaultValue (true)]
public bool CausesValidation {
get { return control.CausesValidation; }
set { control.CausesValidation = value; }
public ContentAlignment ControlAlign {
get { return this.control_align; }
set {
- if (!Enum.IsDefined (typeof (ContentAlignment), value))
- throw new InvalidEnumArgumentException (string.Format ("Enum argument value '{0}' is not valid for ContentAlignment", value));
-
- this.control_align = value;
+ if (control_align != value) {
+ if (!Enum.IsDefined (typeof (ContentAlignment), value))
+ throw new InvalidEnumArgumentException (string.Format ("Enum argument value '{0}' is not valid for ContentAlignment", value));
+
+ this.control_align = value;
+
+ if (control != null)
+ control.Bounds = AlignInRectangle (this.Bounds, control.Size, this.control_align);
+ }
}
}
set { base.ImageTransparentColor = value; }
}
+ public override RightToLeft RightToLeft {
+ get { return base.RightToLeft; }
+ set { base.RightToLeft = value; }
+ }
+
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public new bool RightToLeftAutoMirrorImage {
+ get { return base.RightToLeftAutoMirrorImage; }
+ set { base.RightToLeftAutoMirrorImage = value; }
+ }
+
public override bool Selected {
get { return base.Selected; }
}
}
}
- public override Size Size
- {
- get { return control.Size; }
+ public override Size Size {
+ get { return base.Size; }
set { control.Size = value; base.Size = value; if (this.Owner != null) this.Owner.PerformLayout (); }
}
[DefaultValue ("")]
public override string Text {
- get { return base.Text; }
+ get { return control.Text; }
set {
base.Text = value;
control.Text = value;
set { base.TextAlign = value; }
}
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [DefaultValue (ToolStripTextDirection.Horizontal)]
+ public override ToolStripTextDirection TextDirection {
+ get { return base.TextDirection; }
+ set { base.TextDirection = value; }
+ }
+
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
public new TextImageRelation TextImageRelation {
if (control == null)
return new Size (23, 23);
- return control.GetPreferredSize (Size.Empty);
+ return control.Size;
}
}
#endregion
public override Size GetPreferredSize (Size constrainingSize)
{
- return control.Size;
+ return control.GetPreferredSize (constrainingSize);
}
[EditorBrowsable (EditorBrowsableState.Never)]
protected override void Dispose (bool disposing)
{
base.Dispose (disposing);
-
- if (!control.IsDisposed)
+
+ if (control.Created && !control.IsDisposed)
control.Dispose ();
}
protected override void OnBoundsChanged ()
{
- base.OnBoundsChanged ();
+ if (control != null)
+ control.Bounds = AlignInRectangle (this.Bounds, control.Size, this.control_align);
- control.Size = this.Size;
- if (this.Parent != null) {
- OnLayout (new LayoutEventArgs (null, string.Empty));
- }
+ base.OnBoundsChanged ();
}
protected virtual void OnEnter (EventArgs e)
if (eh != null)
eh (this, e);
}
+
+ void ControlResizeHandler (object obj, EventArgs args)
+ {
+ OnHostedControlResize (args);
+ }
protected virtual void OnHostedControlResize (EventArgs e)
{
+ // Since the control size has been just adjusted, only update the location
+ if (control != null)
+ control.Location = AlignInRectangle (this.Bounds, control.Size, this.control_align).Location;
}
protected virtual void OnKeyDown (KeyEventArgs e)
if (eh != null)
eh (this, e);
}
+
+ protected internal override bool ProcessCmdKey (ref Message m, Keys keyData)
+ {
+ return base.ProcessCmdKey (ref m, keyData);
+ }
+
+ protected internal override bool ProcessDialogKey (Keys keyData)
+ {
+ return base.ProcessDialogKey (keyData);
+ }
+
+ protected override void SetVisibleCore (bool visible)
+ {
+ base.SetVisibleCore (visible);
+ this.control.Visible = visible;
+
+ if (control != null)
+ control.Bounds = AlignInRectangle (this.Bounds, control.Size, this.control_align);
+ }
#endregion
#region Public Events
#endregion
#region Private Methods
+ internal override ToolStripTextDirection DefaultTextDirection { get { return ToolStripTextDirection.Horizontal; } }
+
+ internal override void Dismiss (ToolStripDropDownCloseReason reason)
+ {
+ if (this.Selected)
+ this.Parent.Focus ();
+
+ base.Dismiss (reason);
+ }
+
private void HandleEnter (object sender, EventArgs e)
{
this.OnEnter (e);
{
this.OnValidating (e);
}
+
+ internal override bool InternalVisible {
+ get { return base.InternalVisible; }
+ set {
+ Control.Visible = value;
+ base.InternalVisible = value;
+ }
+ }
#endregion
}
}
-#endif