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.
20 // Copyright (c) 2004-2005 Novell, Inc.
23 // Peter Bartok pbartok@novell.com
27 using System.ComponentModel;
28 using System.ComponentModel.Design;
30 using System.Runtime.InteropServices;
32 namespace System.Windows.Forms {
33 [DefaultEvent("Load")]
34 [DesignerCategory("UserControl")]
35 [Designer("System.Windows.Forms.Design.ControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
36 [Designer("System.Windows.Forms.Design.UserControlDocumentDesigner, " + Consts.AssemblySystem_Design, typeof(IRootDesigner))]
38 [ClassInterface (ClassInterfaceType.AutoDispatch)]
41 public class UserControl : ContainerControl {
42 #region Public Constructors
43 public UserControl() {
45 SetStyle (ControlStyles.SupportsTransparentBackColor, true);
48 #endregion // Public Constructors
50 #region Public Instance Properties
51 protected override Size DefaultSize {
53 return new Size(150, 150);
60 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
61 [EditorBrowsable(EditorBrowsableState.Never)]
62 public override string Text {
71 #endregion // Public Instance Properties
73 #region Protected Instance Methods
74 [EditorBrowsable(EditorBrowsableState.Advanced)]
75 protected override void OnCreateControl() {
76 base.OnCreateControl();
78 // The OnCreateControl isn't neccessarily raised *before* it
79 // becomes first visible, but that's the best we've got
80 OnLoad(EventArgs.Empty);
83 [EditorBrowsable(EditorBrowsableState.Advanced)]
84 protected virtual void OnLoad(EventArgs e) {
85 EventHandler eh = (EventHandler)(Events [LoadEvent]);
90 [EditorBrowsable(EditorBrowsableState.Advanced)]
91 protected override void OnMouseDown(MouseEventArgs e) {
95 [EditorBrowsable(EditorBrowsableState.Advanced)]
96 protected override void WndProc(ref Message m) {
99 #endregion // Protected Instance Methods
102 static object LoadEvent = new object ();
104 public event EventHandler Load {
105 add { Events.AddHandler (LoadEvent, value); }
106 remove { Events.RemoveHandler (LoadEvent, value); }
110 [EditorBrowsable(EditorBrowsableState.Never)]
111 public new event EventHandler TextChanged {
112 add { base.TextChanged += value; }
113 remove { base.TextChanged -= value; }
119 protected override void OnResize (EventArgs e)
125 [DefaultValue (BorderStyle.None)]
126 [EditorBrowsable (EditorBrowsableState.Always)]
127 public BorderStyle BorderStyle {
128 get { return InternalBorderStyle; }
129 set { InternalBorderStyle = value; }