Browse Source

Begin implementing the PropertyEditor.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2246 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
4a578b3c3d
  1. 5
      src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/StandaloneDesigner.csproj
  2. 67
      src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/StrangeDataSource.cs
  3. 35
      src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/Window1.xaml
  4. 36
      src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/Window1.xaml.cs
  5. 11
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/AdornerLayer.cs
  6. 89
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml
  7. 159
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyEditor.cs
  8. 60
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyEditor.xaml
  9. 24
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyEditorCategoryView.cs
  10. 34
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyEditorStyles.xaml
  11. 54
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyGridView.cs
  12. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/SingleVisualChildElement.cs
  13. 10
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/WindowClone.cs
  14. 11
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
  15. 6
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.cs
  16. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SelectedElementRectangleExtension.cs
  17. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TabItemClickableExtension.cs
  18. 10
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Linq.cs
  19. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
  20. 14
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs
  21. 29
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelProperty.cs
  22. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelPropertyCollection.cs
  23. 84
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/themes/generic.xaml
  24. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlConstants.cs
  25. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs
  26. 29
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs
  27. 5
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItemProperty.cs
  28. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/HashSet.cs
  29. 17
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Linq.cs
  30. 82
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/DesignItemDataProperty.cs
  31. 96
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/DesignItemDataSource.cs
  32. 92
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/IPropertyEditorDataSource.cs
  33. 33
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/MultiSelectionDataSource.cs
  34. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ServiceContainer.cs
  35. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs
  36. 5
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj

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

@ -48,6 +48,7 @@ @@ -48,6 +48,7 @@
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="StrangeDataSource.cs" />
<Compile Include="Window1.xaml.cs">
<SubType>Code</SubType>
<DependentUpon>Window1.xaml</DependentUpon>
@ -57,5 +58,9 @@ @@ -57,5 +58,9 @@
<Project>{78CC29AC-CC79-4355-B1F2-97936DF198AC}</Project>
<Name>WpfDesign.Designer</Name>
</ProjectReference>
<ProjectReference Include="..\WpfDesign\Project\WpfDesign.csproj">
<Project>{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}</Project>
<Name>WpfDesign</Name>
</ProjectReference>
</ItemGroup>
</Project>

67
src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/StrangeDataSource.cs

@ -0,0 +1,67 @@ @@ -0,0 +1,67 @@
// <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.PropertyEditor;
using System.Windows;
using System.Windows.Threading;
namespace StandaloneDesigner
{
public class StrangeDataSource : IPropertyEditorDataSource
{
string name;
public string Name {
get { return name; }
set {
name = value;
if (NameChanged != null) {
NameChanged(this, EventArgs.Empty);
}
}
}
public StrangeDataSource()
{
// set the name of this data source to the current time
DispatcherTimer t = new DispatcherTimer();
t.Interval = TimeSpan.FromSeconds(1);
t.Tick += delegate {
this.Name = DateTime.Now.ToString();
};
t.Start();
}
public event EventHandler NameChanged;
public string Type {
get {
return "Strange";
}
}
public System.Windows.Media.ImageSource Icon {
get {
return null;
}
}
public System.Collections.Generic.ICollection<IPropertyEditorDataProperty> Properties {
get {
return new IPropertyEditorDataProperty[0];
}
}
public bool CanAddAttachedProperties {
get {
return false;
}
}
}
}

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

@ -1,11 +1,20 @@ @@ -1,11 +1,20 @@
<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"
xmlns:designer="clr-namespace:ICSharpCode.WpfDesign.Designer;assembly=ICSharpCode.WpfDesign.Designer"
Title="StandaloneDesigner" Height="500" Width="700"
>
<TabControl TabStripPlacement="Bottom" Name="tabControl" SelectionChanged="tabControlSelectionChanged">
<TabItem Header="Code">
<TextBox Name="CodeTextBox" AcceptsReturn="True" xml:space="preserve"><![CDATA[
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="225"/>
</Grid.ColumnDefinitions>
<TabControl TabStripPlacement="Bottom" Name="tabControl" SelectionChanged="tabControlSelectionChanged" Grid.Column="0">
<TabItem Header="Code">
<TextBox Name="CodeTextBox" AcceptsReturn="True"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto"
xml:space="preserve"><![CDATA[
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WindowTitle"
@ -21,12 +30,14 @@ @@ -21,12 +30,14 @@
</StackPanel>
</Window>
]]></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>
</TabItem>
<TabItem Header="Design" Name="designTab">
<designer:DesignSurface
Name="designSurface">
</designer:DesignSurface>
</TabItem>
</TabControl>
<GridSplitter HorizontalAlignment="Left" Width="4" VerticalAlignment="Stretch" Grid.Column="1"/>
<designer:PropertyEditor Name="propertyEditor" Grid.Column="1" Margin="4 0 0 0" FontSize="8.25pt"/>
</Grid>
</Window>

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

@ -6,6 +6,9 @@ using System.Windows.Controls; @@ -6,6 +6,9 @@ using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Markup;
using System.Xml;
using ICSharpCode.WpfDesign;
using ICSharpCode.WpfDesign.Designer;
using ICSharpCode.WpfDesign.PropertyEditor;
namespace StandaloneDesigner
{
@ -16,17 +19,48 @@ namespace StandaloneDesigner @@ -16,17 +19,48 @@ namespace StandaloneDesigner
{
public Window1()
{
InitializeComponent();
try {
InitializeComponent();
} catch (Exception ex) {
MessageBox.Show(ex.ToString());
Close();
}
propertyEditor.EditedObject = new StrangeDataSource();
}
#if XAML_DEFINITIONS
// this is not compiled, but gives us code-completion inside SharpDevelop
TextBox CodeTextBox;
DesignSurface designSurface;
PropertyEditor propertyEditor;
#endif
void tabControlSelectionChanged(object sender, RoutedEventArgs e)
{
if (e.Source != tabControl) return;
if (tabControl.SelectedItem == designTab) {
designSurface.LoadDesigner(new XmlTextReader(new StringReader(CodeTextBox.Text)));
designSurface.DesignContext.Services.Selection.SelectionChanged += OnSelectionChanged;
} else {
if (designSurface.DesignContext != null) {
propertyEditor.EditedObject = null;
using (StringWriter writer = new StringWriter()) {
using (XmlTextWriter xmlWriter = new XmlTextWriter(writer)) {
xmlWriter.Formatting = Formatting.Indented;
designSurface.SaveDesigner(xmlWriter);
}
CodeTextBox.Text = writer.ToString();
}
}
designSurface.UnloadDesigner();
}
}
void OnSelectionChanged(object sender, DesignItemCollectionEventArgs e)
{
propertyEditor.EditedObject = new DesignItemDataSource(designSurface.DesignContext.Services.Selection.PrimarySelection);
}
}
}

11
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/AdornerLayer.cs

@ -6,11 +6,12 @@ @@ -6,11 +6,12 @@
// </file>
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using ICSharpCode.WpfDesign.Adorners;
namespace ICSharpCode.WpfDesign.Designer.Controls
@ -89,7 +90,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -89,7 +90,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
AdornerPanelCollection _adorners;
readonly UIElement _designPanel;
#if DEBUG
#if DEBUG_ADORNERLAYER
int _totalAdornerCount;
#endif
@ -139,7 +140,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -139,7 +140,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
this.Children.Clear();
_dict = new Dictionary<UIElement, AdornerInfo>();
#if DEBUG
#if DEBUG_ADORNERLAYER
_totalAdornerCount = 0;
Debug.WriteLine("AdornerLayer cleared.");
#endif
@ -174,8 +175,10 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -174,8 +175,10 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
AddAdornerToChildren(adornerPanel);
}
#if DEBUG_ADORNERLAYER
Debug.WriteLine("Adorner added. AdornedElements=" + _dict.Count +
", visible adorners=" + VisualChildrenCount + ", total adorners=" + (++_totalAdornerCount));
#endif
}
void AddAdornerToChildren(AdornerPanel adornerPanel)
@ -229,8 +232,10 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -229,8 +232,10 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
_dict.Remove(adornerPanel.AdornedElement);
}
#if DEBUG_ADORNERLAYER
Debug.WriteLine("Adorner removed. AdornedElements=" + _dict.Count +
", visible adorners=" + VisualChildrenCount + ", total adorners=" + (--_totalAdornerCount));
#endif
return true;
} else {

89
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml

@ -0,0 +1,89 @@ @@ -0,0 +1,89 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:src="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls"
>
<!--
This file contains the default styles used by the Controls in ICSharpCode.WpfDesign.Designer.Controls
-->
<Style TargetType="{x:Type src:ResizeThumb}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type src:ResizeThumb}">
<Rectangle Name="thumbRectangle"
Width="7" Height="7" SnapsToDevicePixels="True"
Stroke="Black" Fill="White" RadiusX="1.4142" RadiusY="1.4142"/>
<ControlTemplate.Triggers>
<Trigger Property="IsPrimarySelection" Value="False">
<Setter TargetName="thumbRectangle" Property="Stroke" Value="White"/>
<Setter TargetName="thumbRectangle" Property="Fill" Value="Black"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="thumbRectangle" Property="Fill" Value="Gray"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type src:ContainerDragHandle}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type src:ContainerDragHandle}">
<Canvas Height="13" Width="13" Name="Canvas" SnapsToDevicePixels="True">
<Rectangle Height="13" Width="13" RadiusX="2" RadiusY="2"
Fill="#889ABFE5" Name="BorderRectangle" Stroke="#FF7A8FB5" StrokeThickness="1" />
<Path Fill="#FF748EAA" Canvas.Left="1" Canvas.Top="1">
<Path.Data>
<GeometryGroup>
<PathGeometry Figures="M5.5,0L3,3L8,3 M11,5.5L8,3L8,8 M5.5,11L3,8L8,8 M0,5.5L3,3L3,8" />
<RectangleGeometry Rect="3,5,5,1" />
<RectangleGeometry Rect="5,3,1,5" />
<RectangleGeometry Rect="5,5,1,1" />
</GeometryGroup>
</Path.Data>
</Path>
</Canvas>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type src:WindowClone}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="src:WindowClone">
<Border Background="{DynamicResource {x:Static SystemColors.GradientActiveCaptionBrushKey}}" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" BorderThickness="1,1,1,1" CornerRadius="5,5,5,5">
<DockPanel Margin="4,0,4,4">
<DockPanel Height="26" DockPanel.Dock="Top">
<Image Width="16" Height="16" Margin="1,0,0,0" Source="{TemplateBinding Window.Icon}" />
<Button Name="CloseButton" VerticalAlignment="Top" Width="43" Height="17" DockPanel.Dock="Right">
<Path Fill="#FFF6F2F2" Stretch="Uniform" Margin="1" Stroke="#FF808080" Data="M160,400 L176,400 192,384 208,400 224,400 200,376 224,352 208,352 192,368 176,352 160,352 184,376 z"/>
</Button>
<Button Name="MaximiseButton" VerticalAlignment="Top" Width="25" Height="17" DockPanel.Dock="Right"/>
<Button Name="MinimizeButton" VerticalAlignment="Top" Width="25" Height="17" DockPanel.Dock="Right">
<!--<Rectangle Fill="#FFF6F2F2" RadiusX="0.5" RadiusY="0.5" Width="12" Height="5" Stroke="#FF808080" VerticalAlignment="Bottom" HorizontalAlignment="Center"/>-->
</Button>
<Label Margin="4,0,0,0" Content="{TemplateBinding Window.Title}"/>
</DockPanel>
<Border Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}">
<Border
BorderBrush="{TemplateBinding Border.BorderBrush}"
BorderThickness="{TemplateBinding Border.BorderThickness}"
Background="{TemplateBinding Panel.Background}">
<AdornerDecorator>
<ContentPresenter
ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
Content="{TemplateBinding ContentControl.Content}" />
</AdornerDecorator>
</Border>
</Border>
</DockPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

159
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyEditor.cs

@ -0,0 +1,159 @@ @@ -0,0 +1,159 @@
// <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;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.Designer.Controls;
using ICSharpCode.WpfDesign.PropertyEditor;
namespace ICSharpCode.WpfDesign.Designer
{
/// <summary>
/// Description of PropertyGrid.
/// </summary>
public partial class PropertyEditor : UserControl
{
/// <summary>
/// Dependency property for <see cref="EditedObject"/>.
/// </summary>
public static readonly DependencyProperty EditedObjectProperty
= DependencyProperty.Register("EditedObject", typeof(IPropertyEditorDataSource), typeof(PropertyEditor),
new FrameworkPropertyMetadata(null, _OnEditedObjectPropertyChanged));
#if XAML_DEFINITIONS
// this is not compiled, but gives us code-completion inside SharpDevelop
TextBox nameTextBox;
Label typeLabel;
Image componentImage;
TextBox searchTextBox;
StackPanel contentStackPanel;
#endif
/// <summary>
/// Creates a new PropertyGrid instance.
/// </summary>
public PropertyEditor()
{
try {
InitializeComponent();
} catch (Exception ex) {
Debug.WriteLine(ex.ToString());
throw;
}
PropertyEditorCategoryView v = new PropertyEditorCategoryView();
v.Header = "Titel";
v.Content = "Inhalt";
contentStackPanel.Children.Add(v);
}
/// <summary>
/// Gets/Sets the object being edited.
/// </summary>
public IPropertyEditorDataSource EditedObject {
get { return (IPropertyEditorDataSource)GetValue(EditedObjectProperty); }
set { SetValue(EditedObjectProperty, value); }
}
/// <summary>
/// Is raised when the object being edited changes.
/// </summary>
public event EventHandler EditedObjectChanged;
static void _OnEditedObjectPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
{
((PropertyEditor)obj).OnEditedObjectPropertyChanged(e);
}
void OnEditedObjectPropertyChanged(DependencyPropertyChangedEventArgs e)
{
ShowProperties(e.NewValue as IPropertyEditorDataSource);
if (EditedObjectChanged != null) {
EditedObjectChanged(this, EventArgs.Empty);
}
}
void ShowPropertiesButton_Click(object sender, RoutedEventArgs e)
{
ShowProperties(this.EditedObject);
}
void ShowEventsButton_Click(object sender, RoutedEventArgs e)
{
}
void ShowProperties(IPropertyEditorDataSource dataSource)
{
contentStackPanel.Children.Clear();
if (dataSource == null)
return;
List<PropertyEditorCategoryView> categories = new List<PropertyEditorCategoryView>();
foreach (IPropertyEditorDataProperty p in Linq.Sort(dataSource.Properties, ComparePropertyNames)) {
PropertyEditorCategoryView cv = GetOrCreateCategory(categories, p.Category);
PropertyGridView grid = (PropertyGridView)cv.Content;
grid.AddProperty(p);
}
// Sort category titles alphabetically
categories.Sort(delegate (PropertyEditorCategoryView c1, PropertyEditorCategoryView c2) {
return c1.Header.ToString().CompareTo(c2.Header.ToString());
});
// Add categories to contentStackPanel
foreach (PropertyEditorCategoryView c in categories) {
contentStackPanel.Children.Add(c);
}
}
static int ComparePropertyNames(IPropertyEditorDataProperty p1, IPropertyEditorDataProperty p2)
{
return p1.Name.CompareTo(p2.Name);
}
static PropertyEditorCategoryView GetOrCreateCategory(List<PropertyEditorCategoryView> categories, string category)
{
foreach (PropertyEditorCategoryView c in categories) {
if (c.Header.ToString() == category)
return c;
}
PropertyEditorCategoryView newCategory = new PropertyEditorCategoryView();
newCategory.Header = category;
newCategory.Content = new PropertyGridView();
categories.Add(newCategory);
return newCategory;
}
/*
void clearSearchButton_Click(object sender, RoutedEventArgs e)
{
searchTextBox.Text = "";
}
*/
void nameTextBox_SizeChanged(object sender, RoutedEventArgs e)
{
// Display componentImage only if there is enough space left.
const double minimalNameTextBoxWidth = 80;
const double switchTreshold = 5;
if (componentImage.Visibility != Visibility.Collapsed) {
if (nameTextBox.ActualWidth < minimalNameTextBoxWidth - switchTreshold) {
componentImage.Visibility = Visibility.Collapsed;
}
} else {
if (nameTextBox.ActualWidth > minimalNameTextBoxWidth + componentImage.Width + switchTreshold) {
componentImage.Visibility = Visibility.Visible;
}
}
}
}
}

60
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyEditor.xaml

@ -0,0 +1,60 @@ @@ -0,0 +1,60 @@
<UserControl x:Class="ICSharpCode.WpfDesign.Designer.PropertyEditor"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="userControl">
<DockPanel>
<Border DockPanel.Dock="Top"
Background="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}"
CornerRadius="0 0 0 15" Padding="4">
<StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Image Grid.Column="0" Width="32" Height="32" Name="componentImage" />
<Grid Grid.Column="1" Margin="0 0 2 0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.5*" />
<RowDefinition Height="0.5*" />
</Grid.RowDefinitions>
<Label Grid.Column="0" Grid.Row="0" Target="{Binding ElementName=nameTextBox}">_Name:</Label>
<TextBox Grid.Column="1" Grid.Row="0" Name="nameTextBox" SizeChanged="nameTextBox_SizeChanged"
Text="{Binding ElementName=userControl, Path=EditedObject.Name}"/>
<Label Grid.Column="0" Grid.Row="1">Type:</Label>
<Label Grid.Column="1" Grid.Row="1" Name="typeLabel"
Content="{Binding ElementName=userControl, Path=EditedObject.Type}"/>
</Grid>
<StackPanel Grid.Column="2" Orientation="Horizontal">
<Rectangle Margin="2" Width="1.5" Fill="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}"/>
<Button VerticalAlignment="Center" Click="ShowPropertiesButton_Click">P</Button>
<Button VerticalAlignment="Center" Click="ShowEventsButton_Click">E</Button>
</StackPanel>
</Grid>
<!--
<Rectangle Margin="2" Height="1px" SnapsToDevicePixels="True"
Fill="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Label>_Search:</Label>
<TextBox Grid.Column="1" Name="searchTextBox"></TextBox>
<Button Grid.Column="2" Click="clearSearchButton_Click">X</Button>
</Grid>
-->
</StackPanel>
</Border>
<ScrollViewer Margin="0 1 0 0">
<StackPanel Name="contentStackPanel">
</StackPanel>
</ScrollViewer>
</DockPanel>
</UserControl>

24
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyEditorCategoryView.cs

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
// <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;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// Control used to view a property grid category.
/// </summary>
public sealed class PropertyEditorCategoryView : HeaderedContentControl
{
static PropertyEditorCategoryView()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(PropertyEditorCategoryView), new FrameworkPropertyMetadata(typeof(PropertyEditorCategoryView)));
}
}
}

34
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyEditorStyles.xaml

@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:src="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls"
>
<Style TargetType="{x:Type src:PropertyEditorCategoryView}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type src:PropertyEditorCategoryView}">
<Border Name="border"
Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
CornerRadius="10" Margin="1">
<Expander Name="expander" Header="{TemplateBinding Header}">
<Border Margin="10 0 2 2">
<ContentPresenter/>
</Border>
</Expander>
</Border>
<ControlTemplate.Triggers>
<Trigger SourceName="expander" Property="IsExpanded" Value="True">
<Setter TargetName="border" Property="Background"
Value="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type src:PropertyGridView}">
</Style>
</ResourceDictionary>

54
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyGridView.cs

@ -0,0 +1,54 @@ @@ -0,0 +1,54 @@
// <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 ICSharpCode.WpfDesign.PropertyEditor;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// Control used to view a property grid category.
/// </summary>
public sealed class PropertyGridView : Grid
{
static PropertyGridView()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(PropertyGridView), new FrameworkPropertyMetadata(typeof(PropertyGridView)));
}
/// <summary>
/// Creates a new PropertyGridView instance.
/// </summary>
public PropertyGridView()
{
this.ColumnDefinitions.Add(new ColumnDefinition());
this.ColumnDefinitions.Add(new ColumnDefinition());
this.ColumnDefinitions.Add(new ColumnDefinition());
this.ColumnDefinitions[0].Width = new GridLength(0.45, GridUnitType.Star);
this.ColumnDefinitions[0].MinWidth = 40;
this.ColumnDefinitions[1].Width = new GridLength(0.55, GridUnitType.Star);
this.ColumnDefinitions[2].Width = new GridLength(10);
}
/// <summary>
/// Adds a new property to the PropertyGridView.
/// </summary>
public void AddProperty(IPropertyEditorDataProperty property)
{
this.RowDefinitions.Add(new RowDefinition());
Label propertyNameLabel = new Label();
propertyNameLabel.Content = property.Name;
propertyNameLabel.HorizontalContentAlignment = HorizontalAlignment.Right;
SetRow(propertyNameLabel, this.RowDefinitions.Count - 1);
SetColumn(propertyNameLabel, 0);
this.Children.Add(propertyNameLabel);
}
}
}

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

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace ICSharpCode.WpfDesign.Designer.Controls

10
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/WindowClone.cs

@ -7,15 +7,13 @@ @@ -7,15 +7,13 @@
using System;
using System.ComponentModel;
using System.Windows.Controls;
using System.Diagnostics;
using System.Windows;
using System.Windows.Media;
using System.Windows.Shapes;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Controls.Primitives;
using ICSharpCode.WpfDesign.Adorners;
using System.Windows.Media;
using ICSharpCode.WpfDesign.Extensions;
using System.Diagnostics;
namespace ICSharpCode.WpfDesign.Designer.Controls
{

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

@ -6,15 +6,16 @@ @@ -6,15 +6,16 @@
// </file>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows;
using System.Windows.Input;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Collections.Generic;
using System.Windows.Threading;
using ICSharpCode.WpfDesign.Designer.Controls;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Controls;
namespace ICSharpCode.WpfDesign.Designer
{
@ -44,6 +45,10 @@ namespace ICSharpCode.WpfDesign.Designer @@ -44,6 +45,10 @@ namespace ICSharpCode.WpfDesign.Designer
public DesignPanel()
{
this.Focusable = true;
this.VerticalAlignment = VerticalAlignment.Top;
this.HorizontalAlignment = HorizontalAlignment.Left;
this.Margin = new Thickness(10);
_eatAllHitTestRequests = new EatAllHitTestRequests();
_eatAllHitTestRequests.IsHitTestVisible = false;
_adornerLayer = new AdornerLayer(this);

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

@ -8,10 +8,8 @@ @@ -8,10 +8,8 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Markup;
using System.Xml;
using ICSharpCode.WpfDesign.Designer.Services;
using ICSharpCode.WpfDesign.Designer.Controls;
namespace ICSharpCode.WpfDesign.Designer
@ -33,6 +31,8 @@ namespace ICSharpCode.WpfDesign.Designer @@ -33,6 +31,8 @@ namespace ICSharpCode.WpfDesign.Designer
_scrollViewer = new ScrollViewer();
_designPanel = new DesignPanel();
_scrollViewer.Content = _designPanel;
_scrollViewer.VerticalScrollBarVisibility = ScrollBarVisibility.Visible;
_scrollViewer.HorizontalScrollBarVisibility = ScrollBarVisibility.Visible;
this.VisualChild = _scrollViewer;
}

4
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SelectedElementRectangleExtension.cs

@ -6,12 +6,12 @@ @@ -6,12 +6,12 @@
// </file>
using System;
using System.Windows;
using System.Windows.Media;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Extensions;
using ICSharpCode.WpfDesign.Designer.Controls;
using System.Windows;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TabItemClickableExtension.cs

@ -6,7 +6,6 @@ @@ -6,7 +6,6 @@
// </file>
using System;
using System.Windows;
using System.Windows.Controls;
using ICSharpCode.WpfDesign.Extensions;

10
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Linq.cs

@ -19,5 +19,15 @@ namespace ICSharpCode.WpfDesign.Designer @@ -19,5 +19,15 @@ namespace ICSharpCode.WpfDesign.Designer
collection.CopyTo(arr, 0);
return arr;
}
/// <summary>
/// Returns a sorted copy of the collection.
/// </summary>
public static ICollection<T> Sort<T>(ICollection<T> collection, Comparison<T> comparison)
{
T[] arr = ToArray(collection);
Array.Sort(arr, comparison);
return arr;
}
}
}

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

@ -58,6 +58,9 @@ @@ -58,6 +58,9 @@
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Controls\AdornerLayer.cs" />
<Compile Include="Controls\ContainerDragHandle.cs" />
<Compile Include="Controls\PropertyEditor\PropertyEditor.cs" />
<Compile Include="Controls\PropertyEditor\PropertyEditorCategoryView.cs" />
<Compile Include="Controls\PropertyEditor\PropertyGridView.cs" />
<Compile Include="Controls\ResizeThumb.cs" />
<Compile Include="Controls\SingleVisualChildElement.cs" />
<Compile Include="Controls\WindowClone.cs" />
@ -82,6 +85,7 @@ @@ -82,6 +85,7 @@
<ItemGroup>
<Folder Include="Configuration" />
<Folder Include="Controls" />
<Folder Include="Controls\PropertyEditor" />
<Folder Include="Extensions" />
<Folder Include="themes" />
<Folder Include="Xaml" />
@ -95,6 +99,11 @@ @@ -95,6 +99,11 @@
<Name>WpfDesign</Name>
<SpecificVersion>False</SpecificVersion>
</ProjectReference>
<Page Include="Controls\PropertyEditor\PropertyEditor.xaml">
<DependentUpon>PropertyEditor.cs</DependentUpon>
</Page>
<Page Include="Controls\PropertyEditor\PropertyEditorStyles.xaml" />
<Page Include="Controls\ControlStyles.xaml" />
<Page Include="themes\generic.xaml" />
</ItemGroup>
</Project>

14
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
// </file>
using System;
using System.Diagnostics;
using System.Windows;
using ICSharpCode.WpfDesign.XamlDom;
using ICSharpCode.WpfDesign.Designer.Services;
@ -42,6 +43,19 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -42,6 +43,19 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
}
}
public override string Name {
get { return null; }
set { throw new NotImplementedException(); }
}
/// <summary>
/// Is raised when the name of the design item changes.
/// </summary>
public override event EventHandler NameChanged {
add { Debug.WriteLine("Add event handler to " + this.Component.GetType().Name); }
remove { Debug.WriteLine("Remove event handler from " + this.Component.GetType().Name); }
}
public override DesignItem Parent {
get {
if (_xamlObject.ParentProperty == null)

29
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelProperty.cs

@ -6,25 +6,46 @@ @@ -6,25 +6,46 @@
// </file>
using System;
using System.Diagnostics;
using ICSharpCode.WpfDesign.XamlDom;
namespace ICSharpCode.WpfDesign.Designer.Xaml
{
sealed class XamlModelProperty : DesignItemProperty
sealed class XamlModelProperty : DesignItemProperty, IEquatable<XamlModelProperty>
{
readonly XamlDesignItem _designItem;
readonly XamlProperty _property;
public XamlModelProperty(XamlDesignItem designItem, XamlProperty property)
{
Debug.Assert(designItem != null);
Debug.Assert(property != null);
this._designItem = designItem;
this._property = property;
}
public override bool Equals(object obj)
{
return Equals(obj as XamlModelProperty);
}
public bool Equals(XamlModelProperty other)
{
return this._designItem == other._designItem && this._property == other._property;
}
public override int GetHashCode()
{
return _designItem.GetHashCode() ^ _property.GetHashCode();
}
public override string Name {
get { return _property.PropertyName; }
}
public override bool IsCollection {
get {
return _property.IsCollection;
}
get { return _property.IsCollection; }
}
public override System.Collections.Generic.IList<DesignItem> CollectionElements {

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelPropertyCollection.cs

@ -35,7 +35,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -35,7 +35,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
public override System.Collections.Generic.IEnumerator<DesignItemProperty> GetEnumerator()
{
throw new NotImplementedException();
yield break;
}
}
}

84
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/themes/generic.xaml

@ -1,84 +1,8 @@ @@ -1,84 +1,8 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:src="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls"
>
<!--
This file contains the default styles used by the Controls in ICSharpCode.WpfDesign.Designer.Controls
-->
<Style TargetType="{x:Type src:ResizeThumb}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type src:ResizeThumb}">
<Rectangle Name="thumbRectangle"
Width="7" Height="7" SnapsToDevicePixels="True"
Stroke="Black" Fill="White" RadiusX="1.4142" RadiusY="1.4142"/>
<ControlTemplate.Triggers>
<Trigger Property="IsPrimarySelection" Value="False">
<Setter TargetName="thumbRectangle" Property="Stroke" Value="White"/>
<Setter TargetName="thumbRectangle" Property="Fill" Value="Black"/>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="thumbRectangle" Property="Fill" Value="Gray"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type src:ContainerDragHandle}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type src:ContainerDragHandle}">
<Canvas Height="13" Width="13" Name="Canvas" Background="#00FFFFFF" SnapsToDevicePixels="True">
<Rectangle Height="13" Width="13" RadiusX="2" RadiusY="2"
Fill="#669ABFE5" Name="BorderRectangle" Stroke="#FF9ABFE5" StrokeThickness="1" />
<Path Fill="#FF748EAA" Canvas.Left="1" Canvas.Top="1">
<Path.Data>
<GeometryGroup>
<PathGeometry Figures="M5.5,0L3,3L8,3 M11,5.5L8,3L8,8 M5.5,11L3,8L8,8 M0,5.5L3,3L3,8" />
<RectangleGeometry Rect="3,5,5,1" />
<RectangleGeometry Rect="5,3,1,5" />
<RectangleGeometry Rect="5,5,1,1" />
</GeometryGroup>
</Path.Data>
</Path>
</Canvas>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type src:WindowClone}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="src:WindowClone">
<Border Background="{DynamicResource {x:Static SystemColors.GradientActiveCaptionBrushKey}}" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" BorderThickness="1,1,1,1" CornerRadius="5,5,5,5">
<DockPanel Margin="4,0,4,4">
<DockPanel Height="26" DockPanel.Dock="Top">
<Image Width="16" Height="16" Margin="1,0,0,0" Source="{TemplateBinding Window.Icon}" />
<Button x:Name="CloseButton" VerticalAlignment="Top" Width="23.51" Height="14.857" Content="" DockPanel.Dock="Right"/>
<Button x:Name="MaximiseButton" VerticalAlignment="Top" Width="18.286" Height="14.857" Content="" DockPanel.Dock="Right"/>
<Button x:Name="MinimizeButton" VerticalAlignment="Top" Width="18.286" Height="14.857" Content="" DockPanel.Dock="Right"/>
<Label Margin="4,0,0,0" Content="{TemplateBinding Window.Title}"/>
</DockPanel>
<Border Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}">
<Border
BorderBrush="{TemplateBinding Border.BorderBrush}"
BorderThickness="{TemplateBinding Border.BorderThickness}"
Background="{TemplateBinding Panel.Background}">
<AdornerDecorator>
<ContentPresenter
ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
Content="{TemplateBinding ContentControl.Content}" />
</AdornerDecorator>
</Border>
</Border>
</DockPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/ICSharpCode.WpfDesign.Designer;component/Controls/ControlStyles.xaml"/>
<ResourceDictionary Source="/ICSharpCode.WpfDesign.Designer;component/Controls/PropertyEditor/PropertyEditorStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlConstants.cs

@ -6,7 +6,6 @@ @@ -6,7 +6,6 @@
// </file>
using System;
using System.Collections.ObjectModel;
namespace ICSharpCode.WpfDesign.XamlDom
{

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs

@ -6,8 +6,8 @@ @@ -6,8 +6,8 @@
// </file>
using System;
using System.Xml;
using System.ComponentModel;
using System.Xml;
namespace ICSharpCode.WpfDesign.XamlDom
{

29
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs

@ -7,8 +7,10 @@ @@ -7,8 +7,10 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using ICSharpCode.WpfDesign.Extensions;
namespace ICSharpCode.WpfDesign
@ -17,7 +19,7 @@ namespace ICSharpCode.WpfDesign @@ -17,7 +19,7 @@ namespace ICSharpCode.WpfDesign
/// The DesignItem connects a component with the service system and the designers.
/// Equivalent to Cider's ModelItem.
/// </summary>
public abstract class DesignItem
public abstract class DesignItem : INotifyPropertyChanged
{
/// <summary>
/// Gets the component this DesignSite was created for.
@ -44,6 +46,16 @@ namespace ICSharpCode.WpfDesign @@ -44,6 +46,16 @@ namespace ICSharpCode.WpfDesign
/// </summary>
public abstract DesignItemPropertyCollection Properties { get; }
/// <summary>
/// Gets/Sets the name of the design item.
/// </summary>
public abstract string Name { get; set; }
/// <summary>
/// Is raised when the name of the design item changes.
/// </summary>
public abstract event EventHandler NameChanged;
/// <summary>
/// Gets an instance that provides convenience properties for the most-used designers.
/// </summary>
@ -168,5 +180,20 @@ namespace ICSharpCode.WpfDesign @@ -168,5 +180,20 @@ namespace ICSharpCode.WpfDesign
return (T)obj;
}
#endregion
/// <summary>
/// This event is raised whenever a model property on the DesignItem changes.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// Raises the <see cref="PropertyChanged"/> event.
/// </summary>
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
{
if (PropertyChanged != null) {
PropertyChanged(this, e);
}
}
}
}

5
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItemProperty.cs

@ -20,6 +20,11 @@ namespace ICSharpCode.WpfDesign @@ -20,6 +20,11 @@ namespace ICSharpCode.WpfDesign
/// </summary>
public abstract class DesignItemProperty
{
/// <summary>
/// Gets the property name.
/// </summary>
public abstract string Name { get; }
/// <summary>
/// Gets if the property represents a collection.
/// </summary>

3
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/HashSet.cs

@ -6,9 +6,8 @@ @@ -6,9 +6,8 @@
// </file>
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
namespace ICSharpCode.WpfDesign

17
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Linq.cs

@ -13,11 +13,26 @@ namespace ICSharpCode.WpfDesign @@ -13,11 +13,26 @@ namespace ICSharpCode.WpfDesign
// Static helpers that should become extension methods in the future
static class Linq
{
public static T[] ToArray<T>(ICollection<T> collection)
public static T[] ToArray<T>(ICollection<T> collection) where T : class
{
T[] arr = new T[collection.Count];
collection.CopyTo(arr, 0);
return arr;
}
/// <summary>
/// Outputs distinct elements only, filtering all duplicates.
/// </summary>
public static IEnumerable<T> Distinct<T>(IEnumerable<T> input) where T : class
{
// store elements already seen
HashSet<T> elements = new HashSet<T>();
foreach (T element in input) {
if (elements.Add(element)) {
yield return element;
}
}
}
}
}

82
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/DesignItemDataProperty.cs

@ -0,0 +1,82 @@ @@ -0,0 +1,82 @@
// <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;
namespace ICSharpCode.WpfDesign.PropertyEditor
{
/// <summary>
/// wraps a DesignItemDataProperty for the property editor/grid.
/// </summary>
sealed class DesignItemDataProperty : IPropertyEditorDataProperty
{
readonly DesignItemDataSource ownerDataSource;
readonly DesignItemProperty property;
internal DesignItemDataProperty(DesignItemDataSource ownerDataSource, DesignItemProperty property)
{
Debug.Assert(ownerDataSource != null);
Debug.Assert(property != null);
this.ownerDataSource = ownerDataSource;
this.property = property;
}
public IPropertyEditorDataSource OwnerDataSource {
get { return ownerDataSource; }
}
public string Category {
get { return "Misc"; }
}
public string Name {
get { return property.Name; }
}
public string Description {
get { return "Description for " + property.Name; }
}
public bool IsSet {
get {
return property.IsSet;
}
set {
if (value != property.IsSet) {
if (value) {
// copy default value to local value
property.SetValue(property.ValueOnInstance);
} else {
property.Reset();
}
}
}
}
public object Value {
get {
return property.ValueOnInstance;
}
set {
property.SetValue(value);
}
}
public bool CanUseCustomExpression {
get {
return true;
}
}
public void SetCustomExpression(string expression)
{
throw new NotImplementedException();
}
}
}

96
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/DesignItemDataSource.cs

@ -0,0 +1,96 @@ @@ -0,0 +1,96 @@
// <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;
using System.Windows;
using System.Windows.Media;
using System.Collections.Generic;
namespace ICSharpCode.WpfDesign.PropertyEditor
{
/// <summary>
/// Implements IPropertyEditorDataSource accessing the properties on a DesignItem.
/// </summary>
public sealed class DesignItemDataSource : IPropertyEditorDataSource
{
readonly DesignItem item;
readonly List<IPropertyEditorDataProperty> properties = new List<IPropertyEditorDataProperty>();
/// <summary>
/// Constructs a new DesignItemDataSource for the specified design item.
/// </summary>
public DesignItemDataSource(DesignItem item)
{
if (item == null)
throw new ArgumentNullException("item");
this.item = item;
List<DesignItemProperty> designItemProperties = new List<DesignItemProperty>();
foreach (PropertyDescriptor p in TypeDescriptor.GetProperties(item.Component)) {
if (!p.IsBrowsable) continue;
if (p.IsReadOnly) continue;
if (p.Name.Contains(".")) continue;
designItemProperties.Add(item.Properties[p.Name]);
}
designItemProperties.AddRange(item.Properties);
foreach (DesignItemProperty p in Linq.Distinct(designItemProperties)) {
properties.Add(new DesignItemDataProperty(this, p));
}
}
/// <summary>
/// Gets a data source for the specified design item.
/// This tries to get an existing data source instance (as behavior), or constructs a new
/// DesignItemDataSource instance if that fails.
/// </summary>
public static IPropertyEditorDataSource GetDataSourceForDesignItem(DesignItem item)
{
return item.GetBehavior<IPropertyEditorDataSource>() ?? new DesignItemDataSource(item);
}
/// <summary>See <see cref="IPropertyEditorDataSource"/></summary>
public string Name {
get { return item.Name ?? ""; }
set { item.Name = value; }
}
/// <summary>
/// Is raised when the name of the design item changes.
/// </summary>
public event EventHandler NameChanged {
add { item.NameChanged += value; }
remove { item.NameChanged -= value; }
}
/// <summary>See <see cref="IPropertyEditorDataSource"/></summary>
public string Type {
get {
return item.Component.GetType().Name;
}
}
/// <summary>See <see cref="IPropertyEditorDataSource"/></summary>
public ImageSource Icon {
get { return null; }
}
/// <summary>See <see cref="IPropertyEditorDataSource"/></summary>
public ICollection<IPropertyEditorDataProperty> Properties {
get { return properties; }
}
/// <summary>See <see cref="IPropertyEditorDataSource"/></summary>
public bool CanAddAttachedProperties {
get {
return item.Component is DependencyObject;
}
}
}
}

92
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/IPropertyEditorDataSource.cs

@ -0,0 +1,92 @@ @@ -0,0 +1,92 @@
// <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.ComponentModel;
using System.Windows.Media;
namespace ICSharpCode.WpfDesign.PropertyEditor
{
/// <summary>
/// Interface for data sources used by the property editor to display the list of properties.
/// </summary>
public interface IPropertyEditorDataSource
{
/// <summary>
/// Gets/Sets the name of the item. Returns null when the item does not support having a name.
/// </summary>
string Name { get; set; }
/// <summary>
/// Gets the type of the item (for display only).
/// </summary>
string Type { get; }
/// <summary>
/// Gets the icon of the item (for display only)
/// </summary>
ImageSource Icon { get; }
/// <summary>
/// Gets the collection of properties.
/// </summary>
ICollection<IPropertyEditorDataProperty> Properties { get; }
/// <summary>
/// Gets if adding attached properties is supported.
/// </summary>
bool CanAddAttachedProperties { get; }
}
/// <summary>
/// Represents a property inside a <see cref="IPropertyEditorDataSource"/>.
/// </summary>
public interface IPropertyEditorDataProperty
{
/// <summary>
/// Gets the data source that own this property.
/// </summary>
IPropertyEditorDataSource OwnerDataSource { get; }
/// <summary>
/// Gets the category this property uses.
/// </summary>
string Category { get; }
/// <summary>
/// Gets the name of the property.
/// </summary>
string Name { get; }
/// <summary>
/// Gets the description of the property.
/// </summary>
string Description { get; }
/// <summary>
/// Gets/Sets if the property has been assigned a local value.
/// Setting this property to false has the effect of resetting the value, setting it to true
/// copies the default value to a local value.
/// </summary>
bool IsSet { get; set; }
/// <summary>
/// Gets/Sets the value of the property.
/// </summary>
object Value { get; set; }
/// <summary>
/// Gets if using a custom expression is supported.
/// </summary>
bool CanUseCustomExpression { get; }
/// <summary>
/// Sets a custom expression.
/// </summary>
void SetCustomExpression(string expression);
}
}

33
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/MultiSelectionDataSource.cs

@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
// <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.PropertyEditor
{
/*
/// <summary>
/// Implements IPropertyEditorDataSource by combining the information from multiple data sources.
/// </summary>
public class MultiSelectionDataSource : IPropertyEditorDataSource
{
readonly IPropertyEditorDataSource[] data;
/// <summary>
/// Creates a new MultiSelectionDataSource instance.
/// </summary>
public MultiSelectionDataSource(ICollection<IPropertyEditorDataSource> sources)
{
if (sources == null)
throw new ArgumentNullException("sources");
data = Linq.ToArray(sources);
}
}
*/
}

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/ServiceContainer.cs

@ -7,7 +7,6 @@ @@ -7,7 +7,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
namespace ICSharpCode.WpfDesign
{

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

@ -8,7 +8,6 @@ @@ -8,7 +8,6 @@
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Media;
namespace ICSharpCode.WpfDesign
{

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

@ -79,6 +79,10 @@ @@ -79,6 +79,10 @@
<Compile Include="Extensions\SelectionExtensionServer.cs" />
<Compile Include="HashSet.cs" />
<Compile Include="Linq.cs" />
<Compile Include="PropertyEditor\DesignItemDataProperty.cs" />
<Compile Include="PropertyEditor\DesignItemDataSource.cs" />
<Compile Include="PropertyEditor\IPropertyEditorDataSource.cs" />
<Compile Include="PropertyEditor\MultiSelectionDataSource.cs" />
<Compile Include="ServiceContainer.cs" />
<Compile Include="DesignItem.cs" />
<Compile Include="Services.cs" />
@ -88,5 +92,6 @@ @@ -88,5 +92,6 @@
<Folder Include="Configuration" />
<Folder Include="Extensions" />
<Folder Include="Adorners" />
<Folder Include="PropertyEditor" />
</ItemGroup>
</Project>
Loading…
Cancel
Save