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
;
40 using System
.Windows
.Forms
.Design
.Behavior
;
43 namespace System
.Windows
.Forms
.Design
45 public class ControlDesigner
: ComponentDesigner
, IMessageReceiver
49 private WndProcRouter _messageRouter
;
50 private bool _locked
= false;
51 private bool _mouseDown
= false;
52 private bool _mouseMoveAfterMouseDown
= false;
53 private bool _mouseDownFirstMove
= false;
54 private bool _firstMouseMoveInClient
= true;
56 public ControlDesigner ()
60 #region Initialization
61 public override void Initialize (IComponent component
)
63 base.Initialize (component
);
65 if (!(component
is Control
))
66 throw new ArgumentException ("Component is not a Control.");
68 Control
.Text
= component
.Site
.Name
;
69 _messageRouter
= new WndProcRouter ((Control
) component
, (IMessageReceiver
) this);
70 Control
.WindowTarget
= _messageRouter
;
77 this.AllowDrop
= false;
79 // The control properties
81 Control
.Enabled
= true;
82 Control
.Visible
= true;
83 Control
.AllowDrop
= false;
85 this.Control
.DragDrop
+= new DragEventHandler (OnDragDrop
);
86 this.Control
.DragEnter
+= new DragEventHandler (OnDragEnter
);
87 this.Control
.DragLeave
+= new EventHandler (OnDragLeave
);
88 this.Control
.DragOver
+= new DragEventHandler (OnDragOver
);
90 // XXX: The control already has a handle?
92 if (Control
.IsHandleCreated
)
97 // The default implementation of this method sets the component's Text property to
98 // its name (Component.Site.Name), if the property field is of type string.
100 public override void OnSetComponentDefaults ()
102 if (this.Component
!= null && this.Component
.Site
!= null) {
103 PropertyDescriptor propertyDescriptor
= TypeDescriptor
.GetProperties (this.Component
)["Text"];
104 if (propertyDescriptor
!= null && !propertyDescriptor
.IsReadOnly
&&
105 propertyDescriptor
.PropertyType
== typeof (string)) {
106 propertyDescriptor
.SetValue (Component
, Component
.Site
.Name
);
113 #region Properties and Fields - AccessabilityObject Left
114 protected static readonly Point InvalidPoint
= new Point (int.MinValue
, int.MinValue
);
117 protected internal BehaviorService BehaviorService
{
118 get { throw new NotImplementedException (); }
122 public virtual Control Control
{
123 get { return (Control) base.Component; }
126 protected virtual bool EnableDragRect
{
130 public virtual SelectionRules SelectionRules
{
132 if (this.Control
== null)
133 return SelectionRules
.None
;
135 // all controls on the surface are visible
137 SelectionRules selectionRules
= SelectionRules
.Visible
;
139 if ((bool)GetValue (this.Component
, "Locked") == true) {
140 selectionRules
|= SelectionRules
.Locked
;
143 DockStyle dockStyle
= (DockStyle
) this.GetValue (base.Component
, "Dock", typeof (DockStyle
));
147 selectionRules
|= SelectionRules
.BottomSizeable
;
150 selectionRules
|= SelectionRules
.RightSizeable
;
152 case DockStyle
.Right
:
153 selectionRules
|= SelectionRules
.LeftSizeable
;
155 case DockStyle
.Bottom
:
156 selectionRules
|= SelectionRules
.TopSizeable
;
161 selectionRules
|= SelectionRules
.Moveable
;
162 selectionRules
|= SelectionRules
.AllSizeable
;
167 return selectionRules
;
171 public override ICollection AssociatedComponents
{
173 ArrayList components
= new ArrayList ();
174 foreach (Control c
in this.Control
.Controls
)
182 protected override IComponent ParentComponent
{
183 get { return this.GetValue (this.Control, "Parent") as Control;}
186 // TODO: implement ControlDesigner.ControlAccessabilityObject
188 public virtual AccessibleObject AccessibilityObject
{
190 if (accessibilityObj
== null)
191 accessibilityObj
= new AccessibleObject ();
193 return accessibilityObj
;
196 protected AccessibleObject accessibilityObj
;
203 protected void DefWndProc (ref Message m
)
205 _messageRouter
.ToControl (ref m
);
208 protected void BaseWndProc (ref Message m
)
210 _messageRouter
.ToSystem (ref m
);
213 void IMessageReceiver
.WndProc (ref Message m
)
215 this.WndProc (ref m
);
218 // Keep in mind that messages are recieved for the child controls if routed
220 protected virtual void WndProc (ref Message m
)
222 // Filter out kb input
224 if ((Native
.Msg
) m
.Msg
>= Native
.Msg
.WM_KEYFIRST
&& (Native
.Msg
) m
.Msg
<= Native
.Msg
.WM_KEYLAST
)
227 // Mouse messages should be routed the control, if GetHitTest (virtual) returns true.
229 if (IsMouseMessage ((Native
.Msg
) m
.Msg
) &&
230 this.GetHitTest (new Point (Native
.LoWord((int) m
.LParam
), Native
.HiWord (((int) m
.LParam
))))) {
232 this.DefWndProc (ref m
);
236 switch ((Native
.Msg
) m
.Msg
) {
237 case Native
.Msg
.WM_CREATE
:
238 this.DefWndProc (ref m
);
239 if (m
.HWnd
== this.Control
.Handle
)
243 case Native
.Msg
.WM_CONTEXTMENU
:
244 OnContextMenu (Native
.LoWord ((int) m
.LParam
), Native
.HiWord ((int) m
.LParam
));
247 case Native
.Msg
.WM_SETCURSOR
:
248 if (this.GetHitTest (new Point (Native
.LoWord ((int) m
.LParam
), Native
.HiWord ((int) m
.LParam
))))
249 this.DefWndProc (ref m
);
254 case Native
.Msg
.WM_SETFOCUS
:
255 this.DefWndProc (ref m
);
258 case Native
.Msg
.WM_PAINT
:
259 // Wait for control's WM_PAINT to complete first.
261 this.DefWndProc (ref m
);
263 Graphics gfx
= Graphics
.FromHwnd (m
.HWnd
);
264 PaintEventArgs args
= new PaintEventArgs (gfx
, this.Control
.Bounds
);
265 OnPaintAdornments (args
);
270 case Native
.Msg
.WM_NCRBUTTONDOWN
:
271 case Native
.Msg
.WM_NCLBUTTONDOWN
:
272 case Native
.Msg
.WM_NCMBUTTONDOWN
:
273 case Native
.Msg
.WM_NCLBUTTONDBLCLK
:
274 case Native
.Msg
.WM_NCRBUTTONDBLCLK
:
277 case Native
.Msg
.WM_LBUTTONDBLCLK
:
278 case Native
.Msg
.WM_RBUTTONDBLCLK
:
279 case Native
.Msg
.WM_MBUTTONDBLCLK
:
280 if ((Native
.Msg
)m
.Msg
== Native
.Msg
.WM_LBUTTONDBLCLK
)
281 _mouseButtonDown
= MouseButtons
.Left
;
282 else if ((Native
.Msg
)m
.Msg
== Native
.Msg
.WM_RBUTTONDBLCLK
)
283 _mouseButtonDown
= MouseButtons
.Right
;
284 else if ((Native
.Msg
)m
.Msg
== Native
.Msg
.WM_MBUTTONDBLCLK
)
285 _mouseButtonDown
= MouseButtons
.Middle
;
286 OnMouseDoubleClick ();
287 this.BaseWndProc (ref m
);
290 case Native
.Msg
.WM_MOUSEHOVER
:
294 case Native
.Msg
.WM_LBUTTONDOWN
:
295 case Native
.Msg
.WM_RBUTTONDOWN
:
296 case Native
.Msg
.WM_MBUTTONDOWN
:
297 _mouseMoveAfterMouseDown
= true;
298 if ((Native
.Msg
)m
.Msg
== Native
.Msg
.WM_LBUTTONDOWN
)
299 _mouseButtonDown
= MouseButtons
.Left
;
300 else if ((Native
.Msg
)m
.Msg
== Native
.Msg
.WM_RBUTTONDOWN
)
301 _mouseButtonDown
= MouseButtons
.Right
;
302 else if ((Native
.Msg
)m
.Msg
== Native
.Msg
.WM_MBUTTONDOWN
)
303 _mouseButtonDown
= MouseButtons
.Middle
;
305 if (_firstMouseMoveInClient
) {
307 _firstMouseMoveInClient
= false;
309 this.OnMouseDown (Native
.LoWord ((int)m
.LParam
), Native
.HiWord ((int)m
.LParam
));
310 this.BaseWndProc (ref m
);
313 case Native
.Msg
.WM_MOUSELEAVE
:
314 _firstMouseMoveInClient
= false;
316 this.BaseWndProc (ref m
);
319 // The WM_CANCELMODE message is sent to cancel certain modes, such as mouse capture.
320 // For example, the system sends this message to the active window when a dialog box
321 // or message box is displayed. Certain functions also send this message explicitly to
322 // the specified window regardless of whether it is the active window. For example,
323 // the EnableWindow function sends this message when disabling the specified window.
325 case Native
.Msg
.WM_CANCELMODE
:
326 OnMouseDragEnd (true);
327 this.DefWndProc (ref m
);
330 case Native
.Msg
.WM_LBUTTONUP
:
331 case Native
.Msg
.WM_RBUTTONUP
:
332 case Native
.Msg
.WM_NCLBUTTONUP
:
333 case Native
.Msg
.WM_NCRBUTTONUP
:
334 case Native
.Msg
.WM_MBUTTONUP
:
335 case Native
.Msg
.WM_NCMBUTTONUP
:
336 _mouseMoveAfterMouseDown
= false; // just in case
338 this.BaseWndProc (ref m
);
341 // // MWF Specific msg! - must reach control
343 // case Native.Msg.WM_MOUSE_ENTER:
344 // _firstMouseMoveInClient = false; // just so that nothing will get fired in WM_MOUSEMOVE
346 // this.DefWndProc (ref m);
349 // FIXME: The first MOUSEMOVE after WM_MOUSEDOWN should be ingored
351 case Native
.Msg
.WM_MOUSEMOVE
:
352 if (_mouseMoveAfterMouseDown
) { // mousemove is send after each mousedown so ignore that
353 _mouseMoveAfterMouseDown
= false;
354 this.BaseWndProc (ref m
);
357 // If selection is in progress pass the mouse move msg to the primary selection.
358 // If resizing is in progress pass to the parent of the primary selection (remmember that the selection
359 // frame is not a control and is drawn in the parent of the primary selection).
361 // Required in order for those 2 operations to continue when the mouse is moving over a control covering
362 // the one where the action takes place.
364 IUISelectionService uiSelectionServ
= this.GetService (typeof (IUISelectionService
)) as IUISelectionService
;
365 ISelectionService selectionServ
= this.GetService (typeof (ISelectionService
)) as ISelectionService
;
366 IDesignerHost host
= this.GetService (typeof (IDesignerHost
)) as IDesignerHost
;
369 if (uiSelectionServ
!= null && selectionServ
!= null && host
!= null) {
370 Control primarySelection
= selectionServ
.PrimarySelection
as Control
;
371 Point location
= new Point (Native
.LoWord ((int)m
.LParam
), Native
.HiWord ((int)m
.LParam
));
373 if (uiSelectionServ
.SelectionInProgress
&&
374 this.Component
!= host
.RootComponent
&&
375 this.Component
!= selectionServ
.PrimarySelection
) {
377 location
= primarySelection
.PointToClient (this.Control
.PointToScreen (location
));
378 Native
.SendMessage (primarySelection
.Handle
, (Native
.Msg
)m
.Msg
, m
.WParam
, Native
.LParam (location
.X
, location
.Y
));
380 else if (uiSelectionServ
.ResizeInProgress
&&
381 // this.Component != host.RootComponent &&
382 this.Control
.Parent
== ((Control
)selectionServ
.PrimarySelection
).Parent
) {
384 location
= this.Control
.Parent
.PointToClient (this.Control
.PointToScreen (location
));
385 Native
.SendMessage (this.Control
.Parent
.Handle
, (Native
.Msg
)m
.Msg
, m
.WParam
, Native
.LParam (location
.X
, location
.Y
));
388 this.OnMouseMove (location
.X
, location
.Y
);
392 this.OnMouseMove (Native
.LoWord ((int)m
.LParam
), Native
.HiWord ((int)m
.LParam
));
394 this.BaseWndProc (ref m
);
398 // Pass everything else to the control and return
400 this.DefWndProc (ref m
);
405 // Indicates whether a mouse click at the specified point should be handled by the control.
407 protected virtual bool GetHitTest (Point point
)
412 private bool IsMouseMessage (Native
.Msg msg
)
414 if (msg
>= Native
.Msg
.WM_MOUSEFIRST
&& msg
<= Native
.Msg
.WM_MOUSELAST
)
416 else if (msg
>= Native
.Msg
.WM_NCLBUTTONDOWN
&& msg
<= Native
.Msg
.WM_NCMBUTTONDBLCLK
)
418 else if (msg
== Native
.Msg
.WM_MOUSEHOVER
|| msg
== Native
.Msg
.WM_MOUSELEAVE
)
426 #region WndProc Message Handlers
428 protected virtual void OnSetCursor ()
432 // Raises the DoDefaultAction.
434 private void OnMouseDoubleClick ()
437 base.DoDefaultAction ();
439 catch (Exception e
) {
440 this.DisplayError (e
);
444 internal virtual void OnMouseDown (int x
, int y
)
447 _mouseDownFirstMove
= true;
448 IUISelectionService uiSelection
= this.GetService (typeof (IUISelectionService
)) as IUISelectionService
;
449 if (uiSelection
!= null && uiSelection
.AdornmentsHitTest (this.Control
, x
, y
)) {
450 // 1) prevent primary selection from being changed at this point.
451 // 2) delegate behaviour in the future to the IUISelectionService
454 ISelectionService selectionService
= this.GetService (typeof (ISelectionService
)) as ISelectionService
;
455 if (selectionService
!= null) {
456 selectionService
.SetSelectedComponents (new IComponent
[] { this.Component }
);
461 // Note that this is a pure WM_MOUSEMOVE acceptor
463 internal virtual void OnMouseMove (int x
, int y
)
466 if (_mouseDownFirstMove
) {
467 OnMouseDragBegin (x
, y
);
468 _mouseDownFirstMove
= false;
471 OnMouseDragMove (x
, y
);
477 internal virtual void OnMouseUp ()
479 IUISelectionService uiSelection
= this.GetService (typeof (IUISelectionService
)) as IUISelectionService
;
482 this.OnMouseDragEnd (false);
483 if (uiSelection
!= null && (uiSelection
.SelectionInProgress
|| uiSelection
.ResizeInProgress
)) {
484 uiSelection
.MouseDragEnd (false);
489 if (uiSelection
!= null && (uiSelection
.SelectionInProgress
|| uiSelection
.ResizeInProgress
)) {
490 // If the mouse up happens over the a control which is not defacto participating in
491 // the selection or resizing in progress, then inform the IUISelectionService of that event
493 uiSelection
.MouseDragEnd (false);
498 protected virtual void OnContextMenu (int x
, int y
)
500 IMenuCommandService service
= this.GetService (typeof(IMenuCommandService
)) as IMenuCommandService
;
501 if (service
!= null) {
502 service
.ShowContextMenu (MenuCommands
.SelectionMenu
, x
, y
);
506 protected virtual void OnMouseEnter ()
510 protected virtual void OnMouseHover ()
514 protected virtual void OnMouseLeave ()
518 // Provides an opportunity to perform additional processing immediately
519 // after the control handle has been created.
521 protected virtual void OnCreateHandle ()
525 // Called after the control is done with the painting so that the designer host
526 // can paint stuff over it.
528 protected virtual void OnPaintAdornments (PaintEventArgs pe
)
534 #region Mouse Dragging
536 MouseButtons _mouseButtonDown
;
538 internal MouseButtons MouseButtonDown
{
539 get { return _mouseButtonDown; }
542 protected virtual void OnMouseDragBegin (int x
, int y
)
544 IUISelectionService selectionServ
= this.GetService (typeof (IUISelectionService
)) as IUISelectionService
;
545 if (selectionServ
!= null && ((this.SelectionRules
& SelectionRules
.Moveable
) == SelectionRules
.Moveable
)) {
546 // once this is fired the parent control (parentcontroldesigner) will start getting dragover events.
548 selectionServ
.DragBegin ();
552 protected virtual void OnMouseDragMove (int x
, int y
)
556 protected virtual void OnMouseDragEnd (bool cancel
)
563 protected void HookChildControls (Control firstControl
)
565 if (firstControl
!= null) {
566 foreach (Control control
in firstControl
.Controls
) {
567 control
.WindowTarget
= (IWindowTarget
) new WndProcRouter (control
, (IMessageReceiver
) this);
572 protected void UnhookChildControls (Control firstControl
)
574 if (firstControl
!= null) {
575 foreach (Control control
in firstControl
.Controls
) {
576 if (control
.WindowTarget
is WndProcRouter
)
577 ((WndProcRouter
) control
.WindowTarget
).Dispose ();
582 // Someone please tell me why the hell is this method here?
583 // What about having ParentControlDesigner.CanParent(...) ?
585 public virtual bool CanBeParentedTo (IDesigner parentDesigner
)
587 IDesignerHost host
= this.GetService (typeof (IDesignerHost
)) as IDesignerHost
;
589 if (parentDesigner
is ParentControlDesigner
&&
590 this.Component
!= host
.RootComponent
&&
591 !this.Control
.Controls
.Contains (((ParentControlDesigner
)parentDesigner
).Control
)) {
599 protected void DisplayError (Exception e
)
602 IUIService uiService
= GetService (typeof (IUIService
)) as IUIService
;
603 if (uiService
!= null) {
604 uiService
.ShowError (e
);
607 string errorText
= e
.Message
;
608 if (errorText
== null || errorText
== String
.Empty
)
609 errorText
= e
.ToString ();
610 MessageBox
.Show (Control
, errorText
, "Error", MessageBoxButtons
.OK
, MessageBoxIcon
.Exclamation
);
615 #region Drag and Drop handling
617 // Enables or disables Drag and Drop
619 protected void EnableDragDrop(bool value)
621 if (this.Control
!= null) {
623 Control
.DragDrop
+= new DragEventHandler (OnDragDrop
);
624 Control
.DragOver
+= new DragEventHandler (OnDragOver
);
625 Control
.DragEnter
+= new DragEventHandler (OnDragEnter
);
626 Control
.DragLeave
+= new EventHandler (OnDragLeave
);
627 Control
.GiveFeedback
+= new GiveFeedbackEventHandler (OnGiveFeedback
);
628 Control
.AllowDrop
= true;
631 Control
.DragDrop
-= new DragEventHandler (OnDragDrop
);
632 Control
.DragOver
-= new DragEventHandler (OnDragOver
);
633 Control
.DragEnter
-= new DragEventHandler (OnDragEnter
);
634 Control
.DragLeave
-= new EventHandler (OnDragLeave
);
635 Control
.GiveFeedback
-= new GiveFeedbackEventHandler (OnGiveFeedback
);
636 Control
.AllowDrop
= false;
641 private void OnGiveFeedback (object sender
, GiveFeedbackEventArgs e
)
646 private void OnDragDrop (object sender
, DragEventArgs e
)
651 private void OnDragEnter (object sender
, DragEventArgs e
)
656 private void OnDragLeave (object sender
, EventArgs e
)
661 private void OnDragOver (object sender
, DragEventArgs e
)
666 protected virtual void OnGiveFeedback (GiveFeedbackEventArgs e
)
668 e
.UseDefaultCursors
= false;
671 protected virtual void OnDragDrop (DragEventArgs e
)
675 protected virtual void OnDragEnter (DragEventArgs e
)
679 protected virtual void OnDragLeave (EventArgs e
)
683 protected virtual void OnDragOver (DragEventArgs e
)
689 #region Redirected Properties
691 // This IDesignerFilter interface method override adds a set of properties
692 // to this designer's component at design time. This method adds the following
693 // browsable properties: "Visible", "Enabled", "ContextMenu", "AllowDrop", "Location",
694 // "Name", "Controls", and "Locked".
696 // XXX: We aren't redirecting Controls
698 protected override void PreFilterProperties (IDictionary properties
)
700 base.PreFilterProperties (properties
);
702 string[] newProperties
= {
703 "Visible", "Enabled", "ContextMenu", "AllowDrop", "Location", "Name",
706 Attribute
[][] attributes
= {
707 new Attribute
[] { new DefaultValueAttribute (true) }
,
708 new Attribute
[] { new DefaultValueAttribute (true) }
,
709 new Attribute
[] { new DefaultValueAttribute (null) }
,
710 new Attribute
[] { new DefaultValueAttribute (false) }
,
711 new Attribute
[] { new DefaultValueAttribute (typeof (Point), "0, 0") }
,
715 PropertyDescriptor propertyDescriptor
= null;
717 // If existing redirect each property to the ControlDesigner.
719 for (int i
=0; i
< newProperties
.Length
; i
++) {
720 propertyDescriptor
= properties
[newProperties
[i
]] as PropertyDescriptor
;
721 if (propertyDescriptor
!= null)
722 properties
[newProperties
[i
]] = TypeDescriptor
.CreateProperty (typeof (ControlDesigner
),
727 // This one is a must to have.
729 properties
["Locked"] = TypeDescriptor
.CreateProperty (typeof (ControlDesigner
), "Locked",
732 DesignOnlyAttribute
.Yes
,
733 BrowsableAttribute
.Yes
,
734 CategoryAttribute
.Design
,
735 new DefaultValueAttribute (false),
736 new DescriptionAttribute("The Locked property determines if we can move or resize the control.")
741 // ShadowProperties returns the real property value if there is no "shadow" one set
742 // Welcome to the land of shadows... :-)
744 private bool Visible
{
745 get { return (bool) base.ShadowProperties["Visible"]; }
746 set { base.ShadowProperties["Visible"] = value; }
749 private bool Enabled
{
750 get { return (bool) base.ShadowProperties["Enabled"]; }
751 set { base.ShadowProperties["Enabled"] = value; }
754 private bool Locked
{
755 get { return _locked; }
756 set { _locked = value; }
759 private bool AllowDrop
{
760 get { return (bool)base.ShadowProperties["AllowDrop"]; }
761 set { base.ShadowProperties["AllowDrop"] = value; }
764 private string Name
{
765 get { return base.Component.Site.Name; }
766 set { base.Component.Site.Name = value; }
769 private ContextMenu ContextMenu
{
770 get { return (ContextMenu) base.ShadowProperties["ContextMenu"]; }
771 set { base.ShadowProperties["ContextMenu"] = value; }
774 private Point Location
{
775 get { return this.Control.Location; }
776 set { this.Control.Location = value; }
781 #region Utility methods
782 internal object GetValue (object component
, string propertyName
)
784 return this.GetValue (component
, propertyName
, null);
787 internal object GetValue (object component
, string propertyName
, Type propertyType
)
789 PropertyDescriptor prop
= TypeDescriptor
.GetProperties (component
)[propertyName
] as PropertyDescriptor
;
791 throw new InvalidOperationException ("Property \"" + propertyName
+ "\" is missing on " +
792 component
.GetType().AssemblyQualifiedName
);
793 if (propertyType
!= null && !propertyType
.IsAssignableFrom (prop
.PropertyType
))
794 throw new InvalidOperationException ("Types do not match: " + prop
.PropertyType
.AssemblyQualifiedName
+
795 " : " + propertyType
.AssemblyQualifiedName
);
796 return prop
.GetValue (component
);
799 internal void SetValue (object component
, string propertyName
, object value)
801 PropertyDescriptor prop
= TypeDescriptor
.GetProperties (component
)[propertyName
] as PropertyDescriptor
;
804 throw new InvalidOperationException ("Property \"" + propertyName
+ "\" is missing on " +
805 component
.GetType().AssemblyQualifiedName
);
806 if (!prop
.PropertyType
.IsAssignableFrom (value.GetType ()))
807 throw new InvalidOperationException ("Types do not match: " + value.GetType ().AssemblyQualifiedName
+
808 " : " + prop
.PropertyType
.AssemblyQualifiedName
);
809 if (!prop
.IsReadOnly
)
810 prop
.SetValue (component
, value);
814 protected override void Dispose (bool disposing
)
817 if (this.Control
!= null) {
818 UnhookChildControls (Control
);
819 OnMouseDragEnd (true);
820 _messageRouter
.Dispose ();
821 this.Control
.DragDrop
-= new DragEventHandler (OnDragDrop
);
822 this.Control
.DragEnter
-= new DragEventHandler (OnDragEnter
);
823 this.Control
.DragLeave
-= new EventHandler (OnDragLeave
);
824 this.Control
.DragOver
-= new DragEventHandler (OnDragOver
);
833 public virtual ControlDesigner
InternalControlDesigner (int internalControlIndex
)
838 public virtual int NumberOfInternalControlDesigners ()
843 protected bool EnableDesignMode (Control child
, string name
)
846 throw new ArgumentNullException ("name");
848 throw new ArgumentNullException ("child");
850 bool success
= false;
851 INestedContainer nestedContainer
= this.GetService (typeof (INestedContainer
)) as INestedContainer
;
852 if (nestedContainer
!= null) {
853 nestedContainer
.Add (child
, name
);
859 #region NET_2_0 Stubs
862 public class ControlDesignerAccessibleObject
: AccessibleObject
865 public ControlDesignerAccessibleObject (ControlDesigner designer
, Control control
)
867 throw new NotImplementedException ();
871 public override AccessibleObject
GetChild (int index
)
873 throw new NotImplementedException ();
877 public override int GetChildCount ()
879 throw new NotImplementedException ();
883 public override AccessibleObject
GetFocused ()
885 throw new NotImplementedException ();
889 public override AccessibleObject
GetSelected ()
891 throw new NotImplementedException ();
895 public override AccessibleObject
HitTest (int x
, int y
)
897 throw new NotImplementedException ();
901 public override Rectangle Bounds
{
902 get { throw new NotImplementedException (); }
906 public override string DefaultAction
{
907 get { throw new NotImplementedException (); }
911 public override string Description
{
912 get { throw new NotImplementedException (); }
916 public override string Name
{
917 get { throw new NotImplementedException (); }
921 public override AccessibleObject Parent
{
922 get { throw new NotImplementedException (); }
926 public override AccessibleRole Role
{
927 get { throw new NotImplementedException (); }
931 public override AccessibleStates State
{
932 get { throw new NotImplementedException (); }
936 public override string Value
{
937 get { throw new NotImplementedException (); }
942 protected virtual ControlBodyGlyph
GetControlGlyph (GlyphSelectionType selectionType
)
944 throw new NotImplementedException ();
948 public virtual GlyphCollection
GetGlyphs (GlyphSelectionType selectionType
)
950 throw new NotImplementedException ();
954 public override void InitializeExistingComponent (IDictionary defaultValues
)
956 throw new NotImplementedException ();
960 public override void InitializeNewComponent (IDictionary defaultValues
)
962 throw new NotImplementedException ();
966 protected virtual void OnDragComplete (DragEventArgs de
)
968 throw new NotImplementedException ();
972 protected override InheritanceAttribute InheritanceAttribute
{
973 get { throw new NotImplementedException (); }
977 public virtual IList SnapLines
{
978 get { throw new NotImplementedException (); }
982 public virtual bool ParticipatesWithSnapLines
{
983 get { throw new NotImplementedException (); }
987 public bool AutoResizeHandles
{
988 get { throw new NotImplementedException (); }
989 set { throw new NotImplementedException (); }