diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
index 78ffc31030..b09a84e857 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
@@ -65,7 +65,7 @@ namespace ICSharpCode.WpfDesign.Designer
base.OnPreviewMouseDown(e);
if (!_isInInputAction) {
Debug.WriteLine("DesignPanel.PreviewMouseDown Source=" + e.Source.GetType().Name + " OriginalSource=" + e.OriginalSource.GetType().Name);
- DesignSite site = FindDesignedElementForOriginalSource(e.OriginalSource);
+ DesignItem site = FindDesignedElementForOriginalSource(e.OriginalSource);
if (site != null) {
Debug.WriteLine(" Found designed element: " + site.Component.GetType().Name);
}
@@ -73,11 +73,11 @@ namespace ICSharpCode.WpfDesign.Designer
}
}
- public DesignSite FindDesignedElementForOriginalSource(object originalSource)
+ public DesignItem FindDesignedElementForOriginalSource(object originalSource)
{
if (originalSource == null)
return null;
- DesignSite site = _services.Component.GetSite(originalSource);
+ DesignItem site = _services.Component.GetDesignItem(originalSource);
if (site != null)
return site;
if (originalSource == _innerDesignPanel)
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.cs
index 64b895bb1d..c65615cdad 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.cs
@@ -85,8 +85,10 @@ namespace ICSharpCode.WpfDesign.Designer
void InitializeDesigner(XamlDocument document)
{
_currentDocument = document;
- DesignSite rootSite = _componentService.RegisterXamlComponentRecursive(document.RootElement);
- _designPanel.DesignedElement = DefaultVisualDesignService.CreateUIElementFor(rootSite);
+ XamlDesignItem rootSite = _componentService.RegisterXamlComponentRecursive(document.RootElement);
+ UIElement rootUI = DefaultVisualDesignService.CreateUIElementFor(rootSite);
+ rootSite.SetView(rootUI);
+ _designPanel.DesignedElement = rootUI;
}
///
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ServiceRequiredException.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ServiceRequiredException.cs
new file mode 100644
index 0000000000..2de88f5cac
--- /dev/null
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ServiceRequiredException.cs
@@ -0,0 +1,56 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Runtime.Serialization;
+
+namespace ICSharpCode.WpfDesign.Designer
+{
+ ///
+ /// Exception class used for designer failures.
+ ///
+ [Serializable]
+ public class ServiceRequiredException : DesignerException
+ {
+ ///
+ /// Create a new ServiceRequiredException instance.
+ ///
+ public ServiceRequiredException(Type serviceType)
+ : this("Service " + serviceType.FullName + " is required.")
+ {
+ }
+
+ ///
+ /// Create a new ServiceRequiredException instance.
+ ///
+ public ServiceRequiredException()
+ {
+ }
+
+ ///
+ /// Create a new ServiceRequiredException instance.
+ ///
+ public ServiceRequiredException(string message) : base(message)
+ {
+ }
+
+ ///
+ /// Create a new ServiceRequiredException instance.
+ ///
+ public ServiceRequiredException(string message, Exception innerException) : base(message, innerException)
+ {
+ }
+
+ ///
+ /// Create a new ServiceRequiredException instance.
+ ///
+ protected ServiceRequiredException(SerializationInfo info, StreamingContext context)
+ : base(info, context)
+ {
+ }
+ }
+}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ComponentService.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ComponentService.cs
index ca4eab3450..74dd91e085 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ComponentService.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ComponentService.cs
@@ -20,21 +20,21 @@ namespace ICSharpCode.WpfDesign.Designer.Services
this._surface = surface;
}
- public event EventHandler ComponentRegistered;
- public event EventHandler ComponentUnregistered;
+ public event EventHandler ComponentRegistered;
+ public event EventHandler ComponentUnregistered;
- Dictionary
sealed class DefaultSelectionService : ISelectionService
{
- HashSet _selectedComponents = new HashSet();
- object _primarySelection;
+ HashSet _selectedComponents = new HashSet();
+ DesignItem _primarySelection;
- public bool IsComponentSelected(object component)
+ public bool IsComponentSelected(DesignItem component)
{
return _selectedComponents.Contains(component);
}
- public ICollection SelectedComponents {
+ public ICollection SelectedItems {
get { return _selectedComponents.Clone(); }
}
- public object PrimarySelection
+ public DesignItem PrimarySelection
{
get { return _primarySelection; }
}
@@ -40,24 +40,24 @@ namespace ICSharpCode.WpfDesign.Designer.Services
}
public event EventHandler SelectionChanging;
- public event EventHandler SelectionChanged;
+ public event EventHandler SelectionChanged;
public event EventHandler PrimarySelectionChanging;
public event EventHandler PrimarySelectionChanged;
- public void SetSelectedComponents(ICollection components)
+ public void SetSelectedComponents(ICollection components)
{
SetSelectedComponents(components, SelectionTypes.Auto);
}
- public void SetSelectedComponents(ICollection components, SelectionTypes selectionType)
+ public void SetSelectedComponents(ICollection components, SelectionTypes selectionType)
{
if (components == null)
- components = new object[0];
+ components = new DesignItem[0];
if (SelectionChanging != null)
SelectionChanging(this, EventArgs.Empty);
- object newPrimarySelection = _primarySelection;
+ DesignItem newPrimarySelection = _primarySelection;
if (selectionType == SelectionTypes.Auto) {
if (Keyboard.Modifiers == ModifierKeys.Control)
@@ -71,7 +71,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
if ((selectionType & SelectionTypes.Primary) == SelectionTypes.Primary) {
// change primary selection to first new component
newPrimarySelection = null;
- foreach (object obj in components) {
+ foreach (DesignItem obj in components) {
newPrimarySelection = obj;
break;
}
@@ -84,18 +84,18 @@ namespace ICSharpCode.WpfDesign.Designer.Services
}
}
- HashSet componentsToNotifyOfSelectionChange = new HashSet();
+ HashSet componentsToNotifyOfSelectionChange = new HashSet();
switch (selectionType) {
case SelectionTypes.Add:
// add to selection and notify if required
- foreach (object obj in components) {
+ foreach (DesignItem obj in components) {
if (_selectedComponents.Add(obj))
componentsToNotifyOfSelectionChange.Add(obj);
}
break;
case SelectionTypes.Remove:
// remove from selection and notify if required
- foreach (object obj in components) {
+ foreach (DesignItem obj in components) {
if (_selectedComponents.Remove(obj))
componentsToNotifyOfSelectionChange.Add(obj);
}
@@ -105,7 +105,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
componentsToNotifyOfSelectionChange.AddRange(_selectedComponents);
// set _selectedCompontents to new components
_selectedComponents.Clear();
- foreach (object obj in components) {
+ foreach (DesignItem obj in components) {
_selectedComponents.Add(obj);
// notify the new components
componentsToNotifyOfSelectionChange.Add(obj);
@@ -113,7 +113,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
break;
case SelectionTypes.Toggle:
// toggle selection and notify
- foreach (object obj in components) {
+ foreach (DesignItem obj in components) {
if (_selectedComponents.Contains(obj)) {
_selectedComponents.Remove(obj);
} else {
@@ -132,7 +132,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
if (!IsComponentSelected(newPrimarySelection)) {
// primary selection is not selected anymore - change primary selection to any other selected component
newPrimarySelection = null;
- foreach (object obj in _selectedComponents) {
+ foreach (DesignItem obj in _selectedComponents) {
newPrimarySelection = obj;
break;
}
@@ -151,17 +151,8 @@ namespace ICSharpCode.WpfDesign.Designer.Services
}
}
- // Notify the components that changed selection state:
- /*
- foreach (object obj in componentsToNotifyOfSelectionChange) {
- DesignSite objSite = DesignSite.GetSite(obj as DependencyObject);
- if (objSite != null)
- objSite.Notify(this, null);
- }
- */
-
if (SelectionChanged != null) {
- SelectionChanged(this, new ComponentCollectionEventArgs(componentsToNotifyOfSelectionChange));
+ SelectionChanged(this, new DesignItemCollectionEventArgs(componentsToNotifyOfSelectionChange));
}
}
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/VisualDesignService.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/VisualDesignService.cs
index 2511bd6c2c..da3b5a4d2e 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/VisualDesignService.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/VisualDesignService.cs
@@ -14,7 +14,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
{
sealed class DefaultVisualDesignService : IVisualDesignService
{
- public UIElement CreateWrapper(DesignSite site)
+ public UIElement CreateWrapper(DesignItem site)
{
if (site == null)
throw new ArgumentNullException("site");
@@ -27,9 +27,12 @@ namespace ICSharpCode.WpfDesign.Designer.Services
return new FallbackObjectWrapper(site);
}
- internal static UIElement CreateUIElementFor(DesignSite site)
+ internal static UIElement CreateUIElementFor(DesignItem site)
{
- UIElement element = site.Services.VisualDesign.CreateWrapper(site);
+ IVisualDesignService service = site.Services.GetService();
+ if (service == null)
+ throw new ServiceRequiredException(typeof(IVisualDesignService));
+ UIElement element = service.CreateWrapper(site);
if (element != null) {
if (!(element is IVisualDesignObjectWrapper)) {
throw new DesignerException("IVisualDesignService.CreateWrapper must return null or UIElement implementing IVisualDesignObjectWrapper");
@@ -46,9 +49,9 @@ namespace ICSharpCode.WpfDesign.Designer.Services
sealed class FallbackObjectWrapper : ContentControl, IVisualDesignObjectWrapper
{
- DesignSite _site;
+ DesignItem _site;
- public FallbackObjectWrapper(DesignSite site)
+ public FallbackObjectWrapper(DesignItem site)
{
this._site = site;
@@ -59,7 +62,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
this.Content = site.Component;
}
- public DesignSite WrappedSite {
+ public DesignItem WrappedSite {
get { return _site; }
}
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
index 869d2d892c..904bd12b4c 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
@@ -60,12 +60,13 @@
+
-
+
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/XamlDesignSite.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/XamlDesignItem.cs
similarity index 73%
rename from src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/XamlDesignSite.cs
rename to src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/XamlDesignItem.cs
index 2dd7080a8f..1fc523be4f 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/XamlDesignSite.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/XamlDesignItem.cs
@@ -11,12 +11,13 @@ using ICSharpCode.WpfDesign.XamlDom;
namespace ICSharpCode.WpfDesign.Designer
{
- sealed class XamlDesignSite : DesignSite
+ sealed class XamlDesignItem : DesignItem
{
readonly XamlObject xamlObject;
readonly DesignSurface designSurface;
+ UIElement _view;
- public XamlDesignSite(XamlObject xamlObject, DesignSurface designSurface)
+ public XamlDesignItem(XamlObject xamlObject, DesignSurface designSurface)
{
this.xamlObject = xamlObject;
this.designSurface = designSurface;
@@ -30,10 +31,18 @@ namespace ICSharpCode.WpfDesign.Designer
public override UIElement View {
get {
- return null;
+ if (_view != null)
+ return _view;
+ else
+ return this.Component as UIElement;
}
}
+ internal void SetView(UIElement newView)
+ {
+ _view = newView;
+ }
+
public override object GetService(Type serviceType)
{
return designSurface.Services.GetService(serviceType);
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DefaultServiceProvider.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DefaultServiceProvider.cs
index 4038087b7b..e5a41e34a2 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DefaultServiceProvider.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DefaultServiceProvider.cs
@@ -62,16 +62,6 @@ namespace ICSharpCode.WpfDesign
}
}
- ///
- /// Gets the .
- /// This service is guaranteed to always exist -> this property will never return null.
- ///
- public IVisualDesignService VisualDesign {
- get {
- return GetServiceChecked();
- }
- }
-
///
/// Gets the .
/// This service is guaranteed to always exist -> this property will never return null.
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignSite.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs
similarity index 89%
rename from src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignSite.cs
rename to src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs
index 27d763e3d2..ff836866d3 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignSite.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs
@@ -12,14 +12,15 @@ using System.Windows;
namespace ICSharpCode.WpfDesign
{
///
- /// The DesignSite connects a component with the service system and the designers.
+ /// The DesignItem connects a component with the service system and the designers.
+ /// Equivalent to Cider's ModelItem.
///
///
/// About the Cider extension system:
/// http://blogs.msdn.com/jnak/archive/2006/04/24/580393.aspx
/// http://blogs.msdn.com/jnak/archive/2006/08/04/687166.aspx
///
- public abstract class DesignSite : IServiceProvider
+ public abstract class DesignItem : IServiceProvider
{
///
/// Gets the component this DesignSite was created for.
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/EventArgs.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/EventArgs.cs
index 13036b3ef1..9dfd25a699 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/EventArgs.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/EventArgs.cs
@@ -13,46 +13,46 @@ namespace ICSharpCode.WpfDesign
///
/// Event arguments specifying a component as parameter.
///
- public class SiteEventArgs : EventArgs
+ public class DesignItemEventArgs : EventArgs
{
- readonly DesignSite _site;
+ readonly DesignItem _item;
///
/// Creates a new ComponentEventArgs instance.
///
- public SiteEventArgs(DesignSite site)
+ public DesignItemEventArgs(DesignItem item)
{
- _site = site;
+ _item = item;
}
///
/// The component affected by the event.
///
- public DesignSite Site {
- get { return _site; }
+ public DesignItem Item {
+ get { return _item; }
}
}
///
/// Event arguments specifying a component as parameter.
///
- public class ComponentCollectionEventArgs : EventArgs
+ public class DesignItemCollectionEventArgs : EventArgs
{
- readonly ICollection _components;
+ readonly ICollection _items;
///
/// Creates a new ComponentCollectionEventArgs instance.
///
- public ComponentCollectionEventArgs(ICollection components)
+ public DesignItemCollectionEventArgs(ICollection items)
{
- _components = components;
+ _items = items;
}
///
/// The components affected by the event.
///
- public ICollection Components {
- get { return _components; }
+ public ICollection Items {
+ get { return _items; }
}
}
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs
index 3b91c30eab..8e0bb0e98a 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs
@@ -46,7 +46,7 @@ namespace ICSharpCode.WpfDesign
/// ,
/// or returns null to use the component itself as UIElement.
///
- UIElement CreateWrapper(DesignSite site);
+ UIElement CreateWrapper(DesignItem site);
}
///
@@ -58,7 +58,7 @@ namespace ICSharpCode.WpfDesign
///
/// Gets the design site this object was wrapping.
///
- DesignSite WrappedSite { get; }
+ DesignItem WrappedSite { get; }
}
#endregion
@@ -109,7 +109,7 @@ namespace ICSharpCode.WpfDesign
event EventHandler SelectionChanging;
/// Occurs after the current selection has changed.
- event EventHandler SelectionChanged;
+ event EventHandler SelectionChanged;
/// Occurs when the primary selection is about to change.
event EventHandler PrimarySelectionChanging;
@@ -119,28 +119,28 @@ namespace ICSharpCode.WpfDesign
///
/// Gets if the specified component is selected.
///
- bool IsComponentSelected(object component);
+ bool IsComponentSelected(DesignItem component);
///
/// Gets the collection of selected components.
/// This is a copy of the actual selected components collection, the returned copy
/// of the collection will not reflect future changes to the selection.
///
- ICollection SelectedComponents { get; }
+ ICollection SelectedItems { get; }
///
/// Replaces the current selection with the specified selection.
///
- void SetSelectedComponents(ICollection components);
+ void SetSelectedComponents(ICollection components);
///
/// Modifies the current selection using the specified components and selectionType.
///
- void SetSelectedComponents(ICollection components, SelectionTypes selectionType);
+ void SetSelectedComponents(ICollection components, SelectionTypes selectionType);
/// Gets the object that is currently the primary selected object.
/// The object that is currently the primary selected object.
- object PrimarySelection { get; }
+ DesignItem PrimarySelection { get; }
/// Gets the count of selected objects.
/// The number of selected objects.
@@ -158,18 +158,18 @@ namespace ICSharpCode.WpfDesign
///
/// The site of the component, or null if the component is not registered.
///
- DesignSite GetSite(object component);
+ DesignItem GetDesignItem(object component);
/// Registers a component for usage in the designer.
- DesignSite RegisterComponentForDesigner(object component);
+ DesignItem RegisterComponentForDesigner(object component);
// /// Unregisters a component from usage in the designer.
// void UnregisterComponentFromDesigner(DesignSite site);
/// Event raised whenever a component is registered
- event EventHandler ComponentRegistered;
+ event EventHandler ComponentRegistered;
/// Event raised whenever a component is unregistered
- event EventHandler ComponentUnregistered;
+ event EventHandler ComponentUnregistered;
}
#endregion
}
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs
index 65e14bb8cb..5d6751abcf 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs
@@ -105,7 +105,7 @@ namespace ICSharpCode.WpfDesign
///
/// Finds the designed element for the specified original source.
///
- DesignSite FindDesignedElementForOriginalSource(object originalSource);
+ DesignItem FindDesignedElementForOriginalSource(object originalSource);
// The following members were missing in , but of course
diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj
index b2ba4f406e..0b2e03eb67 100644
--- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj
+++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj
@@ -59,7 +59,7 @@
-
+