Browse Source

Add "IsSet" button to property grid.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2248 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
bc26b06010
  1. 71
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/DependencyPropertyDotButton.cs
  2. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyEditorCategoryView.cs
  3. 43
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyEditorStyles.xaml
  4. 13
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyGridView.cs
  5. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj

71
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/DependencyPropertyDotButton.cs

@ -0,0 +1,71 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using ICSharpCode.WpfDesign.PropertyEditor;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// The "dot" button appearing after dependency properties to specified advanced values like data bindings.
/// </summary>
public class DependencyPropertyDotButton : ButtonBase
{
/*
/// <summary>
/// Dependency property for <see cref="DataProperty"/>.
/// </summary>
public static readonly DependencyProperty DataPropertyProperty
= DependencyProperty.Register("DataProperty", typeof(IPropertyEditorDataProperty), typeof(DependencyPropertyDotButton));
*/
/// <summary>
/// Dependency property for <see cref="Checked"/>.
/// </summary>
public static readonly DependencyProperty CheckedProperty
= DependencyProperty.Register("Checked", typeof(bool), typeof(DependencyPropertyDotButton),
new FrameworkPropertyMetadata(false));
static DependencyPropertyDotButton()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(DependencyPropertyDotButton), new FrameworkPropertyMetadata(typeof(DependencyPropertyDotButton)));
}
/*
/// <summary>
/// Gets/Sets the property the button is used for.
/// </summary>
public IPropertyEditorDataProperty DataProperty {
get { return (IPropertyEditorDataProperty)GetValue(DataPropertyProperty); }
set { SetValue(DataPropertyProperty, value); }
}
*/
/// <summary>
/// Gets/Sets if the button looks checked.
/// </summary>
public bool Checked {
get { return (bool)GetValue(CheckedProperty); }
set { SetValue(CheckedProperty, value); }
}
/// <summary>
/// Fires the Click event and opens the context menu.
/// </summary>
protected override void OnClick()
{
base.OnClick();
if (ContextMenu != null) {
ContextMenu.IsOpen = true;
}
}
}
}

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

@ -14,7 +14,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
/// <summary> /// <summary>
/// Control used to view a property grid category. /// Control used to view a property grid category.
/// </summary> /// </summary>
public sealed class PropertyEditorCategoryView : HeaderedContentControl public sealed class PropertyEditorCategoryView : Expander
{ {
static PropertyEditorCategoryView() static PropertyEditorCategoryView()
{ {

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

@ -10,7 +10,12 @@
<Border Name="border" <Border Name="border"
Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
CornerRadius="10" Margin="1"> CornerRadius="10" Margin="1">
<Expander Name="expander" Header="{TemplateBinding Header}"> <Expander Name="expander" IsExpanded="{TemplateBinding IsExpanded}">
<Expander.Header>
<ContentControl Name="header" FontWeight="Bold"
Foreground="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"
Content="{TemplateBinding Header}"/>
</Expander.Header>
<Border Margin="10 0 2 2"> <Border Margin="10 0 2 2">
<ContentPresenter/> <ContentPresenter/>
</Border> </Border>
@ -21,6 +26,8 @@
<Trigger SourceName="expander" Property="IsExpanded" Value="True"> <Trigger SourceName="expander" Property="IsExpanded" Value="True">
<Setter TargetName="border" Property="Background" <Setter TargetName="border" Property="Background"
Value="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}"/> Value="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}"/>
<Setter TargetName="header" Property="Foreground"
Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
</Trigger> </Trigger>
</ControlTemplate.Triggers> </ControlTemplate.Triggers>
</ControlTemplate> </ControlTemplate>
@ -29,6 +36,38 @@
</Style> </Style>
<Style TargetType="{x:Type src:PropertyGridView}"> <Style TargetType="{x:Type src:PropertyGridView}">
</Style>
<Style TargetType="{x:Type src:DependencyPropertyDotButton}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Padding" Value="2"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type src:DependencyPropertyDotButton}">
<Border
BorderBrush="{TemplateBinding Border.BorderBrush}"
BorderThickness="{TemplateBinding Border.BorderThickness}"
Background="{TemplateBinding Panel.Background}"
SnapsToDevicePixels="True"
Padding="{TemplateBinding Control.Padding}">
<Border Name="hoverBorder" Width="12" Height="12"
BorderThickness="2" BorderBrush="Transparent" CornerRadius="2">
<Rectangle Name="rectangle"
Stroke="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"
Fill="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
</Border>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="hoverBorder" Property="BorderBrush" Value="#808080FF"/>
</Trigger>
<Trigger Property="Checked" Value="False">
<Setter TargetName="rectangle" Property="Fill" Value="Transparent"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style> </Style>
</ResourceDictionary> </ResourceDictionary>

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

@ -7,6 +7,7 @@
using System; using System;
using System.Windows; using System.Windows;
using System.Windows.Data;
using System.Windows.Controls; using System.Windows.Controls;
using ICSharpCode.WpfDesign.PropertyEditor; using ICSharpCode.WpfDesign.PropertyEditor;
@ -33,7 +34,7 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
this.ColumnDefinitions[0].Width = new GridLength(0.45, GridUnitType.Star); this.ColumnDefinitions[0].Width = new GridLength(0.45, GridUnitType.Star);
this.ColumnDefinitions[0].MinWidth = 40; this.ColumnDefinitions[0].MinWidth = 40;
this.ColumnDefinitions[1].Width = new GridLength(0.55, GridUnitType.Star); this.ColumnDefinitions[1].Width = new GridLength(0.55, GridUnitType.Star);
this.ColumnDefinitions[2].Width = new GridLength(10); this.ColumnDefinitions[2].Width = new GridLength(16);
} }
/// <summary> /// <summary>
@ -49,6 +50,16 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
SetRow(propertyNameLabel, this.RowDefinitions.Count - 1); SetRow(propertyNameLabel, this.RowDefinitions.Count - 1);
SetColumn(propertyNameLabel, 0); SetColumn(propertyNameLabel, 0);
this.Children.Add(propertyNameLabel); this.Children.Add(propertyNameLabel);
DependencyPropertyDotButton dotButton = new DependencyPropertyDotButton();
dotButton.VerticalAlignment = VerticalAlignment.Center;
dotButton.HorizontalAlignment = HorizontalAlignment.Center;
Binding binding = new Binding("IsSet");
binding.Source = property;
dotButton.SetBinding(DependencyPropertyDotButton.CheckedProperty, binding);
SetRow(dotButton, this.RowDefinitions.Count - 1);
SetColumn(dotButton, 2);
this.Children.Add(dotButton);
} }
} }
} }

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

@ -58,6 +58,7 @@
<Compile Include="Configuration\AssemblyInfo.cs" /> <Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Controls\AdornerLayer.cs" /> <Compile Include="Controls\AdornerLayer.cs" />
<Compile Include="Controls\ContainerDragHandle.cs" /> <Compile Include="Controls\ContainerDragHandle.cs" />
<Compile Include="Controls\PropertyEditor\DependencyPropertyDotButton.cs" />
<Compile Include="Controls\PropertyEditor\PropertyEditor.cs" /> <Compile Include="Controls\PropertyEditor\PropertyEditor.cs" />
<Compile Include="Controls\PropertyEditor\PropertyEditorCategoryView.cs" /> <Compile Include="Controls\PropertyEditor\PropertyEditorCategoryView.cs" />
<Compile Include="Controls\PropertyEditor\PropertyGridView.cs" /> <Compile Include="Controls\PropertyEditor\PropertyGridView.cs" />

Loading…
Cancel
Save