Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2246 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
36 changed files with 997 additions and 125 deletions
@ -0,0 +1,67 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using ICSharpCode.WpfDesign.PropertyEditor; |
||||||
|
using System.Windows; |
||||||
|
using System.Windows.Threading; |
||||||
|
|
||||||
|
namespace StandaloneDesigner |
||||||
|
{ |
||||||
|
public class StrangeDataSource : IPropertyEditorDataSource |
||||||
|
{ |
||||||
|
string name; |
||||||
|
|
||||||
|
public string Name { |
||||||
|
get { return name; } |
||||||
|
set { |
||||||
|
name = value; |
||||||
|
|
||||||
|
if (NameChanged != null) { |
||||||
|
NameChanged(this, EventArgs.Empty); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public StrangeDataSource() |
||||||
|
{ |
||||||
|
// set the name of this data source to the current time
|
||||||
|
DispatcherTimer t = new DispatcherTimer(); |
||||||
|
t.Interval = TimeSpan.FromSeconds(1); |
||||||
|
t.Tick += delegate { |
||||||
|
this.Name = DateTime.Now.ToString(); |
||||||
|
}; |
||||||
|
t.Start(); |
||||||
|
} |
||||||
|
|
||||||
|
public event EventHandler NameChanged; |
||||||
|
|
||||||
|
public string Type { |
||||||
|
get { |
||||||
|
return "Strange"; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public System.Windows.Media.ImageSource Icon { |
||||||
|
get { |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public System.Collections.Generic.ICollection<IPropertyEditorDataProperty> Properties { |
||||||
|
get { |
||||||
|
return new IPropertyEditorDataProperty[0]; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool CanAddAttachedProperties { |
||||||
|
get { |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,89 @@ |
|||||||
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||||
|
xmlns:src="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls" |
||||||
|
> |
||||||
|
<!-- |
||||||
|
This file contains the default styles used by the Controls in ICSharpCode.WpfDesign.Designer.Controls |
||||||
|
--> |
||||||
|
|
||||||
|
<Style TargetType="{x:Type src:ResizeThumb}"> |
||||||
|
<Setter Property="Template"> |
||||||
|
<Setter.Value> |
||||||
|
<ControlTemplate TargetType="{x:Type src:ResizeThumb}"> |
||||||
|
<Rectangle Name="thumbRectangle" |
||||||
|
Width="7" Height="7" SnapsToDevicePixels="True" |
||||||
|
Stroke="Black" Fill="White" RadiusX="1.4142" RadiusY="1.4142"/> |
||||||
|
<ControlTemplate.Triggers> |
||||||
|
<Trigger Property="IsPrimarySelection" Value="False"> |
||||||
|
<Setter TargetName="thumbRectangle" Property="Stroke" Value="White"/> |
||||||
|
<Setter TargetName="thumbRectangle" Property="Fill" Value="Black"/> |
||||||
|
</Trigger> |
||||||
|
<Trigger Property="IsEnabled" Value="False"> |
||||||
|
<Setter TargetName="thumbRectangle" Property="Fill" Value="Gray"/> |
||||||
|
</Trigger> |
||||||
|
</ControlTemplate.Triggers> |
||||||
|
</ControlTemplate> |
||||||
|
</Setter.Value> |
||||||
|
</Setter> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style TargetType="{x:Type src:ContainerDragHandle}"> |
||||||
|
<Setter Property="Template"> |
||||||
|
<Setter.Value> |
||||||
|
<ControlTemplate TargetType="{x:Type src:ContainerDragHandle}"> |
||||||
|
<Canvas Height="13" Width="13" Name="Canvas" SnapsToDevicePixels="True"> |
||||||
|
<Rectangle Height="13" Width="13" RadiusX="2" RadiusY="2" |
||||||
|
Fill="#889ABFE5" Name="BorderRectangle" Stroke="#FF7A8FB5" StrokeThickness="1" /> |
||||||
|
<Path Fill="#FF748EAA" Canvas.Left="1" Canvas.Top="1"> |
||||||
|
<Path.Data> |
||||||
|
<GeometryGroup> |
||||||
|
<PathGeometry Figures="M5.5,0L3,3L8,3 M11,5.5L8,3L8,8 M5.5,11L3,8L8,8 M0,5.5L3,3L3,8" /> |
||||||
|
<RectangleGeometry Rect="3,5,5,1" /> |
||||||
|
<RectangleGeometry Rect="5,3,1,5" /> |
||||||
|
<RectangleGeometry Rect="5,5,1,1" /> |
||||||
|
</GeometryGroup> |
||||||
|
</Path.Data> |
||||||
|
</Path> |
||||||
|
</Canvas> |
||||||
|
</ControlTemplate> |
||||||
|
</Setter.Value> |
||||||
|
</Setter> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style TargetType="{x:Type src:WindowClone}"> |
||||||
|
<Setter Property="Template"> |
||||||
|
<Setter.Value> |
||||||
|
<ControlTemplate TargetType="src:WindowClone"> |
||||||
|
<Border Background="{DynamicResource {x:Static SystemColors.GradientActiveCaptionBrushKey}}" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" BorderThickness="1,1,1,1" CornerRadius="5,5,5,5"> |
||||||
|
<DockPanel Margin="4,0,4,4"> |
||||||
|
<DockPanel Height="26" DockPanel.Dock="Top"> |
||||||
|
<Image Width="16" Height="16" Margin="1,0,0,0" Source="{TemplateBinding Window.Icon}" /> |
||||||
|
<Button Name="CloseButton" VerticalAlignment="Top" Width="43" Height="17" DockPanel.Dock="Right"> |
||||||
|
<Path Fill="#FFF6F2F2" Stretch="Uniform" Margin="1" Stroke="#FF808080" Data="M160,400 L176,400 192,384 208,400 224,400 200,376 224,352 208,352 192,368 176,352 160,352 184,376 z"/> |
||||||
|
</Button> |
||||||
|
<Button Name="MaximiseButton" VerticalAlignment="Top" Width="25" Height="17" DockPanel.Dock="Right"/> |
||||||
|
<Button Name="MinimizeButton" VerticalAlignment="Top" Width="25" Height="17" DockPanel.Dock="Right"> |
||||||
|
<!--<Rectangle Fill="#FFF6F2F2" RadiusX="0.5" RadiusY="0.5" Width="12" Height="5" Stroke="#FF808080" VerticalAlignment="Bottom" HorizontalAlignment="Center"/>--> |
||||||
|
</Button> |
||||||
|
<Label Margin="4,0,0,0" Content="{TemplateBinding Window.Title}"/> |
||||||
|
</DockPanel> |
||||||
|
<Border Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"> |
||||||
|
<Border |
||||||
|
BorderBrush="{TemplateBinding Border.BorderBrush}" |
||||||
|
BorderThickness="{TemplateBinding Border.BorderThickness}" |
||||||
|
Background="{TemplateBinding Panel.Background}"> |
||||||
|
<AdornerDecorator> |
||||||
|
<ContentPresenter |
||||||
|
ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" |
||||||
|
Content="{TemplateBinding ContentControl.Content}" /> |
||||||
|
</AdornerDecorator> |
||||||
|
</Border> |
||||||
|
</Border> |
||||||
|
</DockPanel> |
||||||
|
</Border> |
||||||
|
</ControlTemplate> |
||||||
|
</Setter.Value> |
||||||
|
</Setter> |
||||||
|
</Style> |
||||||
|
|
||||||
|
</ResourceDictionary> |
@ -0,0 +1,159 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.ComponentModel; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Diagnostics; |
||||||
|
using System.Windows; |
||||||
|
using System.Windows.Controls; |
||||||
|
using System.Windows.Input; |
||||||
|
using System.Windows.Media; |
||||||
|
using System.Windows.Shapes; |
||||||
|
using ICSharpCode.WpfDesign.Designer.Controls; |
||||||
|
using ICSharpCode.WpfDesign.PropertyEditor; |
||||||
|
|
||||||
|
namespace ICSharpCode.WpfDesign.Designer |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of PropertyGrid.
|
||||||
|
/// </summary>
|
||||||
|
public partial class PropertyEditor : UserControl |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Dependency property for <see cref="EditedObject"/>.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly DependencyProperty EditedObjectProperty |
||||||
|
= DependencyProperty.Register("EditedObject", typeof(IPropertyEditorDataSource), typeof(PropertyEditor), |
||||||
|
new FrameworkPropertyMetadata(null, _OnEditedObjectPropertyChanged)); |
||||||
|
|
||||||
|
#if XAML_DEFINITIONS
|
||||||
|
// this is not compiled, but gives us code-completion inside SharpDevelop
|
||||||
|
TextBox nameTextBox; |
||||||
|
Label typeLabel; |
||||||
|
Image componentImage; |
||||||
|
TextBox searchTextBox; |
||||||
|
StackPanel contentStackPanel; |
||||||
|
#endif
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new PropertyGrid instance.
|
||||||
|
/// </summary>
|
||||||
|
public PropertyEditor() |
||||||
|
{ |
||||||
|
try { |
||||||
|
InitializeComponent(); |
||||||
|
} catch (Exception ex) { |
||||||
|
Debug.WriteLine(ex.ToString()); |
||||||
|
throw; |
||||||
|
} |
||||||
|
PropertyEditorCategoryView v = new PropertyEditorCategoryView(); |
||||||
|
v.Header = "Titel"; |
||||||
|
v.Content = "Inhalt"; |
||||||
|
contentStackPanel.Children.Add(v); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets/Sets the object being edited.
|
||||||
|
/// </summary>
|
||||||
|
public IPropertyEditorDataSource EditedObject { |
||||||
|
get { return (IPropertyEditorDataSource)GetValue(EditedObjectProperty); } |
||||||
|
set { SetValue(EditedObjectProperty, value); } |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Is raised when the object being edited changes.
|
||||||
|
/// </summary>
|
||||||
|
public event EventHandler EditedObjectChanged; |
||||||
|
|
||||||
|
static void _OnEditedObjectPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) |
||||||
|
{ |
||||||
|
((PropertyEditor)obj).OnEditedObjectPropertyChanged(e); |
||||||
|
} |
||||||
|
|
||||||
|
void OnEditedObjectPropertyChanged(DependencyPropertyChangedEventArgs e) |
||||||
|
{ |
||||||
|
ShowProperties(e.NewValue as IPropertyEditorDataSource); |
||||||
|
if (EditedObjectChanged != null) { |
||||||
|
EditedObjectChanged(this, EventArgs.Empty); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void ShowPropertiesButton_Click(object sender, RoutedEventArgs e) |
||||||
|
{ |
||||||
|
ShowProperties(this.EditedObject); |
||||||
|
} |
||||||
|
|
||||||
|
void ShowEventsButton_Click(object sender, RoutedEventArgs e) |
||||||
|
{ |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
void ShowProperties(IPropertyEditorDataSource dataSource) |
||||||
|
{ |
||||||
|
contentStackPanel.Children.Clear(); |
||||||
|
if (dataSource == null) |
||||||
|
return; |
||||||
|
|
||||||
|
List<PropertyEditorCategoryView> categories = new List<PropertyEditorCategoryView>(); |
||||||
|
foreach (IPropertyEditorDataProperty p in Linq.Sort(dataSource.Properties, ComparePropertyNames)) { |
||||||
|
PropertyEditorCategoryView cv = GetOrCreateCategory(categories, p.Category); |
||||||
|
PropertyGridView grid = (PropertyGridView)cv.Content; |
||||||
|
grid.AddProperty(p); |
||||||
|
} |
||||||
|
// Sort category titles alphabetically
|
||||||
|
categories.Sort(delegate (PropertyEditorCategoryView c1, PropertyEditorCategoryView c2) { |
||||||
|
return c1.Header.ToString().CompareTo(c2.Header.ToString()); |
||||||
|
}); |
||||||
|
// Add categories to contentStackPanel
|
||||||
|
foreach (PropertyEditorCategoryView c in categories) { |
||||||
|
contentStackPanel.Children.Add(c); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
static int ComparePropertyNames(IPropertyEditorDataProperty p1, IPropertyEditorDataProperty p2) |
||||||
|
{ |
||||||
|
return p1.Name.CompareTo(p2.Name); |
||||||
|
} |
||||||
|
|
||||||
|
static PropertyEditorCategoryView GetOrCreateCategory(List<PropertyEditorCategoryView> categories, string category) |
||||||
|
{ |
||||||
|
foreach (PropertyEditorCategoryView c in categories) { |
||||||
|
if (c.Header.ToString() == category) |
||||||
|
return c; |
||||||
|
} |
||||||
|
PropertyEditorCategoryView newCategory = new PropertyEditorCategoryView(); |
||||||
|
newCategory.Header = category; |
||||||
|
newCategory.Content = new PropertyGridView(); |
||||||
|
categories.Add(newCategory); |
||||||
|
return newCategory; |
||||||
|
} |
||||||
|
|
||||||
|
/* |
||||||
|
void clearSearchButton_Click(object sender, RoutedEventArgs e) |
||||||
|
{ |
||||||
|
searchTextBox.Text = ""; |
||||||
|
} |
||||||
|
*/ |
||||||
|
|
||||||
|
void nameTextBox_SizeChanged(object sender, RoutedEventArgs e) |
||||||
|
{ |
||||||
|
// Display componentImage only if there is enough space left.
|
||||||
|
const double minimalNameTextBoxWidth = 80; |
||||||
|
const double switchTreshold = 5; |
||||||
|
if (componentImage.Visibility != Visibility.Collapsed) { |
||||||
|
if (nameTextBox.ActualWidth < minimalNameTextBoxWidth - switchTreshold) { |
||||||
|
componentImage.Visibility = Visibility.Collapsed; |
||||||
|
} |
||||||
|
} else { |
||||||
|
if (nameTextBox.ActualWidth > minimalNameTextBoxWidth + componentImage.Width + switchTreshold) { |
||||||
|
componentImage.Visibility = Visibility.Visible; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,60 @@ |
|||||||
|
<UserControl x:Class="ICSharpCode.WpfDesign.Designer.PropertyEditor" |
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||||
|
x:Name="userControl"> |
||||||
|
<DockPanel> |
||||||
|
<Border DockPanel.Dock="Top" |
||||||
|
Background="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}" |
||||||
|
CornerRadius="0 0 0 15" Padding="4"> |
||||||
|
<StackPanel> |
||||||
|
<Grid> |
||||||
|
<Grid.ColumnDefinitions> |
||||||
|
<ColumnDefinition Width="Auto" /> |
||||||
|
<ColumnDefinition Width="*" /> |
||||||
|
<ColumnDefinition Width="Auto" /> |
||||||
|
</Grid.ColumnDefinitions> |
||||||
|
<Image Grid.Column="0" Width="32" Height="32" Name="componentImage" /> |
||||||
|
<Grid Grid.Column="1" Margin="0 0 2 0"> |
||||||
|
<Grid.ColumnDefinitions> |
||||||
|
<ColumnDefinition Width="Auto" /> |
||||||
|
<ColumnDefinition Width="*" /> |
||||||
|
</Grid.ColumnDefinitions> |
||||||
|
<Grid.RowDefinitions> |
||||||
|
<RowDefinition Height="0.5*" /> |
||||||
|
<RowDefinition Height="0.5*" /> |
||||||
|
</Grid.RowDefinitions> |
||||||
|
<Label Grid.Column="0" Grid.Row="0" Target="{Binding ElementName=nameTextBox}">_Name:</Label> |
||||||
|
<TextBox Grid.Column="1" Grid.Row="0" Name="nameTextBox" SizeChanged="nameTextBox_SizeChanged" |
||||||
|
Text="{Binding ElementName=userControl, Path=EditedObject.Name}"/> |
||||||
|
<Label Grid.Column="0" Grid.Row="1">Type:</Label> |
||||||
|
<Label Grid.Column="1" Grid.Row="1" Name="typeLabel" |
||||||
|
Content="{Binding ElementName=userControl, Path=EditedObject.Type}"/> |
||||||
|
</Grid> |
||||||
|
<StackPanel Grid.Column="2" Orientation="Horizontal"> |
||||||
|
<Rectangle Margin="2" Width="1.5" Fill="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}"/> |
||||||
|
<Button VerticalAlignment="Center" Click="ShowPropertiesButton_Click">P</Button> |
||||||
|
<Button VerticalAlignment="Center" Click="ShowEventsButton_Click">E</Button> |
||||||
|
</StackPanel> |
||||||
|
</Grid> |
||||||
|
<!-- |
||||||
|
<Rectangle Margin="2" Height="1px" SnapsToDevicePixels="True" |
||||||
|
Fill="{DynamicResource {x:Static SystemColors.ControlDarkDarkBrushKey}}"/> |
||||||
|
<Grid> |
||||||
|
<Grid.ColumnDefinitions> |
||||||
|
<ColumnDefinition Width="Auto" /> |
||||||
|
<ColumnDefinition Width="*" /> |
||||||
|
<ColumnDefinition Width="Auto" /> |
||||||
|
</Grid.ColumnDefinitions> |
||||||
|
<Label>_Search:</Label> |
||||||
|
<TextBox Grid.Column="1" Name="searchTextBox"></TextBox> |
||||||
|
<Button Grid.Column="2" Click="clearSearchButton_Click">X</Button> |
||||||
|
</Grid> |
||||||
|
--> |
||||||
|
</StackPanel> |
||||||
|
</Border> |
||||||
|
<ScrollViewer Margin="0 1 0 0"> |
||||||
|
<StackPanel Name="contentStackPanel"> |
||||||
|
</StackPanel> |
||||||
|
</ScrollViewer> |
||||||
|
</DockPanel> |
||||||
|
</UserControl> |
@ -0,0 +1,24 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Windows; |
||||||
|
using System.Windows.Controls; |
||||||
|
|
||||||
|
namespace ICSharpCode.WpfDesign.Designer.Controls |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Control used to view a property grid category.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class PropertyEditorCategoryView : HeaderedContentControl |
||||||
|
{ |
||||||
|
static PropertyEditorCategoryView() |
||||||
|
{ |
||||||
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(PropertyEditorCategoryView), new FrameworkPropertyMetadata(typeof(PropertyEditorCategoryView))); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,34 @@ |
|||||||
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||||
|
xmlns:src="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls" |
||||||
|
> |
||||||
|
|
||||||
|
<Style TargetType="{x:Type src:PropertyEditorCategoryView}"> |
||||||
|
<Setter Property="Template"> |
||||||
|
<Setter.Value> |
||||||
|
<ControlTemplate TargetType="{x:Type src:PropertyEditorCategoryView}"> |
||||||
|
<Border Name="border" |
||||||
|
Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" |
||||||
|
CornerRadius="10" Margin="1"> |
||||||
|
<Expander Name="expander" Header="{TemplateBinding Header}"> |
||||||
|
<Border Margin="10 0 2 2"> |
||||||
|
<ContentPresenter/> |
||||||
|
</Border> |
||||||
|
</Expander> |
||||||
|
</Border> |
||||||
|
|
||||||
|
<ControlTemplate.Triggers> |
||||||
|
<Trigger SourceName="expander" Property="IsExpanded" Value="True"> |
||||||
|
<Setter TargetName="border" Property="Background" |
||||||
|
Value="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}"/> |
||||||
|
</Trigger> |
||||||
|
</ControlTemplate.Triggers> |
||||||
|
</ControlTemplate> |
||||||
|
</Setter.Value> |
||||||
|
</Setter> |
||||||
|
</Style> |
||||||
|
|
||||||
|
<Style TargetType="{x:Type src:PropertyGridView}"> |
||||||
|
|
||||||
|
</Style> |
||||||
|
</ResourceDictionary> |
@ -0,0 +1,54 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Windows; |
||||||
|
using System.Windows.Controls; |
||||||
|
using ICSharpCode.WpfDesign.PropertyEditor; |
||||||
|
|
||||||
|
namespace ICSharpCode.WpfDesign.Designer.Controls |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Control used to view a property grid category.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class PropertyGridView : Grid |
||||||
|
{ |
||||||
|
static PropertyGridView() |
||||||
|
{ |
||||||
|
DefaultStyleKeyProperty.OverrideMetadata(typeof(PropertyGridView), new FrameworkPropertyMetadata(typeof(PropertyGridView))); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new PropertyGridView instance.
|
||||||
|
/// </summary>
|
||||||
|
public PropertyGridView() |
||||||
|
{ |
||||||
|
this.ColumnDefinitions.Add(new ColumnDefinition()); |
||||||
|
this.ColumnDefinitions.Add(new ColumnDefinition()); |
||||||
|
this.ColumnDefinitions.Add(new ColumnDefinition()); |
||||||
|
this.ColumnDefinitions[0].Width = new GridLength(0.45, GridUnitType.Star); |
||||||
|
this.ColumnDefinitions[0].MinWidth = 40; |
||||||
|
this.ColumnDefinitions[1].Width = new GridLength(0.55, GridUnitType.Star); |
||||||
|
this.ColumnDefinitions[2].Width = new GridLength(10); |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a new property to the PropertyGridView.
|
||||||
|
/// </summary>
|
||||||
|
public void AddProperty(IPropertyEditorDataProperty property) |
||||||
|
{ |
||||||
|
this.RowDefinitions.Add(new RowDefinition()); |
||||||
|
|
||||||
|
Label propertyNameLabel = new Label(); |
||||||
|
propertyNameLabel.Content = property.Name; |
||||||
|
propertyNameLabel.HorizontalContentAlignment = HorizontalAlignment.Right; |
||||||
|
SetRow(propertyNameLabel, this.RowDefinitions.Count - 1); |
||||||
|
SetColumn(propertyNameLabel, 0); |
||||||
|
this.Children.Add(propertyNameLabel); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -1,84 +1,8 @@ |
|||||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||||
xmlns:src="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls" |
|
||||||
> |
> |
||||||
<!-- |
<ResourceDictionary.MergedDictionaries> |
||||||
This file contains the default styles used by the Controls in ICSharpCode.WpfDesign.Designer.Controls |
<ResourceDictionary Source="/ICSharpCode.WpfDesign.Designer;component/Controls/ControlStyles.xaml"/> |
||||||
--> |
<ResourceDictionary Source="/ICSharpCode.WpfDesign.Designer;component/Controls/PropertyEditor/PropertyEditorStyles.xaml"/> |
||||||
|
</ResourceDictionary.MergedDictionaries> |
||||||
<Style TargetType="{x:Type src:ResizeThumb}"> |
|
||||||
<Setter Property="Template"> |
|
||||||
<Setter.Value> |
|
||||||
<ControlTemplate TargetType="{x:Type src:ResizeThumb}"> |
|
||||||
<Rectangle Name="thumbRectangle" |
|
||||||
Width="7" Height="7" SnapsToDevicePixels="True" |
|
||||||
Stroke="Black" Fill="White" RadiusX="1.4142" RadiusY="1.4142"/> |
|
||||||
<ControlTemplate.Triggers> |
|
||||||
<Trigger Property="IsPrimarySelection" Value="False"> |
|
||||||
<Setter TargetName="thumbRectangle" Property="Stroke" Value="White"/> |
|
||||||
<Setter TargetName="thumbRectangle" Property="Fill" Value="Black"/> |
|
||||||
</Trigger> |
|
||||||
<Trigger Property="IsEnabled" Value="False"> |
|
||||||
<Setter TargetName="thumbRectangle" Property="Fill" Value="Gray"/> |
|
||||||
</Trigger> |
|
||||||
</ControlTemplate.Triggers> |
|
||||||
</ControlTemplate> |
|
||||||
</Setter.Value> |
|
||||||
</Setter> |
|
||||||
</Style> |
|
||||||
|
|
||||||
<Style TargetType="{x:Type src:ContainerDragHandle}"> |
|
||||||
<Setter Property="Template"> |
|
||||||
<Setter.Value> |
|
||||||
<ControlTemplate TargetType="{x:Type src:ContainerDragHandle}"> |
|
||||||
<Canvas Height="13" Width="13" Name="Canvas" Background="#00FFFFFF" SnapsToDevicePixels="True"> |
|
||||||
<Rectangle Height="13" Width="13" RadiusX="2" RadiusY="2" |
|
||||||
Fill="#669ABFE5" Name="BorderRectangle" Stroke="#FF9ABFE5" StrokeThickness="1" /> |
|
||||||
<Path Fill="#FF748EAA" Canvas.Left="1" Canvas.Top="1"> |
|
||||||
<Path.Data> |
|
||||||
<GeometryGroup> |
|
||||||
<PathGeometry Figures="M5.5,0L3,3L8,3 M11,5.5L8,3L8,8 M5.5,11L3,8L8,8 M0,5.5L3,3L3,8" /> |
|
||||||
<RectangleGeometry Rect="3,5,5,1" /> |
|
||||||
<RectangleGeometry Rect="5,3,1,5" /> |
|
||||||
<RectangleGeometry Rect="5,5,1,1" /> |
|
||||||
</GeometryGroup> |
|
||||||
</Path.Data> |
|
||||||
</Path> |
|
||||||
</Canvas> |
|
||||||
</ControlTemplate> |
|
||||||
</Setter.Value> |
|
||||||
</Setter> |
|
||||||
</Style> |
|
||||||
|
|
||||||
<Style TargetType="{x:Type src:WindowClone}"> |
|
||||||
<Setter Property="Template"> |
|
||||||
<Setter.Value> |
|
||||||
<ControlTemplate TargetType="src:WindowClone"> |
|
||||||
<Border Background="{DynamicResource {x:Static SystemColors.GradientActiveCaptionBrushKey}}" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" BorderThickness="1,1,1,1" CornerRadius="5,5,5,5"> |
|
||||||
<DockPanel Margin="4,0,4,4"> |
|
||||||
<DockPanel Height="26" DockPanel.Dock="Top"> |
|
||||||
<Image Width="16" Height="16" Margin="1,0,0,0" Source="{TemplateBinding Window.Icon}" /> |
|
||||||
<Button x:Name="CloseButton" VerticalAlignment="Top" Width="23.51" Height="14.857" Content="" DockPanel.Dock="Right"/> |
|
||||||
<Button x:Name="MaximiseButton" VerticalAlignment="Top" Width="18.286" Height="14.857" Content="" DockPanel.Dock="Right"/> |
|
||||||
<Button x:Name="MinimizeButton" VerticalAlignment="Top" Width="18.286" Height="14.857" Content="" DockPanel.Dock="Right"/> |
|
||||||
<Label Margin="4,0,0,0" Content="{TemplateBinding Window.Title}"/> |
|
||||||
</DockPanel> |
|
||||||
<Border Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"> |
|
||||||
<Border |
|
||||||
BorderBrush="{TemplateBinding Border.BorderBrush}" |
|
||||||
BorderThickness="{TemplateBinding Border.BorderThickness}" |
|
||||||
Background="{TemplateBinding Panel.Background}"> |
|
||||||
<AdornerDecorator> |
|
||||||
<ContentPresenter |
|
||||||
ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" |
|
||||||
Content="{TemplateBinding ContentControl.Content}" /> |
|
||||||
</AdornerDecorator> |
|
||||||
</Border> |
|
||||||
</Border> |
|
||||||
</DockPanel> |
|
||||||
</Border> |
|
||||||
</ControlTemplate> |
|
||||||
</Setter.Value> |
|
||||||
</Setter> |
|
||||||
</Style> |
|
||||||
</ResourceDictionary> |
</ResourceDictionary> |
||||||
|
@ -0,0 +1,82 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Diagnostics; |
||||||
|
|
||||||
|
namespace ICSharpCode.WpfDesign.PropertyEditor |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// wraps a DesignItemDataProperty for the property editor/grid.
|
||||||
|
/// </summary>
|
||||||
|
sealed class DesignItemDataProperty : IPropertyEditorDataProperty |
||||||
|
{ |
||||||
|
readonly DesignItemDataSource ownerDataSource; |
||||||
|
readonly DesignItemProperty property; |
||||||
|
|
||||||
|
internal DesignItemDataProperty(DesignItemDataSource ownerDataSource, DesignItemProperty property) |
||||||
|
{ |
||||||
|
Debug.Assert(ownerDataSource != null); |
||||||
|
Debug.Assert(property != null); |
||||||
|
|
||||||
|
this.ownerDataSource = ownerDataSource; |
||||||
|
this.property = property; |
||||||
|
} |
||||||
|
|
||||||
|
public IPropertyEditorDataSource OwnerDataSource { |
||||||
|
get { return ownerDataSource; } |
||||||
|
} |
||||||
|
|
||||||
|
public string Category { |
||||||
|
get { return "Misc"; } |
||||||
|
} |
||||||
|
|
||||||
|
public string Name { |
||||||
|
get { return property.Name; } |
||||||
|
} |
||||||
|
|
||||||
|
public string Description { |
||||||
|
get { return "Description for " + property.Name; } |
||||||
|
} |
||||||
|
|
||||||
|
public bool IsSet { |
||||||
|
get { |
||||||
|
return property.IsSet; |
||||||
|
} |
||||||
|
set { |
||||||
|
if (value != property.IsSet) { |
||||||
|
if (value) { |
||||||
|
// copy default value to local value
|
||||||
|
property.SetValue(property.ValueOnInstance); |
||||||
|
} else { |
||||||
|
property.Reset(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public object Value { |
||||||
|
get { |
||||||
|
return property.ValueOnInstance; |
||||||
|
} |
||||||
|
set { |
||||||
|
property.SetValue(value); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public bool CanUseCustomExpression { |
||||||
|
get { |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void SetCustomExpression(string expression) |
||||||
|
{ |
||||||
|
throw new NotImplementedException(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,96 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.ComponentModel; |
||||||
|
using System.Windows; |
||||||
|
using System.Windows.Media; |
||||||
|
using System.Collections.Generic; |
||||||
|
|
||||||
|
namespace ICSharpCode.WpfDesign.PropertyEditor |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Implements IPropertyEditorDataSource accessing the properties on a DesignItem.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class DesignItemDataSource : IPropertyEditorDataSource |
||||||
|
{ |
||||||
|
readonly DesignItem item; |
||||||
|
readonly List<IPropertyEditorDataProperty> properties = new List<IPropertyEditorDataProperty>(); |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructs a new DesignItemDataSource for the specified design item.
|
||||||
|
/// </summary>
|
||||||
|
public DesignItemDataSource(DesignItem item) |
||||||
|
{ |
||||||
|
if (item == null) |
||||||
|
throw new ArgumentNullException("item"); |
||||||
|
this.item = item; |
||||||
|
|
||||||
|
List<DesignItemProperty> designItemProperties = new List<DesignItemProperty>(); |
||||||
|
foreach (PropertyDescriptor p in TypeDescriptor.GetProperties(item.Component)) { |
||||||
|
if (!p.IsBrowsable) continue; |
||||||
|
if (p.IsReadOnly) continue; |
||||||
|
if (p.Name.Contains(".")) continue; |
||||||
|
designItemProperties.Add(item.Properties[p.Name]); |
||||||
|
} |
||||||
|
designItemProperties.AddRange(item.Properties); |
||||||
|
|
||||||
|
foreach (DesignItemProperty p in Linq.Distinct(designItemProperties)) { |
||||||
|
properties.Add(new DesignItemDataProperty(this, p)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a data source for the specified design item.
|
||||||
|
/// This tries to get an existing data source instance (as behavior), or constructs a new
|
||||||
|
/// DesignItemDataSource instance if that fails.
|
||||||
|
/// </summary>
|
||||||
|
public static IPropertyEditorDataSource GetDataSourceForDesignItem(DesignItem item) |
||||||
|
{ |
||||||
|
return item.GetBehavior<IPropertyEditorDataSource>() ?? new DesignItemDataSource(item); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/// <summary>See <see cref="IPropertyEditorDataSource"/></summary>
|
||||||
|
public string Name { |
||||||
|
get { return item.Name ?? ""; } |
||||||
|
set { item.Name = value; } |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Is raised when the name of the design item changes.
|
||||||
|
/// </summary>
|
||||||
|
public event EventHandler NameChanged { |
||||||
|
add { item.NameChanged += value; } |
||||||
|
remove { item.NameChanged -= value; } |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>See <see cref="IPropertyEditorDataSource"/></summary>
|
||||||
|
public string Type { |
||||||
|
get { |
||||||
|
return item.Component.GetType().Name; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>See <see cref="IPropertyEditorDataSource"/></summary>
|
||||||
|
public ImageSource Icon { |
||||||
|
get { return null; } |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>See <see cref="IPropertyEditorDataSource"/></summary>
|
||||||
|
public ICollection<IPropertyEditorDataProperty> Properties { |
||||||
|
get { return properties; } |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>See <see cref="IPropertyEditorDataSource"/></summary>
|
||||||
|
public bool CanAddAttachedProperties { |
||||||
|
get { |
||||||
|
return item.Component is DependencyObject; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,92 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.ComponentModel; |
||||||
|
using System.Windows.Media; |
||||||
|
namespace ICSharpCode.WpfDesign.PropertyEditor |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Interface for data sources used by the property editor to display the list of properties.
|
||||||
|
/// </summary>
|
||||||
|
public interface IPropertyEditorDataSource |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Gets/Sets the name of the item. Returns null when the item does not support having a name.
|
||||||
|
/// </summary>
|
||||||
|
string Name { get; set; } |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the type of the item (for display only).
|
||||||
|
/// </summary>
|
||||||
|
string Type { get; } |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the icon of the item (for display only)
|
||||||
|
/// </summary>
|
||||||
|
ImageSource Icon { get; } |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the collection of properties.
|
||||||
|
/// </summary>
|
||||||
|
ICollection<IPropertyEditorDataProperty> Properties { get; } |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets if adding attached properties is supported.
|
||||||
|
/// </summary>
|
||||||
|
bool CanAddAttachedProperties { get; } |
||||||
|
} |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a property inside a <see cref="IPropertyEditorDataSource"/>.
|
||||||
|
/// </summary>
|
||||||
|
public interface IPropertyEditorDataProperty |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Gets the data source that own this property.
|
||||||
|
/// </summary>
|
||||||
|
IPropertyEditorDataSource OwnerDataSource { get; } |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the category this property uses.
|
||||||
|
/// </summary>
|
||||||
|
string Category { get; } |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the name of the property.
|
||||||
|
/// </summary>
|
||||||
|
string Name { get; } |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the description of the property.
|
||||||
|
/// </summary>
|
||||||
|
string Description { get; } |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets/Sets if the property has been assigned a local value.
|
||||||
|
/// Setting this property to false has the effect of resetting the value, setting it to true
|
||||||
|
/// copies the default value to a local value.
|
||||||
|
/// </summary>
|
||||||
|
bool IsSet { get; set; } |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets/Sets the value of the property.
|
||||||
|
/// </summary>
|
||||||
|
object Value { get; set; } |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets if using a custom expression is supported.
|
||||||
|
/// </summary>
|
||||||
|
bool CanUseCustomExpression { get; } |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets a custom expression.
|
||||||
|
/// </summary>
|
||||||
|
void SetCustomExpression(string expression); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
// <file>
|
||||||
|
// <copyright see="prj:///doc/copyright.txt"/>
|
||||||
|
// <license see="prj:///doc/license.txt"/>
|
||||||
|
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||||
|
// <version>$Revision$</version>
|
||||||
|
// </file>
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
|
||||||
|
namespace ICSharpCode.WpfDesign.PropertyEditor |
||||||
|
{ |
||||||
|
/* |
||||||
|
/// <summary>
|
||||||
|
/// Implements IPropertyEditorDataSource by combining the information from multiple data sources.
|
||||||
|
/// </summary>
|
||||||
|
public class MultiSelectionDataSource : IPropertyEditorDataSource |
||||||
|
{ |
||||||
|
readonly IPropertyEditorDataSource[] data; |
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new MultiSelectionDataSource instance.
|
||||||
|
/// </summary>
|
||||||
|
public MultiSelectionDataSource(ICollection<IPropertyEditorDataSource> sources) |
||||||
|
{ |
||||||
|
if (sources == null) |
||||||
|
throw new ArgumentNullException("sources"); |
||||||
|
data = Linq.ToArray(sources); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
*/ |
||||||
|
} |
Loading…
Reference in new issue