2 // System.Windows.Forms.Design.ControlDesigner
5 // Ivan N. Zlatev (contact i-nZ.net)
7 // (C) 2006-2007 Ivan N. Zlatev
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System
.ComponentModel
;
33 using System
.ComponentModel
.Design
;
34 using System
.Runtime
.InteropServices
;
35 using System
.Windows
.Forms
;
37 using System
.Drawing
.Design
;
38 using System
.Collections
;
39 using System
.Windows
.Forms
.Design
.Behavior
;
41 namespace System
.Windows
.Forms
.Design
43 public class ControlDesigner
: ComponentDesigner
, IMessageReceiver
47 private WndProcRouter _messageRouter
;
48 private bool _locked
= false;
49 private bool _mouseDown
= false;
50 private bool _mouseMoveAfterMouseDown
= false;
51 private bool _mouseDownFirstMove
= false;
52 private bool _firstMouseMoveInClient
= true;
54 public ControlDesigner ()
58 #region Initialization
59 public override void Initialize (IComponent component
)
61 base.Initialize (component
);
63 if (!(component
is Control
))
64 throw new ArgumentException ("Component is not a Control.");
66 Control
.Text
= component
.Site
.Name
;
67 _messageRouter
= new WndProcRouter ((Control
) component
, (IMessageReceiver
) this);
68 Control
.WindowTarget
= _messageRouter
;
75 this.AllowDrop
= false;
77 // The control properties
79 Control
.Enabled
= true;
80 Control
.Visible
= true;
81 Control
.AllowDrop
= false;
83 this.Control
.DragDrop
+= new DragEventHandler (OnDragDrop
);
84 this.Control
.DragEnter
+= new DragEventHandler (OnDragEnter
);
85 this.Control
.DragLeave
+= new EventHandler (OnDragLeave
);
86 this.Control
.DragOver
+= new DragEventHandler (OnDragOver
);
88 // XXX: The control already has a handle?
90 if (Control
.IsHandleCreated
)
95 // The default implementation of this method sets the component's Text property to
96 // its name (Component.Site.Name), if the property field is of type string.
98 public override void OnSetComponentDefaults ()
100 if (this.Component
!= null && this.Component
.Site
!= null) {
101 PropertyDescriptor propertyDescriptor
= TypeDescriptor
.GetProperties (this.Component
)["Text"];
102 if (propertyDescriptor
!= null && !propertyDescriptor
.IsReadOnly
&&
103 propertyDescriptor
.PropertyType
== typeof (string)) {
104 propertyDescriptor
.SetValue (Component
, Component
.Site
.Name
);
111 #region Properties and Fields - AccessabilityObject Left
112 protected static readonly Point InvalidPoint
= new Point (int.MinValue
, int.MinValue
);
114 protected internal BehaviorService BehaviorService
{
115 get { throw new NotImplementedException (); }
118 public virtual Control Control
{
119 get { return (Control) base.Component; }
122 protected virtual bool EnableDragRect
{
126 public virtual SelectionRules SelectionRules
{
128 if (this.Control
== null)
129 return SelectionRules
.None
;
131 // all controls on the surface are visible
133 SelectionRules selectionRules
= SelectionRules
.Visible
;
135 if ((bool)GetValue (this.Component
, "Locked") == true) {
136 selectionRules
|= SelectionRules
.Locked
;
139 DockStyle dockStyle
= (DockStyle
) this.GetValue (base.Component
, "Dock", typeof (DockStyle
));
143 selectionRules
|= SelectionRules
.BottomSizeable
;
146 selectionRules
|= SelectionRules
.RightSizeable
;
148 case DockStyle
.Right
:
149 selectionRules
|= SelectionRules
.LeftSizeable
;
151 case DockStyle
.Bottom
:
152 selectionRules
|= SelectionRules
.TopSizeable
;
157 selectionRules
|= SelectionRules
.Moveable
;
158 selectionRules
|= SelectionRules
.AllSizeable
;
163 return selectionRules
;
167 public override ICollection AssociatedComponents
{
169 ArrayList components
= new ArrayList ();
170 foreach (Control c
in this.Control
.Controls
)
177 protected override IComponent ParentComponent
{
178 get { return this.GetValue (this.Control, "Parent") as Control;}
180 // TODO: implement ControlDesigner.ControlAccessabilityObject
182 public virtual AccessibleObject AccessibilityObject
{
184 if (accessibilityObj
== null)
185 accessibilityObj
= new AccessibleObject ();
187 return accessibilityObj
;
190 protected AccessibleObject accessibilityObj
;
197 protected void DefWndProc (ref Message m
)
199 _messageRouter
.ToControl (ref m
);
202 protected void BaseWndProc (ref Message m
)
204 _messageRouter
.ToSystem (ref m
);
207 void IMessageReceiver
.WndProc (ref Message m
)
209 this.WndProc (ref m
);
212 // Keep in mind that messages are recieved for the child controls if routed
214 protected virtual void WndProc (ref Message m
)
216 // Filter out kb input
218 if ((Native
.Msg
) m
.Msg
>= Native
.Msg
.WM_KEYFIRST
&& (Native
.Msg
) m
.Msg
<= Native
.Msg
.WM_KEYLAST
)
221 // Mouse messages should be routed the control, if GetHitTest (virtual) returns true.
223 if (IsMouseMessage ((Native
.Msg
) m
.Msg
) &&
224 this.GetHitTest (new Point (Native
.LoWord((int) m
.LParam
), Native
.HiWord (((int) m
.LParam
))))) {
226 this.DefWndProc (ref m
);
230 switch ((Native
.Msg
) m
.Msg
) {
231 case Native
.Msg
.WM_CREATE
:
232 this.DefWndProc (ref m
);
233 if (m
.HWnd
== this.Control
.Handle
)
237 case Native
.Msg
.WM_CONTEXTMENU
:
238 OnContextMenu (Native
.LoWord ((int) m
.LParam
), Native
.HiWord ((int) m
.LParam
));
241 case Native
.Msg
.WM_SETCURSOR
:
242 if (this.GetHitTest (new Point (Native
.LoWord ((int) m
.LParam
), Native
.HiWord ((int) m
.LParam
))))
243 this.DefWndProc (ref m
);
248 case Native
.Msg
.WM_SETFOCUS
:
249 this.DefWndProc (ref m
);
252 case Native
.Msg
.WM_PAINT
:
253 // Wait for control's WM_PAINT to complete first.
255 this.DefWndProc (ref m
);
257 Graphics gfx
= Graphics
.FromHwnd (m
.HWnd
);
258 PaintEventArgs args
= new PaintEventArgs (gfx
, this.Control
.Bounds
);
259 OnPaintAdornments (args
);
264 case Native
.Msg
.WM_NCRBUTTONDOWN
:
265 case Native
.Msg
.WM_NCLBUTTONDOWN
:
266 case Native
.Msg
.WM_NCMBUTTONDOWN
:
267 case Native
.Msg
.WM_NCLBUTTONDBLCLK
:
268 case Native
.Msg
.WM_NCRBUTTONDBLCLK
:
271 case Native
.Msg
.WM_LBUTTONDBLCLK
:
272 case Native
.Msg
.WM_RBUTTONDBLCLK
:
273 case Native
.Msg
.WM_MBUTTONDBLCLK
:
274 if ((Native
.Msg
)m
.Msg
== Native
.Msg
.WM_LBUTTONDBLCLK
)
275 _mouseButtonDown
= MouseButtons
.Left
;
276 else if ((Native
.Msg
)m
.Msg
== Native
.Msg
.WM_RBUTTONDBLCLK
)
277 _mouseButtonDown
= MouseButtons
.Right
;
278 else if ((Native
.Msg
)m
.Msg
== Native
.Msg
.WM_MBUTTONDBLCLK
)
279 _mouseButtonDown
= MouseButtons
.Middle
;
280 OnMouseDoubleClick ();
281 this.BaseWndProc (ref m
);
284 case Native
.Msg
.WM_MOUSEHOVER
:
288 case Native
.Msg
.WM_LBUTTONDOWN
:
289 case Native
.Msg
.WM_RBUTTONDOWN
:
290 case Native
.Msg
.WM_MBUTTONDOWN
:
291 _mouseMoveAfterMouseDown
= true;
292 if ((Native
.Msg
)m
.Msg
== Native
.Msg
.WM_LBUTTONDOWN
)
293 _mouseButtonDown
= MouseButtons
.Left
;
294 else if ((Native
.Msg
)m
.Msg
== Native
.Msg
.WM_RBUTTONDOWN
)
295 _mouseButtonDown
= MouseButtons
.Right
;
296 else if ((Native
.Msg
)m
.Msg
== Native
.Msg
.WM_MBUTTONDOWN
)
297 _mouseButtonDown
= MouseButtons
.Middle
;
299 if (_firstMouseMoveInClient
) {
301 _firstMouseMoveInClient
= false;
303 this.OnMouseDown (Native
.LoWord ((int)m
.LParam
), Native
.HiWord ((int)m
.LParam
));
304 this.BaseWndProc (ref m
);
307 case Native
.Msg
.WM_MOUSELEAVE
:
308 _firstMouseMoveInClient
= false;
310 this.BaseWndProc (ref m
);
313 // The WM_CANCELMODE message is sent to cancel certain modes, such as mouse capture.
314 // For example, the system sends this message to the active window when a dialog box
315 // or message box is displayed. Certain functions also send this message explicitly to
316 // the specified window regardless of whether it is the active window. For example,
317 // the EnableWindow function sends this message when disabling the specified window.
319 case Native
.Msg
.WM_CANCELMODE
:
320 OnMouseDragEnd (true);
321 this.DefWndProc (ref m
);
324 case Native
.Msg
.WM_LBUTTONUP
:
325 case Native
.Msg
.WM_RBUTTONUP
:
326 case Native
.Msg
.WM_NCLBUTTONUP
:
327 case Native
.Msg
.WM_NCRBUTTONUP
:
328 case Native
.Msg
.WM_MBUTTONUP
:
329 case Native
.Msg
.WM_NCMBUTTONUP
:
330 _mouseMoveAfterMouseDown
= false; // just in case
332 this.BaseWndProc (ref m
);
335 // // MWF Specific msg! - must reach control
337 // case Native.Msg.WM_MOUSE_ENTER:
338 // _firstMouseMoveInClient = false; // just so that nothing will get fired in WM_MOUSEMOVE
340 // this.DefWndProc (ref m);
343 // FIXME: The first MOUSEMOVE after WM_MOUSEDOWN should be ingored
345 case Native
.Msg
.WM_MOUSEMOVE
:
346 if (_mouseMoveAfterMouseDown
) { // mousemove is send after each mousedown so ignore that
347 _mouseMoveAfterMouseDown
= false;
348 this.BaseWndProc (ref m
);
351 // If selection is in progress pass the mouse move msg to the primary selection.
352 // If resizing is in progress pass to the parent of the primary selection (remmember that the selection
353 // frame is not a control and is drawn in the parent of the primary selection).
355 // Required in order for those 2 operations to continue when the mouse is moving over a control covering
356 // the one where the action takes place.
358 IUISelectionService uiSelectionServ
= this.GetService (typeof (IUISelectionService
)) as IUISelectionService
;
359 ISelectionService selectionServ
= this.GetService (typeof (ISelectionService
)) as ISelectionService
;
360 IDesignerHost host
= this.GetService (typeof (IDesignerHost
)) as IDesignerHost
;
363 if (uiSelectionServ
!= null && selectionServ
!= null && host
!= null) {
364 Control primarySelection
= selectionServ
.PrimarySelection
as Control
;
365 Point location
= new Point (Native
.LoWord ((int)m
.LParam
), Native
.HiWord ((int)m
.LParam
));
367 if (uiSelectionServ
.SelectionInProgress
&&
368 this.Component
!= host
.RootComponent
&&
369 this.Component
!= selectionServ
.PrimarySelection
) {
371 location
= primarySelection
.PointToClient (this.Control
.PointToScreen (location
));
372 Native
.SendMessage (primarySelection
.Handle
, (Native
.Msg
)m
.Msg
, m
.WParam
, Native
.LParam (location
.X
, location
.Y
));
374 else if (uiSelectionServ
.ResizeInProgress
&&
375 // this.Component != host.RootComponent &&
376 this.Control
.Parent
== ((Control
)selectionServ
.PrimarySelection
).Parent
) {
378 location
= this.Control
.Parent
.PointToClient (this.Control
.PointToScreen (location
));
379 Native
.SendMessage (this.Control
.Parent
.Handle
, (Native
.Msg
)m
.Msg
, m
.WParam
, Native
.LParam (location
.X
, location
.Y
));
382 this.OnMouseMove (location
.X
, location
.Y
);
386 this.OnMouseMove (Native
.LoWord ((int)m
.LParam
), Native
.HiWord ((int)m
.LParam
));
388 this.BaseWndProc (ref m
);
392 // Pass everything else to the control and return
394 this.DefWndProc (ref m
);
399 // Indicates whether a mouse click at the specified point should be handled by the control.
401 protected virtual bool GetHitTest (Point point
)
406 private bool IsMouseMessage (Native
.Msg msg
)
408 if (msg
>= Native
.Msg
.WM_MOUSEFIRST
&& msg
<= Native
.Msg
.WM_MOUSELAST
)
410 else if (msg
>= Native
.Msg
.WM_NCLBUTTONDOWN
&& msg
<= Native
.Msg
.WM_NCMBUTTONDBLCLK
)
412 else if (msg
== Native
.Msg
.WM_MOUSEHOVER
|| msg
== Native
.Msg
.WM_MOUSELEAVE
)
420 #region WndProc Message Handlers
422 protected virtual void OnSetCursor ()
426 // Raises the DoDefaultAction.
428 private void OnMouseDoubleClick ()
431 base.DoDefaultAction ();
433 catch (Exception e
) {
434 this.DisplayError (e
);
438 internal virtual void OnMouseDown (int x
, int y
)
441 _mouseDownFirstMove
= true;
442 IUISelectionService uiSelection
= this.GetService (typeof (IUISelectionService
)) as IUISelectionService
;
443 if (uiSelection
!= null && uiSelection
.AdornmentsHitTest (this.Control
, x
, y
)) {
444 // 1) prevent primary selection from being changed at this point.
445 // 2) delegate behaviour in the future to the IUISelectionService
448 ISelectionService selectionService
= this.GetService (typeof (ISelectionService
)) as ISelectionService
;
449 if (selectionService
!= null) {
450 selectionService
.SetSelectedComponents (new IComponent
[] { this.Component }
);
455 // Note that this is a pure WM_MOUSEMOVE acceptor
457 internal virtual void OnMouseMove (int x
, int y
)
460 if (_mouseDownFirstMove
) {
461 OnMouseDragBegin (x
, y
);
462 _mouseDownFirstMove
= false;
465 OnMouseDragMove (x
, y
);
471 internal virtual void OnMouseUp ()
473 IUISelectionService uiSelection
= this.GetService (typeof (IUISelectionService
)) as IUISelectionService
;
476 this.OnMouseDragEnd (false);
477 if (uiSelection
!= null && (uiSelection
.SelectionInProgress
|| uiSelection
.ResizeInProgress
)) {
478 uiSelection
.MouseDragEnd (false);
483 if (uiSelection
!= null && (uiSelection
.SelectionInProgress
|| uiSelection
.ResizeInProgress
)) {
484 // If the mouse up happens over the a control which is not defacto participating in
485 // the selection or resizing in progress, then inform the IUISelectionService of that event
487 uiSelection
.MouseDragEnd (false);
492 protected virtual void OnContextMenu (int x
, int y
)
494 IMenuCommandService service
= this.GetService (typeof(IMenuCommandService
)) as IMenuCommandService
;
495 if (service
!= null) {
496 service
.ShowContextMenu (MenuCommands
.SelectionMenu
, x
, y
);
500 protected virtual void OnMouseEnter ()
504 protected virtual void OnMouseHover ()
508 protected virtual void OnMouseLeave ()
512 // Provides an opportunity to perform additional processing immediately
513 // after the control handle has been created.
515 protected virtual void OnCreateHandle ()
519 // Called after the control is done with the painting so that the designer host
520 // can paint stuff over it.
522 protected virtual void OnPaintAdornments (PaintEventArgs pe
)
528 #region Mouse Dragging
530 MouseButtons _mouseButtonDown
;
532 internal MouseButtons MouseButtonDown
{
533 get { return _mouseButtonDown; }
536 protected virtual void OnMouseDragBegin (int x
, int y
)
538 IUISelectionService selectionServ
= this.GetService (typeof (IUISelectionService
)) as IUISelectionService
;
539 if (selectionServ
!= null && ((this.SelectionRules
& SelectionRules
.Moveable
) == SelectionRules
.Moveable
)) {
540 // once this is fired the parent control (parentcontroldesigner) will start getting dragover events.
542 selectionServ
.DragBegin ();
546 protected virtual void OnMouseDragMove (int x
, int y
)
550 protected virtual void OnMouseDragEnd (bool cancel
)
557 protected void HookChildControls (Control firstChild
)
559 if (firstChild
!= null) {
560 foreach (Control control
in firstChild
.Controls
) {
561 control
.WindowTarget
= (IWindowTarget
) new WndProcRouter (control
, (IMessageReceiver
) this);
566 protected void UnhookChildControls (Control firstChild
)
568 if (firstChild
!= null) {
569 foreach (Control control
in firstChild
.Controls
) {
570 if (control
.WindowTarget
is WndProcRouter
)
571 ((WndProcRouter
) control
.WindowTarget
).Dispose ();
576 // Someone please tell me why the hell is this method here?
577 // What about having ParentControlDesigner.CanParent(...) ?
579 public virtual bool CanBeParentedTo (IDesigner parentDesigner
)
581 IDesignerHost host
= this.GetService (typeof (IDesignerHost
)) as IDesignerHost
;
583 if (parentDesigner
is ParentControlDesigner
&&
584 this.Component
!= host
.RootComponent
&&
585 !this.Control
.Controls
.Contains (((ParentControlDesigner
)parentDesigner
).Control
)) {
593 protected void DisplayError (Exception e
)
596 IUIService uiService
= GetService (typeof (IUIService
)) as IUIService
;
597 if (uiService
!= null) {
598 uiService
.ShowError (e
);
601 string errorText
= e
.Message
;
602 if (errorText
== null || errorText
== String
.Empty
)
603 errorText
= e
.ToString ();
604 MessageBox
.Show (Control
, errorText
, "Error", MessageBoxButtons
.OK
, MessageBoxIcon
.Exclamation
);
609 #region Drag and Drop handling
611 // Enables or disables Drag and Drop
613 protected void EnableDragDrop(bool value)
615 if (this.Control
!= null) {
617 Control
.DragDrop
+= new DragEventHandler (OnDragDrop
);
618 Control
.DragOver
+= new DragEventHandler (OnDragOver
);
619 Control
.DragEnter
+= new DragEventHandler (OnDragEnter
);
620 Control
.DragLeave
+= new EventHandler (OnDragLeave
);
621 Control
.GiveFeedback
+= new GiveFeedbackEventHandler (OnGiveFeedback
);
622 Control
.AllowDrop
= true;
625 Control
.DragDrop
-= new DragEventHandler (OnDragDrop
);
626 Control
.DragOver
-= new DragEventHandler (OnDragOver
);
627 Control
.DragEnter
-= new DragEventHandler (OnDragEnter
);
628 Control
.DragLeave
-= new EventHandler (OnDragLeave
);
629 Control
.GiveFeedback
-= new GiveFeedbackEventHandler (OnGiveFeedback
);
630 Control
.AllowDrop
= false;
635 private void OnGiveFeedback (object sender
, GiveFeedbackEventArgs e
)
640 private void OnDragDrop (object sender
, DragEventArgs e
)
645 private void OnDragEnter (object sender
, DragEventArgs e
)
650 private void OnDragLeave (object sender
, EventArgs e
)
655 private void OnDragOver (object sender
, DragEventArgs e
)
660 protected virtual void OnGiveFeedback (GiveFeedbackEventArgs e
)
662 e
.UseDefaultCursors
= false;
665 protected virtual void OnDragDrop (DragEventArgs de
)
669 protected virtual void OnDragEnter (DragEventArgs de
)
673 protected virtual void OnDragLeave (EventArgs e
)
677 protected virtual void OnDragOver (DragEventArgs de
)
683 #region Redirected Properties
685 // This IDesignerFilter interface method override adds a set of properties
686 // to this designer's component at design time. This method adds the following
687 // browsable properties: "Visible", "Enabled", "ContextMenu", "AllowDrop", "Location",
688 // "Name", "Controls", and "Locked".
690 // XXX: We aren't redirecting Controls
692 protected override void PreFilterProperties (IDictionary properties
)
694 base.PreFilterProperties (properties
);
696 string[] newProperties
= {
697 "Visible", "Enabled", "ContextMenu", "AllowDrop", "Location", "Name",
700 Attribute
[][] attributes
= {
701 new Attribute
[] { new DefaultValueAttribute (true) }
,
702 new Attribute
[] { new DefaultValueAttribute (true) }
,
703 new Attribute
[] { new DefaultValueAttribute (null) }
,
704 new Attribute
[] { new DefaultValueAttribute (false) }
,
705 new Attribute
[] { new DefaultValueAttribute (typeof (Point), "0, 0") }
,
709 PropertyDescriptor propertyDescriptor
= null;
711 // If existing redirect each property to the ControlDesigner.
713 for (int i
=0; i
< newProperties
.Length
; i
++) {
714 propertyDescriptor
= properties
[newProperties
[i
]] as PropertyDescriptor
;
715 if (propertyDescriptor
!= null)
716 properties
[newProperties
[i
]] = TypeDescriptor
.CreateProperty (typeof (ControlDesigner
),
721 // This one is a must to have.
723 properties
["Locked"] = TypeDescriptor
.CreateProperty (typeof (ControlDesigner
), "Locked",
726 DesignOnlyAttribute
.Yes
,
727 BrowsableAttribute
.Yes
,
728 CategoryAttribute
.Design
,
729 new DefaultValueAttribute (false),
730 new DescriptionAttribute("The Locked property determines if we can move or resize the control.")
735 // ShadowProperties returns the real property value if there is no "shadow" one set
736 // Welcome to the land of shadows... :-)
738 private bool Visible
{
739 get { return (bool) base.ShadowProperties["Visible"]; }
740 set { base.ShadowProperties["Visible"] = value; }
743 private bool Enabled
{
744 get { return (bool) base.ShadowProperties["Enabled"]; }
745 set { base.ShadowProperties["Enabled"] = value; }
748 private bool Locked
{
749 get { return _locked; }
750 set { _locked = value; }
753 private bool AllowDrop
{
754 get { return (bool)base.ShadowProperties["AllowDrop"]; }
755 set { base.ShadowProperties["AllowDrop"] = value; }
758 private string Name
{
759 get { return base.Component.Site.Name; }
760 set { base.Component.Site.Name = value; }
763 private ContextMenu ContextMenu
{
764 get { return (ContextMenu) base.ShadowProperties["ContextMenu"]; }
765 set { base.ShadowProperties["ContextMenu"] = value; }
768 private Point Location
{
769 get { return this.Control.Location; }
770 set { this.Control.Location = value; }
775 #region Utility methods
776 internal object GetValue (object component
, string propertyName
)
778 return this.GetValue (component
, propertyName
, null);
781 internal object GetValue (object component
, string propertyName
, Type propertyType
)
783 PropertyDescriptor prop
= TypeDescriptor
.GetProperties (component
)[propertyName
] as PropertyDescriptor
;
785 throw new InvalidOperationException ("Property \"" + propertyName
+ "\" is missing on " +
786 component
.GetType().AssemblyQualifiedName
);
787 if (propertyType
!= null && !propertyType
.IsAssignableFrom (prop
.PropertyType
))
788 throw new InvalidOperationException ("Types do not match: " + prop
.PropertyType
.AssemblyQualifiedName
+
789 " : " + propertyType
.AssemblyQualifiedName
);
790 return prop
.GetValue (component
);
793 internal void SetValue (object component
, string propertyName
, object value)
795 PropertyDescriptor prop
= TypeDescriptor
.GetProperties (component
)[propertyName
] as PropertyDescriptor
;
798 throw new InvalidOperationException ("Property \"" + propertyName
+ "\" is missing on " +
799 component
.GetType().AssemblyQualifiedName
);
800 if (!prop
.PropertyType
.IsAssignableFrom (value.GetType ()))
801 throw new InvalidOperationException ("Types do not match: " + value.GetType ().AssemblyQualifiedName
+
802 " : " + prop
.PropertyType
.AssemblyQualifiedName
);
803 if (!prop
.IsReadOnly
)
804 prop
.SetValue (component
, value);
808 protected override void Dispose (bool disposing
)
811 if (this.Control
!= null) {
812 UnhookChildControls (Control
);
813 OnMouseDragEnd (true);
814 _messageRouter
.Dispose ();
815 this.Control
.DragDrop
-= new DragEventHandler (OnDragDrop
);
816 this.Control
.DragEnter
-= new DragEventHandler (OnDragEnter
);
817 this.Control
.DragLeave
-= new EventHandler (OnDragLeave
);
818 this.Control
.DragOver
-= new DragEventHandler (OnDragOver
);
826 public virtual ControlDesigner
InternalControlDesigner (int internalControlIndex
)
831 public virtual int NumberOfInternalControlDesigners ()
836 protected bool EnableDesignMode (Control child
, string name
)
839 throw new ArgumentNullException ("name");
841 throw new ArgumentNullException ("child");
843 bool success
= false;
844 INestedContainer nestedContainer
= this.GetService (typeof (INestedContainer
)) as INestedContainer
;
845 if (nestedContainer
!= null) {
846 nestedContainer
.Add (child
, name
);
852 #region NET_2_0 Stubs
855 public class ControlDesignerAccessibleObject
: AccessibleObject
858 public ControlDesignerAccessibleObject (ControlDesigner designer
, Control control
)
860 throw new NotImplementedException ();
864 public override AccessibleObject
GetChild (int index
)
866 throw new NotImplementedException ();
870 public override int GetChildCount ()
872 throw new NotImplementedException ();
876 public override AccessibleObject
GetFocused ()
878 throw new NotImplementedException ();
882 public override AccessibleObject
GetSelected ()
884 throw new NotImplementedException ();
888 public override AccessibleObject
HitTest (int x
, int y
)
890 throw new NotImplementedException ();
894 public override Rectangle Bounds
{
895 get { throw new NotImplementedException (); }
899 public override string DefaultAction
{
900 get { throw new NotImplementedException (); }
904 public override string Description
{
905 get { throw new NotImplementedException (); }
909 public override string Name
{
910 get { throw new NotImplementedException (); }
914 public override AccessibleObject Parent
{
915 get { throw new NotImplementedException (); }
919 public override AccessibleRole Role
{
920 get { throw new NotImplementedException (); }
924 public override AccessibleStates State
{
925 get { throw new NotImplementedException (); }
929 public override string Value
{
930 get { throw new NotImplementedException (); }
935 protected virtual ControlBodyGlyph
GetControlGlyph (GlyphSelectionType selectionType
)
937 throw new NotImplementedException ();
941 public virtual GlyphCollection
GetGlyphs (GlyphSelectionType selectionType
)
943 throw new NotImplementedException ();
947 public override void InitializeExistingComponent (IDictionary defaultValues
)
949 throw new NotImplementedException ();
953 public override void InitializeNewComponent (IDictionary defaultValues
)
955 throw new NotImplementedException ();
959 protected virtual void OnDragComplete (DragEventArgs de
)
961 throw new NotImplementedException ();
965 protected override InheritanceAttribute InheritanceAttribute
{
966 get { throw new NotImplementedException (); }
970 public virtual IList SnapLines
{
971 get { throw new NotImplementedException (); }
975 public virtual bool ParticipatesWithSnapLines
{
976 get { throw new NotImplementedException (); }
980 public bool AutoResizeHandles
{
981 get { throw new NotImplementedException (); }
982 set { throw new NotImplementedException (); }