Browse Source

Support to hide Controls from the OutlineView.

pull/52/head
jkuehner 12 years ago
parent
commit
6ea7511873
  1. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/eye_watch.png
  2. 34
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml
  3. 31
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs
  4. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineView.xaml
  5. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 573 B

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

@ -6,10 +6,40 @@ @@ -6,10 +6,40 @@
<UserControl.Resources>
<Style TargetType="ToggleButton" x:Key="eyeStyle">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
<Grid Background="Transparent" IsHitTestVisible="True">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CheckStates">
<VisualState x:Name="Checked">
<Storyboard>
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="eye" Storyboard.TargetProperty="(UIElement.Visibility)">
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Visible}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="circle" Storyboard.TargetProperty="(UIElement.Visibility)">
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Collapsed}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Unchecked"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Image x:Name="eye" Stretch="Uniform" Visibility="Hidden" Source="pack://application:,,,/ICSharpCode.WpfDesign.Designer;component/Images/eye_watch.png" />
<Ellipse Width="6" Height="6" Stroke="Black" StrokeThickness="1" x:Name="circle" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<HierarchicalDataTemplate DataType="{x:Type Default:OutlineNode}"
ItemsSource="{Binding Children}">
<Default:IconItem Icon="../Images/Tag.png"
Text="{Binding Name}" />
<DockPanel>
<ToggleButton Style="{StaticResource eyeStyle}" DockPanel.Dock="Right" Width="20" Margin="0,0,5,0" IsChecked="{Binding IsDesignTimeVisible}" />
<Default:IconItem Icon="../Images/Tag.png" Text="{Binding Name}" />
</DockPanel>
</HierarchicalDataTemplate>
</UserControl.Resources>

31
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs

@ -11,6 +11,9 @@ using System.Collections.ObjectModel; @@ -11,6 +11,9 @@ using System.Collections.ObjectModel;
using System.Collections;
using ICSharpCode.WpfDesign.Designer;
using ICSharpCode.WpfDesign.XamlDom;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace ICSharpCode.WpfDesign.Designer.OutlineView
{
@ -41,6 +44,12 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView @@ -41,6 +44,12 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
DesignItem = designItem;
UpdateChildren();
var hidden = designItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).ValueOnInstance;
if (hidden != null && (bool) hidden == true) {
this._isDesignTimeVisible = false;
((FrameworkElement) this.DesignItem.Component).Visibility = Visibility.Hidden;
}
//TODO
DesignItem.NameChanged += new EventHandler(DesignItem_NameChanged);
DesignItem.PropertyChanged += new PropertyChangedEventHandler(DesignItem_PropertyChanged);
@ -80,6 +89,28 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView @@ -80,6 +89,28 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
}
}
}
bool _isDesignTimeVisible = true;
public bool IsDesignTimeVisible
{
get {
return _isDesignTimeVisible;
}
set {
_isDesignTimeVisible = value;
var ctl = DesignItem.Component as UIElement;
ctl.Visibility = _isDesignTimeVisible ? Visibility.Visible : Visibility.Hidden;
RaisePropertyChanged("IsDesignTimeVisible");
if (!value)
DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).SetValue(true);
else
DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).Reset();
}
}
ObservableCollection<OutlineNode> children = new ObservableCollection<OutlineNode>();

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineView.xaml

@ -107,7 +107,7 @@ @@ -107,7 +107,7 @@
Margin="{TemplateBinding Level, Converter={StaticResource LevelConverter}}"
IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" />
<Border x:Name="contentBorder"
HorizontalAlignment="Left">
HorizontalAlignment="Stretch">
<ContentPresenter x:Name="PART_Header"
ContentSource="Header" />
</Border>

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

@ -323,6 +323,9 @@ @@ -323,6 +323,9 @@
<Resource Include="Images\ZoomIn.png" />
<Resource Include="Images\ZoomOut.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\eye_watch.png" />
</ItemGroup>
<ItemGroup>
<CodeAnalysisDictionary Include="Configuration\CodeAnalysisDictionary.xml" />
</ItemGroup>

Loading…
Cancel
Save