Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
//
// System.ComponentModel.Design.ActiveDesignSurfaceChangedEventArgs
//
// Authors:
// Ivan N. Zlatev (contact i-nZ.net)
//
// (C) 2006 Ivan N. Zlatev
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
namespace System.ComponentModel.Design
{
public class ActiveDesignSurfaceChangedEventArgs : EventArgs
{
private DesignSurface _oldSurface;
private DesignSurface _newSurface;
public ActiveDesignSurfaceChangedEventArgs (DesignSurface oldSurface, DesignSurface newSurface)
{
_newSurface = newSurface;
_oldSurface = oldSurface;
}
public DesignSurface OldSurface {
get { return _oldSurface; }
}
public DesignSurface NewSurface {
get { return _newSurface; }
}
}
}
#endif

View File

@@ -0,0 +1,40 @@
//
// System.ComponentModel.Design.ActiveDesignSurfaceChangedEventHandler
//
// Authors:
// Ivan N. Zlatev (contact i-nZ.net)
//
// (C) 2006 Ivan N. Zlatev
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
namespace System.ComponentModel.Design
{
public delegate void ActiveDesignSurfaceChangedEventHandler (object sender, ActiveDesignSurfaceChangedEventArgs e);
}
#endif

View File

@@ -0,0 +1,73 @@
//
// System.ComponentModel.Design.ArrayEditor
//
// Authors:
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
// Martin Willemoes Hansen (mwh@sysrq.dk)
//
// (C) 2007 Andreas Nahr
// (C) 2003 Martin Willemoes Hansen
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Reflection;
namespace System.ComponentModel.Design
{
public class ArrayEditor : CollectionEditor
{
public ArrayEditor (Type type) : base (type)
{
}
protected override Type CreateCollectionItemType()
{
return CollectionType.GetElementType ();
}
protected override object[] GetItems (object editValue)
{
if (editValue == null)
return null;
if (!(editValue is Array))
return new object[0];
Array editArray = (Array)editValue;
object[] result = new object[editArray.Length];
editArray.CopyTo (result, 0);
return result;
}
protected override object SetItems (object editValue, object[] value)
{
if (editValue == null)
return null;
Array result = Array.CreateInstance (CollectionItemType, value.Length);
value.CopyTo (result, 0);
return result;
}
}
}

View File

@@ -0,0 +1,53 @@
//
// System.ComponentModel.Design.BinaryEditor
//
// Authors:
// Gert Driesen (drieseng@users.sourceforge.net)
//
// (C) 2004 Novell
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Windows.Forms;
using System.Drawing.Design;
namespace System.ComponentModel.Design
{
public sealed class BinaryEditor : UITypeEditor
{
public BinaryEditor ()
{
}
[MonoTODO]
public override object EditValue (ITypeDescriptorContext context, IServiceProvider provider, object value)
{
throw new NotImplementedException ();
}
public override UITypeEditorEditStyle GetEditStyle (ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.Modal;
}
}
}

View File

@@ -0,0 +1,124 @@
//
// System.ComponentModel.Design.ByteViewer
//
// Authors:
// Martin Willemoes Hansen (mwh@sysrq.dk)
//
// (C) 2003 Martin Willemoes Hansen
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Windows.Forms;
namespace System.ComponentModel.Design
{
[DesignTimeVisible(false)]
[ToolboxItem(false)]
#if NET_2_0
public class ByteViewer : TableLayoutPanel
#else
public class ByteViewer : Control
#endif
{
[MonoTODO]
public ByteViewer()
{
}
[MonoTODO]
public virtual DisplayMode GetDisplayMode()
{
throw new NotImplementedException();
}
[MonoTODO]
public virtual void SaveToFile (string path)
{
throw new NotImplementedException();
}
[MonoTODO]
public virtual byte[] GetBytes ()
{
throw new NotImplementedException();
}
[MonoTODO]
public virtual void SetBytes (byte[] bytes)
{
throw new NotImplementedException();
}
[MonoTODO]
public virtual void SetDisplayMode (DisplayMode mode)
{
throw new NotImplementedException();
}
[MonoTODO]
public virtual void SetFile (string path)
{
throw new NotImplementedException();
}
[MonoTODO]
public virtual void SetStartLine (int line)
{
throw new NotImplementedException();
}
[MonoTODO]
protected override void OnKeyDown (KeyEventArgs e)
{
throw new NotImplementedException();
}
[MonoTODO]
protected override void OnPaint (PaintEventArgs e)
{
throw new NotImplementedException();
}
#if NET_2_0
[MonoTODO]
protected override void OnLayout (LayoutEventArgs e)
{
throw new NotImplementedException();
}
#else
[MonoTODO]
protected override void OnResize (EventArgs e)
{
throw new NotImplementedException();
}
#endif
[MonoTODO]
protected virtual void ScrollChanged (object source, EventArgs e)
{
throw new NotImplementedException ();
}
}
}

View File

@@ -0,0 +1,287 @@
2009-09-14 Ivan Zlatev <contact@i-nz.net>
* DesignSurface.cs: Prevent a NRE in Flush by cheching if the
designer loader is null.
[Fixes bug #538929]
2009-09-10 Ivan N. Zlatev <contact@i-nz.net>
* DesignSurface.cs: Changing the ISelectionService at run time was a
bad idea, so wrap it inside the extended UISelectionService instead.
2009-09-10 Ivan N. Zlatev <contact@i-nz.net>
* DesignSurface.cs: Provide the default implementation of the
ISelectionService in the DesignSurface service container.
[Fixes bug #538037]
2009-09-07 Ivan N. Zlatev <contact@i-nz.net>
* DesignSurface.cs: Don't be so strict and allow for the users
to get the View even if the DesignSurface wasn't properly initialized
with a DesignerLoader. MS compatibility.
[Fixes bug #537131]
2008-07-06 Sebastien Pouliot <sebastien@ximian.com>
* DesignerActionMethodItem.cs: Fix typo where the action_list
field was self-assigned (instead of taking the ctor value).
[Found using Gendarme ReviewSelfAssignmentRule]
2008-06-28 Ivan N. Zlatev <contact@i-nz.net>
* DesignSurfaceManager.cs: Set the ActiveSurface only if it
differs from the current one.
2008-06-28 Ivan N. Zlatev <contact@i-nz.net>
* DesignerHost.cs: Surpress remove events when unloading.
2008-06-18 Ivan N. Zlatev <contact@i-nz.net>
* ExtenderService.cs: Do not throw a NRE.
2008-06-18 Ivan N. Zlatev <contact@i-nz.net>
* SelectionService.cs: Handle removal of the root component
properly.
2008-04-18 Ivan N. Zlatev <contact@i-nz.net>
* CollectionEditor.cs: Select the next item after the one
removed, not the one before.
[Fixes bug #375788]
2008-04-03 Ivan N. Zlatev <contact@i-nz.net>
* CollectionEditor.cs:
- Handle removing multiple items at once.
- Select the previous item after removal of other(s).
2008-04-03 Ivan N. Zlatev <contact@i-nz.net>
* CollectionEditor.cs: The display name of an object in the
list is not static. It can dynamically change when the object
get's modified.
[Fixes bug #375786]
2008-03-28 Ivan N. Zlatev <contact@i-nz.net>
* CollectionEditor.cs: Fix multiple bugs.
2008-03-19 Ivan N. Zlatev <contact@i-nz.net>
* MultilineStringEditor.cs: Handle null value by forcing an
empty string to be edited.
[Fixes bug #372264]
2008-03-10 Ivan N. Zlatev <contact@i-nz.net>
* DesignModeSite.cs: Do not return the site specific service
container if GetService is asked for IServiceContainer.
2008-03-02 Ivan N. Zlatev <contact@i-nz.net>
* DesignModeSite.cs: Fix Name setter to actually set the name.
2008-03-01 Ivan N. Zlatev <contact@i-nz.net>
* MenuCommandService.cs: implemeneted
* DesignerHost.cs: Do not fire ComponentChanging/ed events
when removing a component.
* DesignModeSite: Naming fixes.
* UndoEngine.cs: A lot of bugfixes.
* SelectionService: Set root component as selected if the
last remaining component from the current selection has been
removed.
2008-02-25 Ivan N. Zlatev <contact@i-nz.net>
* DateTimeEditor.cs: Set the calendar to the currently edited
date. Patch by Andy Hume. Code is contributed under
MIT/X11 license.
[Fixes #362749]
2008-02-16 Ivan N. Zlatev <contact@i-nz.net>
* CollectionEditor.cs: Handle null collection.
[Part of fix for bugs #360666 and #358332]
2008-02-12 Ivan N. Zlatev <contact@i-nz.net>
* DateTimeEditor.cs: Set edit value only if the user sets it
in the editor.
[Fixes #359159]
2008-02-05 Ivan N. Zlatev <contact@i-nz.net>
* MutilineStringEditor.cs: Make BorderStyle, Width and Height
sensible.
[Fixes #356530]
2008-01-22 Ivan N. Zlatev <contact@i-nz.net>
* MutilineStringEditor.cs: Fix EditValue to return the new
value not the old one.
[Fixes #354991]
2008-01-04 Ivan N. Zlatev <contact@i-nz.net>
* UndoEngine.cs: implemented.
2008-01-04 Ivan N. Zlatev <contact@i-nz.net>
* DesignerHost.cs: Fix lastTransaction to be set properly.
Handle current != raiser transaction commit case.
2008-01-04 Ivan N. Zlatev <contact@i-nz.net>
* SelectionService.cs: Remove the component from the current
selection if it gets removed from the surface.
2007-12-24 Ivan N. Zlatev <contact@i-nz.net>
* DesignerHost.cs: Report Errors.
2007-10-24 Ivan N. Zlatev <contact@i-nz.net>
* DesignSurface.cs:
- Fix a redundancy.
- Dispose the loader if available.
* DesignerHost.cs: serviceContainer can be null after disposing.
2007-09-28 Atsushi Enomoto <atsushi@ximian.com>
* ByteViewer.cs : last one mile to finish 2.0 API (metadata wise).
2007-09-28 Atsushi Enomoto <atsushi@ximian.com>
* ExceptionCollection.cs, IComponentDesignerDebugService.cs,
IComponentDesignerStateService.cs,
MenuCommandsChangedEventArgs.cs,
MenuCommandsChangedEventHandler.cs,
MenuCommandsChangedType.cs : more 2.0 impl.
* MenuCommandService.cs, UndoEngine.cs : more 2.0 stubs.
* DisplayMode.cs, InheritanceService.cs,
LocalizationExtenderProvider.cs, ObjectSelectorEditor.cs:
cosmetic 2.0 API fixes.
2007-09-28 Atsushi Enomoto <atsushi@ximian.com>
* DesignerActionUIStateChangeEventArgs.cs,
DesignerActionUIStateChangeEventHandler.cs,
DesignerActionUIStateChangeType.cs : more 2.0 impl.
* DesignerActionUIService.cs,
DesignerCommandSet.cs : more 2.0 stubs.
2007-09-28 Atsushi Enomoto <atsushi@ximian.com>
* ComponentActionsType.cs : fixed order.
2007-09-28 Atsushi Enomoto <atsushi@ximian.com>
* DesignerActionService.cs : new stub.
* ComponentActionsType.cs,
DesignerActionListsChangedType.cs,
DesignerActionListsChangedEventArgs.cs,
DesignerActionListsChangedEventHandler.cs : new implementations.
* DesignerActionListCollection.cs : [ComVisible].
* DesignerActionItem.cs,
DesignerActionMethodItem.cs,
DesignerActionPropertyItem.cs,
DesignerActionTextItem.cs : fixed protected .ctor() and made
base fields private. Properties is implemented.
2007-09-15 Ivan N. Zlatev <contact@i-nz.net>
* DesignSurface.cs: Binary compatibility fixes.
* ComponentDesigner.cs: Binary compatibility fixes.
* EventBindingService.cs: Binary compatibility fixes.
* DesignSurfaceCollection.cs: Binary compatibility fixes.
2007-08-29 Ivan N. Zlatev <contact@i-nz.net>
* DesignSurfaceManager.cs: implemented.
* DesignerEventService.cs: implemented.
* ComponentDesigner.cs: implemented.
* ActiveDesignSurfaceChangedEventHandler.cs: implemented.
* LoadedEventHandler.cs: implemented.
* DesignSurfaceCollection.cs: implemented.
* DesignerHost.cs: implemented.
* ExtenderService.cs: implemented.
* DesignModeSite.cs: implemented.
* SelectionService.cs: implemented.
* DesignSurfaceServiceContainer.cs: implemented.
* DesignerActionListCollection.cs: implemented.
* ActiveDesignSurfaceChangedEventArgs.cs: implemented.
* LoadedEventArgs.cs: implemented.
* TypeDescriptorFilterService.cs: implemented.
* ReferenceService.cs: implemented.
* DesignSurface.cs: implemented.
* DesignSurfaceEventHandler.cs: implemented.
* DesignModeNestedContainer.cs: implemented.
* EventBindingService.cs: implemented.
* DesignSurfaceEventArgs.cs: implemented.
2007-08-27 Ivan N. Zlatev <contact@i-nz.net>
* CollectionEditor.cs:
- Fix CreateCollectionItemType to deal with "Item" overloads.
- Implement Create/DestroyInstance to check for the
IDesignerHost service and use that.
- Check if SetItems produces a new object(will happen for arrays)
and update EditValue.
2007-07-12 Rolf Bjarne Kvinge <RKvinge@novell.com>
* CollectionEditor.cs: Implement CreateInstance for 1.1 profile (patch
by Andreas Nahr).
2007-07-10 Rolf Bjarne Kvinge <RKvinge@novell.com>
* ArrayEditor.cs, MultilineStringEditor.cs, CollectionEditor.cs,
DateTimeEditor.cs: Implemented (patch by Andreas Nahr).
2006-11-30 Marek Habersack <grendello@gmail.com>
* ComponentDesigner.cs: Add a missing 'verbs' variable and set the
correct return value for Contains.
2006-11-29 Miguel de Icaza <miguel@novell.com>
* ComponentDesigner.cs: Remove a few exceptions being thrown from
a few popular calls. This will just make code that is
automatically generated to run, it will not actually provide any
real designer functionality.
2005-10-04 Sebastien Pouliot <sebastien@ximian.com>
* ComponentDesigner.cs: Added a call to GC.SuppressFinalize in Dispose
method (even if we throw an NotImplementedException afterward). This
will remove warnings from gendarme.
2004-06-13 Gert Driesen <drieseng@users.sourceforge.net>
* DisplayMode.cs: changed enum field values to match MS.NET
2004-06-11 Gert Driesen <drieseng@users.sourceforge.net>
* ArrayEditor.cs: removed extra finalizer
* BinaryEditor.cs: stubbed
* ByteViewer.cs: removed extra finalizer, added missing method
* CollectionEditor.cs: removed extra finalizer
* DateTimeEditor.cs: stubbed
* InheritanceService.cs: removedd extra finalizer
* LocalizationExtenderProvider.cs: added missing attributes,
removed extra finalizer
* ObjectSelectorEditor.cs: stubbed
2004-05-16 Gert Driesen (drieseng@users.sourceforge.net)
* ByteViewer.cs: removed Site property, added GetBytes sub,
added missing attributes
* LocalizationExtenderProvider.cs: added missing attributes
2003-03-31 Alan Tam <Tam@SiuLung.com
* CollectionEditor.cs: Fixed compilation errors.
* ComponentDesigner.cs: Fixed compilation errors.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,41 @@
//
// System.ComponentModel.Design.ComponentActionsType.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2007 Novell, Inc
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
namespace System.ComponentModel.Design
{
public enum ComponentActionsType
{
All,
Component,
Service,
}
}
#endif

View File

@@ -0,0 +1,451 @@
//
// System.ComponentModel.Design.ComponentDesigner
//
// Authors:
// Ivan N. Zlatev (contact i-nZ.net)
//
// (C) 2006-2007 Ivan N. Zlatev
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
using System.ComponentModel;
namespace System.ComponentModel.Design
{
#if NET_2_0
public class ComponentDesigner : ITreeDesigner, IDesigner, IDisposable, IDesignerFilter, IComponentInitializer
#else
public class ComponentDesigner : IDesigner, IDisposable, IDesignerFilter
#endif
{
#region ShadowPropertyCollection
protected sealed class ShadowPropertyCollection
{
private Hashtable _properties = null;
private IComponent _component;
internal ShadowPropertyCollection (IComponent component)
{
_component = component;
}
// Returns Control's property value (if available) if there is no shadowed one.
//
public object this[string propertyName]
{
get {
if (propertyName == null)
throw new System.ArgumentNullException("propertyName");
if (_properties != null && _properties.ContainsKey (propertyName))
return _properties[propertyName];
PropertyDescriptor property = TypeDescriptor.GetProperties (_component.GetType ())[propertyName];
if (property != null)
return property.GetValue (_component);
else
throw new System.Exception ("Propery not found!");
}
set {
if (_properties == null)
_properties = new Hashtable ();
_properties[propertyName] = value;
}
}
public bool Contains (string propertyName)
{
if (_properties != null)
return _properties.ContainsKey (propertyName);
else
return false;
}
} // ShadowPropertyCollection
#endregion
public ComponentDesigner ()
{
}
private IComponent _component;
private DesignerVerbCollection _verbs;
private ShadowPropertyCollection _shadowPropertyCollection;
#if NET_2_0
private DesignerActionListCollection _designerActionList;
#endif
// This property indicates any components to copy or move along with the component managed
// by the designer during a copy, drag, or move operation.
// If this collection contains references to other components in the current design mode document,
// those components will be copied along with the component managed by the designer during a copy operation.
// When the component managed by the designer is selected, this collection is filled with any nested controls.
// This collection can also include other components, such as the buttons of a toolbar.
//
// supposedly contains all the children of the component, thus used for ITreeDesigner.Children
//
public virtual ICollection AssociatedComponents {
get { return new IComponent[0]; }
}
public IComponent Component {
get { return _component; }
}
public virtual DesignerVerbCollection Verbs {
get {
if (_verbs == null)
_verbs = new DesignerVerbCollection ();
return _verbs;
}
}
protected virtual InheritanceAttribute InheritanceAttribute {
get {
IInheritanceService service = (IInheritanceService) this.GetService (typeof (IInheritanceService));
if (service != null)
return service.GetInheritanceAttribute (_component);
else
return InheritanceAttribute.Default;
}
}
protected bool Inherited {
get { return !this.InheritanceAttribute.Equals (InheritanceAttribute.NotInherited); }
}
//Gets a collection of property values that override user settings.
//
protected ShadowPropertyCollection ShadowProperties {
get {
if (_shadowPropertyCollection == null) {
_shadowPropertyCollection = new ShadowPropertyCollection(_component);
}
return _shadowPropertyCollection;
}
}
#if NET_2_0
public virtual DesignerActionListCollection ActionLists {
get {
if (_designerActionList == null)
_designerActionList = new DesignerActionListCollection ();
return _designerActionList;
}
}
protected virtual IComponent ParentComponent {
get {
IDesignerHost host = GetService (typeof (IDesignerHost)) as IDesignerHost;
if (host != null) {
IComponent rootComponent = host.RootComponent;
if (rootComponent != _component)
return rootComponent;
}
return null;
}
}
public virtual void InitializeNewComponent (IDictionary defaultValues)
{
// Reset
//
OnSetComponentDefaults ();
}
// MSDN: The default implementation of this method does nothing.
//
public virtual void InitializeExistingComponent (IDictionary defaultValues)
{
InitializeNonDefault ();
}
#endif
public virtual void Initialize (IComponent component)
{
if (component == null)
throw new ArgumentNullException ("component");
_component = component;
}
#if NET_2_0
[Obsolete ("This method has been deprecated. Use InitializeExistingComponent instead.")]
#endif
public virtual void InitializeNonDefault ()
{
}
// This method is called when a user double-clicks (the representation of) a component.
// Tries to bind the default event to a method or creates a new one.
//
public virtual void DoDefaultAction()
{
IDesignerHost host = (IDesignerHost) this.GetService(typeof(IDesignerHost));
DesignerTransaction transaction = null;
if (host != null)
transaction = host.CreateTransaction ("ComponentDesigner_AddEvent");
IEventBindingService eventBindingService = GetService (typeof(IEventBindingService)) as IEventBindingService;
EventDescriptor defaultEventDescriptor = null;
if (eventBindingService != null) {
ISelectionService selectionService = this.GetService (typeof (ISelectionService)) as ISelectionService;
try {
if (selectionService != null) {
ICollection selectedComponents = selectionService.GetSelectedComponents ();
foreach (IComponent component in selectedComponents) {
EventDescriptor eventDescriptor = TypeDescriptor.GetDefaultEvent (component);
if (eventDescriptor != null) {
PropertyDescriptor eventProperty = eventBindingService.GetEventProperty (eventDescriptor);
if (eventProperty != null && !eventProperty.IsReadOnly) {
string methodName = eventProperty.GetValue (component) as string;
bool newMethod = true;
if (methodName != null || methodName != String.Empty) {
ICollection compatibleMethods = eventBindingService.GetCompatibleMethods (eventDescriptor);
foreach (string signature in compatibleMethods) {
if (signature == methodName) {
newMethod = false;
break;
}
}
}
if (newMethod) {
if (methodName == null)
methodName = eventBindingService.CreateUniqueMethodName (component, eventDescriptor);
eventProperty.SetValue (component, methodName);
}
if (component == _component)
defaultEventDescriptor = eventDescriptor;
}
}
}
}
}
catch {
if (transaction != null) {
transaction.Cancel ();
transaction = null;
}
}
finally {
if (transaction != null)
transaction.Commit ();
}
if (defaultEventDescriptor != null)
eventBindingService.ShowCode (_component, defaultEventDescriptor);
}
}
#if NET_2_0
[Obsolete ("This method has been deprecated. Use InitializeNewComponent instead.")]
#endif
// The default implementation of this method sets the default property of the component to
// the name of the component if the default property is a string and the property is not already set.
// This method can be implemented in a derived class to customize the initialization of the component
// that this designer is designing.
//
public virtual void OnSetComponentDefaults ()
{
if (_component != null && _component.Site != null) {
PropertyDescriptor property = TypeDescriptor.GetDefaultProperty (_component);
if (property != null && property.PropertyType.Equals (typeof (string))) {
string propertyValue = (string)property.GetValue (_component);
if (propertyValue != null && propertyValue.Length != 0)
property.SetValue (_component, _component.Site.Name);
}
}
}
protected InheritanceAttribute InvokeGetInheritanceAttribute (ComponentDesigner toInvoke)
{
return toInvoke.InheritanceAttribute;
}
#region IDesignerFilter
// TypeDescriptor queries the component's site for ITypeDescriptorFilterService
// then invokes ITypeDescriptorFilterService.XXXX before retrieveing props/event/attributes,
// which then invokes the IDesignerFilter implementation of the component
//
protected virtual void PostFilterAttributes (IDictionary attributes)
{
}
protected virtual void PostFilterEvents (IDictionary events)
{
}
protected virtual void PostFilterProperties (IDictionary properties)
{
}
protected virtual void PreFilterAttributes (IDictionary attributes)
{
}
protected virtual void PreFilterEvents (IDictionary events)
{
}
protected virtual void PreFilterProperties (IDictionary properties)
{
}
#endregion
protected void RaiseComponentChanged (MemberDescriptor member, object oldValue, object newValue)
{
IComponentChangeService service = GetService (typeof (IComponentChangeService)) as IComponentChangeService;
if (service != null)
service.OnComponentChanged (_component, member, oldValue, newValue);
}
protected void RaiseComponentChanging (MemberDescriptor member)
{
IComponentChangeService service = GetService (typeof (IComponentChangeService)) as IComponentChangeService;
if (service != null)
service.OnComponentChanging (_component, member);
}
#region Implementation of IDesignerFilter
void IDesignerFilter.PostFilterAttributes (IDictionary attributes)
{
PostFilterAttributes (attributes);
}
void IDesignerFilter.PostFilterEvents (IDictionary events)
{
PostFilterEvents (events);
}
void IDesignerFilter.PostFilterProperties (IDictionary properties)
{
PostFilterProperties (properties);
}
void IDesignerFilter.PreFilterAttributes (IDictionary attributes)
{
PreFilterAttributes (attributes);
}
void IDesignerFilter.PreFilterEvents (IDictionary events)
{
PreFilterEvents (events);
}
void IDesignerFilter.PreFilterProperties (IDictionary properties)
{
PreFilterProperties (properties);
}
#endregion
#if NET_2_0
#region ITreeDesigner
// Returns a collection of the designers of the associated components
//
ICollection ITreeDesigner.Children {
get {
ICollection components = this.AssociatedComponents;
IDesignerHost host = GetService (typeof (IDesignerHost)) as IDesignerHost;
if (host != null) {
ArrayList designers = new ArrayList ();
foreach (IComponent component in components) {
IDesigner designer = host.GetDesigner (component);
if (designer != null)
designers.Add (designer);
}
IDesigner[] result = new IDesigner[designers.Count];
designers.CopyTo (result);
return result;
}
return new IDesigner[0];
}
}
IDesigner ITreeDesigner.Parent {
get {
IDesignerHost host = GetService (typeof (IDesignerHost)) as IDesignerHost;
if (host != null && this.ParentComponent != null)
return host.GetDesigner (this.ParentComponent);
return null;
}
}
#endregion
#endif
// Helper method - not an ISerivceProvider
//
protected virtual object GetService (Type service)
{
if (_component != null && _component.Site != null)
return _component.Site.GetService (service);
return null;
}
public void Dispose ()
{
this.Dispose (true);
GC.SuppressFinalize (this);
}
protected virtual void Dispose (bool disposing)
{
if (disposing)
_component = null;
}
~ComponentDesigner ()
{
this.Dispose (false);
}
}
}

View File

@@ -0,0 +1,96 @@
//
// System.ComponentModel.Design.DateTimeEditor
//
// Authors:
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
// Gert Driesen (drieseng@users.sourceforge.net)
//
// (C) 2004 Novell
// (C) 2007 Andreas Nahr
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.ComponentModel;
using System.Drawing.Design;
using System.Windows.Forms;
using System.Windows.Forms.Design;
namespace System.ComponentModel.Design
{
public class DateTimeEditor : UITypeEditor
{
private class EditorControl : MonthCalendar
{
public EditorControl ()
{
MaxSelectionCount = 1;
}
}
private IWindowsFormsEditorService editorService;
private EditorControl control = new EditorControl ();
private DateTime editContent;
public DateTimeEditor ()
{
control.DateSelected += new DateRangeEventHandler (control_DateSelected);
}
public override object EditValue (ITypeDescriptorContext context, IServiceProvider provider, object value)
{
if (context != null && provider != null)
{
editorService = (IWindowsFormsEditorService)provider.GetService (typeof (IWindowsFormsEditorService));
if (editorService != null)
{
if (!(value is DateTime))
return value;
editContent = (DateTime)value;
if (editContent > control.MaxDate || editContent < control.MinDate)
control.SelectionStart = DateTime.Today;
else
control.SelectionStart = editContent;
editorService.DropDownControl (control);
return editContent;
}
}
return base.EditValue (context, provider, value);
}
void control_DateSelected (object sender, DateRangeEventArgs e)
{
editContent = e.Start;
editorService.CloseDropDown ();
}
public override UITypeEditorEditStyle GetEditStyle (ITypeDescriptorContext context)
{
return UITypeEditorEditStyle.DropDown;
}
}
}

View File

@@ -0,0 +1,141 @@
//
// System.ComponentModel.Design.DesignModeSite
//
// Authors:
// Ivan N. Zlatev (contact i-nZ.net)
//
// (C) 2007 Ivan N. Zlatev
//
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
namespace System.ComponentModel.Design
{
internal class DesignModeNestedContainer : NestedContainer
{
// DesignModeNestedContainer is a NestedContainer where:
// * Site's Name property is a qualified name that includes the owning component's name
// followed by a period (.) and the child component's name.
// * GetService is routed through the owner
private class Site : DesignModeSite, INestedSite
{
public Site (IComponent component, string name, IContainer container, IServiceProvider serviceProvider) :
base (component, name, container, serviceProvider)
{
}
// [owner].[container].[site]
//
public string FullName {
get {
if (this.Name == null)
return null;
string ownerName = ((DesignModeNestedContainer)this.Container).OwnerName;
if (ownerName == null)
return this.Name;
return ownerName + "." + this.Name;
}
}
}
private string _containerName;
public DesignModeNestedContainer (IComponent owner, string containerName) : base (owner)
{
_containerName = containerName;
}
public override void Add (IComponent component, string name)
{
if (this.Owner.Site != null) {
DesignerHost host = this.Owner.Site.GetService (typeof (IDesignerHost)) as DesignerHost;
if (host != null) {
host.AddPreProcess (component, name);
base.Add (component, name);
host.AddPostProcess (component, name);
}
}
}
public override void Remove (IComponent component)
{
if (this.Owner.Site != null) {
DesignerHost host = this.Owner.Site.GetService (typeof (IDesignerHost)) as DesignerHost;
if (host != null) {
host.RemovePreProcess (component);
base.Remove (component);
host.RemovePostProcess (component);
}
}
}
// [owner].[container]
//
protected override string OwnerName {
get {
if (_containerName != null)
return base.OwnerName + "." + _containerName;
else
return base.OwnerName;
}
}
protected override ISite CreateSite (IComponent component, string name)
{
if (component == null)
throw new ArgumentNullException("component");
if (Owner.Site == null)
throw new InvalidOperationException ("Owner not sited.");
return new DesignModeNestedContainer.Site (component, name, this, (IServiceProvider)Owner.Site);
}
protected override object GetService (Type service)
{
if (service == typeof (INestedContainer))
return this;
object serviceInstance = null;
if (this.Owner.Site != null)
serviceInstance = this.Owner.Site.GetService (service);
if (serviceInstance == null)
return base.GetService (service);
return null;
}
}
}
#endif

View File

@@ -0,0 +1,214 @@
//
// System.ComponentModel.Design.DesignModeSite
//
// Authors:
// Ivan N. Zlatev (contact i-nZ.net)
//
// (C) 2006-2007 Ivan N. Zlatev
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
namespace System.ComponentModel.Design
{
internal class DesignModeSite : ISite, IDictionaryService, IServiceProvider, IServiceContainer
{
// The DesignModeSite:
// * offers the IDictionaryService and INestedContaineroffers site-specific services
// * implements the IServiceContainer interface, but according to the tests it:
// - does *NOT* offer IServiceContainer as a site-specific service
// - offers the added site-specific services via IServiceProvider
private IServiceProvider _serviceProvider;
private IComponent _component;
private IContainer _container;
private string _componentName;
private NestedContainer _nestedContainer;
public DesignModeSite (IComponent component, string name, IContainer container, IServiceProvider serviceProvider)
{
_component = component;
_container = container;
_componentName = name;
_serviceProvider = serviceProvider;
}
public IComponent Component {
get { return _component; }
}
public IContainer Container {
get { return _container; }
}
// Yay yay yay, guess who's in design mode ???
//
public bool DesignMode {
get { return true; }
}
// The place where renaming of a component takes place.
// We should validate the new name here, if INameCreation service is present
//
public string Name {
get {
return _componentName;
}
set {
if (value != _componentName && value != null && value.Trim().Length > 0) {
INameCreationService nameService = this.GetService (typeof (INameCreationService)) as INameCreationService;
IComponent component = _container.Components[value]; // get the component with that name
if (component == null &&
(nameService == null || (nameService != null && nameService.IsValidName (value)))) {
string oldName = _componentName;
_componentName = value;
((DesignerHost)this.GetService (typeof (IDesignerHost))).OnComponentRename (_component, oldName, _componentName);
}
}
}
}
#region IServiceContainer
private ServiceContainer _siteSpecificServices;
private ServiceContainer SiteSpecificServices {
get {
if (_siteSpecificServices == null)
_siteSpecificServices = new ServiceContainer (null);
return _siteSpecificServices;
}
}
void IServiceContainer.AddService (Type serviceType, object serviceInstance)
{
SiteSpecificServices.AddService (serviceType, serviceInstance);
}
void IServiceContainer.AddService (Type serviceType, object serviceInstance, bool promote)
{
SiteSpecificServices.AddService (serviceType, serviceInstance, promote);
}
void IServiceContainer.AddService (Type serviceType, ServiceCreatorCallback callback)
{
SiteSpecificServices.AddService (serviceType, callback);
}
void IServiceContainer.AddService (Type serviceType, ServiceCreatorCallback callback, bool promote)
{
SiteSpecificServices.AddService (serviceType, callback, promote);
}
void IServiceContainer.RemoveService (Type serviceType)
{
SiteSpecificServices.RemoveService (serviceType);
}
void IServiceContainer.RemoveService (Type serviceType, bool promote)
{
SiteSpecificServices.RemoveService (serviceType, promote);
}
#endregion
#region IDictionaryService
private Hashtable _dictionary;
object IDictionaryService.GetKey (object value)
{
if (_dictionary != null) {
foreach (DictionaryEntry entry in _dictionary) {
if (value != null && value.Equals (entry.Value))
return entry.Key;
}
}
return null;
}
object IDictionaryService.GetValue (object key)
{
if (_dictionary != null)
return _dictionary[key];
return null;
}
// No Remove method: seting the value to null
// will remove the pair.
//
void IDictionaryService.SetValue (object key, object value)
{
if (_dictionary == null)
_dictionary = new Hashtable ();
if (value == null)
_dictionary.Remove (key);
_dictionary[key] = value;
}
#endregion
#region IServiceProvider
public virtual object GetService (Type service)
{
object serviceInstance = null;
if (typeof (IDictionaryService) == service)
serviceInstance = (IDictionaryService) this;
if (typeof (INestedContainer) == service) {
if (_nestedContainer == null)
_nestedContainer = new DesignModeNestedContainer (_component, null);
serviceInstance = _nestedContainer;
}
// Avoid returning the site specific IServiceContainer
if (serviceInstance == null && service != typeof (IServiceContainer) &&
_siteSpecificServices != null)
serviceInstance = _siteSpecificServices.GetService (service);
if (serviceInstance == null)
serviceInstance = _serviceProvider.GetService (service);
return serviceInstance;
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,408 @@
//
// System.ComponentModel.Design.DesignSurface
//
// Authors:
// Ivan N. Zlatev (contact i-nZ.net)
//
// (C) 2006-2007 Ivan N. Zlatev
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.Collections;
using System.ComponentModel;
using System.ComponentModel.Design.Serialization;
using System.Reflection;
namespace System.ComponentModel.Design
{
public class DesignSurface : IServiceProvider, IDisposable
{
#region DefaultDesignerLoader : DesignerLoader
internal class DefaultDesignerLoader : DesignerLoader
{
// When DesignSurface.BeginLoad is invoked, the designer loader loads the design document, displays the designer
// surface using the IDesignerHost interface, and calls IDesignerLoaderHost.EndLoad
// when done. The IDesignerLoaderHost implementation is usually the same class that implements IDesignerHost.
// The designer loader informs the designer host that it needs to invoke a load or reload so that the designer
// host can perform additional tasks at these times.
private Type _componentType;
private bool _loading;
public override bool Loading
{
get { return _loading; }
}
public DefaultDesignerLoader (Type componentType)
{
if (componentType == null)
throw new ArgumentNullException ("componentType");
_componentType = componentType;
}
// Note that IDesignerLoader : IDesignerHost
//
public override void BeginLoad (IDesignerLoaderHost loaderHost)
{
_loading = true;
// initializa root component and designer
//
loaderHost.CreateComponent (_componentType);
// finish off loading - no error collection here.
//
loaderHost.EndLoad (_componentType.FullName, true, null);
_loading = false;
}
public override void Dispose ()
{
_componentType = null;
}
} // DesignerLoader
#endregion
private DesignerHost _designerHost;
private DesignSurfaceServiceContainer _serviceContainer;
private ICollection _loadErrors;
private bool _isLoaded;
private DesignerLoader _designerLoader;
public DesignSurface () : this ((IServiceProvider) null)
{
}
public DesignSurface (Type rootComponentType) : this (null, rootComponentType)
{
}
public DesignSurface (IServiceProvider parentProvider, Type rootComponentType) : this (parentProvider)
{
if (rootComponentType == null)
throw new System.ArgumentNullException ("rootComponentType");
BeginLoad (rootComponentType);
}
// this ctor doesn't load the surface
//
public DesignSurface (IServiceProvider parentProvider)
{
_serviceContainer = new DesignSurfaceServiceContainer (parentProvider);
_serviceContainer.AddNonReplaceableService (typeof (IServiceContainer), _serviceContainer);
_designerHost = new DesignerHost ((IServiceProvider) _serviceContainer);
_designerHost.DesignerLoaderHostLoaded += new LoadedEventHandler (OnDesignerHost_Loaded);
_designerHost.DesignerLoaderHostLoading += new EventHandler (OnDesignerHost_Loading);
_designerHost.DesignerLoaderHostUnloading += new EventHandler (OnDesignerHost_Unloading);
_designerHost.DesignerLoaderHostUnloaded += new EventHandler (OnDesignerHost_Unloaded);
_designerHost.Activated += new EventHandler (OnDesignerHost_Activated);
_serviceContainer.AddNonReplaceableService (typeof (IComponentChangeService), _designerHost);
_serviceContainer.AddNonReplaceableService (typeof (IDesignerHost), _designerHost);
_serviceContainer.AddNonReplaceableService (typeof (IContainer), _designerHost);
_serviceContainer.AddService (typeof (ITypeDescriptorFilterService),
(ITypeDescriptorFilterService) new TypeDescriptorFilterService (_serviceContainer));
ExtenderService extenderService = new ExtenderService ();
_serviceContainer.AddService (typeof (IExtenderProviderService), (IExtenderProviderService) extenderService);
_serviceContainer.AddService (typeof (IExtenderListService), (IExtenderListService) extenderService);
_serviceContainer.AddService (typeof (DesignSurface), this);
SelectionService selectionService = new SelectionService (_serviceContainer);
_serviceContainer.AddService (typeof (ISelectionService), (ISelectionService) selectionService);
}
protected ServiceContainer ServiceContainer {
get {
if (_designerHost == null)
throw new ObjectDisposedException ("DesignSurface");
return _serviceContainer;
}
}
public IContainer ComponentContainer {
get {
if (_designerHost == null)
throw new ObjectDisposedException ("DesignSurface");
return _designerHost.Container;
}
}
public bool IsLoaded {
get { return _isLoaded; }
}
// Returns a collection of loading errors or a void collection.
//
public ICollection LoadErrors {
get {
if (_loadErrors == null)
_loadErrors = new object[0];
return _loadErrors;
}
}
public object View {
get {
if (_designerHost == null)
throw new ObjectDisposedException ("DesignSurface");
if (_designerHost.RootComponent == null || this.LoadErrors.Count > 0)
throw new InvalidOperationException ("The DesignSurface isn't loaded.");
IRootDesigner designer = _designerHost.GetDesigner (_designerHost.RootComponent) as IRootDesigner;
if (designer == null)
throw new InvalidOperationException ("The DesignSurface isn't loaded.");
ViewTechnology[] viewTech = designer.SupportedTechnologies;
for (int i = 0; i < viewTech.Length; i++) {
try {
return designer.GetView (viewTech[i]);
} catch {}
}
throw new NotSupportedException ("No supported View Technology found.");
}
}
public event EventHandler Disposed;
public event EventHandler Flushed;
public event LoadedEventHandler Loaded;
public event EventHandler Loading;
public event EventHandler Unloaded;
public event EventHandler Unloading;
public event EventHandler ViewActivated;
public void BeginLoad (Type rootComponentType)
{
if (rootComponentType == null)
throw new System.ArgumentNullException ("rootComponentType");
if (_designerHost == null)
throw new ObjectDisposedException ("DesignSurface");
this.BeginLoad (new DefaultDesignerLoader (rootComponentType));
}
public void BeginLoad (DesignerLoader loader)
{
if (loader == null)
throw new System.ArgumentNullException ("loader");
if (_designerHost == null)
throw new ObjectDisposedException ("DesignSurface");
if (!_isLoaded) {
_loadErrors = null;
_designerLoader = loader;
this.OnLoading (EventArgs.Empty);
_designerLoader.BeginLoad (_designerHost);
}
}
#region IDisposable
public void Dispose ()
{
this.Dispose (true);
}
protected virtual void Dispose (bool disposing)
{
if (_designerLoader != null) {
_designerLoader.Dispose ();
_designerLoader = null;
}
if (_designerHost != null) {
_designerHost.Dispose ();
_designerHost.DesignerLoaderHostLoaded -= new LoadedEventHandler (OnDesignerHost_Loaded);
_designerHost.DesignerLoaderHostLoading -= new EventHandler (OnDesignerHost_Loading);
_designerHost.DesignerLoaderHostUnloading -= new EventHandler (OnDesignerHost_Unloading);
_designerHost.DesignerLoaderHostUnloaded -= new EventHandler (OnDesignerHost_Unloaded);
_designerHost.Activated -= new EventHandler (OnDesignerHost_Activated);
_designerHost = null;
}
if (_serviceContainer != null) {
_serviceContainer.Dispose ();
_serviceContainer = null;
}
if (Disposed != null)
Disposed (this, EventArgs.Empty);
}
#endregion
public void Flush ()
{
if (_designerLoader != null)
_designerLoader.Flush ();
if (Flushed != null)
Flushed (this, EventArgs.Empty);
}
private void OnDesignerHost_Loaded (object sender, LoadedEventArgs e)
{
this.OnLoaded (e);
}
private void OnDesignerHost_Loading (object sender, EventArgs e)
{
this.OnLoading (EventArgs.Empty);
}
private void OnDesignerHost_Unloading (object sender, EventArgs e)
{
this.OnUnloading (EventArgs.Empty);
}
private void OnDesignerHost_Unloaded (object sender, EventArgs e)
{
this.OnUnloaded (EventArgs.Empty);
}
protected virtual void OnLoaded (LoadedEventArgs e)
{
_loadErrors = e.Errors;
_isLoaded = e.HasSucceeded;
if (Loaded != null)
Loaded (this, e);
}
protected virtual void OnLoading (EventArgs e)
{
if (Loading != null)
Loading (this, e);
}
protected virtual void OnUnloaded (EventArgs e)
{
if (Unloaded != null)
Unloaded (this, e);
}
protected virtual void OnUnloading (EventArgs e)
{
if (Unloading != null)
Unloading (this, e);
}
internal void OnDesignerHost_Activated (object sender, EventArgs args)
{
this.OnViewActivate (EventArgs.Empty);
}
protected virtual void OnViewActivate (EventArgs e)
{
if (ViewActivated != null)
ViewActivated (this, e);
}
[ObsoleteAttribute("CreateComponent has been replaced by CreateInstance")]
protected internal virtual IComponent CreateComponent (Type componentType)
{
return (this.CreateInstance (componentType)) as IComponent;
}
// XXX: I am not quite sure if this should add the created instance of the component
// to the surface, but it does. (If one finds out that this is wrong just use
// _designerHost.CreateInstance (..)
//
protected internal virtual object CreateInstance (Type type)
{
if (type == null)
throw new System.ArgumentNullException ("type");
return _designerHost.CreateComponent (type);
}
protected internal virtual IDesigner CreateDesigner (IComponent component, bool rootDesigner)
{
if (component == null)
throw new System.ArgumentNullException ("component");
if (_designerHost == null)
throw new System.ObjectDisposedException ("DesignerSurface");
return _designerHost.CreateDesigner (component, rootDesigner);
}
public INestedContainer CreateNestedContainer (IComponent owningComponent)
{
return this.CreateNestedContainer (owningComponent, null);
}
public INestedContainer CreateNestedContainer (IComponent owningComponent, string containerName)
{
if (_designerHost == null)
throw new ObjectDisposedException ("DesignSurface");
return new DesignModeNestedContainer (owningComponent, containerName);
}
#region IServiceProvider
public object GetService (Type serviceType)
{
if (typeof (IServiceContainer) == serviceType)
return _serviceContainer;
return _serviceContainer.GetService (serviceType);
}
#endregion
}
}
#endif

View File

@@ -0,0 +1,141 @@
//
// System.ComponentModel.Design.DesignSurfaceCollection
//
// Authors:
// Ivan N. Zlatev (contact i-nZ.net)
//
// (C) 2006 Ivan N. Zlatev
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.ComponentModel;
using System.Collections;
namespace System.ComponentModel.Design
{
// A read-only collection of design surfaces.
// A wrapper around a DesignerCollection, which get's the DesignSurface for the IDesignerHost
// on the fly.
//
public sealed class DesignSurfaceCollection : ICollection, IEnumerable
{
private class DesignSurfaceEnumerator : IEnumerator
{
IEnumerator _designerCollectionEnumerator;
public DesignSurfaceEnumerator (IEnumerator designerCollectionEnumerator)
{
_designerCollectionEnumerator = designerCollectionEnumerator;
}
public bool MoveNext ()
{
return _designerCollectionEnumerator.MoveNext ();
}
public void Reset ()
{
_designerCollectionEnumerator.Reset ();
}
public object Current {
get {
IDesignerHost designer = (IDesignerHost) _designerCollectionEnumerator.Current;
DesignSurface surface = designer.GetService (typeof (DesignSurface)) as DesignSurface;
if (surface == null)
throw new NotSupportedException ();
return surface;
}
}
} // DesignSurfaceEnumerator
private DesignerCollection _designers;
internal DesignSurfaceCollection (DesignerCollection designers)
{
if (designers == null)
designers = new DesignerCollection (null);
_designers = designers;
}
public int Count {
get { return _designers.Count; }
}
public DesignSurface this[int index] {
get {
IDesignerHost designer = _designers[index];
DesignSurface surface = designer.GetService (typeof (DesignSurface)) as DesignSurface;
if (surface == null)
throw new NotSupportedException ();
return surface;
}
}
public void CopyTo (DesignSurface[] array, int index)
{
((ICollection) this).CopyTo (array, index);
}
void ICollection.CopyTo (Array array, int index)
{
foreach (DesignSurface surface in this) {
array.SetValue (surface, index);
index++;
}
}
public IEnumerator GetEnumerator ()
{
return new DesignSurfaceEnumerator (_designers.GetEnumerator ());
}
IEnumerator IEnumerable.GetEnumerator ()
{
return GetEnumerator ();
}
int ICollection.Count {
get { return this.Count; }
}
bool ICollection.IsSynchronized {
get { return false; }
}
object ICollection.SyncRoot {
get { return null; }
}
}
}
#endif

View File

@@ -0,0 +1,56 @@
//
// System.ComponentModel.Design.DesignSurfaceEventArgs
//
// Authors:
// Ivan N. Zlatev (contact i-nZ.net)
//
// (C) 2006 Ivan N. Zlatev
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.ComponentModel;
namespace System.ComponentModel.Design
{
public class DesignSurfaceEventArgs : EventArgs
{
private DesignSurface _surface;
public DesignSurface Surface {
get { return _surface; }
}
public DesignSurfaceEventArgs (DesignSurface surface)
{
_surface = surface;
}
}
}
#endif

View File

@@ -0,0 +1,41 @@
//
// System.ComponentModel.Design.DesignSurfaceEventHandler
//
// Authors:
// Ivan N. Zlatev (contact i-nZ.net)
//
// (C) 2006 Ivan N. Zlatev
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.ComponentModel;
namespace System.ComponentModel.Design
{
public delegate void DesignSurfaceEventHandler (Object sender, DesignSurfaceEventArgs e);
}
#endif

View File

@@ -0,0 +1,251 @@
//
// System.ComponentModel.Design.DesignSurfaceManager
//
// Authors:
// Ivan N. Zlatev (contact i-nZ.net)
//
// (C) 2006 Ivan N. Zlatev
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.ComponentModel;
using System.Collections;
namespace System.ComponentModel.Design
{
public class DesignSurfaceManager : IServiceProvider, IDisposable
{
private class MergedServiceProvider : IServiceProvider
{
private IServiceProvider _primaryProvider;
private IServiceProvider _secondaryProvider;
public MergedServiceProvider (IServiceProvider primary, IServiceProvider secondary)
{
if (primary == null)
throw new ArgumentNullException ("primary");
if (secondary == null)
throw new ArgumentNullException ("secondary");
_primaryProvider = primary;
_secondaryProvider = secondary;
}
public object GetService (Type service)
{
object result = _primaryProvider.GetService (service);
if (result == null)
result = _secondaryProvider.GetService (service);
return result;
}
} // MergedServiceProvider
private IServiceProvider _parentProvider;
private ServiceContainer _serviceContainer;
public DesignSurfaceManager () : this (null)
{
}
public DesignSurfaceManager (IServiceProvider serviceProvider)
{
_parentProvider = serviceProvider;
this.ServiceContainer.AddService (typeof (IDesignerEventService), new DesignerEventService ());
}
// The CreateDesignSurfaceCore method is called by both CreateDesignSurface methods.
// It is the implementation that actually creates the design surface. The default
// implementation just returns a new DesignSurface. You may override this method to provide
// a custom object that derives from the DesignSurface class.
//
protected virtual DesignSurface CreateDesignSurfaceCore (IServiceProvider parentProvider)
{
DesignSurface surface = new DesignSurface (parentProvider);
OnDesignSurfaceCreated (surface);
return surface;
}
public DesignSurface CreateDesignSurface ()
{
return CreateDesignSurfaceCore (this);
}
// MSDN: parentProvider - A parent service provider. A new merged service provider will be created that
// will first ask this provider for a service, and then delegate any failures to the design surface
// manager object. This merged provider will be passed into the CreateDesignSurfaceCore method.
//
public DesignSurface CreateDesignSurface (IServiceProvider parentProvider)
{
if (parentProvider == null)
throw new ArgumentNullException ("parentProvider");
return CreateDesignSurfaceCore (new MergedServiceProvider (parentProvider, this));
}
public virtual DesignSurface ActiveDesignSurface {
get {
DesignerEventService eventService = GetService (typeof (IDesignerEventService)) as DesignerEventService;
if (eventService != null) {
IDesignerHost designer = eventService.ActiveDesigner;
if (designer != null)
return designer.GetService (typeof (DesignSurface)) as DesignSurface;
}
return null;
}
set {
if (value != null) {
DesignSurface oldSurface = null;
// get current surface
DesignerEventService eventService = GetService (typeof (IDesignerEventService)) as DesignerEventService;
if (eventService != null) {
IDesignerHost designer = eventService.ActiveDesigner;
if (designer != null)
oldSurface = designer.GetService (typeof (DesignSurface)) as DesignSurface;
}
ISelectionService selectionService = null;
if (oldSurface != value) {
// unsubscribe from current's selectionchanged
if (oldSurface != null) {
selectionService = oldSurface.GetService (typeof (ISelectionService)) as ISelectionService;
if (selectionService != null)
selectionService.SelectionChanged -= new EventHandler (OnSelectionChanged);
}
// subscribe to new's selectionchanged
selectionService = value.GetService (typeof (ISelectionService)) as ISelectionService;
if (selectionService != null)
selectionService.SelectionChanged += new EventHandler (OnSelectionChanged);
// set it
eventService.ActiveDesigner = value.GetService (typeof (IDesignerHost)) as IDesignerHost;
// fire event
if (this.ActiveDesignSurfaceChanged != null)
this.ActiveDesignSurfaceChanged (this, new ActiveDesignSurfaceChangedEventArgs (oldSurface, value));
}
}
}
}
public DesignSurfaceCollection DesignSurfaces {
get {
DesignerEventService eventService = GetService (typeof (IDesignerEventService)) as DesignerEventService;
if (eventService != null)
return new DesignSurfaceCollection (eventService.Designers);
return new DesignSurfaceCollection (null);
}
}
protected ServiceContainer ServiceContainer {
get {
if (_serviceContainer == null)
_serviceContainer = new ServiceContainer (_parentProvider);
return _serviceContainer;
}
}
// MSDN2 says those events are mapped through the IDesignerEventService,
// but I preferd not to do that. Should not cause compitability issues.
//
//
// The SelectionChanged is fired only for a changed component selection on the
// active designersurface.
//
public event EventHandler SelectionChanged;
public event DesignSurfaceEventHandler DesignSurfaceDisposed;
public event DesignSurfaceEventHandler DesignSurfaceCreated;
public event ActiveDesignSurfaceChangedEventHandler ActiveDesignSurfaceChanged;
private void OnSelectionChanged (object sender, EventArgs args)
{
if (SelectionChanged != null)
SelectionChanged (this, EventArgs.Empty);
DesignerEventService eventService = GetService (typeof (IDesignerEventService)) as DesignerEventService;
if (eventService != null)
eventService.RaiseSelectionChanged ();
}
private void OnDesignSurfaceCreated (DesignSurface surface)
{
if (DesignSurfaceCreated != null)
DesignSurfaceCreated (this, new DesignSurfaceEventArgs (surface));
// monitor disposing
surface.Disposed += new EventHandler (OnDesignSurfaceDisposed);
DesignerEventService eventService = GetService (typeof (IDesignerEventService)) as DesignerEventService;
if (eventService != null)
eventService.RaiseDesignerCreated (surface.GetService (typeof (IDesignerHost)) as IDesignerHost);
}
private void OnDesignSurfaceDisposed (object sender, EventArgs args)
{
DesignSurface surface = (DesignSurface) sender;
surface.Disposed -= new EventHandler (OnDesignSurfaceDisposed);
if (DesignSurfaceDisposed != null)
DesignSurfaceDisposed (this, new DesignSurfaceEventArgs (surface));
DesignerEventService eventService = GetService (typeof (IDesignerEventService)) as DesignerEventService;
if (eventService != null)
eventService.RaiseDesignerDisposed (surface.GetService (typeof (IDesignerHost)) as IDesignerHost);
}
public object GetService (Type service)
{
if (_serviceContainer != null)
return _serviceContainer.GetService (service);
return null;
}
public void Dispose ()
{
Dispose (true);
}
protected virtual void Dispose (bool disposing)
{
if (disposing && _serviceContainer != null) {
_serviceContainer.Dispose ();
_serviceContainer = null;
}
}
}
}
#endif

View File

@@ -0,0 +1,81 @@
//
// System.ComponentModel.Design.DesignSurfaceServiceContainer
//
// Authors:
// Ivan N. Zlatev (contact i-nz.net)
//
// (C) 2006 Ivan N. Zlatev
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.Collections;
using System.ComponentModel;
namespace System.ComponentModel.Design
{
// Implements a ServiceContainer, which allows specific sets of services
// to be non-replacable for users of the IServiceContainer .
//
internal sealed class DesignSurfaceServiceContainer : ServiceContainer
{
private Hashtable _nonRemoveableServices;
public DesignSurfaceServiceContainer () : this (null)
{
}
public DesignSurfaceServiceContainer (IServiceProvider parentProvider) : base (parentProvider)
{
}
internal void AddNonReplaceableService (Type serviceType, object instance)
{
if (_nonRemoveableServices == null)
_nonRemoveableServices = new Hashtable ();
_nonRemoveableServices[serviceType] = serviceType;
base.AddService (serviceType, instance);
}
internal void RemoveNonReplaceableService (Type serviceType, object instance)
{
if (_nonRemoveableServices != null)
_nonRemoveableServices.Remove (serviceType);
base.RemoveService (serviceType);
}
public override void RemoveService (Type serviceType, bool promote)
{
if (serviceType != null && _nonRemoveableServices != null && _nonRemoveableServices.ContainsKey (serviceType))
throw new InvalidOperationException ("Cannot remove non-replaceable service: " + serviceType.AssemblyQualifiedName);
base.RemoveService (serviceType, promote);
}
}
}
#endif

View File

@@ -0,0 +1,49 @@
//
// System.ComponentModel.Design.DesignerActionHeaderItem.cs
//
// Authors:
// Miguel de Icaza (miguel@novell.com)
//
// Copyright 2006 Novell, Inc
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System.Windows.Forms;
using System.Collections;
namespace System.ComponentModel.Design
{
public sealed class DesignerActionHeaderItem : DesignerActionTextItem
{
public DesignerActionHeaderItem (string displayName)
: base (displayName, null)
{
}
public DesignerActionHeaderItem (string displayName, string category)
: base (displayName, category)
{
}
}
}
#endif

View File

@@ -0,0 +1,89 @@
//
// System.ComponentModel.Design.DesignerActionItem.cs
//
// Authors:
// Miguel de Icaza (miguel@novell.com)
// Atsushi Enomoto (atsushi@ximian.com)
//
// Copyright 2006-2007 Novell, Inc
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System.Windows.Forms;
using System.Collections;
namespace System.ComponentModel.Design
{
public abstract class DesignerActionItem {
bool allow_associate;
string category;
string description;
string display_name;
IDictionary properties;
public DesignerActionItem (string displayName, string category, string description)
{
this.display_name = displayName;
this.description = description;
this.category = category;
}
public bool AllowAssociate {
get {
return allow_associate;
}
set {
allow_associate = value;
}
}
public virtual string Category {
get {
return category;
}
}
public virtual string Description {
get {
return description;
}
}
public virtual string DisplayName {
get {
return display_name;
}
}
public IDictionary Properties {
get {
if (properties == null)
properties = new Hashtable ();
return properties;
}
}
}
}
#endif

Some files were not shown because too many files have changed in this diff Show More