2 // System.Windows.Forms.Design.ComponentTray
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.
35 using System.ComponentModel;
36 using System.ComponentModel.Design;
37 using System.Windows.Forms;
39 using System.Drawing.Design;
40 using System.Collections;
42 namespace System.Windows.Forms.Design
44 [DesignTimeVisible (false)]
46 [ProvideProperty ("Location", typeof (IComponent))]
47 public class ComponentTray : ScrollableControl, IExtenderProvider
50 private IServiceProvider _serviceProvider;
51 private IDesigner _mainDesigner = null;
52 private bool _showLargeIcons = false;
53 private bool _autoArrange = false;
55 public ComponentTray (IDesigner mainDesigner, IServiceProvider serviceProvider)
57 if (mainDesigner == null) {
58 throw new ArgumentNullException ("mainDesigner");
60 if (serviceProvider == null) {
61 throw new ArgumentNullException ("serviceProvider");
64 _mainDesigner = mainDesigner;
65 _serviceProvider = serviceProvider;
68 public bool AutoArrange {
69 get { return _autoArrange; }
70 set { _autoArrange = value; }
74 public int ComponentCount {
78 public bool ShowLargeIcons {
79 get { return _showLargeIcons; }
80 set { _showLargeIcons = value; }
85 public virtual void AddComponent (IComponent component)
89 protected virtual bool CanCreateComponentFromTool (ToolboxItem tool)
94 protected virtual bool CanDisplayComponent (IComponent component)
100 public void CreateComponentFromTool (ToolboxItem tool)
105 protected void DisplayError (Exception e)
109 protected override void Dispose (bool disposing)
115 [Category ("Layout")]
116 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
118 [Localizable (false)]
121 public Point GetLocation (IComponent receiver)
123 return new Point (0,0);
127 public void SetLocation (IComponent receiver, Point location)
133 public IComponent GetNextComponent (IComponent component, bool forward)
135 throw new NotImplementedException ();
139 [Category ("Layout")]
141 [Localizable (false)]
143 public Point GetTrayLocation (IComponent receiver)
145 throw new NotImplementedException ();
149 public bool IsTrayComponent (IComponent comp)
151 throw new NotImplementedException ();
155 public void SetTrayLocation (IComponent receiver, Point location)
157 throw new NotImplementedException ();
161 protected override void OnMouseDoubleClick (MouseEventArgs e)
166 protected override void OnDoubleClick (EventArgs e)
172 protected override void OnDragDrop (DragEventArgs de)
177 protected override void OnDragEnter (DragEventArgs de)
182 protected override void OnDragLeave (EventArgs e)
187 protected override void OnDragOver (DragEventArgs de)
192 protected override void OnGiveFeedback (GiveFeedbackEventArgs gfevent)
197 protected override void OnLayout (LayoutEventArgs levent)
202 protected virtual void OnLostCapture ()
207 protected override void OnMouseDown (MouseEventArgs e)
212 protected override void OnMouseMove (MouseEventArgs e)
217 protected override void OnMouseUp (MouseEventArgs e)
222 protected override void OnPaint (PaintEventArgs pe)
227 protected virtual void OnSetCursor ()
232 public virtual void RemoveComponent (IComponent component)
237 protected override void WndProc (ref Message m)
239 base.WndProc (ref m);
242 bool IExtenderProvider.CanExtend (object component)
247 protected override object GetService (Type service)
249 if (_serviceProvider != null) {
250 return _serviceProvider.GetService (service);