disable broken tests on net_4_0
[mcs.git] / class / Managed.Windows.Forms / System.Windows.Forms.Design / ComponentEditorPage.cs
blob320c3071e1bf00fd11040f75111f04a58b56ec62
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:
8 //
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 //
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 Novell, Inc.
22 // Authors:
23 // Andreas Nahr (ClassDevelopment@A-SoftTech.com)
26 using System.ComponentModel;
27 using System.Drawing;
28 using System.Runtime.InteropServices;
30 namespace System.Windows.Forms.Design
32 #if NET_2_0
33 [ClassInterfaceAttribute (ClassInterfaceType.AutoDispatch)]
34 [ComVisible (true)]
35 #endif
36 public abstract class ComponentEditorPage : Panel
38 private bool commitOnDeactivate = false;
39 private IComponent component;
40 private bool firstActivate = true;
41 private Icon icon;
42 private int loading = 0;
43 private bool loadRequired = false;
44 private IComponentEditorPageSite pageSite;
46 public ComponentEditorPage ()
50 #if NET_2_0
51 [Browsable (false)]
52 [EditorBrowsable (EditorBrowsableState.Never)]
53 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
54 new public virtual bool AutoSize {
55 get { return base.AutoSize; }
56 set { base.AutoSize = value; }
58 #endif
60 public bool CommitOnDeactivate
62 get { return commitOnDeactivate; }
63 set { commitOnDeactivate = value; }
66 protected IComponent Component {
67 get { return component; }
68 set { component = value; }
71 [MonoTODO ("Find out what this does.")]
72 protected override CreateParams CreateParams {
73 get {
74 throw new NotImplementedException ();
78 protected bool FirstActivate {
79 get { return firstActivate; }
80 set { firstActivate = value; }
83 public Icon Icon {
84 get { return icon; }
85 set { icon = value; }
88 protected int Loading {
89 get { return loading; }
90 set { loading = value; }
93 protected bool LoadRequired {
94 get { return loadRequired; }
95 set { loadRequired = value; }
98 protected IComponentEditorPageSite PageSite {
99 get { return pageSite; }
100 set { pageSite = value; }
103 public virtual string Title {
104 get { return base.Text; }
107 public virtual void Activate ()
109 Visible = true;
110 firstActivate = false;
111 if (loadRequired) {
112 EnterLoadingMode ();
113 LoadComponent ();
114 ExitLoadingMode ();
118 public virtual void ApplyChanges ()
120 SaveComponent ();
123 public virtual void Deactivate ()
125 Visible = false;
128 protected void EnterLoadingMode ()
130 loading++;
133 protected void ExitLoadingMode ()
135 loading--;
138 public virtual Control GetControl ()
140 return this;
143 protected IComponent GetSelectedComponent ()
145 return component;
148 protected bool IsFirstActivate ()
150 return firstActivate;
153 protected bool IsLoading ()
155 return (loading != 0);
158 public virtual bool IsPageMessage (ref Message msg)
160 return PreProcessMessage (ref msg);
163 protected abstract void LoadComponent ();
165 [MonoTODO ("Find out what this does.")]
166 public virtual void OnApplyComplete ()
170 protected virtual void ReloadComponent ()
172 loadRequired = true;
175 protected abstract void SaveComponent ();
177 public virtual void SetComponent (IComponent component)
179 this.component = component;
180 ReloadComponent ();
183 [MonoTODO ("Find out what this does.")]
184 protected virtual void SetDirty ()
188 public virtual void SetSite (IComponentEditorPageSite site)
190 pageSite = site;
191 pageSite.GetControl ().Controls.Add (this);
195 public virtual void ShowHelp ()
199 public virtual bool SupportsHelp ()
201 return false;
204 #region Public Events
205 #if NET_2_0
206 [Browsable (false)]
207 [EditorBrowsable (EditorBrowsableState.Never)]
208 public new event EventHandler AutoSizeChanged {
209 add { base.AutoSizeChanged += value; }
210 remove { base.AutoSizeChanged -= value; }
212 #endif
213 #endregion