Browse Source

PropertyGrid for WPF Designer

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@3246 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Ivan Shumilin 18 years ago
parent
commit
4d76a8e594
  1. 25
      src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/EventHandlerService.cs
  2. 31
      src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/Files/1.xaml
  3. 28
      src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/StandaloneDesigner.csproj
  4. 115
      src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/Window1.xaml
  5. 13
      src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/Window1.xaml.cs
  6. 33
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/AbstractEventHandlerService.cs
  7. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/CSharpEventHandlerService.cs
  8. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/ChooseClass.cs
  9. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/ChooseClassDialog.xaml
  10. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/ChooseClassDialog.xaml.cs
  11. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/ChooseClassService.cs
  12. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/GetBitmapExtension.cs
  13. 49
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/IdeChooseClassService.cs
  14. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/ObjectEditor.xaml
  15. 30
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/ObjectEditor.xaml.cs
  16. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfAndWinFormsTopLevelWindowService.cs
  17. 22
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs
  18. 11
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.AddIn.csproj
  19. 109
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/CallExtension.cs
  20. 8
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Configuration/AssemblyInfo.cs
  21. 8
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml
  22. 118
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/DragListener.cs
  23. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/DropDownButton.cs
  24. 31
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnterTextBox.cs
  25. 291
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/NumericUpDown.cs
  26. 146
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/NumericUpDown.xaml
  27. 105
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Converters.cs
  28. 41
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ExtensionMethods.cs
  29. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ContentControlDefaultInitializer.cs
  30. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Class.png
  31. 548
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/BasicMetadata.cs
  32. 62
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Category.cs
  33. 7
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BoolEditor.xaml
  34. 26
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BoolEditor.xaml.cs
  35. 208
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditor.cs
  36. 11
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorPopup.xaml
  37. 36
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorPopup.xaml.cs
  38. 81
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorView.xaml
  39. 51
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorView.xaml.cs
  40. 13
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushTypeEditor.xaml
  41. 36
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushTypeEditor.xaml.cs
  42. 92
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/ColorHelper.cs
  43. 233
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/ColorPicker.xaml
  44. 184
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/ColorPicker.xaml.cs
  45. 12
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientBrushEditor.xaml
  46. 24
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientBrushEditor.xaml.cs
  47. 109
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientSlider.xaml
  48. 159
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientSlider.xaml.cs
  49. 68
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/NormalizedPanel.cs
  50. 137
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/Picker.cs
  51. 19
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/SolidBrushEditor.xaml
  52. 33
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/SolidBrushEditor.xaml.cs
  53. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/EventEditor.xaml
  54. 67
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/EventEditor.xaml.cs
  55. 10
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/NumberEditor.xaml
  56. 108
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/NumberEditor.xaml.cs
  57. 25
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyContextMenu.xaml
  58. 51
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyContextMenu.xaml.cs
  59. 208
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs
  60. 344
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.xaml
  61. 56
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.xaml.cs
  62. 101
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyTreeView.cs
  63. 99
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClass.cs
  64. 70
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClassDialog.xaml
  65. 112
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClassDialog.xaml.cs
  66. 23
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClassServiceBase.cs
  67. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/DragMoveMouseGesture.cs
  68. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/WpfTopLevelWindowService.cs
  69. 160
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
  70. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignContext.cs
  71. 8
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelCollectionElementsCollection.cs
  72. 29
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelProperty.cs
  73. 10
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/themes/generic.xaml
  74. 7
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/WpfDesign.Tests.csproj
  75. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionParser.cs
  76. 12
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs
  77. 29
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlPropertyInfo.cs
  78. 7
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs
  79. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeResolverProvider.cs
  80. 34
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.sln
  81. 21
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItemProperty.cs
  82. 130
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Metadata.cs
  83. 72
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/EditorManager.cs
  84. 10
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/ComboBoxEditor.xaml
  85. 34
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/ComboBoxEditor.xaml.cs
  86. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/TextBoxEditor.xaml
  87. 35
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/TextBoxEditor.xaml.cs
  88. 50
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/PropertyEditorAttribute.cs
  89. 198
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/PropertyNode.cs
  90. 39
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeEditorAttribute.cs
  91. 51
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeHelper.cs
  92. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs
  93. 40
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj

25
src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/EventHandlerService.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// <file>
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
@ -22,24 +22,19 @@ namespace StandaloneDesigner @@ -22,24 +22,19 @@ namespace StandaloneDesigner
this.mainWindow = mainWindow;
}
public void CreateEventHandler(DesignItem item, DesignItemProperty eventProperty)
public void CreateEventHandler(DesignItemProperty eventProperty)
{
var item = eventProperty.DesignItem;
string handlerName = (string)eventProperty.ValueOnInstance;
if (string.IsNullOrEmpty(handlerName)) {
if (string.IsNullOrEmpty(item.Name)) {
// cannot create event for unnamed controls
if (mainWindow.propertyEditor.NameTextBox.Focus()) {
IErrorService errorService = item.Context.Services.GetService<IErrorService>();
if (errorService != null) {
Label errorLabel = new Label();
errorLabel.Content = "You need to give the " + item.ComponentType.Name + " a name.";
errorService.ShowErrorTooltip(mainWindow.propertyEditor.NameTextBox, errorLabel);
}
}
return;
string prefix = item.Name;
if (string.IsNullOrEmpty(prefix)) {
//TODO
prefix = item.ComponentType.Name;
}
handlerName = item.Name + eventProperty.Name;
handlerName = prefix + eventProperty.Name;
eventProperty.SetValue(handlerName);
}

31
src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/Files/1.xaml

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
<Window xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WindowTitle"
BorderThickness="10"
Width="400"
Height="300">
<StackPanel>
<Canvas Height="50">
<Button>CB</Button>
</Canvas>
<TabControl MinHeight="150">
<TabItem Header="StackPanel">
<StackPanel>
<Button>a</Button>
</StackPanel>
</TabItem>
<TabItem Header="Button">
<Button>button on page 2</Button>
</TabItem>
<TabItem Header="Canvas">
<Canvas />
</TabItem>
<TabItem Header="Grid">
<Grid />
</TabItem>
<TabItem Header="DockPanel">
<DockPanel />
</TabItem>
</TabControl>
</StackPanel>
</Window>

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

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<ProjectGuid>{84D65E9C-B66C-44C3-95FD-445EFE3ED322}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -6,6 +6,13 @@ @@ -6,6 +6,13 @@
<OutputType>WinExe</OutputType>
<RootNamespace>StandaloneDesigner</RootNamespace>
<AssemblyName>StandaloneDesigner</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>2.0</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
@ -27,6 +34,9 @@ @@ -27,6 +34,9 @@
<Reference Include="PresentationFramework" />
<Reference Include="ReachFramework" />
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.IdentityModel" />
<Reference Include="System.Printing" />
@ -37,9 +47,11 @@ @@ -37,9 +47,11 @@
<Reference Include="UIAutomationTypes" />
<Reference Include="WindowsBase" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />
<ItemGroup>
<ApplicationDefinition Include="App.xaml" />
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="..\..\..\..\Main\GlobalAssemblyInfo.cs">
<Link>GlobalAssemblyInfo.cs</Link>
</Compile>
@ -54,7 +66,14 @@ @@ -54,7 +66,14 @@
<SubType>Code</SubType>
<DependentUpon>Window1.xaml</DependentUpon>
</Compile>
<Page Include="Window1.xaml" />
<None Include="Files\1.xaml">
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Page Include="Window1.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<ProjectReference Include="..\WpfDesign.Designer\Project\WpfDesign.Designer.csproj">
<Project>{78CC29AC-CC79-4355-B1F2-97936DF198AC}</Project>
<Name>WpfDesign.Designer</Name>
@ -63,7 +82,6 @@ @@ -63,7 +82,6 @@
<Project>{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}</Project>
<Name>WpfDesign</Name>
</ProjectReference>
<Folder Include="Images" />
<Resource Include="Images\Redo.png" />
<Resource Include="Images\Undo.png" />
<Resource Include="Images\Delete.png" />

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

@ -1,63 +1,60 @@ @@ -1,63 +1,60 @@
<Window x:Class="StandaloneDesigner.Window1"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:designer="clr-namespace:ICSharpCode.WpfDesign.Designer;assembly=ICSharpCode.WpfDesign.Designer"
xmlns:sd="http://sharpdevelop.net"
xmlns:my="clr-namespace:StandaloneDesigner"
Title="StandaloneDesigner" Height="500" Width="700"
>
<DockPanel>
<ToolBar DockPanel.Dock="Top" Name="toolBar">
<Button Command="Undo"><Image Source="Images/Undo.png" Stretch="None"/></Button>
<Button Command="Redo"><Image Source="Images/Redo.png" Stretch="None"/></Button>
<Button Command="Delete"><Image Source="Images/Delete.png" Stretch="None"/></Button>
</ToolBar>
<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/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WindowTitle"
BorderThickness="10" Width="400" Height="300">
<StackPanel>
<Canvas Height="50">
<Button>CB</Button>
</Canvas>
<TabControl MinHeight="150">
<TabItem Header="StackPanel"><StackPanel><Button>a</Button></StackPanel> </TabItem>
<TabItem Header="Button"><Button>button on page 2</Button></TabItem>
<TabItem Header="Canvas"><Canvas/></TabItem>
<TabItem Header="Grid"><Grid/></TabItem>
<TabItem Header="DockPanel"><DockPanel/></TabItem>
</TabControl>
</StackPanel>
</Window>
]]></TextBox>
</TabItem>
<TabItem Header="Design" Name="designTab">
<designer:DesignSurface
Name="designSurface">
</designer:DesignSurface>
</TabItem>
</TabControl>
<GridSplitter HorizontalAlignment="Left" Width="4" VerticalAlignment="Stretch" Grid.Column="1"/>
<Grid Grid.Column="1" Margin="4 0 0 0">
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<my:Toolbox x:Name="toolbox"/>
<!--<Button Click="TestButtonClick">TestButton</Button>-->
<GridSplitter HorizontalAlignment="Stretch" Height="4" VerticalAlignment="Top" Grid.Row="1"/>
<designer:PropertyEditor Name="propertyEditor" Grid.Row="1" Margin="0 4 0 0" FontSize="8.25pt"/>
</Grid>
</Grid>
</DockPanel>
</Window>
SnapsToDevicePixels="True"
Title="StandaloneDesigner"
WindowState="Maximized">
<DockPanel>
<ToolBar DockPanel.Dock="Top"
Name="toolBar">
<Button Command="Undo">
<Image Source="Images/Undo.png"
Stretch="None" />
</Button>
<Button Command="Redo">
<Image Source="Images/Redo.png"
Stretch="None" />
</Button>
<Button Command="Delete">
<Image Source="Images/Delete.png"
Stretch="None" />
</Button>
</ToolBar>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="170" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="5" />
<ColumnDefinition Width="270" />
</Grid.ColumnDefinitions>
<my:Toolbox x:Name="toolbox" />
<GridSplitter HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Grid.Column="1" />
<TabControl TabStripPlacement="Bottom"
Name="tabControl"
SelectionChanged="tabControlSelectionChanged"
Grid.Column="2">
<TabItem Header="Code">
<TextBox Name="CodeTextBox"
AcceptsReturn="True"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto" />
</TabItem>
<TabItem Header="Design"
Name="designTab">
<sd:DesignSurface x:Name="designSurface" />
</TabItem>
</TabControl>
<GridSplitter HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Grid.Column="3" />
<sd:PropertyGridView x:Name="propertyGridView"
Grid.Column="4" />
</Grid>
</DockPanel>
</Window>

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

@ -9,7 +9,7 @@ using System.Xml; @@ -9,7 +9,7 @@ using System.Xml;
using ICSharpCode.WpfDesign;
using ICSharpCode.WpfDesign.Designer;
using ICSharpCode.WpfDesign.Designer.Xaml;
using ICSharpCode.WpfDesign.PropertyEditor;
using ICSharpCode.WpfDesign.PropertyGrid;
using System.Threading;
using System.Windows.Threading;
@ -27,6 +27,7 @@ namespace StandaloneDesigner @@ -27,6 +27,7 @@ namespace StandaloneDesigner
};
try {
InitializeComponent();
CodeTextBox.Text = File.ReadAllText("Files/1.xaml");
foreach (object o in toolBar.Items) {
if (o is Button) {
(o as Button).CommandTarget = designSurface;
@ -53,7 +54,7 @@ namespace StandaloneDesigner @@ -53,7 +54,7 @@ namespace StandaloneDesigner
toolbox.ToolService = designSurface.DesignContext.Services.Tool;
} else {
if (designSurface.DesignContext != null) {
propertyEditor.EditedObject = null;
propertyGridView.PropertyGrid.SelectedItems = null;
using (StringWriter writer = new StringWriter()) {
using (XmlTextWriter xmlWriter = new XmlTextWriter(writer)) {
@ -75,8 +76,7 @@ namespace StandaloneDesigner @@ -75,8 +76,7 @@ namespace StandaloneDesigner
ISelectionService selectionService = designSurface.DesignContext.Services.Selection;
ICollection<DesignItem> items = selectionService.SelectedItems;
if (!IsCollectionWithSameElements(items, oldItems)) {
IPropertyEditorDataSource dataSource = DesignItemDataSource.GetDataSourceForDesignItems(items);
propertyEditor.EditedObject = dataSource;
propertyGridView.PropertyGrid.SelectedItems = items;
oldItems = items;
}
}
@ -109,7 +109,4 @@ namespace StandaloneDesigner @@ -109,7 +109,4 @@ namespace StandaloneDesigner
timer.Start();
}
}
}
}

33
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/AbstractEventHandlerService.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// <file>
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
@ -68,29 +68,18 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -68,29 +68,18 @@ namespace ICSharpCode.WpfDesign.AddIn
protected abstract void CreateEventHandlerInternal(Type eventHandlerType, string handlerName);
public void CreateEventHandler(DesignItem item, DesignItemProperty eventProperty)
public void CreateEventHandler(DesignItemProperty eventProperty)
{
string handlerName = (string)eventProperty.ValueOnInstance;
if (string.IsNullOrEmpty(handlerName)) {
if (string.IsNullOrEmpty(item.Name)) {
PadDescriptor padContent = WorkbenchSingleton.Workbench.GetPad(typeof(PropertyPad));
if (padContent != null) {
padContent.BringPadToFront();
}
// cannot create event for unnamed controls
if (viewContent.PropertyEditor.NameTextBox.Focus()) {
IErrorService errorService = item.Context.Services.GetService<IErrorService>();
if (errorService != null) {
Label errorLabel = new Label();
errorLabel.Content = "You need to give the " + item.ComponentType.Name + " a name.";
errorService.ShowErrorTooltip(viewContent.PropertyEditor.NameTextBox, errorLabel);
}
}
return;
var item = eventProperty.DesignItem;
string handlerName = (string)eventProperty.ValueOnInstance;
if (string.IsNullOrEmpty(handlerName)) {
string prefix = item.Name;
if (string.IsNullOrEmpty(prefix)) {
prefix = item.ComponentType.Name;
}
handlerName = item.Name + eventProperty.Name;
handlerName = prefix + eventProperty.Name;
eventProperty.SetValue(handlerName);
}
CreateEventHandlerInternal(eventProperty.ReturnType, handlerName);

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/CSharpEventHandlerService.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// <file>
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/ChooseClass.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Data;

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/ChooseClassDialog.xaml

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<Window x:Class="ICSharpCode.WpfDesign.AddIn.ChooseClassDialog"
<Window x:Class="ICSharpCode.WpfDesign.AddIn.ChooseClassDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sd="clr-namespace:ICSharpCode.WpfDesign.AddIn"

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/ChooseClassDialog.xaml.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Specialized;
using System.Globalization;
using System.Reflection;

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/ChooseClassService.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
using System;
using System;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/GetBitmapExtension.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows;

49
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/IdeChooseClassService.cs

@ -0,0 +1,49 @@ @@ -0,0 +1,49 @@
using System;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
using System.Reflection;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.WpfDesign.Designer.Services;
namespace ICSharpCode.WpfDesign.AddIn
{
//TODO
public class IdeChooseClassService : ChooseClassServiceBase
{
static string GetAssemblyPath(IProjectContent projectContent)
{
var r = projectContent as ReflectionProjectContent;
if (r != null) {
return r.AssemblyLocation;
}
var p = projectContent.Project as IProject;
if (p != null) {
return p.OutputAssemblyFullPath;
}
return null;
}
static Assembly GetAssembly(IProjectContent projectContent)
{
var path = GetAssemblyPath(projectContent);
if (path != null && File.Exists(path)) {
return Assembly.LoadFile(path);
}
return null;
}
public override IEnumerable<Assembly> GetAssemblies()
{
var pc = ParserService.CurrentProjectContent;
var a = GetAssembly(pc);
if (a != null) yield return a;
foreach (var r in pc.ReferencedContents) {
a = GetAssembly(r);
if (a != null) yield return a;
}
}
}
}

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/ObjectEditor.xaml

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<Button
<Button
x:Class="ICSharpCode.WpfDesign.AddIn.ObjectEditor"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

30
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/ObjectEditor.xaml.cs

@ -1,25 +1,31 @@ @@ -1,25 +1,31 @@
using System;
using System;
using System.Windows;
using ICSharpCode.WpfDesign.PropertyEditor;
using ICSharpCode.WpfDesign.PropertyGrid;
using ICSharpCode.WpfDesign.Designer.Services;
namespace ICSharpCode.WpfDesign.AddIn
{
[PropertyEditor(typeof(FrameworkElement), "DataContext")]
public partial class ObjectEditor
{
public ObjectEditor(IPropertyEditorDataProperty property)
public ObjectEditor()
{
InitializeComponent();
var s = property.OwnerDataSource.Services.GetService<ChooseClassService>();
}
public PropertyNode PropertyNode {
get { return DataContext as PropertyNode; }
}
protected override void OnClick()
{
var s = PropertyNode.Services.GetService<ChooseClassServiceBase>();
if (s != null) {
Click += delegate {
var c = s.ChooseClass();
if (c != null) {
MessageBox.Show(c.Name);
}
};
var c = s.ChooseClass();
if (c != null) {
PropertyNode.Value = Activator.CreateInstance(c);
}
}
}
}
}
}

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfAndWinFormsTopLevelWindowService.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// <file>
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>

22
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs

@ -19,7 +19,8 @@ using ICSharpCode.SharpDevelop.Gui; @@ -19,7 +19,8 @@ using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.WpfDesign.Designer;
using ICSharpCode.WpfDesign.Designer.Services;
using ICSharpCode.WpfDesign.Designer.Xaml;
using ICSharpCode.WpfDesign.PropertyEditor;
using ICSharpCode.WpfDesign.PropertyGrid;
using ICSharpCode.WpfDesign.Designer.PropertyGrid;
namespace ICSharpCode.WpfDesign.AddIn
{
@ -62,12 +63,13 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -62,12 +63,13 @@ namespace ICSharpCode.WpfDesign.AddIn
context.Services.AddService(typeof(IPropertyDescriptionService), new PropertyDescriptionService(this.PrimaryFile));
context.Services.AddService(typeof(IEventHandlerService), new CSharpEventHandlerService(this));
context.Services.AddService(typeof(ITopLevelWindowService), new WpfAndWinFormsTopLevelWindowService());
context.Services.AddService(typeof(ChooseClassService), new ChooseClassService());
context.Services.AddService(typeof(ChooseClassServiceBase), new IdeChooseClassService());
});
settings.TypeFinder = MyTypeFinder.Create(this.PrimaryFile);
designer.LoadDesigner(r, settings);
propertyGridView.PropertyGrid.SelectedItems = null;
designer.DesignContext.Services.Selection.SelectionChanged += OnSelectionChanged;
designer.DesignContext.Services.GetService<UndoService>().UndoStackChanged += OnUndoStackChanged;
}
@ -91,14 +93,15 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -91,14 +93,15 @@ namespace ICSharpCode.WpfDesign.AddIn
}
#region Property editor / SelectionChanged
Designer.PropertyEditor propertyEditor;
ElementHost propertyEditorHost;
PropertyGridView propertyGridView;
void InitPropertyEditor()
{
propertyEditorHost = new SharpDevelopElementHost();
propertyEditor = new Designer.PropertyEditor();
propertyEditorHost.Child = propertyEditor;
propertyGridView = new PropertyGridView();
propertyEditorHost.Child = propertyGridView;
propertyContainer.PropertyGridReplacementControl = propertyEditorHost;
}
@ -109,8 +112,7 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -109,8 +112,7 @@ namespace ICSharpCode.WpfDesign.AddIn
ISelectionService selectionService = designer.DesignContext.Services.Selection;
ICollection<DesignItem> items = selectionService.SelectedItems;
if (!IsCollectionWithSameElements(items, oldItems)) {
IPropertyEditorDataSource dataSource = DesignItemDataSource.GetDataSourceForDesignItems(items);
propertyEditor.EditedObject = dataSource;
propertyGridView.PropertyGrid.SelectedItems = items;
oldItems = items;
}
}
@ -129,10 +131,6 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -129,10 +131,6 @@ namespace ICSharpCode.WpfDesign.AddIn
return true;
}
public Designer.PropertyEditor PropertyEditor {
get { return propertyEditor; }
}
PropertyContainer propertyContainer = new PropertyContainer();
public PropertyContainer PropertyContainer {
@ -159,4 +157,4 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -159,4 +157,4 @@ namespace ICSharpCode.WpfDesign.AddIn
}
}
}
}
}

11
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.AddIn.csproj

@ -57,14 +57,14 @@ @@ -57,14 +57,14 @@
</Compile>
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Src\AbstractEventHandlerService.cs" />
<Compile Include="Src\ChooseClass.cs" />
<Compile Include="Src\ChooseClassDialog.xaml.cs" />
<Compile Include="Src\ChooseClassService.cs" />
<Compile Include="Src\CSharpEventHandlerService.cs" />
<Compile Include="Src\FileUriContext.cs" />
<Compile Include="Src\GetBitmapExtension.cs" />
<Compile Include="Src\IdeChooseClassService.cs" />
<Compile Include="Src\MyTypeFinder.cs" />
<Compile Include="Src\ObjectEditor.xaml.cs" />
<Compile Include="Src\ObjectEditor.xaml.cs">
<DependentUpon>ObjectEditor.xaml</DependentUpon>
</Compile>
<Compile Include="Src\PropertyDescriptionService.cs" />
<Compile Include="Src\SharpDevelopElementHost.cs" />
<Compile Include="Src\WpfAndWinFormsTopLevelWindowService.cs" />
@ -119,7 +119,6 @@ @@ -119,7 +119,6 @@
<Name>WpfDesign</Name>
<Private>False</Private>
</ProjectReference>
<Page Include="Src\ChooseClassDialog.xaml" />
<Page Include="Src\ObjectEditor.xaml" />
</ItemGroup>
</Project>
</Project>

109
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/CallExtension.cs

@ -0,0 +1,109 @@ @@ -0,0 +1,109 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Markup;
using System.Windows;
using System.Windows.Data;
using System.Windows.Input;
using System.Reflection;
namespace ICSharpCode.WpfDesign.Designer
{
public class CallExtension : MarkupExtension
{
public CallExtension(string methodName)
{
this.methodName = methodName;
}
string methodName;
public override object ProvideValue(IServiceProvider sp)
{
var t = (IProvideValueTarget)sp.GetService(typeof(IProvideValueTarget));
return new CallCommand(t.TargetObject as FrameworkElement, methodName);
}
}
public class CallCommand : DependencyObject, ICommand
{
public CallCommand(FrameworkElement element, string methodName)
{
this.element = element;
this.methodName = methodName;
element.DataContextChanged += target_DataContextChanged;
BindingOperations.SetBinding(this, CanCallProperty, new Binding("DataContext.Can" + methodName) {
Source = element
});
GetMethod();
}
FrameworkElement element;
string methodName;
MethodInfo method;
public static readonly DependencyProperty CanCallProperty =
DependencyProperty.Register("CanCall", typeof(bool), typeof(CallCommand),
new PropertyMetadata(true));
public bool CanCall {
get { return (bool)GetValue(CanCallProperty); }
set { SetValue(CanCallProperty, value); }
}
public object DataContext {
get { return element.DataContext; }
}
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);
if (e.Property == CanCallProperty) {
RaiseCanExecuteChanged();
}
}
void GetMethod()
{
if (DataContext == null) {
method = null;
}
else {
method = DataContext.GetType().GetMethod(methodName, Type.EmptyTypes);
}
}
void target_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
GetMethod();
RaiseCanExecuteChanged();
}
void RaiseCanExecuteChanged()
{
if (CanExecuteChanged != null) {
CanExecuteChanged(this, EventArgs.Empty);
}
}
#region ICommand Members
public event EventHandler CanExecuteChanged;
public bool CanExecute(object parameter)
{
return method != null && CanCall;
}
public void Execute(object parameter)
{
method.Invoke(DataContext, null);
}
#endregion
}
}

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

@ -8,6 +8,7 @@ using System.Globalization; @@ -8,6 +8,7 @@ using System.Globalization;
using System.Windows;
using System.Runtime.InteropServices;
using ICSharpCode.WpfDesign.Extensions;
using System.Windows.Markup;
#endregion
@ -40,3 +41,10 @@ using ICSharpCode.WpfDesign.Extensions; @@ -40,3 +41,10 @@ using ICSharpCode.WpfDesign.Extensions;
// app, or any theme specific resource dictionaries)
)]
[assembly: XmlnsPrefix("http://sharpdevelop.net", "sd")]
[assembly: XmlnsDefinition("http://sharpdevelop.net", "ICSharpCode.WpfDesign.Designer")]
[assembly: XmlnsDefinition("http://sharpdevelop.net", "ICSharpCode.WpfDesign.Designer.Controls")]
[assembly: XmlnsDefinition("http://sharpdevelop.net", "ICSharpCode.WpfDesign.Designer.PropertyGrid")]
[assembly: XmlnsDefinition("http://sharpdevelop.net", "ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors")]

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

@ -5,8 +5,12 @@ @@ -5,8 +5,12 @@
<!--
This file contains the default styles used by the Controls in ICSharpCode.WpfDesign.Designer.Controls
-->
<Style TargetType="{x:Type src:ResizeThumb}">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="NumericUpDown.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style TargetType="{x:Type src:ResizeThumb}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type src:ResizeThumb}">

118
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/DragListener.cs

@ -0,0 +1,118 @@ @@ -0,0 +1,118 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Input;
using System.Diagnostics;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
public delegate void DragHandler(DragListener drag);
public class DragListener
{
static DragListener()
{
InputManager.Current.PostProcessInput += new ProcessInputEventHandler(PostProcessInput);
}
public DragListener(IInputElement target)
{
Target = target;
Target.PreviewMouseLeftButtonDown += Target_MouseDown;
Target.PreviewMouseMove += Target_MouseMove;
Target.PreviewMouseLeftButtonUp += Target_MouseUp;
}
static DragListener CurrentListener;
static void PostProcessInput(object sender, ProcessInputEventArgs e)
{
if (CurrentListener != null)
{
var a = e.StagingItem.Input as KeyEventArgs;
if (a != null && a.Key == Key.Escape)
{
Mouse.Capture(null);
CurrentListener.IsDown = false;
CurrentListener.Complete();
}
}
}
void Target_MouseDown(object sender, MouseButtonEventArgs e)
{
StartPoint = Mouse.GetPosition(null);
CurrentPoint = StartPoint;
DeltaDelta = new Vector();
IsDown = true;
if (Started != null)
{
Started(this);
}
}
void Target_MouseMove(object sender, MouseEventArgs e)
{
if (IsDown)
{
DeltaDelta = e.GetPosition(null) - CurrentPoint;
CurrentPoint += DeltaDelta;
if (!IsActive)
{
if (Math.Abs(Delta.X) >= SystemParameters.MinimumHorizontalDragDistance ||
Math.Abs(Delta.Y) >= SystemParameters.MinimumVerticalDragDistance)
{
IsActive = true;
CurrentListener = this;
}
}
if (IsActive && Changed != null)
{
Changed(this);
}
}
}
void Target_MouseUp(object sender, MouseButtonEventArgs e)
{
IsDown = false;
if (IsActive)
{
Complete();
}
}
void Complete()
{
IsActive = false;
CurrentListener = null;
if (Completed != null)
{
Completed(this);
}
}
public event DragHandler Started;
public event DragHandler Changed;
public event DragHandler Completed;
public IInputElement Target { get; private set; }
public Point StartPoint { get; private set; }
public Point CurrentPoint { get; private set; }
public Vector DeltaDelta { get; private set; }
public bool IsActive { get; private set; }
public bool IsDown { get; private set; }
public Vector Delta
{
get { return CurrentPoint - StartPoint; }
}
}
}

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/DropDownButton.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// <file>
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <author name="Daniel Grunwald"/>

31
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnterTextBox.cs

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Data;
using System.Windows;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
public class EnterTextBox : TextBox
{
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.Key == Key.Enter) {
var b = BindingOperations.GetBindingExpressionBase(this, TextProperty);
if (b != null) {
b.UpdateSource();
}
SelectAll();
}
else if (e.Key == Key.Escape) {
var b = BindingOperations.GetBindingExpressionBase(this, TextProperty);
if (b != null) {
b.UpdateTarget();
}
}
}
}
}

291
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/NumericUpDown.cs

@ -0,0 +1,291 @@ @@ -0,0 +1,291 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls.Primitives;
using System.Globalization;
using System.Diagnostics;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
public class NumericUpDown : Control
{
static NumericUpDown()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(NumericUpDown),
new FrameworkPropertyMetadata(typeof(NumericUpDown)));
}
TextBox textBox;
DragRepeatButton upButton;
DragRepeatButton downButton;
public static readonly DependencyProperty DecimalPlacesProperty =
DependencyProperty.Register("DecimalPlaces", typeof(int), typeof(NumericUpDown));
public int DecimalPlaces {
get { return (int)GetValue(DecimalPlacesProperty); }
set { SetValue(DecimalPlacesProperty, value); }
}
public static readonly DependencyProperty MinimumProperty =
DependencyProperty.Register("Minimum", typeof(double), typeof(NumericUpDown));
public double Minimum {
get { return (double)GetValue(MinimumProperty); }
set { SetValue(MinimumProperty, value); }
}
public static readonly DependencyProperty MaximumProperty =
DependencyProperty.Register("Maximum", typeof(double), typeof(NumericUpDown),
new FrameworkPropertyMetadata(100.0));
public double Maximum {
get { return (double)GetValue(MaximumProperty); }
set { SetValue(MaximumProperty, value); }
}
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value", typeof(double), typeof(NumericUpDown),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
public double Value {
get { return (double)GetValue(ValueProperty); }
set { SetValue(ValueProperty, value); }
}
public static readonly DependencyProperty SmallChangeProperty =
DependencyProperty.Register("SmallChange", typeof(double), typeof(NumericUpDown),
new FrameworkPropertyMetadata(1.0));
public double SmallChange {
get { return (double)GetValue(SmallChangeProperty); }
set { SetValue(SmallChangeProperty, value); }
}
public static readonly DependencyProperty LargeChangeProperty =
DependencyProperty.Register("LargeChange", typeof(double), typeof(NumericUpDown),
new FrameworkPropertyMetadata(10.0));
public double LargeChange {
get { return (double)GetValue(LargeChangeProperty); }
set { SetValue(LargeChangeProperty, value); }
}
bool IsDragging {
get {
return upButton.IsDragging;
}
set {
upButton.IsDragging = value; downButton.IsDragging = value;
}
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
upButton = (DragRepeatButton)Template.FindName("PART_UpButton", this);
downButton = (DragRepeatButton)Template.FindName("PART_DownButton", this);
textBox = (TextBox)Template.FindName("PART_TextBox", this);
upButton.Click += new RoutedEventHandler(upButton_Click);
downButton.Click += new RoutedEventHandler(downButton_Click);
var upDrag = new DragListener(upButton);
var downDrag = new DragListener(downButton);
upDrag.Changed += drag_Changed;
downDrag.Changed += drag_Changed;
upDrag.Completed += drag_Completed;
downDrag.Completed += drag_Completed;
Print();
}
void drag_Changed(DragListener drag)
{
IsDragging = true;
MoveValue(-drag.DeltaDelta.Y * SmallChange);
}
void drag_Completed(DragListener drag)
{
IsDragging = false;
}
void downButton_Click(object sender, RoutedEventArgs e)
{
if (!IsDragging) SmallDown();
}
void upButton_Click(object sender, RoutedEventArgs e)
{
if (!IsDragging) SmallUp();
}
public void SmallUp()
{
MoveValue(SmallChange);
}
public void SmallDown()
{
MoveValue(-SmallChange);
}
public void LargeUp()
{
MoveValue(LargeChange);
}
public void LargeDown()
{
MoveValue(-LargeChange);
}
public void Minimize()
{
Parse();
Value = Minimum;
}
public void Maximize()
{
Parse();
Value = Maximum;
}
void MoveValue(double delta)
{
Parse();
if (double.IsNaN(Value) || double.IsInfinity(Value)) {
SetValue(delta);
}
else {
SetValue(Value + delta);
}
}
void Parse()
{
double result;
if (double.TryParse(textBox.Text, out result)) {
SetValue(result);
}
else {
Print();
}
}
void Print()
{
if (textBox != null) {
textBox.Text = Value.ToString("F" + DecimalPlaces);
textBox.CaretIndex = int.MaxValue;
}
}
//wpf bug?: Value = -1 updates bindings without coercing, workaround
//update: not derived from RangeBase - no problem
void SetValue(double newValue)
{
Value = (double)Math.Max(Minimum, Math.Min(newValue, Maximum));
Print();
}
protected override void OnPreviewKeyDown(KeyEventArgs e)
{
base.OnPreviewKeyDown(e);
if (e.Key == Key.Enter) {
Parse();
textBox.SelectAll();
e.Handled = true;
}
else if (e.Key == Key.Up) {
SmallUp();
e.Handled = true;
}
else if (e.Key == Key.Down) {
SmallDown();
e.Handled = true;
}
else if (e.Key == Key.PageUp) {
LargeUp();
e.Handled = true;
}
else if (e.Key == Key.PageDown) {
LargeDown();
e.Handled = true;
}
//else if (e.Key == Key.Home) {
// Maximize();
// e.Handled = true;
//}
//else if (e.Key == Key.End) {
// Minimize();
// e.Handled = true;
//}
}
//protected override void OnMouseWheel(MouseWheelEventArgs e)
//{
// if (e.Delta > 0)
// {
// if (Keyboard.IsKeyDown(Key.LeftShift))
// {
// LargeUp();
// }
// else
// {
// SmallUp();
// }
// }
// else
// {
// if (Keyboard.IsKeyDown(Key.LeftShift))
// {
// LargeDown();
// }
// else
// {
// SmallDown();
// }
// }
// e.Handled = true;
//}
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);
if (e.Property == ValueProperty) {
SetValue((double)e.NewValue);
}
else if (e.Property == SmallChangeProperty &&
ReadLocalValue(LargeChangeProperty) == DependencyProperty.UnsetValue) {
LargeChange = SmallChange * 10;
}
}
}
public class DragRepeatButton : RepeatButton
{
public static readonly DependencyProperty IsDraggingProperty =
DependencyProperty.Register("IsDragging", typeof(bool), typeof(DragRepeatButton));
public bool IsDragging {
get { return (bool)GetValue(IsDraggingProperty); }
set { SetValue(IsDraggingProperty, value); }
}
}
}

146
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/NumericUpDown.xaml

@ -0,0 +1,146 @@ @@ -0,0 +1,146 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls"
xmlns:BrushEditor="clr-namespace:ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor">
<!--<Brush x:Key="ButtonNormal">#C3D3FD</Brush>
<Brush x:Key="ButtonHover">#D7ECFC</Brush>
<Brush x:Key="ButtonPressed">#92AAF0</Brush>
<Brush x:Key="BorderBrush">#FF7F9DB9</Brush>
<Brush x:Key="ArrowBrush">#4D6185</Brush>
<Brush x:Key="ArrowsBorderBrush">#B4C8F6</Brush>-->
<Brush x:Key="ButtonNormal">#DADFEA</Brush>
<Brush x:Key="ButtonHover">#E6EBEF</Brush>
<Brush x:Key="ButtonPressed">#B6BDD3</Brush>
<Brush x:Key="BorderBrush">#7F9DB9</Brush>
<Brush x:Key="ArrowBrush">Black</Brush>
<Brush x:Key="ArrowsBorderBrush">#B6BDD3</Brush>
<Style x:Key="UpButton"
TargetType="RepeatButton">
<Setter Property="Focusable"
Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:DragRepeatButton}">
<Border x:Name="bg"
Background="{StaticResource ButtonNormal}"
CornerRadius="2 2 0 0">
<Path Fill="{StaticResource ArrowBrush}"
Data="M 0 3 L 3.5 0 L 7 3"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
<Setter TargetName="bg"
Property="Background"
Value="{StaticResource ButtonHover}" />
</Trigger>
<Trigger Property="IsMouseCaptured"
Value="True">
<Setter TargetName="bg"
Property="Background"
Value="{StaticResource ButtonPressed}" />
</Trigger>
<Trigger Property="IsDragging"
Value="True">
<Setter TargetName="bg"
Property="Background"
Value="{StaticResource ButtonPressed}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="DownButton"
TargetType="RepeatButton">
<Setter Property="Focusable"
Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:DragRepeatButton}">
<Border x:Name="bg"
Background="{StaticResource ButtonNormal}"
CornerRadius="0 0 2 2">
<Path Fill="{StaticResource ArrowBrush}"
Data="M 0 0 L 3.5 3 L 7 0"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
<Setter TargetName="bg"
Property="Background"
Value="{StaticResource ButtonHover}" />
</Trigger>
<Trigger Property="IsMouseCaptured"
Value="True">
<Setter TargetName="bg"
Property="Background"
Value="{StaticResource ButtonPressed}" />
</Trigger>
<Trigger Property="IsDragging"
Value="True">
<Setter TargetName="bg"
Property="Background"
Value="{StaticResource ButtonPressed}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:NumericUpDown}">
<Setter Property="BorderThickness"
Value="1" />
<Setter Property="BorderBrush"
Value="{StaticResource BorderBrush}" />
<Setter Property="Focusable"
Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:NumericUpDown}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="15" />
</Grid.ColumnDefinitions>
<TextBox x:Name="PART_TextBox"
BorderThickness="0"
Background="{x:Null}"
Grid.RowSpan="2" />
<Controls:DragRepeatButton x:Name="PART_UpButton"
Style="{StaticResource UpButton}"
Grid.Column="1" />
<Controls:DragRepeatButton x:Name="PART_DownButton"
Style="{StaticResource DownButton}"
Grid.Column="1"
Grid.Row="1" />
<Border Grid.Column="1"
Grid.RowSpan="2"
BorderBrush="{StaticResource ArrowsBorderBrush}"
BorderThickness="1"
CornerRadius="2" />
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

105
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Converters.cs

@ -0,0 +1,105 @@ @@ -0,0 +1,105 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Globalization;
using System.Windows;
using System.Collections;
namespace ICSharpCode.WpfDesign.Designer.Converters
{
public class IntFromEnumConverter : IValueConverter
{
public static IntFromEnumConverter Instance = new IntFromEnumConverter();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (int)value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return Enum.ToObject(targetType, (int)value);
}
}
public class HiddenWhenFalse : IValueConverter
{
public static HiddenWhenFalse Instance = new HiddenWhenFalse();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (bool)value ? Visibility.Visible : Visibility.Hidden;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class LevelConverter : IValueConverter
{
public static LevelConverter Instance = new LevelConverter();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return new Thickness(2 + 14 * (int)value, 0, 0, 0);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class CollapsedWhenEmptyCollection : IValueConverter
{
public static CollapsedWhenEmptyCollection Instance = new CollapsedWhenEmptyCollection();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
ICollection col = value as ICollection;
if (col != null && col.Count == 0) {
return Visibility.Collapsed;
}
return Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class FalseWhenNull : IValueConverter
{
public static FalseWhenNull Instance = new FalseWhenNull();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value != null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class BoldWhenTrue : IValueConverter
{
public static BoldWhenTrue Instance = new BoldWhenTrue();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (bool)value ? FontWeights.Bold : FontWeights.Normal;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

41
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ExtensionMethods.cs

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Collections;
using System.Windows;
namespace ICSharpCode.WpfDesign.Designer
{
public static class ExtensionMethods
{
//public static T[] GetValues<T>(this Type type)
//{
// return type
// .GetProperties(BindingFlags.Static | BindingFlags.Public)
// .Select(p => p.GetValue(null, null)).OfType<T>().ToArray();
//}
public static double Coerce(this double d, double min, double max)
{
return Math.Max(Math.Min(d, max), min);
}
public static void AddRange<T>(this ICollection<T> col, IEnumerable<T> items)
{
foreach (var item in items) {
col.Add(item);
}
}
public static object GetDataContext(this RoutedEventArgs e)
{
var f = e.OriginalSource as FrameworkElement;
if (f != null) {
return f.DataContext;;
}
return null;
}
}
}

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ContentControlDefaultInitializer.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// <file>
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Class.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 624 B

548
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/BasicMetadata.cs

@ -0,0 +1,548 @@ @@ -0,0 +1,548 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
using System.Windows;
using System.Windows.Input;
using System.Windows.Documents;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid
{
public class BasicMetadata
{
public const string Category_Brushes = "Brushes";
public const string Category_Text = "Text";
public const string Category_Appearance = "Appearance";
public const string Category_Layout = "Layout";
public const string Category_Common_Properties = "Common Properties";
public const string Category_Misc = "Misc";
public const string Category_Transform = "Transform";
public const string Category_Media = "Media";
public const string Category_Light = "Light";
public const string Category_Camera = "Camera";
public const string Category_Materials = "Materials";
public BasicMetadata()
{
Metadata.AddStandardValues(typeof(Brush), typeof(Brushes));
Metadata.AddStandardValues(typeof(Color), typeof(Colors));
Metadata.AddStandardValues(typeof(FontStretch), typeof(FontStretches));
Metadata.AddStandardValues(typeof(FontWeight), typeof(FontWeights));
Metadata.AddStandardValues(typeof(FontStyle), typeof(FontStyles));
Metadata.AddStandardValues(typeof(Cursor), typeof(Cursors));
Metadata.AddStandardValues(typeof(PixelFormat), typeof(PixelFormats));
Metadata.AddStandardValues(typeof(TextDecorationCollection), typeof(TextDecorations));
Metadata.AddStandardValues(typeof(FontFamily), Fonts.SystemFontFamilies);
//Metadata.AddStandardValues(typeof(ICommand), typeof(ApplicationCommands));
//Metadata.AddStandardValues(typeof(ICommand), typeof(EditingCommands));
//Metadata.AddStandardValues(typeof(ICommand), typeof(NavigationCommands));
//Metadata.AddStandardValues(typeof(ICommand), typeof(ComponentCommands));
//Metadata.AddStandardValues(typeof(ICommand), typeof(MediaCommands));
Metadata.CategoryOrder = new[] {
Category_Brushes,
Category_Appearance,
Category_Layout,
Category_Common_Properties,
Category_Text,
Category_Transform,
Category_Media,
Category_Light,
Category_Camera,
Category_Brushes,
Category_Materials,
Category_Misc
};
Metadata.AddCategory(AccessText.TextProperty, Category_Text);
Metadata.AddCategory(Block.BorderBrushProperty, Category_Appearance);
Metadata.AddCategory(Block.BorderThicknessProperty, Category_Appearance);
Metadata.AddCategory(Block.BreakColumnBeforeProperty, Category_Text);
Metadata.AddCategory(Block.BreakPageBeforeProperty, Category_Text);
Metadata.AddCategory(Block.LineHeightProperty, Category_Layout);
Metadata.AddCategory(Block.MarginProperty, Category_Layout);
Metadata.AddCategory(Block.PaddingProperty, Category_Layout);
Metadata.AddCategory(Block.TextAlignmentProperty, Category_Text);
Metadata.AddCategory(Border.BorderBrushProperty, Category_Brushes);
Metadata.AddCategory(Border.BorderThicknessProperty, Category_Appearance);
Metadata.AddCategory(Border.CornerRadiusProperty, Category_Appearance);
Metadata.AddCategory(Border.PaddingProperty, Category_Layout);
Metadata.AddCategory(Button.IsCancelProperty, Category_Common_Properties);
Metadata.AddCategory(Button.IsDefaultProperty, Category_Common_Properties);
Metadata.AddCategory(ButtonBase.ClickModeProperty, Category_Misc);
Metadata.AddCategory(ButtonBase.CommandParameterProperty, Category_Misc);
Metadata.AddCategory(ButtonBase.CommandProperty, Category_Misc);
Metadata.AddCategory(ButtonBase.CommandTargetProperty, Category_Misc);
Metadata.AddCategory(ButtonBase.IsPressedProperty, Category_Common_Properties);
Metadata.AddCategory(Camera.TransformProperty, Category_Transform);
Metadata.AddCategory(Canvas.BottomProperty, Category_Layout);
Metadata.AddCategory(Canvas.LeftProperty, Category_Layout);
Metadata.AddCategory(Canvas.RightProperty, Category_Layout);
Metadata.AddCategory(Canvas.TopProperty, Category_Layout);
Metadata.AddCategory(ColumnDefinition.MaxWidthProperty, Category_Layout);
Metadata.AddCategory(ColumnDefinition.MinWidthProperty, Category_Layout);
Metadata.AddCategory(ColumnDefinition.WidthProperty, Category_Layout);
Metadata.AddCategory(ComboBox.IsDropDownOpenProperty, Category_Common_Properties);
Metadata.AddCategory(ComboBox.IsEditableProperty, Category_Common_Properties);
Metadata.AddCategory(ComboBox.StaysOpenOnEditProperty, Category_Common_Properties);
Metadata.AddCategory(ComboBox.TextProperty, Category_Common_Properties);
Metadata.AddCategory(ContentControl.ContentProperty, Category_Common_Properties);
Metadata.AddCategory(ContentControl.ContentTemplateProperty, Category_Misc);
Metadata.AddCategory(ContentControl.ContentTemplateSelectorProperty, Category_Misc);
Metadata.AddCategory(Control.HorizontalContentAlignmentProperty, Category_Layout);
Metadata.AddCategory(Control.PaddingProperty, Category_Layout);
Metadata.AddCategory(Control.VerticalContentAlignmentProperty, Category_Layout);
Metadata.AddCategory(DashStyle.DashesProperty, Category_Appearance);
Metadata.AddCategory(DiffuseMaterial.BrushProperty, Category_Appearance);
Metadata.AddCategory(DirectionalLight.DirectionProperty, Category_Light);
Metadata.AddCategory(DockPanel.DockProperty, Category_Layout);
Metadata.AddCategory(DockPanel.LastChildFillProperty, Category_Layout);
Metadata.AddCategory(DocumentViewer.ExtentHeightProperty, Category_Layout);
Metadata.AddCategory(DocumentViewer.ExtentWidthProperty, Category_Layout);
Metadata.AddCategory(DocumentViewer.HorizontalOffsetProperty, Category_Layout);
Metadata.AddCategory(DocumentViewer.HorizontalPageSpacingProperty, Category_Layout);
Metadata.AddCategory(DocumentViewer.ViewportHeightProperty, Category_Layout);
Metadata.AddCategory(DocumentViewer.ViewportWidthProperty, Category_Layout);
Metadata.AddCategory(DrawingGroup.ClipGeometryProperty, Category_Appearance);
Metadata.AddCategory(DrawingGroup.OpacityProperty, Category_Appearance);
Metadata.AddCategory(EllipseGeometry.CenterProperty, Category_Layout);
Metadata.AddCategory(EmissiveMaterial.BrushProperty, Category_Appearance);
Metadata.AddCategory(Expander.ExpandDirectionProperty, Category_Common_Properties);
Metadata.AddCategory(Expander.IsExpandedProperty, Category_Common_Properties);
Metadata.AddCategory(Figure.HeightProperty, Category_Layout);
Metadata.AddCategory(Figure.HorizontalAnchorProperty, Category_Layout);
Metadata.AddCategory(Figure.HorizontalOffsetProperty, Category_Layout);
Metadata.AddCategory(Figure.VerticalAnchorProperty, Category_Layout);
Metadata.AddCategory(Figure.VerticalOffsetProperty, Category_Layout);
Metadata.AddCategory(Figure.WidthProperty, Category_Layout);
Metadata.AddCategory(FixedPage.ContentBoxProperty, Category_Layout);
Metadata.AddCategory(Floater.WidthProperty, Category_Layout);
Metadata.AddCategory(FlowDocument.ColumnGapProperty, Category_Layout);
Metadata.AddCategory(FlowDocument.ColumnRuleBrushProperty, Category_Layout);
Metadata.AddCategory(FlowDocument.ColumnRuleWidthProperty, Category_Layout);
Metadata.AddCategory(FlowDocument.ColumnWidthProperty, Category_Layout);
Metadata.AddCategory(FlowDocument.IsColumnWidthFlexibleProperty, Category_Layout);
Metadata.AddCategory(FormatConvertedBitmap.AlphaThresholdProperty, Category_Appearance);
Metadata.AddCategory(Frame.NavigationUIVisibilityProperty, Category_Common_Properties);
Metadata.AddCategory(Frame.SourceProperty, Category_Common_Properties);
Metadata.AddCategory(FrameworkElement.ActualHeightProperty, Category_Layout);
Metadata.AddCategory(FrameworkElement.ActualWidthProperty, Category_Layout);
Metadata.AddCategory(FrameworkElement.CursorProperty, Category_Common_Properties);
Metadata.AddCategory(FrameworkElement.DataContextProperty, Category_Common_Properties);
Metadata.AddCategory(FrameworkElement.HeightProperty, Category_Layout);
Metadata.AddCategory(FrameworkElement.HorizontalAlignmentProperty, Category_Layout);
Metadata.AddCategory(FrameworkElement.LayoutTransformProperty, Category_Transform);
Metadata.AddCategory(FrameworkElement.MarginProperty, Category_Layout);
Metadata.AddCategory(FrameworkElement.MaxHeightProperty, Category_Layout);
Metadata.AddCategory(FrameworkElement.MaxWidthProperty, Category_Layout);
Metadata.AddCategory(FrameworkElement.MinHeightProperty, Category_Layout);
Metadata.AddCategory(FrameworkElement.MinWidthProperty, Category_Layout);
Metadata.AddCategory(FrameworkElement.TagProperty, Category_Common_Properties);
Metadata.AddCategory(FrameworkElement.VerticalAlignmentProperty, Category_Layout);
Metadata.AddCategory(FrameworkElement.WidthProperty, Category_Layout);
Metadata.AddCategory(Geometry.TransformProperty, Category_Transform);
Metadata.AddCategory(GeometryDrawing.BrushProperty, Category_Appearance);
Metadata.AddCategory(GeometryGroup.FillRuleProperty, Category_Appearance);
Metadata.AddCategory(GeometryModel3D.BackMaterialProperty, Category_Materials);
Metadata.AddCategory(GeometryModel3D.MaterialProperty, Category_Materials);
Metadata.AddCategory(GlyphRunDrawing.ForegroundBrushProperty, Category_Appearance);
Metadata.AddCategory(Glyphs.FillProperty, Category_Appearance);
Metadata.AddCategory(Glyphs.FontRenderingEmSizeProperty, Category_Text);
Metadata.AddCategory(Glyphs.FontUriProperty, Category_Text);
Metadata.AddCategory(GradientStop.ColorProperty, Category_Appearance);
Metadata.AddCategory(Grid.ColumnProperty, Category_Layout);
Metadata.AddCategory(Grid.ColumnSpanProperty, Category_Layout);
Metadata.AddCategory(Grid.IsSharedSizeScopeProperty, Category_Layout);
Metadata.AddCategory(Grid.RowProperty, Category_Layout);
Metadata.AddCategory(Grid.RowSpanProperty, Category_Layout);
Metadata.AddCategory(Grid.ShowGridLinesProperty, Category_Layout);
Metadata.AddCategory(GridSplitter.DragIncrementProperty, Category_Common_Properties);
Metadata.AddCategory(GridSplitter.ResizeBehaviorProperty, Category_Common_Properties);
Metadata.AddCategory(GridSplitter.ResizeDirectionProperty, Category_Common_Properties);
Metadata.AddCategory(GridSplitter.ShowsPreviewProperty, Category_Common_Properties);
Metadata.AddCategory(HeaderedContentControl.HeaderProperty, Category_Common_Properties);
Metadata.AddCategory(HeaderedContentControl.HeaderTemplateProperty, Category_Misc);
Metadata.AddCategory(HeaderedContentControl.HeaderTemplateSelectorProperty, Category_Misc);
Metadata.AddCategory(Image.SourceProperty, Category_Common_Properties);
Metadata.AddCategory(InkCanvas.EditingModeProperty, Category_Common_Properties);
Metadata.AddCategory(Inline.TextDecorationsProperty, Category_Text);
Metadata.AddCategory(ItemsControl.DisplayMemberPathProperty, Category_Common_Properties);
Metadata.AddCategory(ItemsControl.IsTextSearchEnabledProperty, Category_Common_Properties);
Metadata.AddCategory(ItemsControl.ItemContainerStyleProperty, Category_Misc);
Metadata.AddCategory(ItemsControl.ItemContainerStyleSelectorProperty, Category_Misc);
Metadata.AddCategory(ItemsControl.ItemsSourceProperty, Category_Common_Properties);
Metadata.AddCategory(ItemsControl.ItemTemplateProperty, Category_Misc);
Metadata.AddCategory(ItemsControl.ItemTemplateSelectorProperty, Category_Misc);
Metadata.AddCategory(Light.ColorProperty, Category_Light);
Metadata.AddCategory(Line.X1Property, Category_Appearance);
Metadata.AddCategory(Line.X2Property, Category_Appearance);
Metadata.AddCategory(Line.Y1Property, Category_Appearance);
Metadata.AddCategory(Line.Y2Property, Category_Appearance);
Metadata.AddCategory(LineGeometry.EndPointProperty, Category_Layout);
Metadata.AddCategory(LineGeometry.StartPointProperty, Category_Layout);
Metadata.AddCategory(MediaElement.BalanceProperty, Category_Media);
Metadata.AddCategory(MediaElement.IsMutedProperty, Category_Media);
Metadata.AddCategory(MediaElement.LoadedBehaviorProperty, Category_Media);
Metadata.AddCategory(MediaElement.ScrubbingEnabledProperty, Category_Media);
Metadata.AddCategory(MediaElement.SourceProperty, Category_Media);
Metadata.AddCategory(MediaElement.UnloadedBehaviorProperty, Category_Media);
Metadata.AddCategory(MediaElement.VolumeProperty, Category_Media);
Metadata.AddCategory(MenuItem.IconProperty, Category_Common_Properties);
Metadata.AddCategory(MenuItem.IsCheckableProperty, Category_Common_Properties);
Metadata.AddCategory(MenuItem.IsHighlightedProperty, Category_Common_Properties);
Metadata.AddCategory(MenuItem.IsPressedProperty, Category_Common_Properties);
Metadata.AddCategory(MenuItem.IsSubmenuOpenProperty, Category_Common_Properties);
Metadata.AddCategory(Model3D.TransformProperty, Category_Transform);
Metadata.AddCategory(OrthographicCamera.WidthProperty, Category_Camera);
Metadata.AddCategory(Page.TitleProperty, Category_Common_Properties);
Metadata.AddCategory(Panel.BackgroundProperty, Category_Brushes);
Metadata.AddCategory(Panel.IsItemsHostProperty, Category_Common_Properties);
Metadata.AddCategory(Panel.ZIndexProperty, Category_Layout);
Metadata.AddCategory(PasswordBox.PasswordCharProperty, Category_Text);
Metadata.AddCategory(Path.DataProperty, Category_Appearance);
Metadata.AddCategory(PathGeometry.FillRuleProperty, Category_Appearance);
Metadata.AddCategory(PathSegment.IsStrokedProperty, Category_Appearance);
Metadata.AddCategory(Pen.BrushProperty, Category_Appearance);
Metadata.AddCategory(Pen.DashCapProperty, Category_Appearance);
Metadata.AddCategory(Pen.DashStyleProperty, Category_Appearance);
Metadata.AddCategory(PerspectiveCamera.FieldOfViewProperty, Category_Camera);
Metadata.AddCategory(PointLightBase.ConstantAttenuationProperty, Category_Light);
Metadata.AddCategory(PointLightBase.LinearAttenuationProperty, Category_Light);
Metadata.AddCategory(PointLightBase.PositionProperty, Category_Light);
Metadata.AddCategory(PointLightBase.QuadraticAttenuationProperty, Category_Light);
Metadata.AddCategory(PointLightBase.RangeProperty, Category_Light);
Metadata.AddCategory(Polygon.FillRuleProperty, Category_Appearance);
Metadata.AddCategory(Polygon.PointsProperty, Category_Appearance);
Metadata.AddCategory(Polyline.FillRuleProperty, Category_Appearance);
Metadata.AddCategory(Polyline.PointsProperty, Category_Appearance);
Metadata.AddCategory(Popup.CustomPopupPlacementCallbackProperty, Category_Misc);
Metadata.AddCategory(Popup.HasDropShadowProperty, Category_Appearance);
Metadata.AddCategory(Popup.HorizontalOffsetProperty, Category_Layout);
Metadata.AddCategory(Popup.IsOpenProperty, Category_Common_Properties);
Metadata.AddCategory(Popup.PlacementProperty, Category_Layout);
Metadata.AddCategory(Popup.PlacementRectangleProperty, Category_Misc);
Metadata.AddCategory(Popup.PlacementTargetProperty, Category_Misc);
Metadata.AddCategory(Popup.StaysOpenProperty, Category_Common_Properties);
Metadata.AddCategory(Popup.VerticalOffsetProperty, Category_Layout);
Metadata.AddCategory(ProgressBar.IsIndeterminateProperty, Category_Common_Properties);
Metadata.AddCategory(ProgressBar.OrientationProperty, Category_Common_Properties);
Metadata.AddCategory(ProjectionCamera.FarPlaneDistanceProperty, Category_Camera);
Metadata.AddCategory(ProjectionCamera.LookDirectionProperty, Category_Camera);
Metadata.AddCategory(ProjectionCamera.NearPlaneDistanceProperty, Category_Camera);
Metadata.AddCategory(ProjectionCamera.PositionProperty, Category_Camera);
Metadata.AddCategory(ProjectionCamera.UpDirectionProperty, Category_Camera);
Metadata.AddCategory(RadialGradientBrush.CenterProperty, Category_Layout);
Metadata.AddCategory(RadioButton.GroupNameProperty, Category_Common_Properties);
Metadata.AddCategory(RangeBase.LargeChangeProperty, Category_Common_Properties);
Metadata.AddCategory(RangeBase.MaximumProperty, Category_Common_Properties);
Metadata.AddCategory(RangeBase.MinimumProperty, Category_Common_Properties);
Metadata.AddCategory(RangeBase.SmallChangeProperty, Category_Common_Properties);
Metadata.AddCategory(RangeBase.ValueProperty, Category_Common_Properties);
Metadata.AddCategory(Rectangle.RadiusXProperty, Category_Appearance);
Metadata.AddCategory(Rectangle.RadiusYProperty, Category_Appearance);
Metadata.AddCategory(RotateTransform.AngleProperty, Category_Transform);
Metadata.AddCategory(RotateTransform.CenterXProperty, Category_Transform);
Metadata.AddCategory(RotateTransform.CenterYProperty, Category_Transform);
Metadata.AddCategory(RowDefinition.HeightProperty, Category_Layout);
Metadata.AddCategory(RowDefinition.MaxHeightProperty, Category_Layout);
Metadata.AddCategory(RowDefinition.MinHeightProperty, Category_Layout);
Metadata.AddCategory(ScrollBar.OrientationProperty, Category_Layout);
Metadata.AddCategory(ScrollViewer.CanContentScrollProperty, Category_Layout);
Metadata.AddCategory(ScrollViewer.ComputedHorizontalScrollBarVisibilityProperty, Category_Appearance);
Metadata.AddCategory(ScrollViewer.ComputedVerticalScrollBarVisibilityProperty, Category_Appearance);
Metadata.AddCategory(ScrollViewer.ExtentHeightProperty, Category_Layout);
Metadata.AddCategory(ScrollViewer.ExtentWidthProperty, Category_Layout);
Metadata.AddCategory(ScrollViewer.HorizontalOffsetProperty, Category_Layout);
Metadata.AddCategory(ScrollViewer.HorizontalScrollBarVisibilityProperty, Category_Layout);
Metadata.AddCategory(ScrollViewer.ScrollableHeightProperty, Category_Layout);
Metadata.AddCategory(ScrollViewer.ScrollableWidthProperty, Category_Layout);
Metadata.AddCategory(ScrollViewer.VerticalOffsetProperty, Category_Layout);
Metadata.AddCategory(ScrollViewer.VerticalScrollBarVisibilityProperty, Category_Layout);
Metadata.AddCategory(ScrollViewer.ViewportHeightProperty, Category_Layout);
Metadata.AddCategory(ScrollViewer.ViewportWidthProperty, Category_Layout);
Metadata.AddCategory(Selector.IsSynchronizedWithCurrentItemProperty, Category_Common_Properties);
Metadata.AddCategory(Selector.SelectedIndexProperty, Category_Common_Properties);
Metadata.AddCategory(Selector.SelectedItemProperty, Category_Common_Properties);
Metadata.AddCategory(Selector.SelectedValuePathProperty, Category_Common_Properties);
Metadata.AddCategory(Selector.SelectedValueProperty, Category_Common_Properties);
Metadata.AddCategory(Shape.FillProperty, Category_Brushes);
Metadata.AddCategory(Shape.StretchProperty, Category_Appearance);
Metadata.AddCategory(Shape.StrokeDashArrayProperty, Category_Appearance);
Metadata.AddCategory(Shape.StrokeDashCapProperty, Category_Appearance);
Metadata.AddCategory(Shape.StrokeDashOffsetProperty, Category_Appearance);
Metadata.AddCategory(Shape.StrokeEndLineCapProperty, Category_Appearance);
Metadata.AddCategory(Shape.StrokeLineJoinProperty, Category_Appearance);
Metadata.AddCategory(Shape.StrokeMiterLimitProperty, Category_Appearance);
Metadata.AddCategory(Shape.StrokeProperty, Category_Brushes);
Metadata.AddCategory(Shape.StrokeStartLineCapProperty, Category_Appearance);
Metadata.AddCategory(Shape.StrokeThicknessProperty, Category_Appearance);
Metadata.AddCategory(SkewTransform.AngleXProperty, Category_Transform);
Metadata.AddCategory(SkewTransform.AngleYProperty, Category_Transform);
Metadata.AddCategory(SkewTransform.CenterXProperty, Category_Transform);
Metadata.AddCategory(SkewTransform.CenterYProperty, Category_Transform);
Metadata.AddCategory(Slider.AutoToolTipPlacementProperty, Category_Common_Properties);
Metadata.AddCategory(Slider.AutoToolTipPrecisionProperty, Category_Common_Properties);
Metadata.AddCategory(Slider.IsDirectionReversedProperty, Category_Common_Properties);
Metadata.AddCategory(Slider.IsMoveToPointEnabledProperty, Category_Common_Properties);
Metadata.AddCategory(Slider.IsSelectionRangeEnabledProperty, Category_Common_Properties);
Metadata.AddCategory(Slider.IsSnapToTickEnabledProperty, Category_Common_Properties);
Metadata.AddCategory(Slider.OrientationProperty, Category_Common_Properties);
Metadata.AddCategory(Slider.SelectionEndProperty, Category_Common_Properties);
Metadata.AddCategory(Slider.SelectionStartProperty, Category_Common_Properties);
Metadata.AddCategory(Slider.TickFrequencyProperty, Category_Common_Properties);
Metadata.AddCategory(Slider.TickPlacementProperty, Category_Common_Properties);
Metadata.AddCategory(Slider.TicksProperty, Category_Common_Properties);
Metadata.AddCategory(SolidColorBrush.ColorProperty, Category_Appearance);
Metadata.AddCategory(SpecularMaterial.BrushProperty, Category_Appearance);
Metadata.AddCategory(SpotLight.DirectionProperty, Category_Light);
Metadata.AddCategory(SpotLight.InnerConeAngleProperty, Category_Light);
Metadata.AddCategory(SpotLight.OuterConeAngleProperty, Category_Light);
Metadata.AddCategory(StackPanel.OrientationProperty, Category_Layout);
Metadata.AddCategory(StickyNoteControl.CaptionFontFamilyProperty, Category_Text);
Metadata.AddCategory(StickyNoteControl.CaptionFontSizeProperty, Category_Text);
Metadata.AddCategory(StickyNoteControl.CaptionFontStretchProperty, Category_Text);
Metadata.AddCategory(StickyNoteControl.CaptionFontStyleProperty, Category_Text);
Metadata.AddCategory(StickyNoteControl.CaptionFontWeightProperty, Category_Text);
Metadata.AddCategory(TabControl.ContentTemplateProperty, Category_Misc);
Metadata.AddCategory(TabControl.ContentTemplateSelectorProperty, Category_Misc);
Metadata.AddCategory(TabControl.SelectedContentTemplateProperty, Category_Misc);
Metadata.AddCategory(TabControl.SelectedContentTemplateSelectorProperty, Category_Misc);
Metadata.AddCategory(TabControl.TabStripPlacementProperty, Category_Common_Properties);
Metadata.AddCategory(Table.CellSpacingProperty, Category_Layout);
Metadata.AddCategory(TableCell.ColumnSpanProperty, Category_Layout);
Metadata.AddCategory(TableColumn.WidthProperty, Category_Layout);
Metadata.AddCategory(TextBlock.TextProperty, Category_Common_Properties);
Metadata.AddCategory(TextBlock.TextTrimmingProperty, Category_Text);
Metadata.AddCategory(TextBlock.TextWrappingProperty, Category_Text);
Metadata.AddCategory(TextBox.CharacterCasingProperty, Category_Text);
Metadata.AddCategory(TextBox.MaxLengthProperty, Category_Text);
Metadata.AddCategory(TextBox.MaxLinesProperty, Category_Text);
Metadata.AddCategory(TextBox.MinLinesProperty, Category_Text);
Metadata.AddCategory(TextBox.TextProperty, Category_Common_Properties);
Metadata.AddCategory(TextBoxBase.AcceptsTabProperty, Category_Text);
Metadata.AddCategory(TextBoxBase.AutoWordSelectionProperty, Category_Text);
Metadata.AddCategory(TextBoxBase.IsUndoEnabledProperty, Category_Text);
Metadata.AddCategory(TextEffect.ClipProperty, Category_Appearance);
Metadata.AddCategory(TextEffect.ForegroundProperty, Category_Appearance);
Metadata.AddCategory(TextElement.BackgroundProperty, Category_Brushes);
Metadata.AddCategory(TextElement.FontFamilyProperty, Category_Text);
Metadata.AddCategory(TextElement.FontSizeProperty, Category_Text);
Metadata.AddCategory(TextElement.FontStretchProperty, Category_Text);
Metadata.AddCategory(TextElement.FontStyleProperty, Category_Text);
Metadata.AddCategory(TextElement.FontWeightProperty, Category_Text);
Metadata.AddCategory(TextElement.ForegroundProperty, Category_Brushes);
Metadata.AddCategory(TextElement.TextEffectsProperty, Category_Text);
Metadata.AddCategory(TickBar.FillProperty, Category_Appearance);
Metadata.AddCategory(TileBrush.AlignmentXProperty, Category_Layout);
Metadata.AddCategory(TileBrush.AlignmentYProperty, Category_Layout);
Metadata.AddCategory(ToggleButton.IsCheckedProperty, Category_Common_Properties);
Metadata.AddCategory(ToggleButton.IsThreeStateProperty, Category_Common_Properties);
Metadata.AddCategory(TransformGroup.ChildrenProperty, Category_Transform);
Metadata.AddCategory(TranslateTransform.XProperty, Category_Layout);
Metadata.AddCategory(TranslateTransform.YProperty, Category_Layout);
Metadata.AddCategory(TreeViewItem.IsSelectedProperty, Category_Common_Properties);
Metadata.AddCategory(UIElement.BitmapEffectInputProperty, Category_Appearance);
Metadata.AddCategory(UIElement.BitmapEffectProperty, Category_Appearance);
Metadata.AddCategory(UIElement.ClipToBoundsProperty, Category_Appearance);
Metadata.AddCategory(UIElement.FocusableProperty, Category_Common_Properties);
Metadata.AddCategory(UIElement.IsEnabledProperty, Category_Common_Properties);
Metadata.AddCategory(UIElement.IsFocusedProperty, Category_Common_Properties);
Metadata.AddCategory(UIElement.IsHitTestVisibleProperty, Category_Common_Properties);
Metadata.AddCategory(UIElement.IsKeyboardFocusedProperty, Category_Common_Properties);
Metadata.AddCategory(UIElement.IsMouseOverProperty, Category_Common_Properties);
Metadata.AddCategory(UIElement.IsStylusDirectlyOverProperty, Category_Common_Properties);
Metadata.AddCategory(UIElement.OpacityMaskProperty, Category_Brushes);
Metadata.AddCategory(UIElement.OpacityProperty, Category_Appearance);
Metadata.AddCategory(UIElement.RenderTransformProperty, Category_Transform);
Metadata.AddCategory(UIElement.SnapsToDevicePixelsProperty, Category_Appearance);
Metadata.AddCategory(UIElement.VisibilityProperty, Category_Appearance);
Metadata.AddCategory(UniformGrid.ColumnsProperty, Category_Common_Properties);
Metadata.AddCategory(UniformGrid.RowsProperty, Category_Common_Properties);
Metadata.AddCategory(Viewbox.StretchDirectionProperty, Category_Appearance);
Metadata.AddCategory(Viewbox.StretchProperty, Category_Appearance);
Metadata.AddCategory(VirtualizingStackPanel.OrientationProperty, Category_Layout);
Metadata.AddCategory(Window.AllowsTransparencyProperty, Category_Appearance);
Metadata.AddCategory(Window.IconProperty, Category_Common_Properties);
Metadata.AddCategory(Window.ResizeModeProperty, Category_Common_Properties);
Metadata.AddCategory(Window.ShowInTaskbarProperty, Category_Common_Properties);
Metadata.AddCategory(Window.SizeToContentProperty, Category_Common_Properties);
Metadata.AddCategory(Window.TitleProperty, Category_Common_Properties);
Metadata.AddCategory(Window.TopmostProperty, Category_Common_Properties);
Metadata.AddCategory(Window.WindowStateProperty, Category_Common_Properties);
Metadata.AddCategory(Window.WindowStyleProperty, Category_Appearance);
Metadata.AddCategory(WrapPanel.ItemHeightProperty, Category_Layout);
Metadata.AddCategory(WrapPanel.ItemWidthProperty, Category_Layout);
Metadata.AddAdvancedProperty(Block.BreakColumnBeforeProperty);
Metadata.AddAdvancedProperty(Block.BreakPageBeforeProperty);
Metadata.AddAdvancedProperty(Block.PaddingProperty);
Metadata.AddAdvancedProperty(ColumnDefinition.MaxWidthProperty);
Metadata.AddAdvancedProperty(ColumnDefinition.MinWidthProperty);
Metadata.AddAdvancedProperty(ComboBox.StaysOpenOnEditProperty);
Metadata.AddAdvancedProperty(ComboBox.TextProperty);
Metadata.AddAdvancedProperty(Control.HorizontalContentAlignmentProperty);
Metadata.AddAdvancedProperty(Control.PaddingProperty);
Metadata.AddAdvancedProperty(Control.VerticalContentAlignmentProperty);
Metadata.AddAdvancedProperty(DashStyle.DashesProperty);
Metadata.AddAdvancedProperty(DocumentViewer.ExtentHeightProperty);
Metadata.AddAdvancedProperty(DocumentViewer.ExtentWidthProperty);
Metadata.AddAdvancedProperty(DocumentViewer.HorizontalOffsetProperty);
Metadata.AddAdvancedProperty(DocumentViewer.HorizontalPageSpacingProperty);
Metadata.AddAdvancedProperty(DocumentViewer.ViewportHeightProperty);
Metadata.AddAdvancedProperty(DocumentViewer.ViewportWidthProperty);
Metadata.AddAdvancedProperty(DrawingGroup.ClipGeometryProperty);
Metadata.AddAdvancedProperty(Figure.CanDelayPlacementProperty);
Metadata.AddAdvancedProperty(Figure.HorizontalAnchorProperty);
Metadata.AddAdvancedProperty(Figure.HorizontalOffsetProperty);
Metadata.AddAdvancedProperty(Figure.VerticalAnchorProperty);
Metadata.AddAdvancedProperty(Figure.VerticalOffsetProperty);
Metadata.AddAdvancedProperty(FlowDocument.ColumnGapProperty);
Metadata.AddAdvancedProperty(FlowDocument.ColumnRuleBrushProperty);
Metadata.AddAdvancedProperty(FlowDocument.ColumnRuleWidthProperty);
Metadata.AddAdvancedProperty(FlowDocument.ColumnWidthProperty);
Metadata.AddAdvancedProperty(FlowDocument.IsColumnWidthFlexibleProperty);
Metadata.AddAdvancedProperty(FormatConvertedBitmap.AlphaThresholdProperty);
Metadata.AddAdvancedProperty(FrameworkElement.ActualHeightProperty);
Metadata.AddAdvancedProperty(FrameworkElement.ActualWidthProperty);
Metadata.AddAdvancedProperty(FrameworkElement.LayoutTransformProperty);
Metadata.AddAdvancedProperty(FrameworkElement.MaxHeightProperty);
Metadata.AddAdvancedProperty(FrameworkElement.MaxWidthProperty);
Metadata.AddAdvancedProperty(FrameworkElement.MinHeightProperty);
Metadata.AddAdvancedProperty(FrameworkElement.MinWidthProperty);
Metadata.AddAdvancedProperty(FrameworkElement.TagProperty);
Metadata.AddAdvancedProperty(GeometryGroup.FillRuleProperty);
Metadata.AddAdvancedProperty(Glyphs.FontRenderingEmSizeProperty);
Metadata.AddAdvancedProperty(Glyphs.FontUriProperty);
Metadata.AddAdvancedProperty(Grid.IsSharedSizeScopeProperty);
Metadata.AddAdvancedProperty(Grid.ShowGridLinesProperty);
Metadata.AddAdvancedProperty(ItemsControl.DisplayMemberPathProperty);
Metadata.AddAdvancedProperty(ItemsControl.IsTextSearchEnabledProperty);
Metadata.AddAdvancedProperty(MediaElement.LoadedBehaviorProperty);
Metadata.AddAdvancedProperty(MediaElement.ScrubbingEnabledProperty);
Metadata.AddAdvancedProperty(MediaElement.UnloadedBehaviorProperty);
Metadata.AddAdvancedProperty(PasswordBox.PasswordCharProperty);
Metadata.AddAdvancedProperty(PathGeometry.FillRuleProperty);
Metadata.AddAdvancedProperty(PathSegment.IsStrokedProperty);
Metadata.AddAdvancedProperty(Pen.DashCapProperty);
Metadata.AddAdvancedProperty(Pen.DashStyleProperty);
Metadata.AddAdvancedProperty(RowDefinition.MaxHeightProperty);
Metadata.AddAdvancedProperty(RowDefinition.MinHeightProperty);
Metadata.AddAdvancedProperty(ScrollViewer.CanContentScrollProperty);
Metadata.AddAdvancedProperty(ScrollViewer.CanContentScrollProperty);
Metadata.AddAdvancedProperty(ScrollViewer.ComputedHorizontalScrollBarVisibilityProperty);
Metadata.AddAdvancedProperty(ScrollViewer.ComputedVerticalScrollBarVisibilityProperty);
Metadata.AddAdvancedProperty(ScrollViewer.ExtentHeightProperty);
Metadata.AddAdvancedProperty(ScrollViewer.ExtentWidthProperty);
Metadata.AddAdvancedProperty(ScrollViewer.HorizontalOffsetProperty);
Metadata.AddAdvancedProperty(ScrollViewer.HorizontalScrollBarVisibilityProperty);
Metadata.AddAdvancedProperty(ScrollViewer.ScrollableHeightProperty);
Metadata.AddAdvancedProperty(ScrollViewer.ScrollableWidthProperty);
Metadata.AddAdvancedProperty(ScrollViewer.VerticalOffsetProperty);
Metadata.AddAdvancedProperty(ScrollViewer.VerticalScrollBarVisibilityProperty);
Metadata.AddAdvancedProperty(ScrollViewer.ViewportHeightProperty);
Metadata.AddAdvancedProperty(ScrollViewer.ViewportWidthProperty);
Metadata.AddAdvancedProperty(Selector.SelectedItemProperty);
Metadata.AddAdvancedProperty(Selector.SelectedValuePathProperty);
Metadata.AddAdvancedProperty(Selector.SelectedValueProperty);
Metadata.AddAdvancedProperty(Shape.StretchProperty);
Metadata.AddAdvancedProperty(Shape.StrokeDashArrayProperty);
Metadata.AddAdvancedProperty(Shape.StrokeDashCapProperty);
Metadata.AddAdvancedProperty(Shape.StrokeDashOffsetProperty);
Metadata.AddAdvancedProperty(Shape.StrokeEndLineCapProperty);
Metadata.AddAdvancedProperty(Shape.StrokeLineJoinProperty);
Metadata.AddAdvancedProperty(Shape.StrokeMiterLimitProperty);
Metadata.AddAdvancedProperty(Shape.StrokeStartLineCapProperty);
Metadata.AddAdvancedProperty(SkewTransform.CenterXProperty);
Metadata.AddAdvancedProperty(SkewTransform.CenterYProperty);
Metadata.AddAdvancedProperty(Slider.AutoToolTipPrecisionProperty);
Metadata.AddAdvancedProperty(Slider.IsMoveToPointEnabledProperty);
Metadata.AddAdvancedProperty(Slider.IsSelectionRangeEnabledProperty);
Metadata.AddAdvancedProperty(Slider.IsSnapToTickEnabledProperty);
Metadata.AddAdvancedProperty(Slider.SelectionEndProperty);
Metadata.AddAdvancedProperty(Slider.SelectionStartProperty);
Metadata.AddAdvancedProperty(Slider.TicksProperty);
Metadata.AddAdvancedProperty(TextBlock.TextTrimmingProperty);
Metadata.AddAdvancedProperty(TextBlock.TextWrappingProperty);
Metadata.AddAdvancedProperty(TextBox.CharacterCasingProperty);
Metadata.AddAdvancedProperty(TextBox.MaxLengthProperty);
Metadata.AddAdvancedProperty(TextBox.MaxLinesProperty);
Metadata.AddAdvancedProperty(TextBox.MinLinesProperty);
Metadata.AddAdvancedProperty(TextBoxBase.AcceptsTabProperty);
Metadata.AddAdvancedProperty(TextBoxBase.AutoWordSelectionProperty);
Metadata.AddAdvancedProperty(TextBoxBase.IsUndoEnabledProperty);
Metadata.AddAdvancedProperty(TextEffect.ClipProperty);
Metadata.AddAdvancedProperty(TextElement.FontStretchProperty);
Metadata.AddAdvancedProperty(TextElement.FontStyleProperty);
Metadata.AddAdvancedProperty(TextElement.FontWeightProperty);
Metadata.AddAdvancedProperty(TextElement.TextEffectsProperty);
Metadata.AddAdvancedProperty(UIElement.BitmapEffectInputProperty);
Metadata.AddAdvancedProperty(UIElement.BitmapEffectProperty);
Metadata.AddAdvancedProperty(UIElement.ClipToBoundsProperty);
Metadata.AddAdvancedProperty(UIElement.FocusableProperty);
Metadata.AddAdvancedProperty(UIElement.IsHitTestVisibleProperty);
Metadata.AddAdvancedProperty(UIElement.SnapsToDevicePixelsProperty);
Metadata.AddValueRange(Block.LineHeightProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(Canvas.BottomProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(Canvas.LeftProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(Canvas.TopProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(Canvas.RightProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(ColumnDefinition.MaxWidthProperty, 0, double.PositiveInfinity);
Metadata.AddValueRange(DocumentViewer.MaxPagesAcrossProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(Figure.HorizontalOffsetProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(Figure.VerticalOffsetProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(FlowDocument.MaxPageWidthProperty, 0, double.PositiveInfinity);
Metadata.AddValueRange(FlowDocument.MaxPageHeightProperty, 0, double.PositiveInfinity);
Metadata.AddValueRange(FlowDocumentPageViewer.ZoomProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(FlowDocumentPageViewer.ZoomIncrementProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(FlowDocumentPageViewer.MinZoomProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(FlowDocumentPageViewer.MaxZoomProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(FrameworkElement.MaxHeightProperty, 0, double.PositiveInfinity);
Metadata.AddValueRange(FrameworkElement.MaxWidthProperty, 0, double.PositiveInfinity);
Metadata.AddValueRange(Grid.ColumnSpanProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(Grid.RowSpanProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(GridSplitter.KeyboardIncrementProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(GridSplitter.DragIncrementProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(InkCanvas.BottomProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(InkCanvas.TopProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(InkCanvas.RightProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(InkCanvas.LeftProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(Line.Y2Property, double.MinValue, double.MaxValue);
Metadata.AddValueRange(Line.X1Property, double.MinValue, double.MaxValue);
Metadata.AddValueRange(Line.Y1Property, double.MinValue, double.MaxValue);
Metadata.AddValueRange(Line.X2Property, double.MinValue, double.MaxValue);
Metadata.AddValueRange(List.MarkerOffsetProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(List.StartIndexProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(Paragraph.TextIndentProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(RangeBase.ValueProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(RangeBase.MaximumProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(RangeBase.MinimumProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(RepeatButton.IntervalProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(RowDefinition.MaxHeightProperty, 0, double.PositiveInfinity);
Metadata.AddValueRange(Selector.SelectedIndexProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(Slider.TickFrequencyProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(Slider.SelectionStartProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(Slider.SelectionEndProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(TableCell.RowSpanProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(TableCell.ColumnSpanProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(TextBox.MinLinesProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(TextBox.MaxLinesProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(TextBoxBase.UndoLimitProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(TextElement.FontSizeProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(Timeline.SpeedRatioProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(Timeline.DecelerationRatioProperty, 0, 1);
Metadata.AddValueRange(Timeline.AccelerationRatioProperty, 0, 1);
Metadata.AddValueRange(Track.ViewportSizeProperty, 0, double.PositiveInfinity);
Metadata.AddValueRange(UIElement.OpacityProperty, 0, 1);
}
}
}

62
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Category.cs

@ -0,0 +1,62 @@ @@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.ComponentModel;
using ICSharpCode.WpfDesign.PropertyGrid;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid
{
public class Category : INotifyPropertyChanged
{
public Category(string name)
{
Name = name;
Properties = new ObservableCollection<PropertyNode>();
MoreProperties = new ObservableCollection<PropertyNode>();
}
public string Name { get; private set; }
public ObservableCollection<PropertyNode> Properties { get; private set; }
public ObservableCollection<PropertyNode> MoreProperties { get; private set; }
bool isExpanded = true;
public bool IsExpanded {
get {
return isExpanded;
}
set {
isExpanded = value;
RaisePropertyChanged("IsExpanded");
}
}
bool showMore;
internal bool ShowMoreByFilter;
public bool ShowMore {
get {
return showMore;
}
set {
showMore = value;
RaisePropertyChanged("ShowMore");
}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
void RaisePropertyChanged(string name)
{
if (PropertyChanged != null) {
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
#endregion
}
}

7
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BoolEditor.xaml

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
<CheckBox
x:Class="ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BoolEditor"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
IsChecked="{Binding Value}"
>
</CheckBox>

26
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BoolEditor.xaml.cs

@ -0,0 +1,26 @@ @@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.PropertyGrid;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
{
[TypeEditor(typeof(bool))]
public partial class BoolEditor
{
public BoolEditor()
{
InitializeComponent();
}
}
}

208
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditor.cs

@ -0,0 +1,208 @@ @@ -0,0 +1,208 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using ICSharpCode.WpfDesign.PropertyGrid;
using System.Windows.Media;
using System.Reflection;
using System.Windows;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
{
public enum BrushEditorKind
{
None,
Solid,
Linear,
Radial,
List
}
public class BrushItem
{
public string Name { get; set; }
public Brush Brush { get; set; }
}
public class BrushEditor : INotifyPropertyChanged
{
public BrushEditor()
{
GradientStopCollection stops = new GradientStopCollection();
stops.Add(new GradientStop(Colors.Black, 0));
stops.Add(new GradientStop(Colors.White, 1));
linearGradientBrush = new LinearGradientBrush(stops);
linearGradientBrush.EndPoint = new Point(1, 0);
radialGradientBrush = new RadialGradientBrush(stops);
}
public static BrushItem[] SystemBrushes = typeof(SystemColors)
.GetProperties(BindingFlags.Static | BindingFlags.Public)
.Where(p => p.PropertyType == typeof(SolidColorBrush))
.Select(p => new BrushItem() { Name = p.Name, Brush = (Brush)p.GetValue(null, null) })
.ToArray();
public static BrushItem[] SystemColors = typeof(SystemColors)
.GetProperties(BindingFlags.Static | BindingFlags.Public)
.Where(p => p.PropertyType == typeof(Color))
.Select(p => new BrushItem()
{
Name = p.Name,
Brush = new SolidColorBrush((Color)p.GetValue(null, null))
})
.ToArray();
SolidColorBrush solidColorBrush = new SolidColorBrush(Colors.White);
LinearGradientBrush linearGradientBrush;
RadialGradientBrush radialGradientBrush;
PropertyNode property;
public PropertyNode Property {
get {
return property;
}
set {
property = value;
if (property != null) {
var f = property.Value as Freezable;
if (f != null && f.IsFrozen) property.Value = f.Clone();
}
DetermineCurrentKind();
RaisePropertyChanged("Property");
RaisePropertyChanged("Brush");
}
}
public Brush Brush {
get {
if (property != null) {
return property.Value as Brush;
}
return null;
}
set {
if (property != null && property.Value != value) {
if (value != null && value.IsFrozen) {
value = value.Clone();
}
property.Value = value;
DetermineCurrentKind();
RaisePropertyChanged("Brush");
}
}
}
void DetermineCurrentKind()
{
if (Brush == null) {
CurrentKind = BrushEditorKind.None;
}
else if (Brush is SolidColorBrush) {
solidColorBrush = Brush as SolidColorBrush;
CurrentKind = BrushEditorKind.Solid;
}
else if (Brush is LinearGradientBrush) {
linearGradientBrush = Brush as LinearGradientBrush;
radialGradientBrush.GradientStops = linearGradientBrush.GradientStops;
CurrentKind = BrushEditorKind.Linear;
}
else if (Brush is RadialGradientBrush) {
radialGradientBrush = Brush as RadialGradientBrush;
linearGradientBrush.GradientStops = linearGradientBrush.GradientStops;
CurrentKind = BrushEditorKind.Radial;
}
}
BrushEditorKind currentKind;
public BrushEditorKind CurrentKind {
get {
return currentKind;
}
set {
currentKind = value;
RaisePropertyChanged("CurrentKind");
switch (CurrentKind) {
case BrushEditorKind.None:
Brush = null;
break;
case BrushEditorKind.Solid:
Brush = solidColorBrush;
break;
case BrushEditorKind.Linear:
Brush = linearGradientBrush;
break;
case BrushEditorKind.Radial:
Brush = radialGradientBrush;
break;
case BrushEditorKind.List:
Brush = solidColorBrush;
break;
}
}
}
public double GradientAngle {
get {
var x = linearGradientBrush.EndPoint.X - linearGradientBrush.StartPoint.X;
var y = linearGradientBrush.EndPoint.Y - linearGradientBrush.StartPoint.Y;
return Vector.AngleBetween(new Vector(1, 0), new Vector(x, -y));
}
set {
var d = value * Math.PI / 180;
var p = new Point(Math.Cos(d), -Math.Sin(d));
var k = 1 / Math.Max(Math.Abs(p.X), Math.Abs(p.Y));
p.X *= k;
p.Y *= k;
var p2 = new Point(-p.X, -p.Y);
linearGradientBrush.StartPoint = new Point((p2.X + 1) / 2, (p2.Y + 1) / 2);
linearGradientBrush.EndPoint = new Point((p.X + 1) / 2, (p.Y + 1) / 2);
RaisePropertyChanged("GradientAngle");
}
}
public IEnumerable<BrushItem> AvailableColors {
get { return SystemColors; }
}
public IEnumerable<BrushItem> AvailableBrushes {
get { return SystemBrushes; }
}
public void MakeGradientHorizontal()
{
GradientAngle = 0;
}
public void MakeGradientVertical()
{
GradientAngle = -90;
}
public void Commit()
{
Property.Value = Property.Value;
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
void RaisePropertyChanged(string name)
{
if (PropertyChanged != null) {
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
#endregion
}
}

11
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorPopup.xaml

@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
<Popup x:Class="ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor.BrushEditorPopup"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:BrushEditor="clr-namespace:ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor"
Placement="Bottom"
AllowsTransparency="True"
SnapsToDevicePixels="True"
StaysOpen="False">
<BrushEditor:BrushEditorView x:Name="BrushEditorView"
x:FieldModifier="public" />
</Popup>

36
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorPopup.xaml.cs

@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Diagnostics;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
{
public partial class BrushEditorPopup
{
public BrushEditorPopup()
{
InitializeComponent();
}
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
BrushEditorView.BrushEditor.Commit();
}
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.Key == Key.Escape) IsOpen = false;
}
}
}

81
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorView.xaml

@ -0,0 +1,81 @@ @@ -0,0 +1,81 @@
<UserControl x:Class="ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor.BrushEditorView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Designer="clr-namespace:ICSharpCode.WpfDesign.Designer"
xmlns:Controls="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls"
xmlns:BrushEditor="clr-namespace:ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor"
xmlns:Converters="clr-namespace:ICSharpCode.WpfDesign.Designer.Converters"
xmlns:PropertyGrid="clr-namespace:ICSharpCode.WpfDesign.Designer.PropertyGrid"
Width="395">
<UserControl.Resources>
<DataTemplate DataType="{x:Type BrushEditor:BrushItem}">
<StackPanel Orientation="Horizontal">
<Border Background="{Binding Brush}"
Width="30"
Height="15"
Margin="2"
BorderThickness="1"
BorderBrush="Black" />
<TextBlock Text="{Binding Name}"
VerticalAlignment="Center" />
</StackPanel>
</DataTemplate>
</UserControl.Resources>
<TabControl x:Name="tabControl"
SelectedIndex="{Binding CurrentKind, Converter={x:Static Converters:IntFromEnumConverter.Instance}}">
<TabItem Header="None">
<Border Background="White"
BorderThickness="1"
BorderBrush="Black"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<Line X1="0"
Y1="40"
X2="70"
Y2="0"
Stroke="Red"
StrokeThickness="1" />
</Border>
</TabItem>
<TabItem Header="Solid">
<BrushEditor:SolidBrushEditor Color="{Binding Brush.Color}" />
</TabItem>
<TabItem Header="Linear">
<DockPanel>
<StackPanel DockPanel.Dock="Top"
Orientation="Horizontal"
Margin="5">
<TextBlock Text="Angle"
VerticalAlignment="Center" />
<Controls:NumericUpDown Value="{Binding GradientAngle}"
Minimum="-360"
Maximum="360"
Margin="5 0 0 0"
Width="50" />
<Button Content="H"
Command="{Designer:Call MakeGradientHorizontal}"
Margin="5 0 0 0"
Width="30" />
<Button Content="V"
Command="{Designer:Call MakeGradientVertical}"
Margin="5 0 0 0"
Width="30" />
</StackPanel>
<BrushEditor:GradientBrushEditor />
</DockPanel>
</TabItem>
<TabItem Header="Radial">
<BrushEditor:GradientBrushEditor />
</TabItem>
<TabItem Header="Brush List">
<ListBox ItemsSource="{Binding AvailableBrushes}"
SelectedValue="{Binding Brush.Color}"
SelectedValuePath="Brush.Color" />
</TabItem>
</TabControl>
</UserControl>

51
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorView.xaml.cs

@ -0,0 +1,51 @@ @@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Diagnostics;
using System.Globalization;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
{
public partial class BrushEditorView
{
public BrushEditorView()
{
BrushEditor = new BrushEditor();
DataContext = BrushEditor;
InitializeComponent();
SetBinding(HeightProperty, new Binding("Brush") {
Converter = HeightConverter.Instance
});
}
public BrushEditor BrushEditor { get; private set; }
class HeightConverter : IValueConverter
{
public static HeightConverter Instance = new HeightConverter();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is GradientBrush) return double.NaN;
return 315;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
}

13
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushTypeEditor.xaml

@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
<UserControl x:Class="ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor.BrushTypeEditor"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Border BorderThickness="1"
BorderBrush="Black"
Background="Transparent"
HorizontalAlignment="Left"
Cursor="Hand"
Width="30"
Height="16">
<Border Background="{Binding Value}" />
</Border>
</UserControl>

36
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushTypeEditor.xaml.cs

@ -0,0 +1,36 @@ @@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.PropertyGrid;
using System.Windows.Controls.Primitives;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
{
[TypeEditor(typeof(Brush))]
public partial class BrushTypeEditor
{
public BrushTypeEditor()
{
InitializeComponent();
}
static BrushEditorPopup brushEditorPopup = new BrushEditorPopup();
protected override void OnMouseUp(MouseButtonEventArgs e)
{
brushEditorPopup.BrushEditorView.BrushEditor.Property = DataContext as PropertyNode;
brushEditorPopup.PlacementTarget = this;
brushEditorPopup.IsOpen = true;
}
}
}

92
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/ColorHelper.cs

@ -0,0 +1,92 @@ @@ -0,0 +1,92 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
{
public static class ColorHelper
{
public static Color ColorFromString(string s)
{
if (string.IsNullOrEmpty(s)) {
return Colors.White;
}
if (s[0] != '#') s = "#" + s;
try {
return (Color)ColorConverter.ConvertFromString(s);
}
catch {
return Colors.White;
}
}
public static string StringFromColor(Color c)
{
return c.ToString().Substring(1);
}
public static Color ColorFromHsv(double h, double s, double v)
{
double r, g, b;
RgbFromHsv(h, s, v, out r, out g, out b);
return Color.FromRgb((byte)(r * 255), (byte)(g * 255), (byte)(b * 255));
}
public static void HsvFromColor(Color c, out double h, out double s, out double v)
{
HsvFromRgb(c.R / 255.0, c.G / 255.0, c.B / 255.0, out h, out s, out v);
}
// http://en.wikipedia.org/wiki/HSV_color_space
public static void HsvFromRgb(double r, double g, double b, out double h, out double s, out double v)
{
var max = Math.Max(r, Math.Max(g, b));
var min = Math.Min(r, Math.Min(g, b));
if (max == min) {
h = 0;
}
else if (max == r) {
h = (60 * (g - b) / (max - min)) % 360;
}
else if (max == g) {
h = 60 * (b - r) / (max - min) + 120;
}
else {
h = 60 * (r - g) / (max - min) + 240;
}
if (max == 0) {
s = 0;
}
else {
s = 1 - min / max;
}
v = max;
}
// http://en.wikipedia.org/wiki/HSV_color_space
public static void RgbFromHsv(double h, double s, double v, out double r, out double g, out double b)
{
h = h % 360;
int hi = (int)(h / 60) % 6;
var f = h / 60 - (int)(h / 60);
var p = v * (1 - s);
var q = v * (1 - f * s);
var t = v * (1 - (1 - f) * s);
switch (hi) {
case 0: r = v; g = t; b = p; break;
case 1: r = q; g = v; b = p; break;
case 2: r = p; g = v; b = t; break;
case 3: r = p; g = q; b = v; break;
case 4: r = t; g = p; b = v; break;
default: r = v; g = p; b = q; break;
}
}
}
}

233
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/ColorPicker.xaml

@ -0,0 +1,233 @@ @@ -0,0 +1,233 @@
<UserControl x:Class="ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor.ColorPicker"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls"
xmlns:BrushEditor="clr-namespace:ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor"
x:Name="this"
Padding="5"
Width="373">
<UserControl.Resources>
<DrawingBrush x:Key="ChessBrush"
TileMode="Tile"
ViewportUnits="Absolute"
Viewport="0 0 9 9">
<DrawingBrush.Drawing>
<DrawingGroup>
<GeometryDrawing Brush="White">
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="0 0 2 2" />
</GeometryDrawing.Geometry>
</GeometryDrawing>
<GeometryDrawing Brush="Gray">
<GeometryDrawing.Geometry>
<GeometryGroup>
<RectangleGeometry Rect="0 0 1 1" />
<RectangleGeometry Rect="1 1 1 1" />
</GeometryGroup>
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</UserControl.Resources>
<DockPanel>
<StackPanel VerticalAlignment="Top"
DockPanel.Dock="Right"
Margin="10 0 0 0">
<Border Background="{StaticResource ChessBrush}"
HorizontalAlignment="Right"
BorderBrush="Black"
BorderThickness="1"
Height="50"
Width="70">
<Rectangle>
<Rectangle.Fill>
<SolidColorBrush Color="{Binding Color, ElementName=this}" />
</Rectangle.Fill>
</Rectangle>
</Border>
<DockPanel Margin="0 3 0 0">
<BrushEditor:HexTextBox Text="{Binding Hex, ElementName=this, UpdateSourceTrigger=PropertyChanged}"
Width="70"
Margin="5 0 0 0"
DockPanel.Dock="Right" />
<TextBlock Text="#"
VerticalAlignment="Center"
HorizontalAlignment="Right" />
</DockPanel>
<DockPanel Margin="0 3 0 0">
<Controls:NumericUpDown Value="{Binding H, ElementName=this}"
Maximum="360"
Width="70"
Margin="5 0 0 0"
DockPanel.Dock="Right" />
<TextBlock Text="H"
VerticalAlignment="Center"
HorizontalAlignment="Right" />
</DockPanel>
<DockPanel Margin="0 3 0 0">
<Controls:NumericUpDown Value="{Binding S, ElementName=this}"
Width="70"
Margin="5 0 0 0"
DockPanel.Dock="Right" />
<TextBlock Text="S"
VerticalAlignment="Center"
HorizontalAlignment="Right" />
</DockPanel>
<DockPanel Margin="0 3 0 0">
<Controls:NumericUpDown Value="{Binding V, ElementName=this}"
Width="70"
Margin="5 0 0 0"
DockPanel.Dock="Right" />
<TextBlock Text="V"
VerticalAlignment="Center"
HorizontalAlignment="Right" />
</DockPanel>
<DockPanel Margin="0 3 0 0">
<Controls:NumericUpDown Value="{Binding R, ElementName=this}"
Maximum="255"
Width="70"
Margin="5 0 0 0"
DockPanel.Dock="Right" />
<TextBlock Text="R"
VerticalAlignment="Center"
HorizontalAlignment="Right" />
</DockPanel>
<DockPanel Margin="0 3 0 0">
<Controls:NumericUpDown Value="{Binding G, ElementName=this}"
Maximum="255"
Width="70"
Margin="5 0 0 0"
DockPanel.Dock="Right" />
<TextBlock Text="G"
VerticalAlignment="Center"
HorizontalAlignment="Right" />
</DockPanel>
<DockPanel Margin="0 3 0 0">
<Controls:NumericUpDown Value="{Binding B, ElementName=this}"
Maximum="255"
Width="70"
Margin="5 0 0 0"
DockPanel.Dock="Right" />
<TextBlock Text="B"
VerticalAlignment="Center"
HorizontalAlignment="Right" />
</DockPanel>
<DockPanel Margin="0 3 0 0">
<Controls:NumericUpDown Value="{Binding A, ElementName=this}"
Maximum="255"
Width="70"
Margin="5 0 0 0"
DockPanel.Dock="Right" />
<TextBlock Text="A"
VerticalAlignment="Center"
HorizontalAlignment="Right" />
</DockPanel>
</StackPanel>
<Border Margin="10 0 0 0"
DockPanel.Dock="Right">
<BrushEditor:Picker Orientation="Vertical"
Value="{Binding H, ElementName=this}"
Minimum="360"
Maximum="0"
Marker="{Binding ElementName=arrows}"
Width="20">
<Border Margin="0 -1">
<Border.Background>
<LinearGradientBrush EndPoint="0 1">
<GradientStop Offset="0"
Color="#F00" />
<GradientStop Offset="0.16"
Color="#F0F" />
<GradientStop Offset="0.33"
Color="#00F" />
<GradientStop Offset="0.5"
Color="#0FF" />
<GradientStop Offset="0.76"
Color="#0F0" />
<GradientStop Offset="0.85"
Color="#FF0" />
<GradientStop Offset="1"
Color="#F00" />
</LinearGradientBrush>
</Border.Background>
</Border>
<Grid x:Name="arrows"
IsHitTestVisible="False"
VerticalAlignment="Top"
Margin="-5">
<Path HorizontalAlignment="Left"
Data="M 0 0 L 5 5 L 0 10 Z"
Fill="Black" />
<Path HorizontalAlignment="Right"
Data="M 0 0 L -5 5 L 0 10 Z"
Fill="Black" />
</Grid>
</BrushEditor:Picker>
</Border>
<Border BorderBrush="Black"
BorderThickness="1">
<BrushEditor:Picker Value="{Binding S, ElementName=this}"
Marker="{Binding ElementName=point}"
ClipToBounds="True">
<BrushEditor:Picker Orientation="Vertical"
Value="{Binding V, ElementName=this}"
Minimum="100"
Maximum="0"
Marker="{Binding ElementName=point}">
<Rectangle>
<Rectangle.Fill>
<LinearGradientBrush EndPoint="1 0">
<GradientStop Offset="0"
Color="White" />
<GradientStop Offset="1"
Color="{Binding HueColor, ElementName=this}" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Rectangle>
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0 1">
<GradientStop Offset="0"
Color="#0000" />
<GradientStop Offset="1"
Color="#F000" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Grid x:Name="point"
VerticalAlignment="Top"
HorizontalAlignment="Left"
Width="12"
Height="12"
Margin="-6 -6 0 0">
<Ellipse Stroke="Black"
IsHitTestVisible="False" />
<Ellipse Stroke="White"
Margin="1"
IsHitTestVisible="False" />
</Grid>
</BrushEditor:Picker>
</BrushEditor:Picker>
</Border>
</DockPanel>
</UserControl>

184
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/ColorPicker.xaml.cs

@ -0,0 +1,184 @@ @@ -0,0 +1,184 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.ComponentModel;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
{
public partial class ColorPicker
{
public ColorPicker()
{
InitializeComponent();
}
public static readonly DependencyProperty ColorProperty =
DependencyProperty.Register("Color", typeof(Color), typeof(ColorPicker),
new FrameworkPropertyMetadata(new Color(), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
public Color Color {
get { return (Color)GetValue(ColorProperty); }
set { SetValue(ColorProperty, value); }
}
public static readonly DependencyProperty HProperty =
DependencyProperty.Register("H", typeof(int), typeof(ColorPicker));
public int H {
get { return (int)GetValue(HProperty); }
set { SetValue(HProperty, value); }
}
public static readonly DependencyProperty SProperty =
DependencyProperty.Register("S", typeof(int), typeof(ColorPicker));
public int S {
get { return (int)GetValue(SProperty); }
set { SetValue(SProperty, value); }
}
public static readonly DependencyProperty VProperty =
DependencyProperty.Register("V", typeof(int), typeof(ColorPicker));
public int V {
get { return (int)GetValue(VProperty); }
set { SetValue(VProperty, value); }
}
public static readonly DependencyProperty RProperty =
DependencyProperty.Register("R", typeof(byte), typeof(ColorPicker));
public byte R {
get { return (byte)GetValue(RProperty); }
set { SetValue(RProperty, value); }
}
public static readonly DependencyProperty GProperty =
DependencyProperty.Register("G", typeof(byte), typeof(ColorPicker));
public byte G {
get { return (byte)GetValue(GProperty); }
set { SetValue(GProperty, value); }
}
public static readonly DependencyProperty BProperty =
DependencyProperty.Register("B", typeof(byte), typeof(ColorPicker));
public byte B {
get { return (byte)GetValue(BProperty); }
set { SetValue(BProperty, value); }
}
public static readonly DependencyProperty AProperty =
DependencyProperty.Register("A", typeof(byte), typeof(ColorPicker));
public byte A {
get { return (byte)GetValue(AProperty); }
set { SetValue(AProperty, value); }
}
public static readonly DependencyProperty HexProperty =
DependencyProperty.Register("Hex", typeof(string), typeof(ColorPicker));
public string Hex {
get { return (string)GetValue(HexProperty); }
set { SetValue(HexProperty, value); }
}
public static readonly DependencyProperty HueColorProperty =
DependencyProperty.Register("HueColor", typeof(Color), typeof(ColorPicker));
public Color HueColor {
get { return (Color)GetValue(HueColorProperty); }
set { SetValue(HueColorProperty, value); }
}
bool updating;
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);
if (updating) return;
updating = true;
if (e.Property == ColorProperty) {
UpdateSource(ColorSource.Hsv);
UpdateRest(ColorSource.Hsv);
}
else if (e.Property == HProperty || e.Property == SProperty || e.Property == VProperty) {
var c = ColorHelper.ColorFromHsv(H, S / 100.0, V / 100.0);
c.A = A;
Color = c;
UpdateRest(ColorSource.Hsv);
}
else if (e.Property == RProperty || e.Property == GProperty || e.Property == BProperty || e.Property == AProperty) {
Color = Color.FromArgb(A, R, G, B);
UpdateRest(ColorSource.Rgba);
}
else if (e.Property == HexProperty) {
Color = ColorHelper.ColorFromString(Hex);
UpdateRest(ColorSource.Hex);
}
updating = false;
}
void UpdateRest(ColorSource source)
{
HueColor = ColorHelper.ColorFromHsv(H, 1, 1);
UpdateSource((ColorSource)(((int)source + 1) % 3));
UpdateSource((ColorSource)(((int)source + 2) % 3));
}
void UpdateSource(ColorSource source)
{
if (source == ColorSource.Hsv) {
double h, s, v;
ColorHelper.HsvFromColor(Color, out h, out s, out v);
H = (int)h;
S = (int)(s * 100);
V = (int)(v * 100);
}
else if (source == ColorSource.Rgba) {
R = Color.R;
G = Color.G;
B = Color.B;
A = Color.A;
}
else {
Hex = ColorHelper.StringFromColor(Color);
}
}
enum ColorSource
{
Hsv, Rgba, Hex
}
}
class HexTextBox : TextBox
{
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.Key == Key.Enter) {
var b = BindingOperations.GetBindingExpressionBase(this, TextProperty);
if (b != null) {
b.UpdateTarget();
}
SelectAll();
}
}
}
}

12
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientBrushEditor.xaml

@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
<UserControl x:Class="ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor.GradientBrushEditor"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:BrushEditor="clr-namespace:ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor"
>
<DockPanel>
<BrushEditor:GradientSlider x:Name="slider"
DockPanel.Dock="Top"
Brush="{Binding Brush}" />
<BrushEditor:SolidBrushEditor Color="{Binding SelectedStop.Color, ElementName=slider}" />
</DockPanel>
</UserControl>

24
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientBrushEditor.xaml.cs

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
{
public partial class GradientBrushEditor
{
public GradientBrushEditor()
{
InitializeComponent();
}
}
}

109
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientSlider.xaml

@ -0,0 +1,109 @@ @@ -0,0 +1,109 @@
<UserControl x:Class="ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor.GradientSlider"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:BrushEditor="clr-namespace:ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor"
x:Name="this"
>
<UserControl.Resources>
<DataTemplate x:Key="GradientStopTemplate">
<Grid>
<Path x:Name="thumb"
Data="m 6 0 l 6 5 v 12 h -12 v -12 z"
Stroke="Black"
Fill="Orange" />
<Border Margin="2 7 2 2"
BorderBrush="Black"
BorderThickness="1">
<Border BorderBrush="White"
BorderThickness="1">
<Border.Background>
<SolidColorBrush Color="red" />
</Border.Background>
</Border>
</Border>
</Grid>
<DataTemplate.Triggers>
<Trigger Property="Selector.IsSelected"
Value="True">
<Setter TargetName="thumb"
Property="Fill"
Value="Gold" />
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<Style TargetType="{x:Type BrushEditor:GradientThumb}">
<Setter Property="BrushEditor:NormalizedPanel.X"
Value="{Binding Offset}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type BrushEditor:GradientThumb}">
<StackPanel>
<Path x:Name="thumb"
Data="m 0 0 l 6 -5 l 6 5"
Stroke="Black"
Fill="White" />
<Border BorderBrush="Black"
BorderThickness="1"
Width="12"
Height="12">
<Border BorderBrush="White"
BorderThickness="1">
<Border.Background>
<SolidColorBrush Color="{Binding Color}" />
</Border.Background>
</Border>
</Border>
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="Selector.IsSelected"
Value="True">
<Setter TargetName="thumb"
Property="Fill"
Value="Orange" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type BrushEditor:Dragger}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type BrushEditor:Dragger}">
<Border BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid>
<BrushEditor:Dragger x:Name="strip"
BorderBrush="Black"
BorderThickness="1"
VerticalAlignment="Top"
Height="20"
Margin="6 0 6 0">
<Control.Background>
<LinearGradientBrush EndPoint="1 0"
GradientStops="{Binding Brush.GradientStops, ElementName=this}" />
</Control.Background>
</BrushEditor:Dragger>
<BrushEditor:GradientItemsControl x:Name="itemsControl"
ItemsSource="{Binding GradientStops, ElementName=this}"
Margin="6 28 6 10">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<BrushEditor:NormalizedPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</BrushEditor:GradientItemsControl>
</Grid>
</UserControl>

159
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientSlider.xaml.cs

@ -0,0 +1,159 @@ @@ -0,0 +1,159 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls.Primitives;
using System.ComponentModel;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
{
public partial class GradientSlider
{
public GradientSlider()
{
InitializeComponent();
BindingOperations.SetBinding(this, SelectedStopProperty, new Binding("SelectedItem") {
Source = itemsControl,
Mode = BindingMode.TwoWay
});
strip.DragStarted += new DragStartedEventHandler(strip_DragStarted);
strip.DragDelta += new DragDeltaEventHandler(strip_DragDelta);
}
static GradientSlider()
{
EventManager.RegisterClassHandler(typeof(GradientSlider),
Thumb.DragDeltaEvent, new DragDeltaEventHandler(ClassDragDelta));
}
GradientStop newStop;
double startOffset;
public static readonly DependencyProperty BrushProperty =
DependencyProperty.Register("Brush", typeof(GradientBrush), typeof(GradientSlider));
public GradientBrush Brush {
get { return (GradientBrush)GetValue(BrushProperty); }
set { SetValue(BrushProperty, value); }
}
public static readonly DependencyProperty SelectedStopProperty =
DependencyProperty.Register("SelectedStop", typeof(GradientStop), typeof(GradientSlider));
public GradientStop SelectedStop {
get { return (GradientStop)GetValue(SelectedStopProperty); }
set { SetValue(SelectedStopProperty, value); }
}
public static readonly DependencyProperty GradientStopsProperty =
DependencyProperty.Register("GradientStops", typeof(BindingList<GradientStop>), typeof(GradientSlider));
public BindingList<GradientStop> GradientStops {
get { return (BindingList<GradientStop>)GetValue(GradientStopsProperty); }
set { SetValue(GradientStopsProperty, value); }
}
public static Color GetColorAtOffset(IList<GradientStop> stops, double offset)
{
GradientStop s1 = stops[0], s2 = stops.Last();
foreach (var item in stops) {
if (item.Offset < offset && item.Offset > s1.Offset) s1 = item;
if (item.Offset > offset && item.Offset < s2.Offset) s2 = item;
}
return Color.FromArgb(
(byte)((s1.Color.A + s2.Color.A) / 2),
(byte)((s1.Color.R + s2.Color.R) / 2),
(byte)((s1.Color.G + s2.Color.G) / 2),
(byte)((s1.Color.B + s2.Color.B) / 2)
);
}
static void ClassDragDelta(object sender, DragDeltaEventArgs e)
{
(sender as GradientSlider).thumb_DragDelta(sender, e);
}
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);
if (e.Property == BrushProperty) {
if (Brush != null) {
GradientStops = new BindingList<GradientStop>(Brush.GradientStops);
SelectedStop = GradientStops.FirstOrDefault();
}
else {
GradientStops = null;
}
}
}
void strip_DragStarted(object sender, DragStartedEventArgs e)
{
startOffset = e.HorizontalOffset / strip.ActualWidth;
newStop = new GradientStop(GetColorAtOffset(GradientStops, startOffset), startOffset);
GradientStops.Add(newStop);
SelectedStop = newStop;
e.Handled = true;
}
void strip_DragDelta(object sender, DragDeltaEventArgs e)
{
MoveStop(newStop, startOffset, e);
e.Handled = true;
}
void thumb_DragDelta(object sender, DragDeltaEventArgs e)
{
var stop = (e.OriginalSource as GradientThumb).GradientStop;
MoveStop(stop, stop.Offset, e);
}
void MoveStop(GradientStop stop, double oldOffset, DragDeltaEventArgs e)
{
if (e.VerticalChange > 50 && GradientStops.Count > 2) {
GradientStops.Remove(stop);
SelectedStop = GradientStops.FirstOrDefault();
return;
}
stop.Offset = (oldOffset + e.HorizontalChange / strip.ActualWidth).Coerce(0, 1);
}
}
public class GradientItemsControl : Selector
{
protected override DependencyObject GetContainerForItemOverride()
{
return new GradientThumb();
}
}
public class GradientThumb : Thumb
{
public GradientStop GradientStop {
get { return DataContext as GradientStop; }
}
protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
{
base.OnPreviewMouseDown(e);
var itemsControl = ItemsControl.ItemsControlFromItemContainer(this) as GradientItemsControl;
itemsControl.SelectedItem = GradientStop;
}
}
public class Dragger : Thumb
{
}
}

68
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/NormalizedPanel.cs

@ -0,0 +1,68 @@ @@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Media;
using System.Windows.Controls;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
{
public class NormalizedPanel : Panel
{
public static double GetX(DependencyObject obj)
{
return (double)obj.GetValue(XProperty);
}
public static void SetX(DependencyObject obj, double value)
{
obj.SetValue(XProperty, value);
}
public static readonly DependencyProperty XProperty =
DependencyProperty.RegisterAttached("X", typeof(double), typeof(NormalizedPanel),
new PropertyMetadata(OnPositioningChanged));
public static double GetY(DependencyObject obj)
{
return (double)obj.GetValue(YProperty);
}
public static void SetY(DependencyObject obj, double value)
{
obj.SetValue(YProperty, value);
}
public static readonly DependencyProperty YProperty =
DependencyProperty.RegisterAttached("Y", typeof(double), typeof(NormalizedPanel),
new PropertyMetadata(OnPositioningChanged));
static void OnPositioningChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
NormalizedPanel parent = VisualTreeHelper.GetParent(d) as NormalizedPanel;
if (parent != null) {
parent.InvalidateArrange();
}
}
protected override Size MeasureOverride(Size availableSize)
{
foreach (UIElement item in Children) {
item.Measure(availableSize);
}
return new Size();
}
protected override Size ArrangeOverride(Size finalSize)
{
foreach (UIElement item in Children) {
Rect r = new Rect(item.DesiredSize);
r.X = GetX(item) * finalSize.Width - item.DesiredSize.Width / 2;
r.Y = GetY(item) * finalSize.Height - item.DesiredSize.Height / 2;
item.Arrange(r);
}
return finalSize;
}
}
}

137
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/Picker.cs

@ -0,0 +1,137 @@ @@ -0,0 +1,137 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls.Primitives;
using System.Windows;
using System.Windows.Input;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Data;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
{
public class Picker : Grid
{
public Picker()
{
SizeChanged += delegate { UpdateValueOffset(); };
}
public static readonly DependencyProperty MarkerProperty =
DependencyProperty.Register("Marker", typeof(UIElement), typeof(Picker));
public UIElement Marker {
get { return (UIElement)GetValue(MarkerProperty); }
set { SetValue(MarkerProperty, value); }
}
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value", typeof(double), typeof(Picker),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
public double Value {
get { return (double)GetValue(ValueProperty); }
set { SetValue(ValueProperty, value); }
}
public static readonly DependencyProperty ValueOffsetProperty =
DependencyProperty.Register("ValueOffset", typeof(double), typeof(Picker));
public double ValueOffset {
get { return (double)GetValue(ValueOffsetProperty); }
set { SetValue(ValueOffsetProperty, value); }
}
public static readonly DependencyProperty OrientationProperty =
DependencyProperty.Register("Orientation", typeof(Orientation), typeof(Picker));
public Orientation Orientation {
get { return (Orientation)GetValue(OrientationProperty); }
set { SetValue(OrientationProperty, value); }
}
public static readonly DependencyProperty MinimumProperty =
DependencyProperty.Register("Minimum", typeof(double), typeof(Picker));
public double Minimum {
get { return (double)GetValue(MinimumProperty); }
set { SetValue(MinimumProperty, value); }
}
public static readonly DependencyProperty MaximumProperty =
DependencyProperty.Register("Maximum", typeof(double), typeof(Picker),
new FrameworkPropertyMetadata(100.0));
public double Maximum {
get { return (double)GetValue(MaximumProperty); }
set { SetValue(MaximumProperty, value); }
}
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);
if (e.Property == MarkerProperty) {
TranslateTransform t = Marker.RenderTransform as TranslateTransform;
if (t == null) {
t = new TranslateTransform();
Marker.RenderTransform = t;
}
var property = Orientation == Orientation.Horizontal ? TranslateTransform.XProperty : TranslateTransform.YProperty;
BindingOperations.SetBinding(t, property, new Binding("ValueOffset") {
Source = this
});
}
else if (e.Property == ValueProperty) {
UpdateValueOffset();
}
}
bool isMouseDown;
protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
{
isMouseDown = true;
CaptureMouse();
UpdateValue();
}
protected override void OnPreviewMouseMove(MouseEventArgs e)
{
if (isMouseDown) {
UpdateValue();
}
}
protected override void OnPreviewMouseUp(MouseButtonEventArgs e)
{
isMouseDown = false;
ReleaseMouseCapture();
}
void UpdateValue()
{
Point p = Mouse.GetPosition(this);
double length = 0, pos = 0;
if (Orientation == Orientation.Horizontal) {
length = ActualWidth;
pos = p.X;
}
else {
length = ActualHeight;
pos = p.Y;
}
pos = Math.Max(0, Math.Min(length, pos));
Value = Minimum + (Maximum - Minimum) * pos / length;
}
void UpdateValueOffset()
{
var length = Orientation == Orientation.Horizontal ? ActualWidth : ActualHeight;
ValueOffset = length * (Value - Minimum) / (Maximum - Minimum);
}
}
}

19
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/SolidBrushEditor.xaml

@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
<UserControl
x:Class="ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor.SolidBrushEditor"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:BrushEditor="clr-namespace:ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor"
x:Name="this"
Height="284"
>
<TabControl>
<TabItem Header="Color Picker">
<BrushEditor:ColorPicker Color="{Binding Color, ElementName=this}" />
</TabItem>
<TabItem Header="Color List">
<ListBox ItemsSource="{Binding AvailableColors}"
SelectedValue="{Binding Color, ElementName=this}"
SelectedValuePath="Brush.Color" />
</TabItem>
</TabControl>
</UserControl>

33
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/SolidBrushEditor.xaml.cs

@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
{
public partial class SolidBrushEditor
{
public SolidBrushEditor()
{
InitializeComponent();
}
public static readonly DependencyProperty ColorProperty =
DependencyProperty.Register("Color", typeof(Color), typeof(SolidBrushEditor),
new FrameworkPropertyMetadata(new Color(), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
public Color Color {
get { return (Color)GetValue(ColorProperty); }
set { SetValue(ColorProperty, value); }
}
}
}

9
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/EventEditor.xaml

@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
<TextBox
x:Class="ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.EventEditor"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
BorderThickness="0"
Background="{x:Null}"
Text="{Binding Value, UpdateSourceTrigger=Explicit}"
>
</TextBox>

67
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/EventEditor.xaml.cs

@ -0,0 +1,67 @@ @@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.PropertyGrid;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
{
[TypeEditor(typeof(MulticastDelegate))]
public partial class EventEditor
{
public EventEditor()
{
InitializeComponent();
}
public PropertyNode PropertyNode {
get { return DataContext as PropertyNode; }
}
public void Commit()
{
PropertyNode.Value = Text;
IEventHandlerService s = PropertyNode.Services.GetService<IEventHandlerService>();
if (s != null) {
s.CreateEventHandler(PropertyNode.FirstProperty);
}
}
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.Key == Key.Enter) {
Commit();
}
else if (e.Key == Key.Escape) {
BindingOperations.GetBindingExpression(this, TextProperty).UpdateTarget();
}
}
protected override void OnMouseDoubleClick(MouseButtonEventArgs e)
{
Commit();
}
protected override void OnPreviewLostKeyboardFocus(KeyboardFocusChangedEventArgs e)
{
if (PropertyNode != null && PropertyNode.Value != Text) {
if (string.IsNullOrEmpty(Text)) {
PropertyNode.Reset();
}
else {
Commit();
}
}
}
}
}

10
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/NumberEditor.xaml

@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
<Controls:NumericUpDown
x:Class="ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.NumberEditor"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls"
BorderThickness="0"
Background="{x:Null}"
Value="{Binding Value}"
>
</Controls:NumericUpDown>

108
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/NumberEditor.xaml.cs

@ -0,0 +1,108 @@ @@ -0,0 +1,108 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.PropertyGrid;
using System.Reflection;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
{
[TypeEditor(typeof(byte))]
[TypeEditor(typeof(sbyte))]
[TypeEditor(typeof(decimal))]
[TypeEditor(typeof(double))]
[TypeEditor(typeof(float))]
[TypeEditor(typeof(int))]
[TypeEditor(typeof(uint))]
[TypeEditor(typeof(long))]
[TypeEditor(typeof(ulong))]
[TypeEditor(typeof(short))]
[TypeEditor(typeof(ushort))]
public partial class NumberEditor
{
static NumberEditor()
{
minimums[typeof(byte)] = byte.MinValue;
minimums[typeof(sbyte)] = sbyte.MinValue;
minimums[typeof(decimal)] = (double)decimal.MinValue;
minimums[typeof(double)] = double.MinValue;
minimums[typeof(float)] = float.MinValue;
minimums[typeof(int)] = int.MinValue;
minimums[typeof(uint)] = uint.MinValue;
minimums[typeof(long)] = long.MinValue;
minimums[typeof(ulong)] = ulong.MinValue;
minimums[typeof(short)] = short.MinValue;
minimums[typeof(ushort)] = ushort.MinValue;
maximums[typeof(byte)] = byte.MaxValue;
maximums[typeof(sbyte)] = sbyte.MaxValue;
maximums[typeof(decimal)] = (double)decimal.MaxValue;
maximums[typeof(double)] = double.MaxValue;
maximums[typeof(float)] = float.MaxValue;
maximums[typeof(int)] = int.MaxValue;
maximums[typeof(uint)] = uint.MaxValue;
maximums[typeof(long)] = long.MaxValue;
maximums[typeof(ulong)] = ulong.MaxValue;
maximums[typeof(short)] = short.MaxValue;
maximums[typeof(ushort)] = ushort.MaxValue;
}
public NumberEditor()
{
InitializeComponent();
DataContextChanged += new DependencyPropertyChangedEventHandler(NumberEditor_DataContextChanged);
}
static Dictionary<Type, double> minimums = new Dictionary<Type, double>();
static Dictionary<Type, double> maximums = new Dictionary<Type, double>();
public PropertyNode PropertyNode {
get { return DataContext as PropertyNode; }
}
void NumberEditor_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if (PropertyNode == null) return;
var type = PropertyNode.FirstProperty.ReturnType;
var range = Metadata.GetValueRange(PropertyNode.FirstProperty);
if (range == null) {
range = new NumberRange() { Min = 0, Max = double.MaxValue };
}
if (range.Min == double.MinValue) {
Minimum = minimums[type];
}
else {
Minimum = range.Min;
}
if (range.Max == double.MaxValue) {
Maximum = maximums[type];
}
else {
Maximum = range.Max;
}
if (Minimum == 0 && Maximum == 1) {
DecimalPlaces = 2;
SmallChange = 0.01;
LargeChange = 0.1;
}
else {
ClearValue(DecimalPlacesProperty);
ClearValue(SmallChangeProperty);
ClearValue(LargeChangeProperty);
}
}
}
}

25
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyContextMenu.xaml

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
<ContextMenu x:Class="ICSharpCode.WpfDesign.Designer.PropertyGrid.PropertyContextMenu"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<MenuItem Header="Reset"
Click="Click_Reset" />
<MenuItem Header="TODO:"
IsEnabled="False"/>
<MenuItem Header="Binding"
Click="Click_Binding" />
<MenuItem x:Name="uxStaticResource"
Header="Static Resource">
<MenuItem Header="Resource1" />
<MenuItem Header="Resource2" />
<MenuItem Header="Resource3" />
</MenuItem>
<MenuItem Header="Custom Expression..."
Click="Click_CustomExpression"/>
<MenuItem Header="Convert To Local Value"
Click="Click_ConvertToLocalValue"/>
<MenuItem Header="Save As Resource..."
Click="Click_SaveAsResource"/>
</ContextMenu>

51
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyContextMenu.xaml.cs

@ -0,0 +1,51 @@ @@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.PropertyGrid;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid
{
public partial class PropertyContextMenu
{
public PropertyContextMenu()
{
InitializeComponent();
}
public PropertyNode PropertyNode {
get { return DataContext as PropertyNode; }
}
void Click_Reset(object sender, RoutedEventArgs e)
{
PropertyNode.Reset();
}
void Click_Binding(object sender, RoutedEventArgs e)
{
PropertyNode.CreateBinding();
}
void Click_CustomExpression(object sender, RoutedEventArgs e)
{
}
void Click_ConvertToLocalValue(object sender, RoutedEventArgs e)
{
}
void Click_SaveAsResource(object sender, RoutedEventArgs e)
{
}
}
}

208
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs

@ -0,0 +1,208 @@ @@ -0,0 +1,208 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Collections.ObjectModel;
using System.Threading;
using System.Globalization;
using ICSharpCode.WpfDesign.PropertyGrid;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid
{
public enum PropertyGridTab
{
Properties,
Events
}
public class PropertyGrid : INotifyPropertyChanged
{
static PropertyGrid()
{
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
new BasicMetadata();
}
public PropertyGrid()
{
Categories = new ObservableCollection<Category>();
Events = new ObservableCollection<PropertyNode>();
}
static SortedDictionary<string, Category> allCategories =
new SortedDictionary<string, Category>(CategoryNameComparer.Instance);
class CategoryNameComparer : IComparer<string>
{
public static CategoryNameComparer Instance = new CategoryNameComparer();
public int Compare(string x, string y)
{
int i1 = Array.IndexOf(Metadata.CategoryOrder, x);
if (i1 == -1) i1 = int.MaxValue;
int i2 = Array.IndexOf(Metadata.CategoryOrder, y);
if (i2 == -1) i2 = int.MaxValue;
if (i1 == i2) return x.CompareTo(y);
return i1.CompareTo(i2);
}
}
public ObservableCollection<Category> Categories { get; private set; }
public ObservableCollection<PropertyNode> Events { get; private set; }
PropertyGridTab currentTab;
public PropertyGridTab CurrentTab {
get {
return currentTab;
}
set {
currentTab = value;
RaisePropertyChanged("CurrentTab");
}
}
string filter;
public string Filter {
get {
return filter;
}
set {
filter = value;
Reload();
RaisePropertyChanged("Filter");
}
}
DesignItem singleItem;
public DesignItem SingleItem {
get {
return singleItem;
}
private set {
singleItem = value;
RaisePropertyChanged("SingleItem");
}
}
IEnumerable<DesignItem> selectedItems;
public IEnumerable<DesignItem> SelectedItems {
get {
return selectedItems;
}
set {
selectedItems = value;
Reload();
RaisePropertyChanged("SelectedItems");
}
}
public void ClearFilter()
{
Filter = null;
}
void Reload()
{
Categories.Clear();
Events.Clear();
SingleItem = null;
foreach (var cat in allCategories.Values) {
cat.Properties.Clear();
cat.MoreProperties.Clear();
}
if (SelectedItems == null || SelectedItems.Count() == 0) return;
List<MemberDescriptor> list = new List<MemberDescriptor>();
if (SelectedItems.Count() == 1) {
SingleItem = SelectedItems.First();
foreach (MemberDescriptor d in TypeHelper.GetAvailableProperties(SingleItem.ComponentType)) {
list.Add(d);
}
foreach (MemberDescriptor d in TypeHelper.GetAvailableEvents(SingleItem.ComponentType)) {
list.Add(d);
}
}
else {
foreach (MemberDescriptor d in TypeHelper.GetCommonAvailableProperties(SelectedItems.Select(t => t.ComponentType))) {
list.Add(d);
}
}
var nodeList = list
.Where(d => PassesFilter(d.Name))
.OrderBy(d => d.Name)
.Select(d => new PropertyNode(SelectedItems.Select(t => t.Properties[d.Name]).ToArray()));
foreach (var node in nodeList) {
if (node.IsEvent) {
Events.Add(node);
}
else {
string catName = Metadata.GetCategory(node.FirstProperty) ?? BasicMetadata.Category_Misc;
Category cat;
if (!allCategories.TryGetValue(catName, out cat)) {
cat = new Category(catName);
allCategories[catName] = cat;
}
if (Metadata.IsAdvanced(node.FirstProperty)) {
cat.MoreProperties.Add(node);
}
else {
cat.Properties.Add(node);
}
}
}
foreach (var cat in allCategories.Values) {
if (cat.Properties.Count > 0 || cat.MoreProperties.Count > 0) {
if (string.IsNullOrEmpty(Filter)) {
if (cat.ShowMoreByFilter) {
cat.ShowMore = false;
cat.ShowMoreByFilter = false;
}
}
else {
cat.ShowMore = true;
cat.ShowMoreByFilter = true;
}
Categories.Add(cat);
}
}
}
bool PassesFilter(string name)
{
if (string.IsNullOrEmpty(Filter)) return true;
for (int i = 0; i < name.Length; i++) {
if (i == 0 || char.IsUpper(name[i])) {
if (string.Compare(name, i, Filter, 0, Filter.Length, true) == 0) {
return true;
}
}
}
return false;
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
void RaisePropertyChanged(string name)
{
if (PropertyChanged != null) {
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
#endregion
}
}

344
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.xaml

@ -0,0 +1,344 @@ @@ -0,0 +1,344 @@
<UserControl x:Class="ICSharpCode.WpfDesign.Designer.PropertyGrid.PropertyGridView"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Converters="clr-namespace:ICSharpCode.WpfDesign.Designer.Converters"
xmlns:PropertyGrid="clr-namespace:ICSharpCode.WpfDesign.Designer.PropertyGrid"
xmlns:PropertyGridBase="clr-namespace:ICSharpCode.WpfDesign.PropertyGrid;assembly=ICSharpCode.WpfDesign"
xmlns:Controls="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls"
Background="{x:Static SystemColors.ControlLightBrush}"
SnapsToDevicePixels="True"
>
<UserControl.Resources>
<Style x:Key="ExpandButtonStyle"
TargetType="{x:Type ToggleButton}">
<Setter Property="Focusable"
Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border Background="Transparent">
<Border Width="9"
Height="9"
SnapsToDevicePixels="true"
BorderBrush="#FF7898B5"
BorderThickness="1"
CornerRadius="1">
<Border.Background>
<LinearGradientBrush EndPoint="1,1"
StartPoint="0,0">
<GradientStop Color="White"
Offset=".2" />
<GradientStop Color="#FFC0B7A6"
Offset="1" />
</LinearGradientBrush>
</Border.Background>
<Path Margin="1,1,1,1"
x:Name="ExpandPath"
Fill="Black"
Data="M 0 2 L 0 3 L 2 3 L 2 5 L 3 5 L 3 3 L 5 3 L 5 2 L 3 2 L 3 0 L 2 0 L 2 2 Z" />
</Border>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked"
Value="True">
<Setter Property="Data"
TargetName="ExpandPath"
Value="M 0 2 L 0 3 L 5 3 L 5 2 Z" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="MoreButtonStyle"
TargetType="{x:Type ToggleButton}">
<Setter Property="Focusable"
Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border Background="#F9F9F4"
BorderThickness="1 0 1 0"
BorderBrush="{x:Static SystemColors.ControlBrush}">
<!--<TextBlock Text="More..."
VerticalAlignment="Center"
HorizontalAlignment="Left"
Margin="18 0 0 0"
Foreground="{x:Static SystemColors.ControlDarkBrush}" />-->
<Path x:Name="arrow"
Data="M 0 0 L 5 5 L 10 0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Fill="{x:Static SystemColors.ControlDarkBrush}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked"
Value="True">
<Setter TargetName="arrow"
Property="Data"
Value="M 0 5 L 5 0 L 10 5" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="CategoryToggleStyle"
TargetType="{x:Type ToggleButton}">
<Setter Property="Focusable"
Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border BorderThickness="0 1 0 0"
BorderBrush="#ECE9D8">
<StackPanel Orientation="Horizontal"
Background="{x:Static SystemColors.ControlLightBrush}">
<ToggleButton Style="{StaticResource ExpandButtonStyle}"
IsChecked="{Binding IsExpanded}"
VerticalAlignment="Center"
Margin="3 0 7 0" />
<TextBlock Text="{Binding Name}"
VerticalAlignment="Center"
FontWeight="Bold"
Foreground="{x:Static SystemColors.ControlDarkBrush}" />
</StackPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type PropertyGrid:PropertyTreeView}">
<Setter Property="Background"
Value="White" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type PropertyGrid:PropertyTreeView}">
<Border BorderThickness="0 1 1 0"
BorderBrush="{x:Static SystemColors.ControlBrush}"
Background="{TemplateBinding Background}">
<!--<ScrollViewer HorizontalScrollBarVisibility="Disabled">-->
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ItemsPresenter />
<Thumb x:Name="PART_Thumb"
HorizontalAlignment="Left"
Width="4"
Margin="-2 0 0 0"
Cursor="SizeWE">
<Thumb.RenderTransform>
<TranslateTransform X="{Binding FirstColumnWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type PropertyGrid:PropertyGridView}}}" />
</Thumb.RenderTransform>
<Thumb.Template>
<ControlTemplate>
<Border Background="Transparent" />
</ControlTemplate>
</Thumb.Template>
</Thumb>
</Grid>
<!--</ScrollViewer>-->
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type PropertyGrid:PropertyTreeViewItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type PropertyGrid:PropertyTreeViewItem}">
<DockPanel>
<Border MinHeight="20"
BorderThickness="1 0 0 1"
BorderBrush="{x:Static SystemColors.ControlBrush}"
Background="{TemplateBinding Background}"
DockPanel.Dock="Top">
<DockPanel>
<DockPanel Width="{Binding FirstColumnWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type PropertyGrid:PropertyGridView}}}"
DockPanel.Dock="Left">
<ToggleButton x:Name="expandButton"
DockPanel.Dock="Left"
Margin="{TemplateBinding Level, Converter={x:Static Converters:LevelConverter.Instance}}"
Style="{StaticResource ExpandButtonStyle}"
IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" />
<TextBlock Text="{Binding Name}"
TextTrimming="CharacterEllipsis"
VerticalAlignment="Center"
Margin="7 0 0 0"
ToolTip="{Binding Description}"
FontWeight="{Binding FontWeight}"
/>
</DockPanel>
<Border BorderThickness="1 0 0 0"
BorderBrush="{x:Static SystemColors.ControlBrush}">
<ContentPresenter Content="{Binding Editor}"
VerticalAlignment="Center"
Margin="3 0" />
</Border>
</DockPanel>
</Border>
<ItemsPresenter x:Name="itemsHost" />
</DockPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsExpanded"
Value="False">
<Setter TargetName="itemsHost"
Property="Visibility"
Value="Collapsed" />
</Trigger>
<Trigger Property="HasItems"
Value="False">
<Setter TargetName="expandButton"
Property="Visibility"
Value="Hidden" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="CategoryExpanderStyle"
TargetType="Expander">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Expander">
<DockPanel>
<ToggleButton Height="17"
IsChecked="{Binding IsExpanded}"
DockPanel.Dock="Top"
Style="{StaticResource CategoryToggleStyle}" />
<ContentPresenter x:Name="ExpandSite"
Visibility="Collapsed" />
</DockPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsExpanded"
Value="True">
<Setter Property="Visibility"
Value="Visible"
TargetName="ExpandSite" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="MoreExpanderStyle"
TargetType="Expander">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Expander">
<DockPanel>
<ToggleButton IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Style="{StaticResource MoreButtonStyle}"
DockPanel.Dock="Top"
Height="12" />
<ContentPresenter x:Name="ExpandSite"
Visibility="Collapsed" />
</DockPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsExpanded"
Value="True">
<Setter Property="Visibility"
Value="Visible"
TargetName="ExpandSite" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<DataTemplate DataType="{x:Type PropertyGrid:Category}">
<Expander Header="{Binding Name}"
Style="{StaticResource CategoryExpanderStyle}"
IsExpanded="{Binding IsExpanded}">
<StackPanel>
<PropertyGrid:PropertyTreeView ItemsSource="{Binding Properties}" />
<Expander Visibility="{Binding MoreProperties, Converter={x:Static Converters:CollapsedWhenEmptyCollection.Instance}}"
Style="{StaticResource MoreExpanderStyle}"
IsExpanded="{Binding ShowMore}">
<PropertyGrid:PropertyTreeView ItemsSource="{Binding MoreProperties}"
Background="#F9F9F4" />
</Expander>
</StackPanel>
</Expander>
</DataTemplate>
<HierarchicalDataTemplate DataType="{x:Type PropertyGridBase:PropertyNode}"
ItemsSource="{Binding Children}" />
<!--<DataTemplate DataType="{x:Type FontFamily}">
<TextBlock Text="{Binding}"
FontFamily="{Binding}"
FontSize="16"/>
</DataTemplate>-->
</UserControl.Resources>
<DockPanel>
<Grid DockPanel.Dock="Top"
Height="78">
<TextBlock Text="Name:"
Margin="6,30.275,0,33.948"
HorizontalAlignment="Left"
Width="32.033" />
<TextBlock Text="Type:"
VerticalAlignment="Top"
Margin="6.424,7.998,0,0"
Height="13.277" />
<TextBlock Text="Filter:"
HorizontalAlignment="Left"
Margin="6,53.553,0,0"
VerticalAlignment="Top" />
<Controls:EnterTextBox x:Name="NameTextBox"
x:FieldModifier="public"
Text="{Binding SingleItem.Name}"
IsEnabled="{Binding SingleItem, Converter={x:Static Converters:FalseWhenNull.Instance}}"
Margin="44.033,27.275,6,0"
Height="19.277"
VerticalAlignment="Top" />
<TextBlock Text="{Binding SingleItem.ComponentType.Name}"
ToolTip="{Binding SingleItem.ComponentType}"
Margin="44.033,7.998,6,0"
Height="13.277"
VerticalAlignment="Top" />
<Controls:EnterTextBox Text="{Binding Filter, UpdateSourceTrigger=PropertyChanged}"
Margin="44.033,50.553,52,0"
VerticalAlignment="Top"
Height="19.277" />
<Button x:Name="clearButton"
Content="Clear"
Click="clearButton_Click"
HorizontalAlignment="Right"
VerticalAlignment="Top"
Margin="0,49.552,6,0"
Height="21.277"
Width="40" />
</Grid>
<TabControl SelectedIndex="{Binding CurrentTab, Converter={x:Static Converters:IntFromEnumConverter.Instance}}">
<TabItem Header="Properties">
<ScrollViewer HorizontalScrollBarVisibility="Disabled">
<ItemsControl ItemsSource="{Binding Categories}" />
</ScrollViewer>
</TabItem>
<TabItem Header="Events">
<PropertyGrid:PropertyTreeView ItemsSource="{Binding Events}" />
</TabItem>
</TabControl>
</DockPanel>
</UserControl>

56
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.xaml.cs

@ -0,0 +1,56 @@ @@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls.Primitives;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid
{
public partial class PropertyGridView
{
public PropertyGridView()
{
PropertyGrid = new PropertyGrid();
DataContext = PropertyGrid;
InitializeComponent();
AddHandler(Thumb.DragDeltaEvent, new DragDeltaEventHandler(dragDeltaHandler));
}
static PropertyContextMenu propertyContextMenu = new PropertyContextMenu();
public PropertyGrid PropertyGrid { get; private set; }
public static readonly DependencyProperty FirstColumnWidthProperty =
DependencyProperty.Register("FirstColumnWidth", typeof(double), typeof(PropertyGridView),
new PropertyMetadata(120.0));
public double FirstColumnWidth {
get { return (double)GetValue(FirstColumnWidthProperty); }
set { SetValue(FirstColumnWidthProperty, value); }
}
void clearButton_Click(object sender, RoutedEventArgs e)
{
PropertyGrid.ClearFilter();
}
void dragDeltaHandler(object sender, DragDeltaEventArgs e)
{
Thumb thumb = e.OriginalSource as Thumb;
if (thumb != null && thumb.Name == "PART_Thumb") {
FirstColumnWidth = Math.Max(0, FirstColumnWidth + e.HorizontalChange);
}
}
}
}

101
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyTreeView.cs

@ -0,0 +1,101 @@ @@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows;
using System.Windows.Input;
using System.Windows.Controls.Primitives;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid
{
public class PropertyTreeView : TreeView
{
//static Dictionary<object, PropertyTreeViewItem> containersCache = new Dictionary<object, PropertyTreeViewItem>();
protected override DependencyObject GetContainerForItemOverride()
{
//return new Decorator();
return new PropertyTreeViewItem();
}
protected override bool IsItemItsOwnContainerOverride(object item)
{
return item is PropertyTreeViewItem;
}
//protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
//{
// PrepareContainer(element, item);
//}
//internal void PrepareContainer(DependencyObject element, object item)
//{
// PropertyTreeViewItem container;
// if (!containersCache.TryGetValue(item, out container))
// {
// container = new PropertyTreeViewItem();
// containersCache[item] = container;
// }
// base.PrepareContainerForItemOverride(container, item);
// (element as Decorator).Child = container;
//}
}
public class PropertyTreeViewItem : TreeViewItem
{
//public PropertyTreeView ParentTree { get; private set; }
public static readonly DependencyProperty LevelProperty =
DependencyProperty.Register("Level", typeof(int), typeof(PropertyTreeViewItem));
public int Level {
get { return (int)GetValue(LevelProperty); }
set { SetValue(LevelProperty, value); }
}
protected override DependencyObject GetContainerForItemOverride()
{
//return new Decorator();
return new PropertyTreeViewItem();
}
protected override bool IsItemItsOwnContainerOverride(object item)
{
return item is PropertyTreeViewItem;
}
//protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
//{
// ParentTree.PrepareContainer(element, item);
//}
protected override void OnVisualParentChanged(DependencyObject oldParent)
{
base.OnVisualParentChanged(oldParent);
var parent = ItemsControl.ItemsControlFromItemContainer(this);
//ParentTree = parent as PropertyTreeView;
var parentItem = parent as PropertyTreeViewItem;
if (parentItem != null) {
Level = parentItem.Level + 1;
//ParentTree = parentItem.ParentTree;
}
}
protected override void OnMouseDown(MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Right) {
e.Handled = true;
var contextMenu = new PropertyContextMenu();
contextMenu.DataContext = DataContext;
contextMenu.Placement = PlacementMode.Bottom;
contextMenu.HorizontalOffset = -30;
contextMenu.PlacementTarget = this;
contextMenu.IsOpen = true;
}
}
}
}

99
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClass.cs

@ -0,0 +1,99 @@ @@ -0,0 +1,99 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Data;
using System.IO;
using System.Reflection;
namespace ICSharpCode.WpfDesign.Designer.Services
{
public class ChooseClass : INotifyPropertyChanged
{
public ChooseClass(IEnumerable<Assembly> assemblies)
{
foreach (var a in assemblies) {
foreach (var t in a.GetExportedTypes()) {
if (t.IsClass) {
if (t.IsAbstract) continue;
if (t.IsNested) continue;
if (t.IsGenericTypeDefinition) continue;
if (t.GetConstructor(Type.EmptyTypes) == null) continue;
projectClasses.Add(t);
}
}
}
projectClasses.Sort((c1, c2) => c1.Name.CompareTo(c2.Name));
classes = new ListCollectionView(projectClasses);
classes.Filter = FilterPredicate;
}
List<Type> projectClasses = new List<Type>();
ListCollectionView classes;
public ICollectionView Classes {
get { return classes; }
}
string filter;
public string Filter {
get {
return filter;
}
set {
filter = value;
Classes.Refresh();
RaisePropertyChanged("Filter");
}
}
bool showSystemClasses;
public bool ShowSystemClasses {
get {
return showSystemClasses;
}
set {
showSystemClasses = value;
Classes.Refresh();
RaisePropertyChanged("ShowSystemClasses");
}
}
public Type CurrentClass {
get { return Classes.CurrentItem as Type; }
}
bool FilterPredicate(object item)
{
Type c = item as Type;
if (!ShowSystemClasses) {
if (c.Namespace.StartsWith("System") || c.Namespace.StartsWith("Microsoft")) {
return false;
}
}
return Match(c.Name, Filter);
}
static bool Match(string className, string filter)
{
if (string.IsNullOrEmpty(filter))
return true;
else
return className.StartsWith(filter, StringComparison.InvariantCultureIgnoreCase);
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
void RaisePropertyChanged(string name)
{
if (PropertyChanged != null) {
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
#endregion
}
}

70
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClassDialog.xaml

@ -0,0 +1,70 @@ @@ -0,0 +1,70 @@
<Window x:Class="ICSharpCode.WpfDesign.Designer.Services.ChooseClassDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Services="clr-namespace:ICSharpCode.WpfDesign.Designer.Services"
Background="{x:Static SystemColors.ControlBrush}"
SnapsToDevicePixels="True"
WindowStartupLocation="CenterScreen"
ResizeMode="CanResizeWithGrip"
Title="Choose Class"
Height="438"
Width="488">
<Grid>
<TextBlock Text="Starts with:"
HorizontalAlignment="Left"
Margin="12,12,0,0"
VerticalAlignment="Top"
Height="13"
Width="55" />
<TextBox x:Name="uxFilter"
Text="{Binding Filter, UpdateSourceTrigger=PropertyChanged}"
Height="23"
Margin="12,31,12,0"
VerticalAlignment="Top" />
<Services:ClassListBox x:Name="uxList"
Margin="12,60,12,78"
ItemsSource="{Binding Classes}"
IsSynchronizedWithCurrentItem="True"
ScrollViewer.HorizontalScrollBarVisibility="Hidden">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="../Images/Class.png"
Width="16"
Height="16"
/>
<TextBlock Margin="5 0 0 0"
Text="{Binding Converter={x:Static Services:ClassNameConverter.Instance}}"
VerticalAlignment="Center" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</Services:ClassListBox>
<CheckBox Content="Show System Classes"
IsChecked="{Binding ShowSystemClasses}"
Height="16"
HorizontalAlignment="Left"
Margin="12,0,0,56"
VerticalAlignment="Bottom"
Width="120" />
<Button x:Name="uxOk"
Content="OK"
Height="23"
Margin="0,0,93,12"
VerticalAlignment="Bottom"
HorizontalAlignment="Right"
Width="75"
IsDefault="True"
IsEnabled="{Binding SelectedItem, ElementName=uxList, Converter={x:Static Services:NullToBoolConverter.Instance}}" />
<Button Content="Cancel"
Height="23"
HorizontalAlignment="Right"
Margin="0,0,12,12"
VerticalAlignment="Bottom"
Width="75"
IsCancel="True" />
</Grid>
</Window>

112
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClassDialog.xaml.cs

@ -0,0 +1,112 @@ @@ -0,0 +1,112 @@
using System;
using System.Collections.Specialized;
using System.Globalization;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Input;
namespace ICSharpCode.WpfDesign.Designer.Services
{
public partial class ChooseClassDialog
{
public ChooseClassDialog(ChooseClass core)
{
DataContext = core;
InitializeComponent();
uxFilter.Focus();
uxList.MouseDoubleClick += uxList_MouseDoubleClick;
uxOk.Click += delegate { Ok(); };
AddHandler(Keyboard.GotKeyboardFocusEvent,
new KeyboardFocusChangedEventHandler(
(sender, e) => uxList.SetValue(IsSelectionActivePropertyKey, true)
),
true);
}
//HACK: listbox is always highlighted
public static DependencyPropertyKey IsSelectionActivePropertyKey =
(DependencyPropertyKey)typeof(Selector).GetField("IsSelectionActivePropertyKey",
BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
protected override void OnPreviewKeyDown(KeyEventArgs e)
{
if (e.Key == Key.Enter) {
Ok();
e.Handled = true;
} else if (e.Key == Key.Up) {
uxList.SelectedIndex = Math.Max(0, uxList.SelectedIndex - 1);
e.Handled = true;
} else if (e.Key == Key.Down) {
uxList.SelectedIndex++;
e.Handled = true;
}
}
void uxList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
var f = e.OriginalSource as FrameworkElement;
if (f != null && f.DataContext is Type) {
Ok();
}
}
void Ok()
{
DialogResult = true;
Close();
}
}
class ClassListBox : ListBox
{
protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
{
base.OnItemsChanged(e);
SelectedIndex = 0;
ScrollIntoView(SelectedItem);
}
protected override void OnSelectionChanged(SelectionChangedEventArgs e)
{
base.OnSelectionChanged(e);
ScrollIntoView(SelectedItem);
}
}
public class ClassNameConverter : IValueConverter
{
public static ClassNameConverter Instance = new ClassNameConverter();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var c = value as Type;
if (c == null) return value;
return c.Name + " (" + c.Namespace + ")";
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class NullToBoolConverter : IValueConverter
{
public static NullToBoolConverter Instance = new NullToBoolConverter();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value == null ? false : true;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

23
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClassServiceBase.cs

@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
using System;
using System.Reflection;
using System.Collections.Generic;
using System.IO;
namespace ICSharpCode.WpfDesign.Designer.Services
{
public abstract class ChooseClassServiceBase
{
public Type ChooseClass()
{
var core = new ChooseClass(GetAssemblies());
var window = new ChooseClassDialog(core);
if (window.ShowDialog().Value) {
return core.CurrentClass;
}
return null;
}
public abstract IEnumerable<Assembly> GetAssemblies();
}
}

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/DragMoveMouseGesture.cs

@ -145,7 +145,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -145,7 +145,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
if (ehs != null) {
DesignItemProperty defaultEvent = ehs.GetDefaultEvent(clickedOn);
if (defaultEvent != null) {
ehs.CreateEventHandler(clickedOn, defaultEvent);
ehs.CreateEventHandler(defaultEvent);
}
}
}

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/WpfTopLevelWindowService.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// <file>
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>

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

@ -63,40 +63,21 @@ @@ -63,40 +63,21 @@
<Compile Include="Controls\AdornerLayer.cs" />
<Compile Include="Controls\ContainerDragHandle.cs" />
<Compile Include="Controls\DropDownButton.cs" />
<Compile Include="Controls\EnterTextBox.cs" />
<Compile Include="Controls\GridAdorner.cs" />
<Compile Include="Controls\PropertyEditor\EventHandlerEditor.cs" />
<Compile Include="Controls\NumericUpDown.cs" />
<Compile Include="Controls\SelectionFrame.cs" />
<Compile Include="Controls\ErrorBalloon.cs" />
<Compile Include="Controls\GrayOutDesignerExceptActiveArea.cs" />
<Compile Include="Controls\PropertyEditor\DependencyPropertyDotButton.cs" />
<Compile Include="Controls\PropertyEditor\PropertyEditor.cs" />
<Compile Include="Controls\PropertyEditor\PropertyEditorCategoryView.cs" />
<Compile Include="Controls\PropertyEditor\PropertyGridView.cs" />
<Compile Include="Controls\PropertyEditor\PropertyNameTextBlock.cs" />
<Compile Include="Controls\ResizeThumb.cs" />
<Compile Include="Controls\SingleVisualChildElement.cs" />
<Compile Include="Controls\TypeEditors\BrushEditor\BrushEditor.cs" />
<Compile Include="Controls\TypeEditors\BrushEditor\BrushEditorPopup.xaml.cs" />
<Compile Include="Controls\TypeEditors\BrushEditor\BrushEditorView.xaml.cs" />
<Compile Include="Controls\TypeEditors\BrushEditor\BrushTypeEditor.xaml.cs" />
<Compile Include="Controls\TypeEditors\BrushEditor\CallExtension.cs" />
<Compile Include="Controls\TypeEditors\BrushEditor\ColorHelper.cs" />
<Compile Include="Controls\TypeEditors\BrushEditor\ColorPicker.xaml.cs" />
<Compile Include="Controls\TypeEditors\BrushEditor\Converters.cs" />
<Compile Include="Controls\TypeEditors\BrushEditor\DragListener.cs" />
<Compile Include="Controls\TypeEditors\BrushEditor\ExtensionMethods.cs" />
<Compile Include="Controls\TypeEditors\BrushEditor\GradientBrushEditor.xaml.cs" />
<Compile Include="Controls\TypeEditors\BrushEditor\GradientSlider.xaml.cs" />
<Compile Include="Controls\TypeEditors\BrushEditor\NormalizedPanel.cs" />
<Compile Include="Controls\TypeEditors\BrushEditor\NumericUpDown.cs" />
<Compile Include="Controls\TypeEditors\BrushEditor\Picker.cs" />
<Compile Include="Controls\TypeEditors\BrushEditor\SolidBrushEditor.xaml.cs" />
<Compile Include="Controls\TypeEditors\ContentEditor.cs" />
<Compile Include="Controls\TypeEditors\CursorEditor.cs" />
<Compile Include="Controls\TypeEditors\NullableBoolEditor.cs" />
<Compile Include="CallExtension.cs" />
<Compile Include="Controls\DragListener.cs" />
<Compile Include="Controls\WindowClone.cs" />
<Compile Include="Converters.cs" />
<Compile Include="DesignPanel.cs" />
<Compile Include="DragDropExceptionHandler.cs" />
<Compile Include="ExtensionMethods.cs" />
<Compile Include="Extensions\ContentControlDefaultInitializer.cs" />
<Compile Include="Extensions\GridAdornerProvider.cs" />
<Compile Include="Extensions\GridPlacementSupport.cs" />
@ -109,7 +90,56 @@ @@ -109,7 +90,56 @@
<Compile Include="Extensions\TopLeftContainerDragHandle.cs" />
<Compile Include="Extensions\ResizeThumbExtension.cs" />
<Compile Include="Extensions\WindowResizeBehavior.cs" />
<Compile Include="PropertyGrid\BasicMetadata.cs" />
<Compile Include="PropertyGrid\Category.cs" />
<Compile Include="PropertyGrid\Editors\BoolEditor.xaml.cs">
<DependentUpon>BoolEditor.xaml</DependentUpon>
</Compile>
<Compile Include="PropertyGrid\Editors\BrushEditor\BrushEditor.cs" />
<Compile Include="PropertyGrid\Editors\BrushEditor\BrushEditorPopup.xaml.cs">
<DependentUpon>BrushEditorPopup.xaml</DependentUpon>
</Compile>
<Compile Include="PropertyGrid\Editors\BrushEditor\BrushEditorView.xaml.cs">
<DependentUpon>BrushEditorView.xaml</DependentUpon>
</Compile>
<Compile Include="PropertyGrid\Editors\BrushEditor\BrushTypeEditor.xaml.cs">
<DependentUpon>BrushTypeEditor.xaml</DependentUpon>
</Compile>
<Compile Include="PropertyGrid\Editors\BrushEditor\ColorHelper.cs" />
<Compile Include="PropertyGrid\Editors\BrushEditor\ColorPicker.xaml.cs">
<DependentUpon>ColorPicker.xaml</DependentUpon>
</Compile>
<Compile Include="PropertyGrid\Editors\BrushEditor\GradientBrushEditor.xaml.cs">
<DependentUpon>GradientBrushEditor.xaml</DependentUpon>
</Compile>
<Compile Include="PropertyGrid\Editors\BrushEditor\GradientSlider.xaml.cs">
<DependentUpon>GradientSlider.xaml</DependentUpon>
</Compile>
<Compile Include="PropertyGrid\Editors\BrushEditor\NormalizedPanel.cs" />
<Compile Include="PropertyGrid\Editors\BrushEditor\Picker.cs" />
<Compile Include="PropertyGrid\Editors\BrushEditor\SolidBrushEditor.xaml.cs">
<DependentUpon>SolidBrushEditor.xaml</DependentUpon>
</Compile>
<Compile Include="PropertyGrid\Editors\EventEditor.xaml.cs">
<DependentUpon>EventEditor.xaml</DependentUpon>
</Compile>
<Compile Include="PropertyGrid\Editors\NumberEditor.xaml.cs">
<DependentUpon>NumberEditor.xaml</DependentUpon>
</Compile>
<Compile Include="PropertyGrid\PropertyContextMenu.xaml.cs">
<DependentUpon>PropertyContextMenu.xaml</DependentUpon>
</Compile>
<Compile Include="PropertyGrid\PropertyGrid.cs" />
<Compile Include="PropertyGrid\PropertyGridView.xaml.cs">
<DependentUpon>PropertyGridView.xaml</DependentUpon>
</Compile>
<Compile Include="PropertyGrid\PropertyTreeView.cs" />
<Compile Include="ServiceRequiredException.cs" />
<Compile Include="Services\ChooseClass.cs" />
<Compile Include="Services\ChooseClassDialog.xaml.cs">
<DependentUpon>ChooseClassDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Services\ChooseClassServiceBase.cs" />
<Compile Include="Services\ClickOrDragMouseGesture.cs" />
<Compile Include="Services\CreateComponentTool.cs" />
<Compile Include="Services\DragMoveMouseGesture.cs" />
@ -133,15 +163,6 @@ @@ -133,15 +163,6 @@
<Compile Include="Xaml\XamlModelPropertyCollection.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Configuration" />
<Folder Include="Controls" />
<Folder Include="Controls\TypeEditors" />
<Folder Include="Controls\PropertyEditor" />
<Folder Include="Controls\TypeEditors\BrushEditor" />
<Folder Include="Extensions" />
<Folder Include="themes" />
<Folder Include="Xaml" />
<Folder Include="Services" />
<ProjectReference Include="..\..\WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj">
<Project>{88DA149F-21B2-48AB-82C4-28FB6BDFD783}</Project>
<Name>WpfDesign.XamlDom</Name>
@ -153,19 +174,66 @@ @@ -153,19 +174,66 @@
<SpecificVersion>False</SpecificVersion>
<Private>True</Private>
</ProjectReference>
<Page Include="Controls\PropertyEditor\PropertyEditor.xaml">
<DependentUpon>PropertyEditor.cs</DependentUpon>
<Page Include="Controls\NumericUpDown.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Controls\PropertyEditor\PropertyEditorStyles.xaml" />
<Page Include="Controls\ControlStyles.xaml" />
<Page Include="Controls\TypeEditors\BrushEditor\BrushEditorPopup.xaml" />
<Page Include="Controls\TypeEditors\BrushEditor\BrushEditorView.xaml" />
<Page Include="Controls\TypeEditors\BrushEditor\BrushTypeEditor.xaml" />
<Page Include="Controls\TypeEditors\BrushEditor\ColorPicker.xaml" />
<Page Include="Controls\TypeEditors\BrushEditor\GradientBrushEditor.xaml" />
<Page Include="Controls\TypeEditors\BrushEditor\GradientSlider.xaml" />
<Page Include="Controls\TypeEditors\BrushEditor\NumericUpDown.xaml" />
<Page Include="Controls\TypeEditors\BrushEditor\SolidBrushEditor.xaml" />
<Page Include="PropertyGrid\Editors\BoolEditor.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="PropertyGrid\Editors\BrushEditor\BrushEditorPopup.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="PropertyGrid\Editors\BrushEditor\BrushEditorView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="PropertyGrid\Editors\BrushEditor\BrushTypeEditor.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="PropertyGrid\Editors\BrushEditor\ColorPicker.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="PropertyGrid\Editors\BrushEditor\GradientBrushEditor.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="PropertyGrid\Editors\BrushEditor\GradientSlider.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="PropertyGrid\Editors\BrushEditor\SolidBrushEditor.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="PropertyGrid\Editors\EventEditor.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="PropertyGrid\Editors\NumberEditor.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="PropertyGrid\PropertyContextMenu.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="PropertyGrid\PropertyGridView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Services\ChooseClassDialog.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="themes\generic.xaml" />
</ItemGroup>
</Project>
<ItemGroup>
<Resource Include="Images\Class.png" />
</ItemGroup>
</Project>

9
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignContext.cs

@ -13,7 +13,7 @@ using ICSharpCode.WpfDesign.XamlDom; @@ -13,7 +13,7 @@ using ICSharpCode.WpfDesign.XamlDom;
using ICSharpCode.WpfDesign.Designer.Services;
using ICSharpCode.WpfDesign.Designer.Extensions;
using ICSharpCode.WpfDesign.Extensions;
using ICSharpCode.WpfDesign.PropertyEditor;
using ICSharpCode.WpfDesign.PropertyGrid;
namespace ICSharpCode.WpfDesign.Designer.Xaml
{
@ -58,9 +58,6 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -58,9 +58,6 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
_componentService = new XamlComponentService(this);
this.Services.AddService(typeof(IComponentService), _componentService);
EditorManager propertyGridEditorManager = new EditorManager();
this.Services.AddService(typeof(EditorManager), propertyGridEditorManager);
foreach (Action<XamlDesignContext> action in loadSettings.CustomServiceRegisterFunctions) {
action(this);
}
@ -73,7 +70,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -73,7 +70,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
// register extensions from the designer assemblies:
foreach (Assembly designerAssembly in loadSettings.DesignerAssemblies) {
this.Services.ExtensionManager.RegisterAssembly(designerAssembly);
propertyGridEditorManager.RegisterAssembly(designerAssembly);
EditorManager.RegisterAssembly(designerAssembly);
}
XamlParserSettings parserSettings = new XamlParserSettings();
@ -116,4 +113,4 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -116,4 +113,4 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
return g;
}
}
}
}

8
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlModelCollectionElementsCollection.cs

@ -190,13 +190,13 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -190,13 +190,13 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
public void Do()
{
collection.InsertInternal(index, item);
collection.modelProperty.DesignItem.NotifyPropertyChanged(collection.modelProperty);
collection.modelProperty.XamlDesignItem.NotifyPropertyChanged(collection.modelProperty);
}
public void Undo()
{
collection.RemoveInternal(index, item);
collection.modelProperty.DesignItem.NotifyPropertyChanged(collection.modelProperty);
collection.modelProperty.XamlDesignItem.NotifyPropertyChanged(collection.modelProperty);
}
}
@ -228,13 +228,13 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -228,13 +228,13 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
public void Do()
{
collection.RemoveInternal(index, item);
collection.modelProperty.DesignItem.NotifyPropertyChanged(collection.modelProperty);
collection.modelProperty.XamlDesignItem.NotifyPropertyChanged(collection.modelProperty);
}
public void Undo()
{
collection.InsertInternal(index, item);
collection.modelProperty.DesignItem.NotifyPropertyChanged(collection.modelProperty);
collection.modelProperty.XamlDesignItem.NotifyPropertyChanged(collection.modelProperty);
}
}
}

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

@ -12,6 +12,7 @@ using System; @@ -12,6 +12,7 @@ using System;
using System.Diagnostics;
using ICSharpCode.WpfDesign.XamlDom;
using ICSharpCode.WpfDesign.Designer.Services;
using System.Windows;
namespace ICSharpCode.WpfDesign.Designer.Xaml
{
@ -20,8 +21,8 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -20,8 +21,8 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
readonly XamlDesignItem _designItem;
readonly XamlProperty _property;
readonly XamlModelCollectionElementsCollection _collectionElements;
internal XamlDesignItem DesignItem {
internal XamlDesignItem XamlDesignItem {
get { return _designItem; }
}
@ -93,14 +94,10 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -93,14 +94,10 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
get {
if (IsCollection)
throw new DesignerException("Cannot access Value for collection properties.");
XamlComponentService componentService = _designItem.ComponentService;
object valueOnInstance = this.ValueOnInstance;
DesignItem designItem = componentService.GetDesignItem(valueOnInstance);
if (designItem != null)
return designItem;
return componentService.RegisterComponentForDesigner(valueOnInstance);
//TODO
if (ValueOnInstance == null) return null;
return _designItem.ComponentService.GetDesignItem(ValueOnInstance);
}
}
@ -272,5 +269,17 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -272,5 +269,17 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
}
}
}
public override DesignItem DesignItem {
get { return _designItem; }
}
public override DependencyProperty DependencyProperty {
get { return _property.DependencyProperty; }
}
public override bool IsAdvanced {
get { return _property.IsAdvanced; }
}
}
}

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

@ -1,8 +1,6 @@ @@ -1,8 +1,6 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/ICSharpCode.WpfDesign.Designer;component/Controls/ControlStyles.xaml"/>
<ResourceDictionary Source="/ICSharpCode.WpfDesign.Designer;component/Controls/PropertyEditor/PropertyEditorStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/ICSharpCode.WpfDesign.Designer;component/Controls/ControlStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

7
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/WpfDesign.Tests.csproj

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup>
<ProjectGuid>{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -11,6 +11,11 @@ @@ -11,6 +11,11 @@
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>2.0</OldToolsVersion>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>

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

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// <file>
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <author name="Daniel Grunwald"/>

12
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs

@ -11,12 +11,14 @@ using System.ComponentModel; @@ -11,12 +11,14 @@ using System.ComponentModel;
using System.Diagnostics;
using System.Text;
using System.Xml;
using System.Windows;
namespace ICSharpCode.WpfDesign.XamlDom
{
/// <summary>
/// Describes a property on a <see cref="XamlObject"/>.
/// </summary>
[DebuggerDisplay("XamlProperty: {PropertyName}")]
public sealed class XamlProperty
{
XamlObject parentObject;
@ -315,5 +317,15 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -315,5 +317,15 @@ namespace ICSharpCode.WpfDesign.XamlDom
return attribute == null && element == null;
}
}*/
public bool IsAdvanced {
get { return propertyInfo.IsAdvanced; }
}
public DependencyProperty DependencyProperty {
get {
return propertyInfo.DependencyProperty;
}
}
}
}

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

@ -33,6 +33,8 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -33,6 +33,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
public abstract bool IsAttached { get; }
public abstract bool IsCollection { get; }
public virtual bool IsEvent { get { return false; } }
public virtual bool IsAdvanced { get { return false; } }
public virtual DependencyProperty DependencyProperty { get { return null; } }
public abstract string Category { get; }
}
@ -41,8 +43,8 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -41,8 +43,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
{
readonly DependencyProperty property;
readonly bool isAttached;
public DependencyProperty Property {
public override DependencyProperty DependencyProperty {
get { return property; }
}
@ -110,10 +112,21 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -110,10 +112,21 @@ namespace ICSharpCode.WpfDesign.XamlDom
internal sealed class XamlNormalPropertyInfo : XamlPropertyInfo
{
PropertyDescriptor _propertyDescriptor;
DependencyProperty dependencyProperty;
public XamlNormalPropertyInfo(PropertyDescriptor propertyDescriptor)
{
this._propertyDescriptor = propertyDescriptor;
var dpd = DependencyPropertyDescriptor.FromProperty(propertyDescriptor);
if (dpd != null) {
dependencyProperty = dpd.DependencyProperty;
}
}
public override DependencyProperty DependencyProperty {
get {
return dependencyProperty;
}
}
public override object GetValue(object instance)
@ -168,6 +181,16 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -168,6 +181,16 @@ namespace ICSharpCode.WpfDesign.XamlDom
return CollectionSupport.IsCollectionType(_propertyDescriptor.PropertyType);
}
}
public override bool IsAdvanced {
get {
var a = _propertyDescriptor.Attributes[typeof(EditorBrowsableAttribute)] as EditorBrowsableAttribute;
if (a != null) {
return a.State == EditorBrowsableState.Advanced;
}
return false;
}
}
public static readonly TypeConverter StringTypeConverter = TypeDescriptor.GetConverter(typeof(string));
@ -235,7 +258,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -235,7 +258,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
throw new XamlLoadException("Could not find property " + value + ".");
XamlDependencyPropertyInfo depProp = prop as XamlDependencyPropertyInfo;
if (depProp != null)
return depProp.Property;
return depProp.DependencyProperty;
FieldInfo field = prop.TargetType.GetField(prop.Name + "Property", BindingFlags.Public | BindingFlags.Static);
if (field != null && field.FieldType == typeof(DependencyProperty)) {
return (DependencyProperty)field.GetValue(null);

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

@ -142,6 +142,13 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -142,6 +142,13 @@ namespace ICSharpCode.WpfDesign.XamlDom
void AddMappingToNamespace(XamlNamespace ns, AssemblyNamespaceMapping mapping)
{
ns.ClrNamespaces.Add(mapping);
string xmlNamespace;
if (reverseDict.TryGetValue(mapping, out xmlNamespace)) {
if (xmlNamespace == XamlConstants.PresentationNamespace) {
return;
}
}
reverseDict[mapping] = ns.XmlNamespace;
}

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

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// <file>
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>

34
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.sln

@ -1,7 +1,6 @@ @@ -1,7 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
# SharpDevelop 3.0.0.3075
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.XamlDom", "WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj", "{88DA149F-21B2-48AB-82C4-28FB6BDFD783}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.Designer", "WpfDesign.Designer\Project\WpfDesign.Designer.csproj", "{78CC29AC-CC79-4355-B1F2-97936DF198AC}"
@ -12,35 +11,40 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign", "WpfDesign\Proj @@ -12,35 +11,40 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign", "WpfDesign\Proj
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.Tests", "WpfDesign.Designer\Tests\WpfDesign.Tests.csproj", "{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.AddIn", "WpfDesign.AddIn\WpfDesign.AddIn.csproj", "{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{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}.Debug|Any CPU.Build.0 = Debug|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
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Release|Any CPU.Build.0 = Release|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}.Debug|Any CPU.Build.0 = Debug|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
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Release|Any CPU.Build.0 = Release|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}.Debug|Any CPU.Build.0 = Debug|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
{84D65E9C-B66C-44C3-95FD-445EFE3ED322}.Release|Any CPU.Build.0 = Release|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}.Debug|Any CPU.Build.0 = Debug|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Release|Any CPU.Build.0 = Release|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Release|Any CPU.Build.0 = Release|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Release|Any CPU.Build.0 = Release|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

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

@ -101,6 +101,27 @@ namespace ICSharpCode.WpfDesign @@ -101,6 +101,27 @@ namespace ICSharpCode.WpfDesign
/// Resets the property value to the default, possibly removing it from the list of properties.
/// </summary>
public abstract void Reset();
public abstract DesignItem DesignItem { get; }
public abstract DependencyProperty DependencyProperty { get; }
public abstract bool IsAdvanced { get; }
public string FullName {
get {
return DeclaringType.FullName + "." + Name;
}
}
public string DependencyFullName {
get {
if (DependencyProperty != null) {
return DependencyProperty.GetFullName();
}
return FullName;
}
}
}
/// <summary>

130
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Metadata.cs

@ -0,0 +1,130 @@ @@ -0,0 +1,130 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Collections;
using System.Windows;
using System.ComponentModel;
namespace ICSharpCode.WpfDesign
{
public class NumberRange
{
public double Min;
public double Max;
}
public static class Metadata
{
public static string GetFullName(this DependencyProperty p)
{
return p.OwnerType.FullName + "." + p.Name;
}
static Dictionary<Type, List<object>> standardValues = new Dictionary<Type, List<object>>();
public static void AddStandardValues(Type type, Type valuesContainer)
{
AddStandardValues(type, valuesContainer
.GetProperties(BindingFlags.Public | BindingFlags.Static)
.Select(p => p.GetValue(null, null)));
}
public static void AddStandardValues<T>(Type type, IEnumerable<T> values)
{
List<object> list;
lock (standardValues) {
if (!standardValues.TryGetValue(type, out list)) {
list = new List<object>();
standardValues[type] = list;
}
foreach (var v in values) {
list.Add(v);
}
}
}
public static IEnumerable GetStandardValues(Type type)
{
if (type.IsEnum) {
return Enum.GetValues(type);
}
List<object> values;
lock (standardValues) {
if (standardValues.TryGetValue(type, out values)) {
return values;
}
}
return null;
}
static Dictionary<string, string> categories = new Dictionary<string, string>();
public static void AddCategory(DependencyProperty p, string category)
{
lock (categories) {
categories[p.GetFullName()] = category;
}
}
public static void AddCategory(Type type, string property, string category)
{
lock (categories) {
categories[type + "." + property] = category;
}
}
public static string GetCategory(DesignItemProperty p)
{
string result;
lock (categories) {
if (categories.TryGetValue(p.DependencyFullName, out result)) {
return result;
}
}
return p.Category;
}
static HashSet<string> advancedProperties = new HashSet<string>();
public static void AddAdvancedProperty(DependencyProperty p)
{
lock (advancedProperties) {
advancedProperties.Add(p.GetFullName());
}
}
public static bool IsAdvanced(DesignItemProperty p)
{
lock (advancedProperties) {
if (advancedProperties.Contains(p.DependencyFullName)) {
return true;
}
}
return p.IsAdvanced;
}
public static string[] CategoryOrder { get; set; }
static Dictionary<string, NumberRange> ranges = new Dictionary<string, NumberRange>();
public static void AddValueRange(DependencyProperty p, double min, double max)
{
lock (ranges) {
ranges[p.GetFullName()] = new NumberRange() { Min = min, Max = max };
}
}
public static NumberRange GetValueRange(DesignItemProperty p)
{
NumberRange r;
lock (ranges) {
if (ranges.TryGetValue(p.DependencyFullName, out r)) {
return r;
}
}
return null;
}
}
}

72
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/EditorManager.cs

@ -0,0 +1,72 @@ @@ -0,0 +1,72 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Collections.Generic;
using System.Reflection;
using System.Windows;
using System.Windows.Input;
using ICSharpCode.WpfDesign.PropertyGrid.Editors;
namespace ICSharpCode.WpfDesign.PropertyGrid
{
/// <summary>
/// Manages registered type and property editors.
/// </summary>
public static class EditorManager
{
// property return type => editor type
static Dictionary<Type, Type> typeEditors = new Dictionary<Type, Type>();
// property full name => editor type
static Dictionary<string, Type> propertyEditors = new Dictionary<string, Type>();
public static FrameworkElement CreateEditor(DesignItemProperty property)
{
Type editorType;
if (!propertyEditors.TryGetValue(property.FullName, out editorType)) {
var type = property.ReturnType;
while (type != null) {
if (typeEditors.TryGetValue(type, out editorType)) {
break;
}
type = type.BaseType;
}
if (editorType == null) {
var standardValues = Metadata.GetStandardValues(property.ReturnType);
if (standardValues != null) {
return new ComboBoxEditor() { ItemsSource = standardValues };
}
return new TextBoxEditor();
}
}
return (FrameworkElement)Activator.CreateInstance(editorType);
}
/// <summary>
/// Registers property editors defined in the specified assembly.
/// </summary>
public static void RegisterAssembly(Assembly assembly)
{
if (assembly == null)
throw new ArgumentNullException("assembly");
foreach (Type type in assembly.GetExportedTypes()) {
foreach (TypeEditorAttribute editorAttribute in type.GetCustomAttributes(typeof(TypeEditorAttribute), false)) {
CheckValidEditor(type);
typeEditors[editorAttribute.SupportedPropertyType] = type;
}
foreach (PropertyEditorAttribute editorAttribute in type.GetCustomAttributes(typeof(PropertyEditorAttribute), false)) {
CheckValidEditor(type);
string propertyName = editorAttribute.PropertyDeclaringType.FullName + "." + editorAttribute.PropertyName;
propertyEditors[propertyName] = type;
}
}
}
static void CheckValidEditor(Type type)
{
if (!typeof(FrameworkElement).IsAssignableFrom(type)) {
throw new DesignerException("Editor types must derive from FrameworkElement!");
}
}
}
}

10
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/ComboBoxEditor.xaml

@ -0,0 +1,10 @@ @@ -0,0 +1,10 @@
<ComboBox
x:Class="ICSharpCode.WpfDesign.PropertyGrid.Editors.ComboBoxEditor"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
BorderThickness="0"
SelectedItem="{Binding Value}"
Background="{x:Null}"
Focusable="False"
>
</ComboBox>

34
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/ComboBoxEditor.xaml.cs

@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.PropertyGrid;
using System.Windows.Controls.Primitives;
namespace ICSharpCode.WpfDesign.PropertyGrid.Editors
{
[TypeEditor(typeof(Enum))]
public partial class ComboBoxEditor
{
public ComboBoxEditor()
{
InitializeComponent();
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
var popup = (Popup)Template.FindName("PART_Popup", this);
popup.SetValue(FontWeightProperty, FontWeights.Normal);
}
}
}

9
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/TextBoxEditor.xaml

@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
<TextBox
x:Class="ICSharpCode.WpfDesign.PropertyGrid.Editors.TextBoxEditor"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Text="{Binding ValueString}"
BorderThickness="0"
Background="{x:Null}"
>
</TextBox>

35
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/TextBoxEditor.xaml.cs

@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace ICSharpCode.WpfDesign.PropertyGrid.Editors
{
public partial class TextBoxEditor
{
public TextBoxEditor()
{
InitializeComponent();
}
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.Key == Key.Enter) {
BindingOperations.GetBindingExpressionBase(this, TextProperty).UpdateSource();
SelectAll();
}
else if (e.Key == Key.Escape) {
BindingOperations.GetBindingExpression(this, TextProperty).UpdateTarget();
}
}
}
}

50
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/PropertyEditorAttribute.cs

@ -0,0 +1,50 @@ @@ -0,0 +1,50 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision: 2254 $</version>
// </file>
using System;
namespace ICSharpCode.WpfDesign.PropertyGrid
{
/// <summary>
/// Attribute to specify that the decorated class is a editor for the specified property.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple=true, Inherited=false)]
public sealed class PropertyEditorAttribute : Attribute
{
readonly Type propertyDeclaringType;
readonly string propertyName;
/// <summary>
/// Creates a new PropertyEditorAttribute that specifies that the decorated class is a editor
/// for the "<paramref name="propertyDeclaringType"/>.<paramref name="propertyName"/>".
/// </summary>
public PropertyEditorAttribute(Type propertyDeclaringType, string propertyName)
{
if (propertyDeclaringType == null)
throw new ArgumentNullException("propertyDeclaringType");
if (propertyName == null)
throw new ArgumentNullException("propertyName");
this.propertyDeclaringType = propertyDeclaringType;
this.propertyName = propertyName;
}
/// <summary>
/// Gets the type that declares the property that the decorated editor supports.
/// </summary>
public Type PropertyDeclaringType {
get { return propertyDeclaringType; }
}
/// <summary>
/// Gets the name of the property that the decorated editor supports.
/// </summary>
public string PropertyName {
get { return propertyName; }
}
}
}

198
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/PropertyNode.cs

@ -0,0 +1,198 @@ @@ -0,0 +1,198 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Collections.ObjectModel;
using System.Windows.Data;
namespace ICSharpCode.WpfDesign.PropertyGrid
{
public class PropertyNode : INotifyPropertyChanged
{
public PropertyNode(DesignItemProperty[] properties)
: this(properties, null)
{
}
PropertyNode(DesignItemProperty[] properties, PropertyNode parent)
{
this.properties = properties;
this.Parent = parent;
foreach (var property in properties) {
property.ValueChanged += new EventHandler(property_ValueChanged);
}
Editor = EditorManager.CreateEditor(FirstProperty);
Children = new ObservableCollection<PropertyNode>();
UpdateChildren();
}
void property_ValueChanged(object sender, EventArgs e)
{
if (raiseEvents) {
OnValueChanged();
}
}
static object Unset = new object();
DesignItemProperty[] properties;
bool raiseEvents = true;
public string Name { get { return FirstProperty.Name; } }
public bool IsEvent { get { return FirstProperty.IsEvent; } }
public ServiceContainer Services { get { return FirstProperty.DesignItem.Services; } }
public FrameworkElement Editor { get; private set; }
public DesignItemProperty FirstProperty { get { return properties[0]; } }
public PropertyNode Parent { get; private set; }
public ObservableCollection<PropertyNode> Children { get; private set; }
bool isExpanded;
public bool IsExpanded {
get {
return isExpanded;
}
set {
isExpanded = value;
RaisePropertyChanged("IsExpanded");
}
}
public object Description {
get {
IPropertyDescriptionService s = Services.GetService<IPropertyDescriptionService>();
if (s != null) {
return s.GetDescription(FirstProperty);
}
return null;
}
}
public object Value {
get {
if (IsAmbiguous) return null;
return FirstProperty.ValueOnInstance;
}
set {
SetValueCore(value);
}
}
public string ValueString {
get {
if (Value == null) return null;
return FirstProperty.TypeConverter.ConvertToString(Value);
}
set {
Value = FirstProperty.TypeConverter.ConvertFromString(value);
}
}
public bool IsSet {
get {
foreach (var p in properties) {
if (p.IsSet) return true;
}
return false;
}
}
public FontWeight FontWeight {
get {
return IsSet ? FontWeights.Bold : FontWeights.Normal;
}
}
public bool IsAmbiguous {
get {
foreach (var p in properties) {
if (!object.Equals(p.ValueOnInstance, FirstProperty.ValueOnInstance)) {
return true;
}
}
return false;
}
}
public bool CanReset {
get { return IsSet; }
}
public void Reset()
{
SetValueCore(Unset);
}
public void CreateBinding()
{
Value = new Binding();
}
void SetValueCore(object value)
{
raiseEvents = false;
if (value == Unset) {
foreach (var p in properties) {
p.Reset();
}
}
else {
foreach (var p in properties) {
p.SetValue(value);
}
}
raiseEvents = true;
OnValueChanged();
}
void OnValueChanged()
{
RaisePropertyChanged("IsSet");
RaisePropertyChanged("Value");
RaisePropertyChanged("ValueString");
RaisePropertyChanged("IsAmbiguous");
RaisePropertyChanged("FontWeight");
UpdateChildren();
}
void UpdateChildren()
{
Children.Clear();
if (Parent == null || Parent.IsExpanded) {
if (IsAmbiguous || FirstProperty.IsCollection || FirstProperty.Value == null) {
return;
}
var item = FirstProperty.Value;
var list = TypeHelper.GetAvailableProperties(item.ComponentType)
.OrderBy(d => d.Name)
.Select(d => new PropertyNode(new[] { item.Properties[d.Name] }, this));
foreach (var node in list) {
Children.Add(node);
}
}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
void RaisePropertyChanged(string name)
{
if (PropertyChanged != null) {
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
#endregion
}
}

39
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeEditorAttribute.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: 2254 $</version>
// </file>
using System;
namespace ICSharpCode.WpfDesign.PropertyGrid
{
/// <summary>
/// Attribute to specify that the decorated class is a editor for properties with the specified
/// return type.
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple=true, Inherited=false)]
public sealed class TypeEditorAttribute : Attribute
{
readonly Type supportedPropertyType;
/// <summary>
/// Creates a new TypeEditorAttribute that specifies that the decorated class is a editor
/// for properties with the return type "<paramref name="supportedPropertyType"/>".
/// </summary>
public TypeEditorAttribute(Type supportedPropertyType)
{
if (supportedPropertyType == null)
throw new ArgumentNullException("supportedPropertyType");
this.supportedPropertyType = supportedPropertyType;
}
/// <summary>
/// Gets the supported property type.
/// </summary>
public Type SupportedPropertyType {
get { return supportedPropertyType; }
}
}
}

51
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeHelper.cs

@ -0,0 +1,51 @@ @@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
namespace ICSharpCode.WpfDesign.PropertyGrid
{
public static class TypeHelper
{
public static IEnumerable<PropertyDescriptor> GetCommonAvailableProperties(IEnumerable<Type> types)
{
foreach (var pd1 in GetAvailableProperties(types.First())) {
bool propertyOk = true;
foreach (var type in types.Skip(1)) {
bool typeOk = false;
foreach (var pd2 in GetAvailableProperties(type)) {
if (pd1 == pd2) {
typeOk = true;
break;
}
}
if (!typeOk) {
propertyOk = false;
break;
}
}
if (propertyOk) yield return pd1;
}
}
public static IEnumerable<PropertyDescriptor> GetAvailableProperties(Type forType)
{
foreach (PropertyDescriptor p in TypeDescriptor.GetProperties(forType)) {
if (!p.IsBrowsable) continue;
if (p.IsReadOnly) continue;
if (p.Name.Contains(".")) continue;
yield return p;
}
}
public static IEnumerable<EventDescriptor> GetAvailableEvents(Type forType)
{
foreach (EventDescriptor e in TypeDescriptor.GetEvents(forType)) {
if (!e.IsBrowsable) continue;
if (e.Name.Contains(".")) continue;
yield return e;
}
}
}
}

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

@ -177,7 +177,7 @@ namespace ICSharpCode.WpfDesign @@ -177,7 +177,7 @@ namespace ICSharpCode.WpfDesign
/// <summary>
/// Creates an event handler for the specified event.
/// </summary>
void CreateEventHandler(DesignItem item, DesignItemProperty eventProperty);
void CreateEventHandler(DesignItemProperty eventProperty);
/// <summary>
/// Gets the default event of the specified design item.

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

@ -67,6 +67,7 @@ @@ -67,6 +67,7 @@
<Compile Include="Adorners\AdornerProvider.cs" />
<Compile Include="Adorners\AdornerProviderClasses.cs" />
<Compile Include="Adorners\RelativePlacement.cs" />
<Compile Include="Metadata.cs" />
<Compile Include="PlacementInformation.cs" />
<Compile Include="PlacementBehavior.cs" />
<Compile Include="MouseInteraction.cs" />
@ -91,32 +92,31 @@ @@ -91,32 +92,31 @@
<Compile Include="HashSet.cs" />
<Compile Include="PlacementOperation.cs" />
<Compile Include="PlacementType.cs" />
<Compile Include="PropertyEditor\BooleanEditor.cs" />
<Compile Include="PropertyEditor\DesignItemDataEvent.cs" />
<Compile Include="PropertyEditor\DesignItemDataMember.cs" />
<Compile Include="PropertyEditor\MultipleSelectionDataProperty.cs" />
<Compile Include="PropertyEditor\ProxyPropertyEditorDataProperty.cs" />
<Compile Include="PropertyEditor\StandardValuesComboBoxEditor.cs" />
<Compile Include="PropertyEditor\DesignItemDataProperty.cs" />
<Compile Include="PropertyEditor\DesignItemDataSource.cs" />
<Compile Include="PropertyEditor\EditorManager.cs" />
<Compile Include="PropertyEditor\FallbackEditor.cs" />
<Compile Include="PropertyEditor\IPropertyEditorDataSource.cs" />
<Compile Include="PropertyEditor\MultipleSelectionDataSource.cs" />
<Compile Include="PropertyEditor\TextBoxEditor.cs" />
<Compile Include="PropertyEditor\PropertyEditorAttribute.cs" />
<Compile Include="PropertyEditor\PropertyEditorBindingHelper.cs" />
<Compile Include="PropertyEditor\TypeEditorAttribute.cs" />
<Compile Include="PlacementAlignment.cs" />
<Compile Include="PropertyGrid\EditorManager.cs" />
<Compile Include="PropertyGrid\Editors\ComboBoxEditor.xaml.cs">
<DependentUpon>ComboBoxEditor.xaml</DependentUpon>
</Compile>
<Compile Include="PropertyGrid\Editors\TextBoxEditor.xaml.cs">
<DependentUpon>TextBoxEditor.xaml</DependentUpon>
</Compile>
<Compile Include="PropertyGrid\PropertyEditorAttribute.cs" />
<Compile Include="PropertyGrid\PropertyNode.cs" />
<Compile Include="PropertyGrid\TypeEditorAttribute.cs" />
<Compile Include="PropertyGrid\TypeHelper.cs" />
<Compile Include="ServiceContainer.cs" />
<Compile Include="DesignItem.cs" />
<Compile Include="Services.cs" />
<Compile Include="Tools.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Configuration" />
<Folder Include="Extensions" />
<Folder Include="Adorners" />
<Folder Include="PropertyEditor" />
<Page Include="PropertyGrid\Editors\ComboBoxEditor.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="PropertyGrid\Editors\TextBoxEditor.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
</Project>
Loading…
Cancel
Save