Browse Source

Split ContextActionsControl into 2 user controls: the TreeView and the Header.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@6165 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Martin Koníček 16 years ago
parent
commit
b2c80c66bb
  1. 9
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActionsRenderer.cs
  2. 5
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  3. 148
      src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsControl.xaml
  4. 2
      src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsControl.xaml.cs
  5. 38
      src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsHeaderedControl.xaml
  6. 41
      src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsHeaderedControl.xaml.cs
  7. 10
      src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsPopup.cs
  8. 4
      src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsViewModel.cs

9
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActionsRenderer.cs

@ -62,7 +62,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -62,7 +62,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
return;
this.popup.Actions = new ContextActionsViewModel {
Title = "Actions",
Title = "A",
Actions = availableActionsVM
};
this.popup.OpenAtLineStart(this.Editor);
@ -70,8 +70,11 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -70,8 +70,11 @@ namespace ICSharpCode.AvalonEdit.AddIn
void CaretPositionChanged(object sender, EventArgs e)
{
this.popup.Close();
this.popup.Actions = null;
if (this.popup.IsOpen)
{
this.popup.Close();
this.popup.Actions = null;
}
this.delayMoveTimer.Stop();
this.delayMoveTimer.Start();
}

5
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -330,6 +330,10 @@ @@ -330,6 +330,10 @@
<Compile Include="Src\Services\ParserService\ParserService.cs" />
<Compile Include="Src\Services\ProjectService\CompileModifiedProjectsOnly.cs" />
<Compile Include="Src\Services\ProjectService\SolutionConfigurationEventHandler.cs" />
<Compile Include="Src\Services\RefactoringService\ContextActions\ContextActionsHeaderedControl.xaml.cs">
<DependentUpon>ContextActionsHeaderedControl.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Src\Services\RefactoringService\ContextActions\IContextAction.cs" />
<Compile Include="Src\Services\RefactoringService\ContextActions\ContextActionCommand.cs" />
<Compile Include="Src\Services\RefactoringService\ContextActions\ContextActionsControl.xaml.cs">
@ -786,6 +790,7 @@ @@ -786,6 +790,7 @@
</ItemGroup>
<ItemGroup>
<Page Include="Src\Services\RefactoringService\ContextActions\ContextActionsControl.xaml" />
<Page Include="Src\Services\RefactoringService\ContextActions\ContextActionsHeaderedControl.xaml" />
<ProjectReference Include="..\..\..\Libraries\AvalonDock\AvalonDock\AvalonDock.csproj">
<Project>{2FF700C2-A38A-48BD-A637-8CAFD4FE6237}</Project>
<Name>AvalonDock</Name>

148
src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsControl.xaml

@ -6,6 +6,8 @@ @@ -6,6 +6,8 @@
xmlns:s="clr-namespace:System;assembly=mscorlib"
xmlns:aero="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero">
<!--ContextActionsControl accepts IEnumerable<ContextActionViewModel> as its DataContext.-->
<UserControl.Resources>
<SolidColorBrush x:Key="OuterBorderBrush" Color="#436C82"></SolidColorBrush>
@ -49,92 +51,66 @@ @@ -49,92 +51,66 @@
</Setter>
</Style>
</UserControl.Resources>
<Grid Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<!-- Header -->
<Border Grid.Row="0" Grid.Column="0" Padding="4" BorderThickness="1 1 1 0"
BorderBrush="{StaticResource OuterBorderBrush}" HorizontalAlignment="Left">
<Border.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#D6E9FF" Offset="0"/>
<GradientStop Color="#A3CEFF" Offset="0.5"/>
<Border Padding="0 0 8 8">
<aero:SystemDropShadowChrome>
<Border BorderThickness="1" BorderBrush="{StaticResource OuterBorderBrush}" HorizontalAlignment="Stretch">
<TreeView ItemsSource="{Binding}" x:Name="TreeView">
<TreeView.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
<GradientStop Color="White"/>
</LinearGradientBrush>
</Border.Background>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding Image}"></Image>
<TextBlock Text="{Binding Title}"></TextBlock>
</StackPanel>
</Border>
<!-- Content - TreeView -->
<Border Grid.Row="1" Grid.Column="0" Padding="0 0 8 8">
<aero:SystemDropShadowChrome>
<Border BorderThickness="1" BorderBrush="{StaticResource OuterBorderBrush}" HorizontalAlignment="Stretch">
<TreeView ItemsSource="{Binding Actions}" x:Name="TreeView">
<TreeView.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
<GradientStop Color="White"/>
</LinearGradientBrush>
</TreeView.Background>
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TreeViewItem">
<StackPanel>
<!-- ActionButtonClick is used just to close the Popup -->
<Button Command="{Binding ActionCommand}" Style="{StaticResource ClearButton}" Click="ActionButtonClick">
<Border SnapsToDevicePixels="True">
<ContentPresenter Content="{TemplateBinding HeaderedContentControl.Header}" ContentTemplate="{TemplateBinding HeaderedContentControl.HeaderTemplate}" ContentStringFormat="{TemplateBinding HeaderedItemsControl.HeaderStringFormat}" ContentSource="Header" Name="PART_Header"
HorizontalAlignment="Stretch" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
</Border>
</Button>
<Border Padding="14 0 0 0">
<ItemsPresenter Name="ItemsHost" />
</TreeView.Background>
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TreeViewItem">
<StackPanel>
<!-- ActionButtonClick is used just to close the Popup -->
<Button Command="{Binding ActionCommand}" Style="{StaticResource ClearButton}" Click="ActionButtonClick">
<Border SnapsToDevicePixels="True">
<ContentPresenter Content="{TemplateBinding HeaderedContentControl.Header}" ContentTemplate="{TemplateBinding HeaderedContentControl.HeaderTemplate}" ContentStringFormat="{TemplateBinding HeaderedItemsControl.HeaderStringFormat}" ContentSource="Header" Name="PART_Header"
HorizontalAlignment="Stretch" SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}" />
</Border>
</StackPanel>
<ControlTemplate.Triggers>
<!-- Disable collapsing -->
<!--<Trigger Property="TreeViewItem.IsExpanded">
<Setter Property="UIElement.Visibility" TargetName="ItemsHost">
<Setter.Value>
<x:Static Member="Visibility.Collapsed" />
</Setter.Value>
</Setter>
<Trigger.Value>
<s:Boolean>False</s:Boolean>
</Trigger.Value>
</Trigger>-->
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<!-- Make all items expanded -->
<Setter Property="IsExpanded" Value="True"></Setter>
<!-- Make items not focusable so that contained button (not the TreeViewItem) gets focus on Down arrow -->
<Setter Property="Focusable" Value="False"></Setter>
</Style>
</TreeView.ItemContainerStyle>
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding ChildActions}">
<DockPanel HorizontalAlignment="Stretch">
<Image Source="{Binding Image}" Margin="3 2 4 2" />
<TextBlock Text="{Binding Name}" Margin="0 2 20 2" />
<TextBlock Text="{Binding Comment}" Foreground="Gray" TextAlignment="Right" HorizontalAlignment="Right"/>
</DockPanel>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
</Border>
</aero:SystemDropShadowChrome>
</Border>
</Grid>
</Button>
<Border Padding="14 0 0 0">
<ItemsPresenter Name="ItemsHost" />
</Border>
</StackPanel>
<ControlTemplate.Triggers>
<!-- Disable collapsing -->
<!--<Trigger Property="TreeViewItem.IsExpanded">
<Setter Property="UIElement.Visibility" TargetName="ItemsHost">
<Setter.Value>
<x:Static Member="Visibility.Collapsed" />
</Setter.Value>
</Setter>
<Trigger.Value>
<s:Boolean>False</s:Boolean>
</Trigger.Value>
</Trigger>-->
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<!-- Make all items expanded -->
<Setter Property="IsExpanded" Value="True"></Setter>
<!-- Make items not focusable so that contained button (not the TreeViewItem) gets focus on Down arrow -->
<Setter Property="Focusable" Value="False"></Setter>
</Style>
</TreeView.ItemContainerStyle>
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding ChildActions}">
<DockPanel HorizontalAlignment="Stretch">
<Image Source="{Binding Image}" Margin="3 2 4 2" />
<TextBlock Text="{Binding Name}" Margin="0 2 20 2" />
<TextBlock Text="{Binding Comment}" Foreground="Gray" TextAlignment="Right" HorizontalAlignment="Right"/>
</DockPanel>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
</Border>
</aero:SystemDropShadowChrome>
</Border>
</UserControl>

2
src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsControl.xaml.cs

@ -17,7 +17,7 @@ using System.Windows.Media; @@ -17,7 +17,7 @@ using System.Windows.Media;
namespace ICSharpCode.SharpDevelop.Refactoring
{
/// <summary>
/// Interaction logic for ContextActionsControl.xaml
/// ContextActionsControl accepts IEnumerable&lt;ContextActionViewModel&gt; as its DataContext.
/// </summary>
public partial class ContextActionsControl : UserControl
{

38
src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsHeaderedControl.xaml

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
<UserControl x:Class="ICSharpCode.SharpDevelop.Refactoring.ContextActionsHeaderedControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ICSharpCode.SharpDevelop.Refactoring"
xmlns:aero="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero">
<UserControl.Resources>
<SolidColorBrush x:Key="OuterBorderBrush" Color="#436C82"></SolidColorBrush>
</UserControl.Resources>
<Grid Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<!-- Header -->
<Border Grid.Row="0" Grid.Column="0" Padding="4" BorderThickness="1 1 1 0"
BorderBrush="{StaticResource OuterBorderBrush}" HorizontalAlignment="Left">
<Border.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#D6E9FF" Offset="0"/>
<GradientStop Color="#A3CEFF" Offset="0.5"/>
</LinearGradientBrush>
</Border.Background>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding Image}"></Image>
<TextBlock Text="{Binding Title}"></TextBlock>
</StackPanel>
</Border>
<!-- Content - TreeView -->
<local:ContextActionsControl x:Name="ActionsTreeView" Grid.Row="1" Grid.Column="0" DataContext="{Binding Actions}"></local:ContextActionsControl>
</Grid>
</UserControl>

41
src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsHeaderedControl.xaml.cs

@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Martin Konicek" email="martin.konicek@gmail.com"/>
// <version>$Revision: $</version>
// </file>
using System;
using System.Collections.Generic;
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;
namespace ICSharpCode.SharpDevelop.Refactoring
{
/// <summary>
/// Interaction logic for ContextActionsHeaderedControl.xaml
/// </summary>
public partial class ContextActionsHeaderedControl : UserControl
{
public ContextActionsHeaderedControl()
{
InitializeComponent();
}
public event EventHandler ActionExecuted
{
add { this.ActionsTreeView.ActionExecuted += value; }
remove { this.ActionsTreeView.ActionExecuted -= value; }
}
public new void Focus()
{
if (this.ActionsTreeView != null)
this.ActionsTreeView.Focus();
}
}
}

10
src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsPopup.cs

@ -23,7 +23,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -23,7 +23,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring
this.StaysOpen = false;
// Close on lost focus
this.AllowsTransparency = true;
this.ActionsControl = new ContextActionsControl();
this.ActionsControl = new ContextActionsHeaderedControl();
// Close when any action excecuted
this.ActionsControl.ActionExecuted += delegate { this.Close(); };
this.KeyDown += new KeyEventHandler(ContextActionsPopup_KeyDown);
@ -35,16 +35,18 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -35,16 +35,18 @@ namespace ICSharpCode.SharpDevelop.Refactoring
Close();
}
private ContextActionsControl ActionsControl
ContextActionsHeaderedControl ActionsControl
{
get { return (ContextActionsControl)this.Child; }
get { return (ContextActionsHeaderedControl)this.Child; }
set { this.Child = value; }
}
public ContextActionsViewModel Actions
{
get { return (ContextActionsViewModel)ActionsControl.DataContext; }
set { ActionsControl.DataContext = value; }
set {
ActionsControl.DataContext = value;
}
}
public new void Focus()

4
src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsViewModel.cs

@ -18,8 +18,8 @@ namespace ICSharpCode.SharpDevelop.Refactoring @@ -18,8 +18,8 @@ namespace ICSharpCode.SharpDevelop.Refactoring
{
public ImageSource Image { get; set; }
public ObservableCollection<ContextActionViewModel> Actions { get; set; }
public string Title { get; set; }
public ObservableCollection<ContextActionViewModel> Actions { get; set; }
}
}

Loading…
Cancel
Save