Browse Source

Create WpfDesign project.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2220 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
320b1acb30
  1. 9
      src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/App.xaml
  2. 22
      src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/App.xaml.cs
  3. 39
      src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/AssemblyInfo.cs
  4. 61
      src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/StandaloneDesigner.csproj
  5. 29
      src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/Window1.xaml
  6. 30
      src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/Window1.xaml.cs
  7. 41
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Configuration/AssemblyInfo.cs
  8. 79
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/SingleVisualChildElement.cs
  9. 36
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
  10. 89
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.cs
  11. 197
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/HashSet.cs
  12. 39
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/DesignServiceContainer.cs
  13. 168
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/SelectionService.cs
  14. 66
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/VisualDesignService.cs
  15. 82
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
  16. 35
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/XamlDesignSite.cs
  17. 5
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/WpfDesign.XamlDom.csproj
  18. 25
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlPropertyInfo.cs
  19. 5
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs
  20. 17
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Tests/WpfDesign.XamlDom.Tests.csproj
  21. 18
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.sln
  22. 58
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ComponentEventArgs.cs
  23. 17
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Configuration/AssemblyInfo.cs
  24. 85
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DefaultServiceProvider.cs
  25. 42
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignSite.cs
  26. 48
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignerException.cs
  27. 148
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs
  28. 68
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj
  29. 21
      src/SharpDevelop.Tests.sln

9
src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/App.xaml

@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
<Application x:Class="StandaloneDesigner.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Window1.xaml"
>
<Application.Resources>
</Application.Resources>
</Application>

22
src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/App.xaml.cs

@ -0,0 +1,22 @@ @@ -0,0 +1,22 @@
using System;
using System.Windows;
using System.Data;
using System.Xml;
using System.Configuration;
namespace StandaloneDesigner
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public App()
{
InitializeComponent();
}
}
}

39
src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/AssemblyInfo.cs

@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
#region Using directives
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Resources;
using System.Globalization;
using System.Windows;
using System.Runtime.InteropServices;
#endregion
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("StandaloneDesigner")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

61
src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/StandaloneDesigner.csproj

@ -0,0 +1,61 @@ @@ -0,0 +1,61 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{84D65E9C-B66C-44C3-95FD-445EFE3ED322}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>WinExe</OutputType>
<RootNamespace>StandaloneDesigner</RootNamespace>
<AssemblyName>StandaloneDesigner</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
<DebugSymbols>True</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="ReachFramework" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.IdentityModel" />
<Reference Include="System.Printing" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Xml" />
<Reference Include="UIAutomationProvider" />
<Reference Include="UIAutomationTypes" />
<Reference Include="WindowsBase" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />
<ItemGroup>
<ApplicationDefinition Include="App.xaml" />
<Compile Include="..\..\..\..\Main\GlobalAssemblyInfo.cs">
<Link>GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="App.xaml.cs">
<SubType>Code</SubType>
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Window1.xaml.cs">
<SubType>Code</SubType>
<DependentUpon>Window1.xaml</DependentUpon>
</Compile>
<Page Include="Window1.xaml" />
<ProjectReference Include="..\WpfDesign.Designer\Project\WpfDesign.Designer.csproj">
<Project>{78CC29AC-CC79-4355-B1F2-97936DF198AC}</Project>
<Name>WpfDesign.Designer</Name>
</ProjectReference>
</ItemGroup>
</Project>

29
src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/Window1.xaml

@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
<Window x:Class="StandaloneDesigner.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="StandaloneDesigner" Height="500" Width="600"
>
<TabControl TabStripPlacement="Bottom" Name="tabControl" SelectionChanged="tabControlSelectionChanged">
<TabItem Header="Code">
<TextBox Name="CodeTextBox" AcceptsReturn="True" xml:space="preserve">
<![CDATA[
<Border xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" BorderThickness="10">
<StackPanel>
<Canvas Height="50" Background="White"></Canvas>
<Button>Button 1</Button>
<Button>Button 2</Button>
<Canvas Height="50"></Canvas>
</StackPanel>
</Border>
]]>
</TextBox>
</TabItem>
<TabItem Header="Design" Name="designTab">
<designer:DesignSurface
xmlns:designer="clr-namespace:ICSharpCode.WpfDesign.Designer;assembly=ICSharpCode.WpfDesign.Designer"
Name="designSurface">
</designer:DesignSurface>
</TabItem>
</TabControl>
</Window>

30
src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/Window1.xaml.cs

@ -0,0 +1,30 @@ @@ -0,0 +1,30 @@
using System;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Markup;
using System.Xml;
namespace StandaloneDesigner
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
}
void tabControlSelectionChanged(object sender, RoutedEventArgs e)
{
if (tabControl.SelectedItem == designTab) {
designSurface.LoadDesigner(new XmlTextReader(new StringReader(CodeTextBox.Text)));
} else {
designSurface.UnloadDesigner();
}
}
}
}

41
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Configuration/AssemblyInfo.cs

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
#region Using directives
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Resources;
using System.Globalization;
using System.Windows;
using System.Runtime.InteropServices;
#endregion
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("WpfDesign.Designer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: CLSCompliant(true)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

79
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/SingleVisualChildElement.cs

@ -0,0 +1,79 @@ @@ -0,0 +1,79 @@
// <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.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// Base class for elements that have a single visual child.
/// </summary>
public class SingleVisualChildElement : FrameworkElement
{
UIElement _visualChild;
/// <summary>
/// Gets/sets the visual child.
/// </summary>
protected UIElement VisualChild {
get { return _visualChild; }
set {
RemoveVisualChild(_visualChild);
_visualChild = value;
AddVisualChild(_visualChild);
InvalidateMeasure();
}
}
/// <summary>
/// Gets the visual child the design surfaces uses to display itself.
/// </summary>
protected override Visual GetVisualChild(int index)
{
if (index == 0 && _visualChild != null)
return _visualChild;
else
throw new ArgumentOutOfRangeException("index");
}
/// <summary>
/// Gets the number of visual children the design surface has.
/// </summary>
protected override int VisualChildrenCount {
get { return _visualChild != null ? 1 : 0; }
}
/// <summary>
/// Measure the visual child.
/// </summary>
protected override Size MeasureOverride(Size availableSize)
{
if (_visualChild != null) {
_visualChild.Measure(availableSize);
return _visualChild.DesiredSize;
} else {
return base.MeasureOverride(availableSize);
}
}
/// <summary>
/// Arrange the visual child.
/// </summary>
protected override Size ArrangeOverride(Size finalSize)
{
if (_visualChild != null) {
_visualChild.Arrange(new Rect(new Point(0, 0), finalSize));
return finalSize;
} else {
return base.ArrangeOverride(finalSize);
}
}
}
}

36
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs

@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
// <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.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using ICSharpCode.WpfDesign.Designer.Controls;
namespace ICSharpCode.WpfDesign.Designer
{
sealed class DesignPanel : SingleVisualChildElement
{
UIElement _designedElement;
public UIElement DesignedElement {
get {
return _designedElement;
}
set {
_designedElement = value;
this.VisualChild = value;
}
}
protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
{
return base.HitTestCore(hitTestParameters);
}
}
}

89
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.cs

@ -0,0 +1,89 @@ @@ -0,0 +1,89 @@
// <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.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Markup;
using System.Xml;
using ICSharpCode.WpfDesign.XamlDom;
using ICSharpCode.WpfDesign.Designer.Services;
using ICSharpCode.WpfDesign.Designer.Controls;
namespace ICSharpCode.WpfDesign.Designer
{
/// <summary>
/// Surface hosting the WPF designer.
/// </summary>
public sealed class DesignSurface : SingleVisualChildElement
{
readonly DefaultServiceProvider _defaultServiceProvider;
readonly ScrollViewer _scrollViewer;
readonly DesignPanel _designPanel;
/// <summary>
/// Create a new DesignSurface instance.
/// </summary>
public DesignSurface()
{
DesignServiceContainer serviceContainer = new DesignServiceContainer();
serviceContainer.AddService(typeof(IVisualDesignService), new DefaultVisualDesignService());
serviceContainer.AddService(typeof(ISelectionService), new DefaultSelectionService());
_defaultServiceProvider = new DefaultServiceProvider(serviceContainer);
_scrollViewer = new ScrollViewer();
_designPanel = new DesignPanel();
_scrollViewer.Content = _designPanel;
this.VisualChild = _scrollViewer;
}
/// <summary>
/// Gets the service provider.
/// </summary>
public DefaultServiceProvider DefaultServiceProvider {
get { return _defaultServiceProvider; }
}
/// <summary>
/// Gets the designed element.
/// </summary>
public UIElement DesignedElement {
get {
return _designPanel.DesignedElement;
}
}
/// <summary>
/// Initializes the designer content from the specified XmlReader.
/// </summary>
public void LoadDesigner(XmlReader xamlReader)
{
UnloadDesigner();
InitializeDesigner(XamlParser.Parse(xamlReader));
}
void InitializeDesigner(XamlDocument document)
{
DesignSite rootSite = new XamlDesignSite(document.RootElement, this);
_designPanel.DesignedElement = DefaultVisualDesignService.CreateUIElementFor(rootSite);
}
/// <summary>
/// Unloads the designer content.
/// </summary>
public void UnloadDesigner()
{
UIElement designedElement = this.DesignedElement;
if (designedElement != null) {
_designPanel.DesignedElement = null;
}
}
}
}

197
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/HashSet.cs

@ -0,0 +1,197 @@ @@ -0,0 +1,197 @@
// <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;
using System.Text;
using System.Collections;
using System.Collections.Specialized;
namespace ICSharpCode.WpfDesign.Designer
{
/// <summary>
/// Represents a set of items. The set does not preserve the order of items and does not allow items to
/// be added twice.
/// It supports collection change notifications and is cloned by sharing the underlying
/// data structure and delaying the actual copy until the next change.
/// </summary>
sealed class HashSet<T> : ICollection<T>, ICollection, ICloneable, INotifyCollectionChanged
where T : class
{
Dictionary<T, object> _dict;
bool _copyOnWrite;
public event NotifyCollectionChangedEventHandler CollectionChanged;
/// <summary>
/// Creates a new, empty set.
/// </summary>
public HashSet()
{
_dict = new Dictionary<T, object>();
}
/// <summary>
/// Creates a copy of the existing set.
/// </summary>
public HashSet(HashSet<T> existingSet)
{
existingSet._copyOnWrite = true;
this._copyOnWrite = true;
_dict = existingSet._dict;
}
/// <summary>
/// Adds the item to the set.
/// Trying to add <c>null</c> will return false without changing the collection.
/// </summary>
/// <returns>True when the item was added, false when it was not added because it already is in the set</returns>
public bool Add(T item)
{
if (item == null)
return false;
if (_dict.ContainsKey(item)) {
return false;
} else {
CopyIfRequired();
_dict.Add(item, null);
if (CollectionChanged != null) {
CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item));
}
return true;
}
}
public void AddRange(IEnumerable<T> items)
{
foreach (T item in items) {
Add(item);
}
}
private void CopyIfRequired()
{
if (_copyOnWrite) {
_copyOnWrite = false;
_dict = new Dictionary<T, object>(_dict);
}
}
/// <summary>
/// Removes all items from the set.
/// </summary>
public void Clear()
{
_dict.Clear();
}
/// <summary>
/// Tests if this set contains the specified item.
/// Checking for <c>null</c> always returns false.
/// </summary>
public bool Contains(T item)
{
if (item == null)
return false;
else
return _dict.ContainsKey(item);
}
/// <summary>
/// Gets the number of items in the collection.
/// </summary>
public int Count
{
get { return _dict.Count; }
}
/// <summary>
/// Removes an item from the set.
/// Trying to remove <c>null</c> will return false without changing the collection.
/// </summary>
public bool Remove(T item)
{
if (item == null)
return false;
CopyIfRequired();
if (_dict.Remove(item)) {
if (CollectionChanged != null) {
CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item));
}
return true;
} else {
return false;
}
}
/// <summary>
/// Copy all items to the specified array.
/// </summary>
void ICollection<T>.CopyTo(T[] array, int arrayIndex)
{
_dict.Keys.CopyTo(array, arrayIndex);
}
void ICollection<T>.Add(T item)
{
this.Add(item);
}
bool ICollection<T>.IsReadOnly
{
get { return false; }
}
#region IEnumerable Members
public IEnumerator<T> GetEnumerator()
{
return _dict.Keys.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return _dict.Keys.GetEnumerator();
}
#endregion
#region ICollection Members
void ICollection.CopyTo(Array array, int index)
{
((ICollection)_dict).CopyTo(array, index);
}
bool ICollection.IsSynchronized
{
get { return false; }
}
object ICollection.SyncRoot
{
get { return null; }
}
#endregion
#region ICloneable Members
/// <summary>
/// Create a copy of this set.
/// </summary>
public HashSet<T> Clone()
{
return new HashSet<T>(this);
}
object ICloneable.Clone()
{
return this.Clone();
}
#endregion
}
}

39
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/DesignServiceContainer.cs

@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
// <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;
}
}
}

168
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/SelectionService.cs

@ -0,0 +1,168 @@ @@ -0,0 +1,168 @@
// <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;
using System.Windows.Input;
namespace ICSharpCode.WpfDesign.Designer.Services
{
/// <summary>
/// Manages the collection of selected components and the primary selection.
/// Notifies components with attached DesignSite when their selection state changes.
/// </summary>
sealed class DefaultSelectionService : ISelectionService
{
HashSet<object> _selectedComponents = new HashSet<object>();
object _primarySelection;
public bool IsComponentSelected(object component)
{
return _selectedComponents.Contains(component);
}
public ICollection<object> SelectedComponents {
get { return _selectedComponents.Clone(); }
}
public object PrimarySelection
{
get { return _primarySelection; }
}
public int SelectionCount
{
get { return _selectedComponents.Count; }
}
public event EventHandler SelectionChanging;
public event EventHandler<ComponentCollectionEventArgs> SelectionChanged;
public event EventHandler PrimarySelectionChanging;
public event EventHandler PrimarySelectionChanged;
public void SetSelectedComponents(ICollection<object> components)
{
SetSelectedComponents(components, SelectionTypes.Auto);
}
public void SetSelectedComponents(ICollection<object> components, SelectionTypes selectionType)
{
if (components == null)
components = new object[0];
if (SelectionChanging != null)
SelectionChanging(this, EventArgs.Empty);
object newPrimarySelection = _primarySelection;
if (selectionType == SelectionTypes.Auto) {
if (Keyboard.Modifiers == ModifierKeys.Control)
selectionType = SelectionTypes.Toggle; // Ctrl pressed: toggle selection
else if ((Keyboard.Modifiers & ~ModifierKeys.Control) == ModifierKeys.Shift)
selectionType = SelectionTypes.Add; // Shift or Ctrl+Shift pressed: add to selection
else
selectionType = SelectionTypes.Primary; // otherwise: change primary selection
}
if ((selectionType & SelectionTypes.Primary) == SelectionTypes.Primary) {
// change primary selection to first new component
newPrimarySelection = null;
foreach (object obj in components) {
newPrimarySelection = obj;
break;
}
selectionType &= ~SelectionTypes.Primary;
// if selectionType was only Primary, keep current selection; but if new primary selection
// is not yet selected, replace existing selection with new
if (selectionType == 0 && IsComponentSelected(newPrimarySelection) == false) {
selectionType = SelectionTypes.Replace;
}
}
HashSet<object> componentsToNotifyOfSelectionChange = new HashSet<object>();
switch (selectionType) {
case SelectionTypes.Add:
// add to selection and notify if required
foreach (object 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) {
if (_selectedComponents.Remove(obj))
componentsToNotifyOfSelectionChange.Add(obj);
}
break;
case SelectionTypes.Replace:
// notify all old components:
componentsToNotifyOfSelectionChange.AddRange(_selectedComponents);
// set _selectedCompontents to new components
_selectedComponents.Clear();
foreach (object obj in components) {
_selectedComponents.Add(obj);
// notify the new components
componentsToNotifyOfSelectionChange.Add(obj);
}
break;
case SelectionTypes.Toggle:
// toggle selection and notify
foreach (object obj in components) {
if (_selectedComponents.Contains(obj)) {
_selectedComponents.Remove(obj);
} else {
_selectedComponents.Add(obj);
}
componentsToNotifyOfSelectionChange.Add(obj);
}
break;
case 0:
// do nothing
break;
default:
throw new NotSupportedException("The selection type " + selectionType + " is not supported");
}
if (!IsComponentSelected(newPrimarySelection)) {
// primary selection is not selected anymore - change primary selection to any other selected component
newPrimarySelection = null;
foreach (object obj in _selectedComponents) {
newPrimarySelection = obj;
break;
}
}
// Primary selection has changed:
if (newPrimarySelection != _primarySelection) {
componentsToNotifyOfSelectionChange.Add(_primarySelection);
componentsToNotifyOfSelectionChange.Add(newPrimarySelection);
if (PrimarySelectionChanging != null) {
PrimarySelectionChanging(this, EventArgs.Empty);
}
_primarySelection = newPrimarySelection;
if (PrimarySelectionChanged != null) {
PrimarySelectionChanged(this, EventArgs.Empty);
}
}
// 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));
}
}
}
}

66
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/VisualDesignService.cs

@ -0,0 +1,66 @@ @@ -0,0 +1,66 @@
// <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.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace ICSharpCode.WpfDesign.Designer.Services
{
sealed class DefaultVisualDesignService : IVisualDesignService
{
public UIElement CreateWrapper(DesignSite site)
{
if (site == null)
throw new ArgumentNullException("site");
object obj = site.Component;
if (obj is UIElement)
return null;
else
return new FallbackObjectWrapper(site);
}
internal static UIElement CreateUIElementFor(DesignSite site)
{
UIElement element = site.Services.VisualDesign.CreateWrapper(site);
if (element != null) {
if (!(element is IVisualDesignObjectWrapper)) {
throw new DesignerException("IVisualDesignService.CreateWrapper must return null or UIElement implementing IVisualDesignObjectWrapper");
}
} else {
element = site.Component as UIElement;
if (element == null) {
throw new DesignerException("IVisualDesignService.CreateWrapper may not return null if site.Component is no UIElement");
}
}
return element;
}
}
sealed class FallbackObjectWrapper : ContentControl, IVisualDesignObjectWrapper
{
DesignSite _site;
public FallbackObjectWrapper(DesignSite site)
{
this._site = site;
this.BorderThickness = new Thickness(1);
this.BorderBrush = Brushes.Black;
this.Background = Brushes.White;
this.Foreground = Brushes.Black;
this.Content = site.Component;
}
public DesignSite WrappedSite {
get { return _site; }
}
}
}

82
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj

@ -0,0 +1,82 @@ @@ -0,0 +1,82 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{78CC29AC-CC79-4355-B1F2-97936DF198AC}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.WpfDesign.Designer</RootNamespace>
<AssemblyName>ICSharpCode.WpfDesign.Designer</AssemblyName>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<OutputPath>..\..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\</OutputPath>
<DocumentationFile>..\..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.Designer.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>False</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="PresentationCore">
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="PresentationFramework">
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase">
<Private>False</Private>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />
<ItemGroup>
<Compile Include="..\..\..\..\..\Main\GlobalAssemblyInfo.cs">
<Link>Configuration\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Controls\SingleVisualChildElement.cs" />
<Compile Include="DesignPanel.cs" />
<Compile Include="HashSet.cs" />
<Compile Include="Services\DesignServiceContainer.cs" />
<Compile Include="Services\SelectionService.cs" />
<Compile Include="Services\VisualDesignService.cs" />
<Compile Include="XamlDesignSite.cs" />
<Compile Include="DesignSurface.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Configuration" />
<Folder Include="Controls" />
<Folder Include="Services" />
<ProjectReference Include="..\..\WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj">
<Project>{88DA149F-21B2-48AB-82C4-28FB6BDFD783}</Project>
<Name>WpfDesign.XamlDom</Name>
</ProjectReference>
<ProjectReference Include="..\..\WpfDesign\Project\WpfDesign.csproj">
<Project>{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}</Project>
<Name>WpfDesign</Name>
<SpecificVersion>False</SpecificVersion>
</ProjectReference>
</ItemGroup>
</Project>

35
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/XamlDesignSite.cs

@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@
// <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;
namespace ICSharpCode.WpfDesign.Designer
{
sealed class XamlDesignSite : DesignSite
{
readonly XamlObject xamlObject;
readonly DesignSurface designSurface;
public XamlDesignSite(XamlObject xamlObject, DesignSurface designSurface)
{
this.xamlObject = xamlObject;
this.designSurface = designSurface;
}
public override object Component {
get {
return xamlObject.Instance;
}
}
public override object GetService(Type serviceType)
{
return designSurface.DefaultServiceProvider.GetService(serviceType);
}
}
}

5
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/WpfDesign.XamlDom.csproj

@ -6,7 +6,6 @@ @@ -6,7 +6,6 @@
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.WpfDesign.XamlDom</RootNamespace>
<AssemblyName>ICSharpCode.WpfDesign.XamlDom</AssemblyName>
<DocumentationFile>bin\Debug\ICSharpCode.WpfDesign.XamlDom.xml</DocumentationFile>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
@ -17,9 +16,10 @@ @@ -17,9 +16,10 @@
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
<RunCodeAnalysis>False</RunCodeAnalysis>
<CodeAnalysisRules>-Microsoft.Globalization#CA1303</CodeAnalysisRules>
<OutputPath>..\..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\</OutputPath>
<DocumentationFile>..\..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.XamlDom.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
@ -27,7 +27,6 @@ @@ -27,7 +27,6 @@
<Optimize>False</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>

25
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlPropertyInfo.cs

@ -115,12 +115,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -115,12 +115,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
internal override void AddValue(object collectionInstance, XamlPropertyValue newElement)
{
_propertyDescriptor.PropertyType.InvokeMember(
"Add", BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Instance,
null, collectionInstance,
new object[] {
newElement.GetValueFor(null)
}, CultureInfo.InvariantCulture);
CollectionSupport.AddToCollection(_propertyDescriptor.PropertyType, collectionInstance, newElement);
}
}
@ -134,6 +129,22 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -134,6 +129,22 @@ namespace ICSharpCode.WpfDesign.XamlDom
|| typeof(IAddChild).IsAssignableFrom(type);
}
//public static
public static void AddToCollection(Type collectionType, object collectionInstance, XamlPropertyValue newElement)
{
IAddChild addChild = collectionInstance as IAddChild;
if (addChild != null) {
if (newElement is XamlTextValue) {
addChild.AddText((string)newElement.GetValueFor(null));
} else {
addChild.AddChild(newElement.GetValueFor(null));
}
} else {
collectionType.InvokeMember(
"Add", BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Instance,
null, collectionInstance,
new object[] { newElement.GetValueFor(null) },
CultureInfo.InvariantCulture);
}
}
}
}

5
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs

@ -94,7 +94,10 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -94,7 +94,10 @@ namespace ICSharpCode.WpfDesign.XamlDom
assembly = name.Substring("assembly=".Length);
}
XamlNamespace ns = new XamlNamespace();
ns.ClrNamespaces.Add(new AssemblyNamespaceMapping(LoadAssembly(assembly), namespaceName));
Assembly asm = LoadAssembly(assembly);
if (asm != null) {
ns.ClrNamespaces.Add(new AssemblyNamespaceMapping(asm, namespaceName));
}
return ns;
}

17
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Tests/WpfDesign.XamlDom.Tests.csproj

@ -6,21 +6,32 @@ @@ -6,21 +6,32 @@
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.WpfDesign.XamlDom.Tests</RootNamespace>
<AssemblyName>ICSharpCode.WpfDesign.XamlDom.Tests</AssemblyName>
<OutputPath>..\..\..\..\..\..\bin\UnitTests\</OutputPath>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
<DebugSymbols>True</DebugSymbols>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>False</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="nunit.framework">

18
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.sln

@ -6,6 +6,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.XamlDom", "WpfDes @@ -6,6 +6,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.XamlDom", "WpfDes
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.XamlDom.Tests", "WpfDesign.XamlDom\Tests\WpfDesign.XamlDom.Tests.csproj", "{BD62F5BC-115F-4339-8B5B-96C7A21DC67E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.Designer", "WpfDesign.Designer\Project\WpfDesign.Designer.csproj", "{78CC29AC-CC79-4355-B1F2-97936DF198AC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StandaloneDesigner", "StandaloneDesigner\StandaloneDesigner.csproj", "{84D65E9C-B66C-44C3-95FD-445EFE3ED322}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign", "WpfDesign\Project\WpfDesign.csproj", "{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -20,5 +26,17 @@ Global @@ -20,5 +26,17 @@ Global
{BD62F5BC-115F-4339-8B5B-96C7A21DC67E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BD62F5BC-115F-4339-8B5B-96C7A21DC67E}.Release|Any CPU.Build.0 = Release|Any CPU
{BD62F5BC-115F-4339-8B5B-96C7A21DC67E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Release|Any CPU.Build.0 = Release|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{84D65E9C-B66C-44C3-95FD-445EFE3ED322}.Debug|Any CPU.Build.0 = Debug|Any CPU
{84D65E9C-B66C-44C3-95FD-445EFE3ED322}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{84D65E9C-B66C-44C3-95FD-445EFE3ED322}.Release|Any CPU.Build.0 = Release|Any CPU
{84D65E9C-B66C-44C3-95FD-445EFE3ED322}.Release|Any CPU.ActiveCfg = Release|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Release|Any CPU.Build.0 = Release|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
EndGlobal

58
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ComponentEventArgs.cs

@ -0,0 +1,58 @@ @@ -0,0 +1,58 @@
// <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
{
/// <summary>
/// Event arguments specifying a component as parameter.
/// </summary>
public class ComponentEventArgs : EventArgs
{
readonly object _component;
/// <summary>
/// Creates a new ComponentEventArgs instance.
/// </summary>
public ComponentEventArgs(object component)
{
_component = component;
}
/// <summary>
/// The component affected by the event.
/// </summary>
public object Component {
get { return _component; }
}
}
/// <summary>
/// Event arguments specifying a component as parameter.
/// </summary>
public class ComponentCollectionEventArgs : EventArgs
{
readonly ICollection<object> _components;
/// <summary>
/// Creates a new ComponentCollectionEventArgs instance.
/// </summary>
public ComponentCollectionEventArgs(ICollection<object> components)
{
_components = components;
}
/// <summary>
/// The components affected by the event.
/// </summary>
public ICollection<object> Components {
get { return _components; }
}
}
}

17
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Configuration/AssemblyInfo.cs

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("WpfDesign")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: CLSCompliant(true)]

85
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DefaultServiceProvider.cs

@ -0,0 +1,85 @@ @@ -0,0 +1,85 @@
// <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.ComponentModel;
namespace ICSharpCode.WpfDesign
{
/// <summary>
/// Provides convenience methods for well-known service instances.
/// </summary>
public sealed class DefaultServiceProvider : IServiceProvider
{
readonly IServiceProvider _serviceProvider;
/// <summary>
/// Creates a new DefaultServiceProvider that requests services from the specified service
/// provider.
/// </summary>
public DefaultServiceProvider(IServiceProvider serviceProvider)
{
this._serviceProvider = serviceProvider;
}
/// <summary>
/// Gets the service object of the specified type.
/// </summary>
public object GetService(Type serviceType)
{
return _serviceProvider.GetService(serviceType);
}
/// <summary>
/// Gets the service object of the specified type.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter")]
public T GetService<T>() where T : class
{
return (T)_serviceProvider.GetService(typeof(T));
}
T GetServiceChecked<T>() where T : class
{
T service = (T)_serviceProvider.GetService(typeof(T));
if (service == null) {
throw new DesignerException("Could not find guaranteed service " + typeof(T).FullName);
}
return service;
}
/// <summary>
/// Gets the <see cref="IServiceContainer"/>.
/// This service is guaranteed to always exist -> this property will never return null.
/// </summary>
public IServiceContainer ServiceContainer {
get {
return GetServiceChecked<IServiceContainer>();
}
}
/// <summary>
/// Gets the <see cref="IVisualDesignService"/>.
/// This service is guaranteed to always exist -> this property will never return null.
/// </summary>
public IVisualDesignService VisualDesign {
get {
return GetServiceChecked<IVisualDesignService>();
}
}
/// <summary>
/// Gets the <see cref="ISelectionService"/>.
/// This service is guaranteed to always exist -> this property will never return null.
/// </summary>
public ISelectionService Selection {
get {
return GetServiceChecked<ISelectionService>();
}
}
}
}

42
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignSite.cs

@ -0,0 +1,42 @@ @@ -0,0 +1,42 @@
// <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
{
/// <summary>
/// The DesignSite connects a component with the service system and the designers.
/// </summary>
public abstract class DesignSite : IServiceProvider
{
/// <summary>
/// Gets the component this DesignSite was created for.
/// </summary>
public abstract object Component { get; }
DefaultServiceProvider _defaultServiceProvider;
/// <summary>
/// Gets an instance that provides convenience properties for the most-used designers.
/// </summary>
public DefaultServiceProvider Services {
get {
if (_defaultServiceProvider == null) {
_defaultServiceProvider = new DefaultServiceProvider(this);
}
return _defaultServiceProvider;
}
}
/// <summary>
/// Gets the service with the specified type.
/// </summary>
public abstract object GetService(Type serviceType);
}
}

48
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignerException.cs

@ -0,0 +1,48 @@ @@ -0,0 +1,48 @@
// <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.Runtime.Serialization;
namespace ICSharpCode.WpfDesign
{
/// <summary>
/// Exception class used for designer failures.
/// </summary>
[Serializable]
public class DesignerException : Exception
{
/// <summary>
/// Create a new DesignerException instance.
/// </summary>
public DesignerException()
{
}
/// <summary>
/// Create a new DesignerException instance.
/// </summary>
public DesignerException(string message) : base(message)
{
}
/// <summary>
/// Create a new DesignerException instance.
/// </summary>
public DesignerException(string message, Exception innerException) : base(message, innerException)
{
}
/// <summary>
/// Create a new DesignerException instance.
/// </summary>
protected DesignerException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}

148
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs

@ -0,0 +1,148 @@ @@ -0,0 +1,148 @@
// <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;
using System.Windows;
namespace ICSharpCode.WpfDesign
{
#region IServiceContainer
/// <summary>
/// The <see cref="IServiceContainer"/> is a built-in service that manages the list of services.
/// You can only add services to it, removing or replacing services is not supported because
/// many designers depend on keeping their services available.
/// </summary>
public interface IServiceContainer : IServiceProvider
{
/// <summary>
/// Adds a new service to the container.
/// </summary>
/// <param name="serviceInterface">
/// The type of the service interface to use as a key for the service.
/// </param>
/// <param name="serviceInstance">
/// The service instance implementing that interface.
/// </param>
void AddService(Type serviceInterface, object serviceInstance);
}
#endregion
#region IVisualDesignService
/// <summary>
/// A service that can visualize non-UIElement objects on a design surface.
/// </summary>
public interface IVisualDesignService
{
/// <summary>
/// Create an UIElement for visualizing the object specified by the design site.
/// </summary>
/// <returns>
/// Returns either an UIElement instance that also implements
/// <see cref="IVisualDesignObjectWrapper"/>,
/// or returns null to use the component itself as UIElement.
/// </returns>
UIElement CreateWrapper(DesignSite site);
}
/// <summary>
/// Interface used by the <see cref="IVisualDesignService"/> for UIElements that
/// are inside the design surfaced but used only to represent a non-UIElement entity.
/// </summary>
public interface IVisualDesignObjectWrapper
{
/// <summary>
/// Gets the design site this object was wrapping.
/// </summary>
DesignSite WrappedSite { get; }
}
#endregion
#region ISelectionService
/// <summary>
/// Defines the type how a selection can be changed.
/// </summary>
[Flags]
public enum SelectionTypes
{
/// <summary>
/// No selection type specified.
/// </summary>
None = 0,
/// <summary>
/// Automatically determine the selection type using the currently pressed
/// modifier keys.
/// </summary>
Auto = 1,
/// <summary>
/// Change the primary selection only.
/// </summary>
Primary = 2,
/// <summary>
/// Toggle the selection.
/// </summary>
Toggle = 4,
/// <summary>
/// Add to the selection.
/// </summary>
Add = 8,
/// <summary>
/// Remove from the selection.
/// </summary>
Remove = 0x1,
/// <summary>
/// Replace the selection.
/// </summary>
Replace = 0x2
}
/// <summary>
/// Manages selecting components.
/// </summary>
public interface ISelectionService
{
/// <summary>Occurs when the current selection is about to change.</summary>
event EventHandler SelectionChanging;
/// <summary>Occurs after the current selection has changed.</summary>
event EventHandler<ComponentCollectionEventArgs> SelectionChanged;
/// <summary>Occurs when the primary selection is about to change.</summary>
event EventHandler PrimarySelectionChanging;
/// <summary>Occurs after the primary selection has changed.</summary>
event EventHandler PrimarySelectionChanged;
/// <summary>
/// Gets if the specified component is selected.
/// </summary>
bool IsComponentSelected(object component);
/// <summary>
/// Gets the collection of selected components.
/// </summary>
ICollection<object> SelectedComponents { get; }
/// <summary>
/// Replaces the current selection with the specified selection.
/// </summary>
void SetSelectedComponents(ICollection<object> components);
/// <summary>
/// Modifies the current selection using the specified components and selectionType.
/// </summary>
void SetSelectedComponents(ICollection<object> components, SelectionTypes selectionType);
/// <summary>Gets the object that is currently the primary selected object.</summary>
/// <returns>The object that is currently the primary selected object.</returns>
object PrimarySelection { get; }
/// <summary>Gets the count of selected objects.</summary>
/// <returns>The number of selected objects.</returns>
int SelectionCount { get; }
}
#endregion
}

68
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj

@ -0,0 +1,68 @@ @@ -0,0 +1,68 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.WpfDesign</RootNamespace>
<AssemblyName>ICSharpCode.WpfDesign</AssemblyName>
<DocumentationFile>..\..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.xml</DocumentationFile>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\..\..\..\Main\ICSharpCode.SharpDevelop.snk</AssemblyOriginatorKeyFile>
<DelaySign>False</DelaySign>
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
<OutputPath>..\..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>False</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="PresentationCore">
<Private>False</Private>
</Reference>
<Reference Include="PresentationFramework">
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase">
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\..\..\..\Main\GlobalAssemblyInfo.cs">
<Link>Configuration\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="ComponentEventArgs.cs" />
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="DesignerException.cs" />
<Compile Include="DefaultServiceProvider.cs" />
<Compile Include="DesignSite.cs" />
<Compile Include="Services.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Configuration" />
</ItemGroup>
</Project>

21
src/SharpDevelop.Tests.sln

@ -1,11 +1,19 @@ @@ -1,11 +1,19 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
# SharpDevelop 2.1.0.2166
# SharpDevelop 2.1.0.2192
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AddIns", "AddIns", "{14A277EE-7DF1-4529-B639-7D1EF334C1C5}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WpfDesign", "WpfDesign", "{C12B6EA7-2EFC-4368-B585-EC69EFCC3F97}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.XamlDom.Tests", "AddIns\DisplayBindings\WpfDesign\WpfDesign.XamlDom\Tests\WpfDesign.XamlDom.Tests.csproj", "{BD62F5BC-115F-4339-8B5B-96C7A21DC67E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.XamlDom", "AddIns\DisplayBindings\WpfDesign\WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj", "{88DA149F-21B2-48AB-82C4-28FB6BDFD783}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting.Tests", "AddIns\Misc\UnitTesting\Test\UnitTesting.Tests.csproj", "{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WixBinding.Tests", "AddIns\BackendBindings\WixBinding\Test\WixBinding.Tests.csproj", "{388E7B64-0393-4EB4-A3E3-5C474F141853}"
@ -272,6 +280,14 @@ Global @@ -272,6 +280,14 @@ Global
{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Release|Any CPU.Build.0 = Release|Any CPU
{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Release|Any CPU.ActiveCfg = Release|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Release|Any CPU.Build.0 = Release|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BD62F5BC-115F-4339-8B5B-96C7A21DC67E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BD62F5BC-115F-4339-8B5B-96C7A21DC67E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BD62F5BC-115F-4339-8B5B-96C7A21DC67E}.Release|Any CPU.Build.0 = Release|Any CPU
{BD62F5BC-115F-4339-8B5B-96C7A21DC67E}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -296,6 +312,9 @@ Global @@ -296,6 +312,9 @@ Global
{e1b288a2-08ee-4318-8bbb-8ab72c69e33e} = {14A277EE-7DF1-4529-B639-7D1EF334C1C5}
{388E7B64-0393-4EB4-A3E3-5C474F141853} = {14A277EE-7DF1-4529-B639-7D1EF334C1C5}
{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181} = {14A277EE-7DF1-4529-B639-7D1EF334C1C5}
{C12B6EA7-2EFC-4368-B585-EC69EFCC3F97} = {14A277EE-7DF1-4529-B639-7D1EF334C1C5}
{88DA149F-21B2-48AB-82C4-28FB6BDFD783} = {C12B6EA7-2EFC-4368-B585-EC69EFCC3F97}
{BD62F5BC-115F-4339-8B5B-96C7A21DC67E} = {C12B6EA7-2EFC-4368-B585-EC69EFCC3F97}
{B08385CD-F0CC-488C-B4F4-EEB34B6D2688} = {6604365C-C702-4C10-9BA8-637F1E3D4D0D}
{1D18D788-F7EE-4585-A23B-34DC8EC63CB8} = {6604365C-C702-4C10-9BA8-637F1E3D4D0D}
{EC06F96A-AEEC-49D6-B03D-AB87C6EB674C} = {6604365C-C702-4C10-9BA8-637F1E3D4D0D}

Loading…
Cancel
Save