Browse Source

replace some icons in WPF designer with icons suggested by Michael Seeger

pull/55/merge
Siegfried Pammer 13 years ago
parent
commit
3e62472120
  1. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.Properties.Categorized.png
  2. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.Properties.Events.png
  3. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.Properties.Properties.png
  4. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.Properties.SortAlphabet.png
  5. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.WpfOutline.Eye.png
  6. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.WpfOutline.EyeClose.png
  7. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/events.png
  8. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/eye_watch.png
  9. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/group.png
  10. 15
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/license.txt
  11. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/properties.png
  12. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/sort.png
  13. 6
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml
  14. 8
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.xaml
  15. 15
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
  16. 820
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/PropertyNode.cs

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.Properties.Categorized.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.Properties.Events.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.Properties.Properties.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.Properties.SortAlphabet.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 571 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.WpfOutline.Eye.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.WpfOutline.EyeClose.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 573 B

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 258 B

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 573 B

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 204 B

15
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/license.txt

@ -4,4 +4,17 @@ License: Creative Commons Attribution 3.0 License
http://p.yusukekamiyamane.com/ http://p.yusukekamiyamane.com/
Icons created by the SharpDevelop Team: Icons created by the SharpDevelop Team:
Class.png Class.png
Copied from the Fugue Icon Library and left unmodified:
- Icons.16x16.Properties.Events.png
- Icons.16x16.Properties.SortAlphabet.png
- Icons.16x16.WpfOutline.Eye.png
- Icons.16x16.WpfOutline.EyeClosed.png
Copied from the Fugue Icon Library and modified or mashed up with other Fugue
Icons or parts taken from them:
- Icons.16x16.Properties.Properties.png
- Icons.16x16.Properties.Categorized.png

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 178 B

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 288 B

6
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml

@ -18,7 +18,7 @@
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="eye" Storyboard.TargetProperty="(UIElement.Visibility)"> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="eye" Storyboard.TargetProperty="(UIElement.Visibility)">
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Visible}"/> <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Visible}"/>
</ObjectAnimationUsingKeyFrames> </ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="circle" Storyboard.TargetProperty="(UIElement.Visibility)"> <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="closed_eye" Storyboard.TargetProperty="(UIElement.Visibility)">
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Collapsed}"/> <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Collapsed}"/>
</ObjectAnimationUsingKeyFrames> </ObjectAnimationUsingKeyFrames>
</Storyboard> </Storyboard>
@ -26,8 +26,8 @@
<VisualState x:Name="Unchecked"/> <VisualState x:Name="Unchecked"/>
</VisualStateGroup> </VisualStateGroup>
</VisualStateManager.VisualStateGroups> </VisualStateManager.VisualStateGroups>
<Image x:Name="eye" Stretch="Uniform" Visibility="Hidden" Source="pack://application:,,,/ICSharpCode.WpfDesign.Designer;component/Images/eye_watch.png" /> <Image x:Name="eye" Stretch="None" Visibility="Hidden" Source="pack://application:,,,/ICSharpCode.WpfDesign.Designer;component/Images/Icons.16x16.WpfOutline.Eye.png" />
<Ellipse Width="6" Height="6" Stroke="Black" StrokeThickness="1" x:Name="circle" /> <Image x:Name="closed_eye" Stretch="None" Source="pack://application:,,,/ICSharpCode.WpfDesign.Designer;component/Images/Icons.16x16.WpfOutline.EyeClose.png" />
</Grid> </Grid>
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>

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

@ -191,21 +191,21 @@
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<StackPanel Margin="3" HorizontalAlignment="Left" Orientation="Horizontal"> <StackPanel Margin="3" HorizontalAlignment="Left" Orientation="Horizontal">
<RadioButton Style="{StaticResource SelectedImageButton}" GroupName="SortMode" IsChecked="{Binding GroupMode, Converter={x:Static Converters:EnumBoolean.Instance}, ConverterParameter=GroupByPopularCategorys}" Margin="3,0,0,0" Width="20" Height="20"> <RadioButton Style="{StaticResource SelectedImageButton}" GroupName="SortMode" IsChecked="{Binding GroupMode, Converter={x:Static Converters:EnumBoolean.Instance}, ConverterParameter=GroupByPopularCategorys}" Margin="3,0,0,0" Width="20" Height="20">
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/group.png" Stretch="None" /> <Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/Icons.16x16.Properties.Categorized.png" Stretch="None" />
</RadioButton> </RadioButton>
<!--<RadioButton Style="{StaticResource SelectedImageButton}" GroupName="SortMode" IsChecked="{Binding GroupMode, Converter={x:Static Converters:EnumBoolean.Instance}, ConverterParameter=GroupByCategorys}" Margin="3,0,0,0" Width="20" Height="20"> <!--<RadioButton Style="{StaticResource SelectedImageButton}" GroupName="SortMode" IsChecked="{Binding GroupMode, Converter={x:Static Converters:EnumBoolean.Instance}, ConverterParameter=GroupByCategorys}" Margin="3,0,0,0" Width="20" Height="20">
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/group2.png" Stretch="None" /> <Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/group2.png" Stretch="None" />
</RadioButton> </RadioButton>
<RadioButton Style="{StaticResource SelectedImageButton}" GroupName="SortMode" IsChecked="{Binding GroupMode, Converter={x:Static Converters:EnumBoolean.Instance}, ConverterParameter=Ungrouped}" Margin="3,0,0,0" Width="20" Height="20"> <RadioButton Style="{StaticResource SelectedImageButton}" GroupName="SortMode" IsChecked="{Binding GroupMode, Converter={x:Static Converters:EnumBoolean.Instance}, ConverterParameter=Ungrouped}" Margin="3,0,0,0" Width="20" Height="20">
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/sort.png" Stretch="None" /> <Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/Icons.16x16.Properties.SortAlphabet.png" Stretch="None" />
</RadioButton>--> </RadioButton>-->
</StackPanel> </StackPanel>
<StackPanel Margin="3" HorizontalAlignment="Left" Orientation="Horizontal" Visibility="{Binding ShowPropertiesEventsSelector, Converter={x:Static Converters:CollapsedWhenFalse.Instance}, ElementName=root}"> <StackPanel Margin="3" HorizontalAlignment="Left" Orientation="Horizontal" Visibility="{Binding ShowPropertiesEventsSelector, Converter={x:Static Converters:CollapsedWhenFalse.Instance}, ElementName=root}">
<RadioButton Style="{StaticResource SelectedImageButton}" GroupName="ShowType" IsChecked="{Binding CurrentTab, Converter={x:Static Converters:EnumBoolean.Instance}, ConverterParameter=Properties}" Margin="3,0,0,0" Width="20" Height="20"> <RadioButton Style="{StaticResource SelectedImageButton}" GroupName="ShowType" IsChecked="{Binding CurrentTab, Converter={x:Static Converters:EnumBoolean.Instance}, ConverterParameter=Properties}" Margin="3,0,0,0" Width="20" Height="20">
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/properties.png" Stretch="None" /> <Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/Icons.16x16.Properties.Properties.png" Stretch="None" />
</RadioButton> </RadioButton>
<RadioButton Style="{StaticResource SelectedImageButton}" GroupName="ShowType" IsChecked="{Binding CurrentTab, Converter={x:Static Converters:EnumBoolean.Instance}, ConverterParameter=Events}" Margin="3,0,0,0" Width="20" Height="20"> <RadioButton Style="{StaticResource SelectedImageButton}" GroupName="ShowType" IsChecked="{Binding CurrentTab, Converter={x:Static Converters:EnumBoolean.Instance}, ConverterParameter=Events}" Margin="3,0,0,0" Width="20" Height="20">
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/events.png" Stretch="None" /> <Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/Icons.16x16.Properties.Events.png" Stretch="None" />
</RadioButton> </RadioButton>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>

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

@ -334,9 +334,6 @@
<Resource Include="Images\ZoomIn.png" /> <Resource Include="Images\ZoomIn.png" />
<Resource Include="Images\ZoomOut.png" /> <Resource Include="Images\ZoomOut.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Resource Include="Images\eye_watch.png" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<CodeAnalysisDictionary Include="Configuration\CodeAnalysisDictionary.xml" /> <CodeAnalysisDictionary Include="Configuration\CodeAnalysisDictionary.xml" />
</ItemGroup> </ItemGroup>
@ -348,13 +345,17 @@
<Resource Include="Images\rotate.cur" /> <Resource Include="Images\rotate.cur" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Resource Include="Images\events.png" />
<Resource Include="Images\group.png" />
<Resource Include="Images\group2.png" /> <Resource Include="Images\group2.png" />
<Resource Include="Images\properties.png" />
<Resource Include="Images\sort.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="ThumbnailView" /> <Folder Include="ThumbnailView" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Resource Include="Images\Icons.16x16.Properties.Events.png" />
<Resource Include="Images\Icons.16x16.WpfOutline.Eye.png" />
<Resource Include="Images\Icons.16x16.WpfOutline.EyeClose.png" />
<Resource Include="Images\Icons.16x16.Properties.Categorized.png" />
<Resource Include="Images\Icons.16x16.Properties.Properties.png" />
<Resource Include="Images\Icons.16x16.Properties.SortAlphabet.png" />
</ItemGroup>
</Project> </Project>

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

@ -1,42 +1,42 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.ComponentModel; using System.ComponentModel;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Windows.Data; using System.Windows.Data;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Markup; using System.Windows.Markup;
namespace ICSharpCode.WpfDesign.PropertyGrid namespace ICSharpCode.WpfDesign.PropertyGrid
{ {
/// <summary> /// <summary>
/// View-Model class for the property grid. /// View-Model class for the property grid.
/// </summary> /// </summary>
public class PropertyNode : INotifyPropertyChanged public class PropertyNode : INotifyPropertyChanged
{ {
static object Unset = new object(); static object Unset = new object();
/// <summary> /// <summary>
/// Gets the properties that are presented by this node. /// Gets the properties that are presented by this node.
/// This might be multiple properties if multiple controls are selected. /// This might be multiple properties if multiple controls are selected.
/// </summary> /// </summary>
public ReadOnlyCollection<DesignItemProperty> Properties { get; private set; } public ReadOnlyCollection<DesignItemProperty> Properties { get; private set; }
bool raiseEvents = true; bool raiseEvents = true;
bool hasStringConverter; bool hasStringConverter;
/// <summary> /// <summary>
/// Gets the name of the property. /// Gets the name of the property.
/// </summary> /// </summary>
public string Name public string Name
{ {
get get
{ {
var dp = FirstProperty.DependencyProperty; var dp = FirstProperty.DependencyProperty;
if (dp != null) if (dp != null)
@ -47,374 +47,374 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
// Will return the attached property name in the form of <DeclaringType>.<PropertyName> // Will return the attached property name in the form of <DeclaringType>.<PropertyName>
return dpd.Name; return dpd.Name;
} }
} }
return FirstProperty.Name; return FirstProperty.Name;
} }
} }
/// <summary> /// <summary>
/// Gets if this property node represents an event. /// Gets if this property node represents an event.
/// </summary> /// </summary>
public bool IsEvent { get { return FirstProperty.IsEvent; } } public bool IsEvent { get { return FirstProperty.IsEvent; } }
/// <summary> /// <summary>
/// Gets the design context associated with this set of properties. /// Gets the design context associated with this set of properties.
/// </summary> /// </summary>
public DesignContext Context { get { return FirstProperty.DesignItem.Context; } } public DesignContext Context { get { return FirstProperty.DesignItem.Context; } }
/// <summary> /// <summary>
/// Gets the service container associated with this set of properties. /// Gets the service container associated with this set of properties.
/// </summary> /// </summary>
public ServiceContainer Services { get { return FirstProperty.DesignItem.Services; } } public ServiceContainer Services { get { return FirstProperty.DesignItem.Services; } }
/// <summary> /// <summary>
/// Gets the editor control that edits this property. /// Gets the editor control that edits this property.
/// </summary> /// </summary>
public FrameworkElement Editor { get; private set; } public FrameworkElement Editor { get; private set; }
/// <summary> /// <summary>
/// Gets the first property (equivalent to Properties[0]) /// Gets the first property (equivalent to Properties[0])
/// </summary> /// </summary>
public DesignItemProperty FirstProperty { get { return Properties[0]; } } public DesignItemProperty FirstProperty { get { return Properties[0]; } }
/// <summary> /// <summary>
/// For nested property nodes, gets the parent node. /// For nested property nodes, gets the parent node.
/// </summary> /// </summary>
public PropertyNode Parent { get; private set; } public PropertyNode Parent { get; private set; }
/// <summary> /// <summary>
/// For nested property nodes, gets the level of this node. /// For nested property nodes, gets the level of this node.
/// </summary> /// </summary>
public int Level { get; private set; } public int Level { get; private set; }
/// <summary> /// <summary>
/// Gets the category of this node. /// Gets the category of this node.
/// </summary> /// </summary>
public Category Category { get; set; } public Category Category { get; set; }
/// <summary> /// <summary>
/// Gets the list of child nodes. /// Gets the list of child nodes.
/// </summary> /// </summary>
public ObservableCollection<PropertyNode> Children { get; private set; } public ObservableCollection<PropertyNode> Children { get; private set; }
/// <summary> /// <summary>
/// Gets the list of advanced child nodes (not visible by default). /// Gets the list of advanced child nodes (not visible by default).
/// </summary> /// </summary>
public ObservableCollection<PropertyNode> MoreChildren { get; private set; } public ObservableCollection<PropertyNode> MoreChildren { get; private set; }
bool isExpanded; bool isExpanded;
/// <summary> /// <summary>
/// Gets whether this property node is currently expanded. /// Gets whether this property node is currently expanded.
/// </summary> /// </summary>
public bool IsExpanded { public bool IsExpanded {
get { get {
return isExpanded; return isExpanded;
} }
set { set {
isExpanded = value; isExpanded = value;
UpdateChildren(); UpdateChildren();
RaisePropertyChanged("IsExpanded"); RaisePropertyChanged("IsExpanded");
} }
} }
/// <summary> /// <summary>
/// Gets whether this property node has children. /// Gets whether this property node has children.
/// </summary> /// </summary>
public bool HasChildren { public bool HasChildren {
get { return Children.Count > 0 || MoreChildren.Count > 0; } get { return Children.Count > 0 || MoreChildren.Count > 0; }
} }
/// <summary> /// <summary>
/// Gets the description object using the IPropertyDescriptionService. /// Gets the description object using the IPropertyDescriptionService.
/// </summary> /// </summary>
public object Description { public object Description {
get { get {
IPropertyDescriptionService s = Services.GetService<IPropertyDescriptionService>(); IPropertyDescriptionService s = Services.GetService<IPropertyDescriptionService>();
if (s != null) { if (s != null) {
return s.GetDescription(FirstProperty); return s.GetDescription(FirstProperty);
} }
return null; return null;
} }
} }
/// <summary> /// <summary>
/// Gets/Sets the value of this property. /// Gets/Sets the value of this property.
/// </summary> /// </summary>
public object Value { public object Value {
get { get {
if (IsAmbiguous) return null; if (IsAmbiguous) return null;
var result = FirstProperty.ValueOnInstance; var result = FirstProperty.ValueOnInstance;
if (result == DependencyProperty.UnsetValue) return null; if (result == DependencyProperty.UnsetValue) return null;
return result; return result;
} }
set { set {
SetValueCore(value); SetValueCore(value);
} }
} }
/// <summary> /// <summary>
/// Gets/Sets the value of this property in string form /// Gets/Sets the value of this property in string form
/// </summary> /// </summary>
public string ValueString { public string ValueString {
get { get {
if (ValueItem == null || ValueItem.Component is MarkupExtension) { if (ValueItem == null || ValueItem.Component is MarkupExtension) {
if (Value == null) return null; if (Value == null) return null;
if (hasStringConverter) { if (hasStringConverter) {
return FirstProperty.TypeConverter.ConvertToInvariantString(Value); return FirstProperty.TypeConverter.ConvertToInvariantString(Value);
} }
return "(" + Value.GetType().Name + ")"; return "(" + Value.GetType().Name + ")";
} }
return "(" + ValueItem.ComponentType.Name + ")"; return "(" + ValueItem.ComponentType.Name + ")";
} }
set { set {
// make sure we only catch specific exceptions // make sure we only catch specific exceptions
// and/or show the error message to the user // and/or show the error message to the user
//try { //try {
Value = FirstProperty.TypeConverter.ConvertFromInvariantString(value); Value = FirstProperty.TypeConverter.ConvertFromInvariantString(value);
//} catch { //} catch {
// OnValueOnInstanceChanged(); // OnValueOnInstanceChanged();
//} //}
} }
} }
/// <summary> /// <summary>
/// Gets whether the property node is enabled for editing. /// Gets whether the property node is enabled for editing.
/// </summary> /// </summary>
public bool IsEnabled { public bool IsEnabled {
get { get {
return ValueItem == null && hasStringConverter; return ValueItem == null && hasStringConverter;
} }
} }
/// <summary> /// <summary>
/// Gets whether this property was set locally. /// Gets whether this property was set locally.
/// </summary> /// </summary>
public bool IsSet { public bool IsSet {
get { get {
foreach (var p in Properties) { foreach (var p in Properties) {
if (p.IsSet) return true; if (p.IsSet) return true;
} }
return false; return false;
} }
} }
/// <summary> /// <summary>
/// Gets the color of the name. /// Gets the color of the name.
/// Depends on the type of the value (binding/resource/etc.) /// Depends on the type of the value (binding/resource/etc.)
/// </summary> /// </summary>
public Brush NameForeground { public Brush NameForeground {
get { get {
if (ValueItem != null) { if (ValueItem != null) {
object component = ValueItem.Component; object component = ValueItem.Component;
if (component is BindingBase) if (component is BindingBase)
return Brushes.DarkGoldenrod; return Brushes.DarkGoldenrod;
if (component is StaticResourceExtension || component is DynamicResourceExtension) if (component is StaticResourceExtension || component is DynamicResourceExtension)
return Brushes.DarkGreen; return Brushes.DarkGreen;
} }
return SystemColors.WindowTextBrush; return SystemColors.WindowTextBrush;
} }
} }
/// <summary> /// <summary>
/// Returns the DesignItem that owns the property (= the DesignItem that is currently selected). /// Returns the DesignItem that owns the property (= the DesignItem that is currently selected).
/// Returns null if multiple DesignItems are selected. /// Returns null if multiple DesignItems are selected.
/// </summary> /// </summary>
public DesignItem ValueItem { public DesignItem ValueItem {
get { get {
if (Properties.Count == 1) { if (Properties.Count == 1) {
return FirstProperty.Value; return FirstProperty.Value;
} }
return null; return null;
} }
} }
/// <summary> /// <summary>
/// Gets whether the property value is ambiguous (multiple controls having different values are selected). /// Gets whether the property value is ambiguous (multiple controls having different values are selected).
/// </summary> /// </summary>
public bool IsAmbiguous { public bool IsAmbiguous {
get { get {
foreach (var p in Properties) { foreach (var p in Properties) {
if (!object.Equals(p.ValueOnInstance, FirstProperty.ValueOnInstance)) { if (!object.Equals(p.ValueOnInstance, FirstProperty.ValueOnInstance)) {
return true; return true;
} }
} }
return false; return false;
} }
} }
bool isVisible; bool isVisible;
/// <summary> /// <summary>
/// Gets/Sets whether the property is visible. /// Gets/Sets whether the property is visible.
/// </summary> /// </summary>
public bool IsVisible { public bool IsVisible {
get { get {
return isVisible; return isVisible;
} }
set { set {
isVisible = value; isVisible = value;
RaisePropertyChanged("IsVisible"); RaisePropertyChanged("IsVisible");
} }
} }
/// <summary> /// <summary>
/// Gets whether resetting the property is possible. /// Gets whether resetting the property is possible.
/// </summary> /// </summary>
public bool CanReset { public bool CanReset {
get { return IsSet; } get { return IsSet; }
} }
/// <summary> /// <summary>
/// Resets the property. /// Resets the property.
/// </summary> /// </summary>
public void Reset() public void Reset()
{ {
SetValueCore(Unset); SetValueCore(Unset);
} }
/// <summary> /// <summary>
/// Replaces the value of this node with a new binding. /// Replaces the value of this node with a new binding.
/// </summary> /// </summary>
public void CreateBinding() public void CreateBinding()
{ {
Value = new Binding(); Value = new Binding();
IsExpanded = true; IsExpanded = true;
} }
void SetValueCore(object value) void SetValueCore(object value)
{ {
raiseEvents = false; raiseEvents = false;
if (value == Unset) { if (value == Unset) {
foreach (var p in Properties) { foreach (var p in Properties) {
p.Reset(); p.Reset();
} }
} else { } else {
foreach (var p in Properties) { foreach (var p in Properties) {
p.SetValue(value); p.SetValue(value);
} }
} }
raiseEvents = true; raiseEvents = true;
OnValueChanged(); OnValueChanged();
} }
void OnValueChanged() void OnValueChanged()
{ {
RaisePropertyChanged("IsSet"); RaisePropertyChanged("IsSet");
RaisePropertyChanged("Value"); RaisePropertyChanged("Value");
RaisePropertyChanged("ValueString"); RaisePropertyChanged("ValueString");
RaisePropertyChanged("IsAmbiguous"); RaisePropertyChanged("IsAmbiguous");
RaisePropertyChanged("FontWeight"); RaisePropertyChanged("FontWeight");
RaisePropertyChanged("IsEnabled"); RaisePropertyChanged("IsEnabled");
RaisePropertyChanged("NameForeground"); RaisePropertyChanged("NameForeground");
UpdateChildren(); UpdateChildren();
} }
void OnValueOnInstanceChanged() void OnValueOnInstanceChanged()
{ {
RaisePropertyChanged("Value"); RaisePropertyChanged("Value");
RaisePropertyChanged("ValueString"); RaisePropertyChanged("ValueString");
} }
/// <summary> /// <summary>
/// Creates a new PropertyNode instance. /// Creates a new PropertyNode instance.
/// </summary> /// </summary>
public PropertyNode() public PropertyNode()
{ {
Children = new ObservableCollection<PropertyNode>(); Children = new ObservableCollection<PropertyNode>();
MoreChildren = new ObservableCollection<PropertyNode>(); MoreChildren = new ObservableCollection<PropertyNode>();
} }
PropertyNode(DesignItemProperty[] properties, PropertyNode parent) : this() PropertyNode(DesignItemProperty[] properties, PropertyNode parent) : this()
{ {
this.Parent = parent; this.Parent = parent;
this.Level = parent == null ? 0 : parent.Level + 1; this.Level = parent == null ? 0 : parent.Level + 1;
Load(properties); Load(properties);
} }
/// <summary> /// <summary>
/// Initializes this property node with the specified properties. /// Initializes this property node with the specified properties.
/// </summary> /// </summary>
public void Load(DesignItemProperty[] properties) public void Load(DesignItemProperty[] properties)
{ {
if (this.Properties != null) { if (this.Properties != null) {
// detach events from old properties // detach events from old properties
foreach (var property in this.Properties) { foreach (var property in this.Properties) {
property.ValueChanged -= new EventHandler(property_ValueChanged); property.ValueChanged -= new EventHandler(property_ValueChanged);
property.ValueOnInstanceChanged -= new EventHandler(property_ValueOnInstanceChanged); property.ValueOnInstanceChanged -= new EventHandler(property_ValueOnInstanceChanged);
} }
} }
this.Properties = new ReadOnlyCollection<DesignItemProperty>(properties); this.Properties = new ReadOnlyCollection<DesignItemProperty>(properties);
if (Editor == null) if (Editor == null)
Editor = EditorManager.CreateEditor(FirstProperty); Editor = EditorManager.CreateEditor(FirstProperty);
foreach (var property in properties) { foreach (var property in properties) {
property.ValueChanged += new EventHandler(property_ValueChanged); property.ValueChanged += new EventHandler(property_ValueChanged);
property.ValueOnInstanceChanged += new EventHandler(property_ValueOnInstanceChanged); property.ValueOnInstanceChanged += new EventHandler(property_ValueOnInstanceChanged);
} }
hasStringConverter = hasStringConverter =
FirstProperty.TypeConverter.CanConvertFrom(typeof(string)) && FirstProperty.TypeConverter.CanConvertFrom(typeof(string)) &&
FirstProperty.TypeConverter.CanConvertTo(typeof(string)); FirstProperty.TypeConverter.CanConvertTo(typeof(string));
OnValueChanged(); OnValueChanged();
} }
void property_ValueOnInstanceChanged(object sender, EventArgs e) void property_ValueOnInstanceChanged(object sender, EventArgs e)
{ {
if (raiseEvents) OnValueOnInstanceChanged(); if (raiseEvents) OnValueOnInstanceChanged();
} }
void property_ValueChanged(object sender, EventArgs e) void property_ValueChanged(object sender, EventArgs e)
{ {
if (raiseEvents) OnValueChanged(); if (raiseEvents) OnValueChanged();
} }
void UpdateChildren() void UpdateChildren()
{ {
Children.Clear(); Children.Clear();
MoreChildren.Clear(); MoreChildren.Clear();
if (Parent == null || Parent.IsExpanded) { if (Parent == null || Parent.IsExpanded) {
if (ValueItem != null) { if (ValueItem != null) {
var list = TypeHelper.GetAvailableProperties(ValueItem.Component) var list = TypeHelper.GetAvailableProperties(ValueItem.Component)
.OrderBy(d => d.Name) .OrderBy(d => d.Name)
.Select(d => new PropertyNode(new[] { ValueItem.Properties.GetProperty(d) }, this)); .Select(d => new PropertyNode(new[] { ValueItem.Properties.GetProperty(d) }, this));
foreach (var node in list) { foreach (var node in list) {
if (Metadata.IsBrowsable(node.FirstProperty)) { if (Metadata.IsBrowsable(node.FirstProperty)) {
node.IsVisible = true; node.IsVisible = true;
if (Metadata.IsPopularProperty(node.FirstProperty)) { if (Metadata.IsPopularProperty(node.FirstProperty)) {
Children.Add(node); Children.Add(node);
} else { } else {
MoreChildren.Add(node); MoreChildren.Add(node);
} }
} }
} }
} }
} }
RaisePropertyChanged("HasChildren"); RaisePropertyChanged("HasChildren");
} }
#region INotifyPropertyChanged Members #region INotifyPropertyChanged Members
/// <summary> /// <summary>
/// Occurs when a property has changed. Used to support WPF data binding. /// Occurs when a property has changed. Used to support WPF data binding.
/// </summary> /// </summary>
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
void RaisePropertyChanged(string name) void RaisePropertyChanged(string name)
{ {
if (PropertyChanged != null) { if (PropertyChanged != null) {
PropertyChanged(this, new PropertyChangedEventArgs(name)); PropertyChanged(this, new PropertyChangedEventArgs(name));
} }
} }
#endregion #endregion
} }
} }

Loading…
Cancel
Save