Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2223 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
14 changed files with 194 additions and 164 deletions
@ -1,39 +0,0 @@ |
|||||||
// <file>
|
|
||||||
// <copyright see="prj:///doc/copyright.txt"/>
|
|
||||||
// <license see="prj:///doc/license.txt"/>
|
|
||||||
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
|
||||||
// <version>$Revision$</version>
|
|
||||||
// </file>
|
|
||||||
|
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
|
|
||||||
namespace ICSharpCode.WpfDesign.Designer.Services |
|
||||||
{ |
|
||||||
sealed class DesignServiceContainer : IServiceContainer |
|
||||||
{ |
|
||||||
public DesignServiceContainer() |
|
||||||
{ |
|
||||||
AddService(typeof(IServiceContainer), this); |
|
||||||
} |
|
||||||
|
|
||||||
Dictionary<Type, object> _services = new Dictionary<Type, object>(); |
|
||||||
|
|
||||||
public void AddService(Type serviceInterface, object serviceInstance) |
|
||||||
{ |
|
||||||
if (serviceInterface == null) |
|
||||||
throw new ArgumentNullException("serviceInterface"); |
|
||||||
if (serviceInstance == null) |
|
||||||
throw new ArgumentNullException("serviceInstance"); |
|
||||||
|
|
||||||
_services.Add(serviceInterface, serviceInstance); |
|
||||||
} |
|
||||||
|
|
||||||
public object GetService(Type serviceType) |
|
||||||
{ |
|
||||||
object instance; |
|
||||||
_services.TryGetValue(serviceType, out instance); |
|
||||||
return instance; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,45 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.WpfDesign.XamlDom; |
||||||
|
using ICSharpCode.WpfDesign.Designer.Services; |
||||||
|
|
||||||
|
namespace ICSharpCode.WpfDesign.Designer.Xaml |
||||||
|
{ |
||||||
|
sealed class XamlDesignContext : DesignContext |
||||||
|
{ |
||||||
|
readonly XamlDocument _doc; |
||||||
|
readonly XamlDesignItem _rootItem; |
||||||
|
readonly XamlComponentService _componentService; |
||||||
|
|
||||||
|
public XamlDesignContext(XamlDocument doc) |
||||||
|
{ |
||||||
|
if (doc == null) |
||||||
|
throw new ArgumentNullException("doc"); |
||||||
|
this._doc = doc; |
||||||
|
|
||||||
|
this.Services.AddService(typeof(IVisualDesignService), new DefaultVisualDesignService()); |
||||||
|
this.Services.AddService(typeof(ISelectionService), new DefaultSelectionService()); |
||||||
|
this.Services.AddService(typeof(IToolService), new DefaultToolService()); |
||||||
|
|
||||||
|
_componentService = new XamlComponentService(this); |
||||||
|
this.Services.AddService(typeof(IComponentService), _componentService); |
||||||
|
|
||||||
|
_rootItem = _componentService.RegisterXamlComponentRecursive(doc.RootElement); |
||||||
|
} |
||||||
|
|
||||||
|
public override void Save(System.Xml.XmlWriter writer) |
||||||
|
{ |
||||||
|
_doc.Save(writer); |
||||||
|
} |
||||||
|
|
||||||
|
public override DesignItem RootItem { |
||||||
|
get { return _rootItem; } |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,41 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Diagnostics; |
||||||
|
using System.Xml; |
||||||
|
|
||||||
|
namespace ICSharpCode.WpfDesign |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// The context that the designer uses.
|
||||||
|
/// </summary>
|
||||||
|
public abstract class DesignContext |
||||||
|
{ |
||||||
|
readonly ServiceContainer _services = new ServiceContainer(); |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the <see cref="ServiceContainer"/>.
|
||||||
|
/// </summary>
|
||||||
|
public ServiceContainer Services { |
||||||
|
[DebuggerStepThrough] |
||||||
|
get { return _services; } |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the root design item.
|
||||||
|
/// </summary>
|
||||||
|
public abstract DesignItem RootItem { |
||||||
|
get; |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Save the designed elements as XML.
|
||||||
|
/// </summary>
|
||||||
|
public abstract void Save(XmlWriter writer); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,18 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
|
||||||
|
namespace ICSharpCode.WpfDesign.Extensions |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Base class for all Extensions.
|
||||||
|
/// </summary>
|
||||||
|
public abstract class Extension |
||||||
|
{ |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue