Browse Source

Move OutlineTreeView into WpfDesign.Designer.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3498 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 18 years ago
parent
commit
22cb860681
  1. 1
      samples/XamlDesigner/Document.cs
  2. 113
      samples/XamlDesigner/ExtensionMethods.cs
  3. 215
      samples/XamlDesigner/MainWindow.xaml
  4. 29
      samples/XamlDesigner/Outline.xaml
  5. 145
      samples/XamlDesigner/Themes/Generic.xaml
  6. 39
      samples/XamlDesigner/ToolboxView.xaml
  7. 53
      samples/XamlDesigner/ToolboxView.xaml.cs
  8. 14
      samples/XamlDesigner/XamlDesigner.csproj
  9. 27
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ExtensionMethods.cs
  10. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Tag.png
  11. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/DragListener.cs
  12. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/DragTreeView.cs
  13. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/DragTreeViewItem.cs
  14. 16
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/IconItem.cs
  15. 28
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml
  16. 16
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml.cs
  17. 14
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs
  18. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineTreeView.cs
  19. 151
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineView.xaml
  20. 18
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
  21. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/themes/generic.xaml
  22. 4
      src/Main/Base/Project/Src/Project/CustomTool.cs

1
samples/XamlDesigner/Document.cs

@ -6,6 +6,7 @@ using System.ComponentModel; @@ -6,6 +6,7 @@ using System.ComponentModel;
using System.IO;
using ICSharpCode.WpfDesign.Designer;
using ICSharpCode.WpfDesign.Designer.Xaml;
using ICSharpCode.WpfDesign.Designer.OutlineView;
using System.Xml;
using ICSharpCode.WpfDesign;
using ICSharpCode.WpfDesign.Designer.Services;

113
samples/XamlDesigner/ExtensionMethods.cs

@ -12,76 +12,67 @@ using System.Collections; @@ -12,76 +12,67 @@ using System.Collections;
namespace ICSharpCode.XamlDesigner
{
static class ExtensionMethods
{
public static IEnumerable<string> Paths(this IDataObject data)
{
string[] paths = (string[])data.GetData(DataFormats.FileDrop);
if (paths != null) {
foreach (var path in paths) {
yield return path;
}
}
}
public static T GetObject<T>(this IDataObject data)
{
return (T)data.GetData(typeof(T).FullName);
}
static class ExtensionMethods
{
public static IEnumerable<string> Paths(this IDataObject data)
{
string[] paths = (string[])data.GetData(DataFormats.FileDrop);
if (paths != null) {
foreach (var path in paths) {
yield return path;
}
}
}
public static T FindAncestor<T>(this DependencyObject d) where T : class
{
while (true) {
if (d == null) return null;
if (d is T) return d as T;
d = VisualTreeHelper.GetParent(d);
}
}
public static T GetObject<T>(this IDataObject data)
{
return (T)data.GetData(typeof(T).FullName);
}
public static Stream ToStream(this string s)
{
return new MemoryStream(Encoding.UTF8.GetBytes(s));
}
{
return new MemoryStream(Encoding.UTF8.GetBytes(s));
}
public static void AddRange<T>(this ObservableCollection<T> col, IEnumerable<T> items)
{
foreach (var item in items) {
col.Add(item);
}
}
public static void AddRange<T>(this ObservableCollection<T> col, IEnumerable<T> items)
{
foreach (var item in items) {
col.Add(item);
}
}
public static void KeepSyncronizedWith<S>(this IList target, ObservableCollection<S> source, Func<S, object> convert)
{
target.Clear();
foreach (var item in source) {
target.Add(convert(item));
}
public static void KeepSyncronizedWith<S>(this IList target, ObservableCollection<S> source, Func<S, object> convert)
{
target.Clear();
foreach (var item in source) {
target.Add(convert(item));
}
source.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs e) {
switch (e.Action) {
case NotifyCollectionChangedAction.Add:
target.Add(convert((S)e.NewItems[0]));
break;
source.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs e) {
switch (e.Action) {
case NotifyCollectionChangedAction.Add:
target.Add(convert((S)e.NewItems[0]));
break;
case NotifyCollectionChangedAction.Remove:
target.RemoveAt(e.OldStartingIndex);
break;
case NotifyCollectionChangedAction.Remove:
target.RemoveAt(e.OldStartingIndex);
break;
case NotifyCollectionChangedAction.Move:
target.RemoveAt(e.OldStartingIndex);
target.Insert(e.NewStartingIndex, e.NewItems[0]);
break;
case NotifyCollectionChangedAction.Move:
target.RemoveAt(e.OldStartingIndex);
target.Insert(e.NewStartingIndex, e.NewItems[0]);
break;
case NotifyCollectionChangedAction.Replace:
target[e.NewStartingIndex] = convert((S)e.NewItems[0]);
break;
case NotifyCollectionChangedAction.Replace:
target[e.NewStartingIndex] = convert((S)e.NewItems[0]);
break;
case NotifyCollectionChangedAction.Reset:
target.Clear();
break;
}
};
}
case NotifyCollectionChangedAction.Reset:
target.Clear();
break;
}
};
}
public static object GetDataContext(this RoutedEventArgs e)
{
@ -89,5 +80,5 @@ namespace ICSharpCode.XamlDesigner @@ -89,5 +80,5 @@ namespace ICSharpCode.XamlDesigner
if (f != null) return f.DataContext;
return null;
}
}
}
}

215
samples/XamlDesigner/MainWindow.xaml

@ -4,116 +4,115 @@ @@ -4,116 +4,115 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sd="http://sharpdevelop.net"
xmlns:AvalonDock="clr-namespace:AvalonDock;assembly=AvalonDock"
xmlns:Outline="clr-namespace:ICSharpCode.WpfDesign.Designer.OutlineView;assembly=ICSharpCode.WpfDesign.Designer"
xmlns:Default="clr-namespace:ICSharpCode.XamlDesigner"
SnapsToDevicePixels="True"
AllowDrop="True"
Title="{Binding Title}">
<Window.CommandBindings>
<CommandBinding Command="New"
Executed="NewCommand_Executed" />
<CommandBinding Command="Open"
Executed="OpenCommand_Executed" />
<CommandBinding Command="Close"
Executed="CloseCommand_Executed"
CanExecute="CurrentDocument_CanExecute"
PreviewExecuted="CloseCommand_PreviewExecuted"/>
<CommandBinding Command="Default:MainWindow.CloseAllCommand"
Executed="CloseAllCommand_Executed"
CanExecute="CurrentDocument_CanExecute" />
<CommandBinding Command="Save"
Executed="SaveCommand_Executed"
CanExecute="CurrentDocument_CanExecute" />
<CommandBinding Command="SaveAs"
Executed="SaveAsCommand_Executed"
CanExecute="CurrentDocument_CanExecute" />
<CommandBinding Command="Default:MainWindow.SaveAllCommand"
Executed="SaveAllCommand_Executed"
CanExecute="CurrentDocument_CanExecute" />
<CommandBinding Command="Default:MainWindow.ExitCommand"
Executed="ExitCommand_Executed" />
</Window.CommandBindings>
<DockPanel>
<Menu DockPanel.Dock="Top">
<MenuItem Header="File">
<MenuItem Command="New" />
<MenuItem Command="Open" />
<Separator />
<MenuItem Command="Close" />
<MenuItem Command="Default:MainWindow.CloseAllCommand" />
<Separator />
<MenuItem Command="Save" />
<MenuItem Command="SaveAs" />
<MenuItem Command="Default:MainWindow.SaveAllCommand" />
<Separator />
<MenuItem Header="Recent Files"
ItemsSource="{Binding RecentFiles}"
IsEnabled="{Binding RecentFiles.Count, Converter={StaticResource FalseWhenZero}}"
Click="RecentFiles_Click"/>
<Separator />
<MenuItem Command="Default:MainWindow.ExitCommand" />
</MenuItem>
<MenuItem Header="Edit">
<MenuItem Command="Undo" />
<MenuItem Command="Redo" />
<Separator />
<MenuItem Command="Cut" />
<MenuItem Command="Copy" />
<MenuItem Command="Paste" />
<MenuItem Command="Delete" />
<MenuItem Command="SelectAll" />
<Separator />
<MenuItem Command="Default:MainWindow.RefreshCommand" />
<MenuItem Command="Find" />
</MenuItem>
</Menu>
<AvalonDock:DockingManager x:Name="uxDockingManager">
<AvalonDock:ResizingPanel>
<AvalonDock:DocumentPane x:Name="uxDocumentPane"
SelectedValue="{Binding CurrentDocument}"
SelectedValuePath="DataContext"/>
<AvalonDock:DockablePane>
<AvalonDock:DockableContent x:Name="content1" Title="Toolbox">
<Default:ToolboxView />
</AvalonDock:DockableContent>
</AvalonDock:DockablePane>
<AvalonDock:DockablePane>
<AvalonDock:DockableContent x:Name="content2" Title="Outline">
<Default:Outline Root="{Binding CurrentDocument.OutlineRoot}"/>
</AvalonDock:DockableContent>
</AvalonDock:DockablePane>
<AvalonDock:DockablePane>
<AvalonDock:DockableContent x:Name="content3" Title="Errors">
<Default:ErrorListView ItemsSource="{Binding CurrentDocument.XamlErrorService.Errors}"/>
</AvalonDock:DockableContent>
</AvalonDock:DockablePane>
<AvalonDock:DockablePane>
<AvalonDock:DockableContent x:Name="content4" Title="Properties">
<sd:PropertyGridView x:Name="uxPropertyGridView"
SelectedItems="{Binding DataContext.CurrentDocument.SelectionService.SelectedItems, ElementName=root, FallbackValue={x:Null}}"/>
</AvalonDock:DockableContent>
</AvalonDock:DockablePane>
</AvalonDock:ResizingPanel>
</AvalonDock:DockingManager>
</DockPanel>
<Window.CommandBindings>
<CommandBinding Command="New"
Executed="NewCommand_Executed" />
<CommandBinding Command="Open"
Executed="OpenCommand_Executed" />
<CommandBinding Command="Close"
Executed="CloseCommand_Executed"
CanExecute="CurrentDocument_CanExecute"
PreviewExecuted="CloseCommand_PreviewExecuted"/>
<CommandBinding Command="Default:MainWindow.CloseAllCommand"
Executed="CloseAllCommand_Executed"
CanExecute="CurrentDocument_CanExecute" />
<CommandBinding Command="Save"
Executed="SaveCommand_Executed"
CanExecute="CurrentDocument_CanExecute" />
<CommandBinding Command="SaveAs"
Executed="SaveAsCommand_Executed"
CanExecute="CurrentDocument_CanExecute" />
<CommandBinding Command="Default:MainWindow.SaveAllCommand"
Executed="SaveAllCommand_Executed"
CanExecute="CurrentDocument_CanExecute" />
<CommandBinding Command="Default:MainWindow.ExitCommand"
Executed="ExitCommand_Executed" />
</Window.CommandBindings>
<DockPanel>
<Menu DockPanel.Dock="Top">
<MenuItem Header="File">
<MenuItem Command="New" />
<MenuItem Command="Open" />
<Separator />
<MenuItem Command="Close" />
<MenuItem Command="Default:MainWindow.CloseAllCommand" />
<Separator />
<MenuItem Command="Save" />
<MenuItem Command="SaveAs" />
<MenuItem Command="Default:MainWindow.SaveAllCommand" />
<Separator />
<MenuItem Header="Recent Files"
ItemsSource="{Binding RecentFiles}"
IsEnabled="{Binding RecentFiles.Count, Converter={StaticResource FalseWhenZero}}"
Click="RecentFiles_Click"/>
<Separator />
<MenuItem Command="Default:MainWindow.ExitCommand" />
</MenuItem>
<MenuItem Header="Edit">
<MenuItem Command="Undo" />
<MenuItem Command="Redo" />
<Separator />
<MenuItem Command="Cut" />
<MenuItem Command="Copy" />
<MenuItem Command="Paste" />
<MenuItem Command="Delete" />
<MenuItem Command="SelectAll" />
<Separator />
<MenuItem Command="Default:MainWindow.RefreshCommand" />
<MenuItem Command="Find" />
</MenuItem>
</Menu>
<AvalonDock:DockingManager x:Name="uxDockingManager">
<AvalonDock:ResizingPanel>
<AvalonDock:DocumentPane x:Name="uxDocumentPane"
SelectedValue="{Binding CurrentDocument}"
SelectedValuePath="DataContext"/>
<AvalonDock:DockablePane>
<AvalonDock:DockableContent x:Name="content1" Title="Toolbox">
<Default:ToolboxView />
</AvalonDock:DockableContent>
</AvalonDock:DockablePane>
<AvalonDock:DockablePane>
<AvalonDock:DockableContent x:Name="content2" Title="Outline">
<Outline:Outline Root="{Binding CurrentDocument.OutlineRoot}"/>
</AvalonDock:DockableContent>
</AvalonDock:DockablePane>
<AvalonDock:DockablePane>
<AvalonDock:DockableContent x:Name="content3" Title="Errors">
<Default:ErrorListView ItemsSource="{Binding CurrentDocument.XamlErrorService.Errors}"/>
</AvalonDock:DockableContent>
</AvalonDock:DockablePane>
<AvalonDock:DockablePane>
<AvalonDock:DockableContent x:Name="content4" Title="Properties">
<sd:PropertyGridView x:Name="uxPropertyGridView"
SelectedItems="{Binding DataContext.CurrentDocument.SelectionService.SelectedItems, ElementName=root, FallbackValue={x:Null}}"/>
</AvalonDock:DockableContent>
</AvalonDock:DockablePane>
</AvalonDock:ResizingPanel>
</AvalonDock:DockingManager>
</DockPanel>
</Window>

29
samples/XamlDesigner/Outline.xaml

@ -1,29 +0,0 @@ @@ -1,29 +0,0 @@
<UserControl x:Class="ICSharpCode.XamlDesigner.Outline"
x:Name="root"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Default="clr-namespace:ICSharpCode.XamlDesigner"
xmlns:Converters="clr-namespace:ICSharpCode.XamlDesigner.Converters">
<UserControl.Resources>
<HierarchicalDataTemplate DataType="{x:Type Default:OutlineNode}"
ItemsSource="{Binding Children}">
<Default:IconItem Icon="Images/Tag.png"
Text="{Binding Name}" />
</HierarchicalDataTemplate>
</UserControl.Resources>
<Default:OutlineTreeView Root="{Binding Root, ElementName=root}">
<ItemsControl.ItemContainerStyle>
<Style TargetType="{x:Type Default:DragTreeViewItem}">
<Setter Property="IsSelected"
Value="{Binding IsSelected}" />
<Setter Property="IsExpanded"
Value="{Binding IsExpanded, Mode=TwoWay}" />
</Style>
</ItemsControl.ItemContainerStyle>
</Default:OutlineTreeView>
</UserControl>

145
samples/XamlDesigner/Themes/Generic.xaml

@ -3,149 +3,4 @@ @@ -3,149 +3,4 @@
xmlns:Default="clr-namespace:ICSharpCode.XamlDesigner"
xmlns:Converters="clr-namespace:ICSharpCode.XamlDesigner.Converters">
<Converters:LevelConverter x:Key="LevelConverter" />
<Style TargetType="{x:Type Default:IconItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Default:IconItem}">
<StackPanel Orientation="Horizontal">
<Image Source="{TemplateBinding Icon}"
Stretch="None" />
<TextBlock Text="{TemplateBinding Text}"
VerticalAlignment="Center"
Margin="5 0 0 0" />
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Brush x:Key="InsertBrush">#FFC73C</Brush>
<Style x:Key="ExpandButtonStyle"
TargetType="ToggleButton">
<Setter Property="Focusable"
Value="False" />
<Setter Property="ClickMode"
Value="Press" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
<Border Background="Transparent">
<Border Width="9"
Height="9"
SnapsToDevicePixels="true"
BorderBrush="#FF7898B5"
BorderThickness="1"
CornerRadius="1">
<Border.Background>
<LinearGradientBrush EndPoint="1,1"
StartPoint="0,0">
<GradientStop Color="White"
Offset=".2" />
<GradientStop Color="#FFC0B7A6"
Offset="1" />
</LinearGradientBrush>
</Border.Background>
<Path Margin="1,1,1,1"
x:Name="ExpandPath"
Fill="Black"
Data="M 0 2 L 0 3 L 2 3 L 2 5 L 3 5 L 3 3 L 5 3 L 5 2 L 3 2 L 3 0 L 2 0 L 2 2 Z" />
</Border>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked"
Value="True">
<Setter Property="Data"
TargetName="ExpandPath"
Value="M 0 2 L 0 3 L 5 3 L 5 2 Z" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Default:DragTreeView}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Default:DragTreeView}">
<Grid Background="White">
<ScrollViewer HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<ItemsPresenter />
</ScrollViewer>
<Border x:Name="PART_InsertLine"
Background="{StaticResource InsertBrush}"
Height="2"
Width="50"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Visibility="Collapsed"
IsHitTestVisible="False" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Default:DragTreeViewItem}">
<Setter Property="Foreground"
Value="{x:Static SystemColors.ControlTextBrush}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Default:DragTreeViewItem}">
<DockPanel Background="White">
<DockPanel x:Name="bg"
DockPanel.Dock="Top"
Background="{TemplateBinding Background}">
<ToggleButton x:Name="expandButton"
Style="{StaticResource ExpandButtonStyle}"
DockPanel.Dock="Left"
Margin="{TemplateBinding Level, Converter={StaticResource LevelConverter}}"
IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" />
<Border x:Name="contentBorder"
HorizontalAlignment="Left">
<ContentPresenter x:Name="PART_Header"
ContentSource="Header" />
</Border>
</DockPanel>
<ItemsPresenter x:Name="itemsHost" />
</DockPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsExpanded"
Value="False">
<Setter TargetName="itemsHost"
Property="Visibility"
Value="Collapsed" />
</Trigger>
<Trigger Property="HasItems"
Value="False">
<Setter TargetName="expandButton"
Property="Visibility"
Value="Hidden" />
</Trigger>
<Trigger Property="IsSelected"
Value="True">
<Setter TargetName="bg"
Property="Background"
Value="{x:Static SystemColors.HighlightBrush}" />
<Setter Property="Foreground"
Value="{x:Static SystemColors.HighlightTextBrush}" />
</Trigger>
<Trigger Property="IsDragHover"
Value="True">
<Setter TargetName="contentBorder"
Property="Background"
Value="{StaticResource InsertBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

39
samples/XamlDesigner/ToolboxView.xaml

@ -1,25 +1,26 @@ @@ -1,25 +1,26 @@
<UserControl x:Class="ICSharpCode.XamlDesigner.ToolboxView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Outline="clr-namespace:ICSharpCode.WpfDesign.Designer.OutlineView;assembly=ICSharpCode.WpfDesign.Designer"
xmlns:Default="clr-namespace:ICSharpCode.XamlDesigner">
<UserControl.Resources>
<HierarchicalDataTemplate DataType="{x:Type Default:AssemblyNode}"
ItemsSource="{Binding Controls}">
<Default:IconItem Icon="Images/Reference.png"
Text="{Binding Name}"
ToolTip="{Binding Path}" />
</HierarchicalDataTemplate>
<UserControl.Resources>
<HierarchicalDataTemplate DataType="{x:Type Default:AssemblyNode}"
ItemsSource="{Binding Controls}">
<Outline:IconItem Icon="Images/Reference.png"
Text="{Binding Name}"
ToolTip="{Binding Path}" />
</HierarchicalDataTemplate>
<DataTemplate DataType="{x:Type Default:ControlNode}">
<Outline:IconItem Icon="Images/Tag.png"
Text="{Binding Type.Name}" />
</DataTemplate>
</UserControl.Resources>
<TreeView x:Name="uxTreeView"
ItemsSource="{Binding AssemblyNodes}"
BorderThickness="0"/>
<DataTemplate DataType="{x:Type Default:ControlNode}">
<Default:IconItem Icon="Images/Tag.png"
Text="{Binding Type.Name}" />
</DataTemplate>
</UserControl.Resources>
<TreeView x:Name="uxTreeView"
ItemsSource="{Binding AssemblyNodes}"
BorderThickness="0"/>
</UserControl>

53
samples/XamlDesigner/ToolboxView.xaml.cs

@ -1,6 +1,10 @@ @@ -1,6 +1,10 @@
using ICSharpCode.WpfDesign.Designer.OutlineView;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows;
using System.Windows.Controls;
@ -11,24 +15,21 @@ using System.Windows.Media; @@ -11,24 +15,21 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Reflection;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using ICSharpCode.WpfDesign.Designer.Services;
namespace ICSharpCode.XamlDesigner
{
public partial class ToolboxView
{
public ToolboxView()
{
public partial class ToolboxView
{
public ToolboxView()
{
DataContext = Toolbox.Instance;
InitializeComponent();
InitializeComponent();
new DragListener(this).DragStarted += Toolbox_DragStarted;
new DragListener(this).DragStarted += Toolbox_DragStarted;
uxTreeView.SelectedItemChanged += uxTreeView_SelectedItemChanged;
uxTreeView.GotKeyboardFocus += uxTreeView_GotKeyboardFocus;
}
}
void uxTreeView_GotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
{
@ -47,7 +48,7 @@ namespace ICSharpCode.XamlDesigner @@ -47,7 +48,7 @@ namespace ICSharpCode.XamlDesigner
void PrepareTool(ControlNode node, bool drag)
{
if (node != null) {
if (node != null) {
var tool = new CreateComponentTool(node.Type);
if (Shell.Instance.CurrentDocument != null) {
Shell.Instance.CurrentDocument.DesignContext.Services.Tool.CurrentTool = tool;
@ -55,22 +56,22 @@ namespace ICSharpCode.XamlDesigner @@ -55,22 +56,22 @@ namespace ICSharpCode.XamlDesigner
DragDrop.DoDragDrop(this, tool, DragDropEffects.Copy);
}
}
}
}
}
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.Key == Key.Delete) {
Remove();
}
}
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.Key == Key.Delete) {
Remove();
}
}
void Remove()
{
AssemblyNode node = uxTreeView.SelectedItem as AssemblyNode;
if (node != null) {
Toolbox.Instance.Remove(node);
}
}
}
void Remove()
{
AssemblyNode node = uxTreeView.SelectedItem as AssemblyNode;
if (node != null) {
Toolbox.Instance.Remove(node);
}
}
}
}

14
samples/XamlDesigner/XamlDesigner.csproj

@ -108,21 +108,11 @@ @@ -108,21 +108,11 @@
<Compile Include="DocumentView.xaml.cs">
<DependentUpon>DocumentView.xaml</DependentUpon>
</Compile>
<Compile Include="DragListener.cs" />
<Compile Include="DragTreeView.cs" />
<Compile Include="DragTreeViewItem.cs" />
<Compile Include="ErrorListView.xaml.cs">
<DependentUpon>ErrorListView.xaml</DependentUpon>
</Compile>
<Compile Include="ExtensionMethods.cs" />
<Compile Include="IconItem.cs" />
<Compile Include="MainWindow_Commands.cs" />
<Compile Include="Outline.xaml.cs">
<DependentUpon>Outline.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="OutlineNode.cs" />
<Compile Include="OutlineTreeView.cs" />
<Compile Include="Shell.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
@ -161,10 +151,6 @@ @@ -161,10 +151,6 @@
<None Include="TestFiles\2.xaml">
<SubType>Designer</SubType>
</None>
<Page Include="Outline.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<None Include="TestFiles\3.xaml">
<SubType>Designer</SubType>
</None>

27
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ExtensionMethods.cs

@ -34,13 +34,22 @@ namespace ICSharpCode.WpfDesign.Designer @@ -34,13 +34,22 @@ namespace ICSharpCode.WpfDesign.Designer
}
public static T FindAncestor<T>(this DependencyObject d, string name) where T : class
{
while (true) {
if (d == null) return null;
if (d is T && d is FrameworkElement && (d as FrameworkElement).Name == name) return d as T;
d = VisualTreeHelper.GetParent(d);
}
}
{
while (true) {
if (d == null) return null;
if (d is T && d is FrameworkElement && (d as FrameworkElement).Name == name) return d as T;
d = VisualTreeHelper.GetParent(d);
}
}
public static T FindAncestor<T>(this DependencyObject d) where T : class
{
while (true) {
if (d == null) return null;
if (d is T) return d as T;
d = VisualTreeHelper.GetParent(d);
}
}
public static T FindChild<T>(this DependencyObject d) where T : class
{
@ -52,8 +61,8 @@ namespace ICSharpCode.WpfDesign.Designer @@ -52,8 +61,8 @@ namespace ICSharpCode.WpfDesign.Designer
if (result != null) return result;
}
return null;
}
}
public static void AddCommandHandler(this UIElement element, ICommand command, Action execute)
{
AddCommandHandler(element, command, execute, null);

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 389 B

2
samples/XamlDesigner/DragListener.cs → src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/DragListener.cs

@ -5,7 +5,7 @@ using System.Text; @@ -5,7 +5,7 @@ using System.Text;
using System.Windows;
using System.Windows.Input;
namespace ICSharpCode.XamlDesigner
namespace ICSharpCode.WpfDesign.Designer.OutlineView
{
public class DragListener
{

3
samples/XamlDesigner/DragTreeView.cs → src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/DragTreeView.cs

@ -12,10 +12,9 @@ using System.Windows.Media.Imaging; @@ -12,10 +12,9 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Collections.Specialized;
using ICSharpCode.XamlDesigner.Converters;
using System.Collections;
namespace ICSharpCode.XamlDesigner
namespace ICSharpCode.WpfDesign.Designer.OutlineView
{
// limitations:
// - Do not use ItemsSource (use Root)

2
samples/XamlDesigner/DragTreeViewItem.cs → src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/DragTreeViewItem.cs

@ -13,7 +13,7 @@ using System.Windows.Navigation; @@ -13,7 +13,7 @@ using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls.Primitives;
namespace ICSharpCode.XamlDesigner
namespace ICSharpCode.WpfDesign.Designer.OutlineView
{
public class DragTreeViewItem : TreeViewItem
{

16
samples/XamlDesigner/IconItem.cs → src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/IconItem.cs

@ -6,23 +6,23 @@ using System.Windows.Controls; @@ -6,23 +6,23 @@ using System.Windows.Controls;
using System.Windows;
using System.Windows.Media;
namespace ICSharpCode.XamlDesigner
namespace ICSharpCode.WpfDesign.Designer.OutlineView
{
public class IconItem : Control
{
static IconItem()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(IconItem),
new FrameworkPropertyMetadata(typeof(IconItem)));
DefaultStyleKeyProperty.OverrideMetadata(typeof(IconItem),
new FrameworkPropertyMetadata(typeof(IconItem)));
}
public static readonly DependencyProperty IconProperty =
DependencyProperty.Register("Icon", typeof(ImageSource), typeof(IconItem));
DependencyProperty.Register("Icon", typeof(ImageSource), typeof(IconItem));
public ImageSource Icon {
get { return (ImageSource)GetValue(IconProperty); }
set { SetValue(IconProperty, value); }
}
public ImageSource Icon {
get { return (ImageSource)GetValue(IconProperty); }
set { SetValue(IconProperty, value); }
}
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text", typeof(string), typeof(IconItem));

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

@ -0,0 +1,28 @@ @@ -0,0 +1,28 @@
<UserControl x:Class="ICSharpCode.WpfDesign.Designer.OutlineView.Outline"
x:Name="root"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Default="clr-namespace:ICSharpCode.WpfDesign.Designer.OutlineView">
<UserControl.Resources>
<HierarchicalDataTemplate DataType="{x:Type Default:OutlineNode}"
ItemsSource="{Binding Children}">
<Default:IconItem Icon="../Images/Tag.png"
Text="{Binding Name}" />
</HierarchicalDataTemplate>
</UserControl.Resources>
<Default:OutlineTreeView Root="{Binding Root, ElementName=root}">
<ItemsControl.ItemContainerStyle>
<Style TargetType="{x:Type Default:DragTreeViewItem}">
<Setter Property="IsSelected"
Value="{Binding IsSelected}" />
<Setter Property="IsExpanded"
Value="{Binding IsExpanded, Mode=TwoWay}" />
</Style>
</ItemsControl.ItemContainerStyle>
</Default:OutlineTreeView>
</UserControl>

16
samples/XamlDesigner/Outline.xaml.cs → src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml.cs

@ -12,14 +12,14 @@ using System.Windows.Media.Imaging; @@ -12,14 +12,14 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace ICSharpCode.XamlDesigner
namespace ICSharpCode.WpfDesign.Designer.OutlineView
{
public partial class Outline
{
public Outline()
{
InitializeComponent();
}
public partial class Outline
{
public Outline()
{
InitializeComponent();
}
public static readonly DependencyProperty RootProperty =
DependencyProperty.Register("Root", typeof(OutlineNode), typeof(Outline));
@ -28,5 +28,5 @@ namespace ICSharpCode.XamlDesigner @@ -28,5 +28,5 @@ namespace ICSharpCode.XamlDesigner
get { return (OutlineNode)GetValue(RootProperty); }
set { SetValue(RootProperty, value); }
}
}
}
}

14
samples/XamlDesigner/OutlineNode.cs → src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs

@ -9,7 +9,7 @@ using System.Collections; @@ -9,7 +9,7 @@ using System.Collections;
using ICSharpCode.WpfDesign.Designer;
using ICSharpCode.WpfDesign.XamlDom;
namespace ICSharpCode.XamlDesigner
namespace ICSharpCode.WpfDesign.Designer.OutlineView
{
public class OutlineNode : INotifyPropertyChanged
{
@ -64,8 +64,8 @@ namespace ICSharpCode.XamlDesigner @@ -64,8 +64,8 @@ namespace ICSharpCode.XamlDesigner
set {
if (isSelected != value) {
isSelected = value;
SelectionService.SetSelectedComponents(new[] { DesignItem },
value ? SelectionTypes.Add : SelectionTypes.Remove);
SelectionService.SetSelectedComponents(new[] { DesignItem },
value ? SelectionTypes.Add : SelectionTypes.Remove);
RaisePropertyChanged("IsSelected");
}
}
@ -80,7 +80,7 @@ namespace ICSharpCode.XamlDesigner @@ -80,7 +80,7 @@ namespace ICSharpCode.XamlDesigner
public string Name {
get {
if (string.IsNullOrEmpty(DesignItem.Name)) {
return DesignItem.ComponentType.Name;
return DesignItem.ComponentType.Name;
}
return DesignItem.ComponentType.Name + " (" + DesignItem.Name + ")";
}
@ -137,8 +137,8 @@ namespace ICSharpCode.XamlDesigner @@ -137,8 +137,8 @@ namespace ICSharpCode.XamlDesigner
if (DesignItem.ContentProperty.IsCollection) {
foreach (var node in nodes) {
if (!CollectionSupport.CanCollectionAdd(DesignItem.ContentProperty.ReturnType,
node.DesignItem.ComponentType)) {
if (!CollectionSupport.CanCollectionAdd(DesignItem.ContentProperty.ReturnType,
node.DesignItem.ComponentType)) {
return false;
}
}
@ -147,7 +147,7 @@ namespace ICSharpCode.XamlDesigner @@ -147,7 +147,7 @@ namespace ICSharpCode.XamlDesigner
else {
return after == null && nodes.Count() == 1 &&
DesignItem.ContentProperty.DeclaringType.IsAssignableFrom(
nodes.First().DesignItem.ComponentType);
nodes.First().DesignItem.ComponentType);
}
}

2
samples/XamlDesigner/OutlineTreeView.cs → src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineTreeView.cs

@ -3,7 +3,7 @@ using System.Collections.Generic; @@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ICSharpCode.XamlDesigner
namespace ICSharpCode.WpfDesign.Designer.OutlineView
{
public class OutlineTreeView : DragTreeView
{

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

@ -0,0 +1,151 @@ @@ -0,0 +1,151 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Default="clr-namespace:ICSharpCode.WpfDesign.Designer.OutlineView"
xmlns:Converters="clr-namespace:ICSharpCode.WpfDesign.Designer.Converters"
>
<Converters:LevelConverter x:Key="LevelConverter" />
<Style TargetType="{x:Type Default:IconItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Default:IconItem}">
<StackPanel Orientation="Horizontal">
<Image Source="{TemplateBinding Icon}"
Stretch="None" />
<TextBlock Text="{TemplateBinding Text}"
VerticalAlignment="Center"
Margin="5 0 0 0" />
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ExpandButtonStyle"
TargetType="ToggleButton">
<Setter Property="Focusable"
Value="False" />
<Setter Property="ClickMode"
Value="Press" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
<Border Background="Transparent">
<Border Width="9"
Height="9"
SnapsToDevicePixels="true"
BorderBrush="#FF7898B5"
BorderThickness="1"
CornerRadius="1">
<Border.Background>
<LinearGradientBrush EndPoint="1,1"
StartPoint="0,0">
<GradientStop Color="White"
Offset=".2" />
<GradientStop Color="#FFC0B7A6"
Offset="1" />
</LinearGradientBrush>
</Border.Background>
<Path Margin="1,1,1,1"
x:Name="ExpandPath"
Fill="Black"
Data="M 0 2 L 0 3 L 2 3 L 2 5 L 3 5 L 3 3 L 5 3 L 5 2 L 3 2 L 3 0 L 2 0 L 2 2 Z" />
</Border>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked"
Value="True">
<Setter Property="Data"
TargetName="ExpandPath"
Value="M 0 2 L 0 3 L 5 3 L 5 2 Z" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Brush x:Key="InsertBrush">#FFC73C</Brush>
<Style TargetType="{x:Type Default:DragTreeView}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Default:DragTreeView}">
<Grid Background="White">
<ScrollViewer HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<ItemsPresenter />
</ScrollViewer>
<Border x:Name="PART_InsertLine"
Background="{StaticResource InsertBrush}"
Height="2"
Width="50"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Visibility="Collapsed"
IsHitTestVisible="False" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Default:DragTreeViewItem}">
<Setter Property="Foreground"
Value="{x:Static SystemColors.ControlTextBrush}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Default:DragTreeViewItem}">
<DockPanel Background="White">
<DockPanel x:Name="bg"
DockPanel.Dock="Top"
Background="{TemplateBinding Background}">
<ToggleButton x:Name="expandButton"
Style="{StaticResource ExpandButtonStyle}"
DockPanel.Dock="Left"
Margin="{TemplateBinding Level, Converter={StaticResource LevelConverter}}"
IsChecked="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" />
<Border x:Name="contentBorder"
HorizontalAlignment="Left">
<ContentPresenter x:Name="PART_Header"
ContentSource="Header" />
</Border>
</DockPanel>
<ItemsPresenter x:Name="itemsHost" />
</DockPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsExpanded"
Value="False">
<Setter TargetName="itemsHost"
Property="Visibility"
Value="Collapsed" />
</Trigger>
<Trigger Property="HasItems"
Value="False">
<Setter TargetName="expandButton"
Property="Visibility"
Value="Hidden" />
</Trigger>
<Trigger Property="IsSelected"
Value="True">
<Setter TargetName="bg"
Property="Background"
Value="{x:Static SystemColors.HighlightBrush}" />
<Setter Property="Foreground"
Value="{x:Static SystemColors.HighlightTextBrush}" />
</Trigger>
<Trigger Property="IsDragHover"
Value="True">
<Setter TargetName="contentBorder"
Property="Background"
Value="{StaticResource InsertBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

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

@ -116,6 +116,17 @@ @@ -116,6 +116,17 @@
<Compile Include="Extensions\ResizeThumbExtension.cs" />
<Compile Include="Extensions\WindowResizeBehavior.cs" />
<Compile Include="BasicMetadata.cs" />
<Compile Include="OutlineView\DragListener.cs" />
<Compile Include="OutlineView\DragTreeView.cs" />
<Compile Include="OutlineView\DragTreeViewItem.cs" />
<Compile Include="OutlineView\IconItem.cs" />
<Compile Include="OutlineView\Outline.xaml.cs">
<DependentUpon>Outline.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="OutlineView\OutlineNode.cs">
</Compile>
<Compile Include="OutlineView\OutlineTreeView.cs" />
<Compile Include="PropertyGrid\Editors\BoolEditor.xaml.cs">
<DependentUpon>BoolEditor.xaml</DependentUpon>
</Compile>
@ -186,6 +197,7 @@ @@ -186,6 +197,7 @@
<Compile Include="Xaml\XamlDesignItem.cs" />
<Compile Include="Xaml\XamlModelProperty.cs" />
<Compile Include="Xaml\XamlModelPropertyCollection.cs" />
<Resource Include="Images\Tag.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj">
@ -212,6 +224,11 @@ @@ -212,6 +224,11 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="OutlineView\Outline.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="OutlineView\OutlineView.xaml" />
<Page Include="PropertyGrid\Editors\BoolEditor.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@ -267,6 +284,7 @@ @@ -267,6 +284,7 @@
<Page Include="Themes\Generic.xaml">
<SubType>Designer</SubType>
</Page>
<Folder Include="OutlineView" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\Class.png" />

9
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/themes/generic.xaml

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/ICSharpCode.WpfDesign.Designer;component/Controls/ControlStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/ICSharpCode.WpfDesign.Designer;component/Controls/ControlStyles.xaml" />
<ResourceDictionary Source="/ICSharpCode.WpfDesign.Designer;component/OutlineView/OutlineView.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

4
src/Main/Base/Project/Src/Project/CustomTool.cs

@ -375,7 +375,9 @@ namespace ICSharpCode.SharpDevelop.Project @@ -375,7 +375,9 @@ namespace ICSharpCode.SharpDevelop.Project
ICustomTool customTool = GetCustomTool(baseItem.CustomTool);
if (customTool == null) {
string message = "Cannot find custom tool '" + baseItem.CustomTool + "'.";
CustomToolContext.StaticMessageView.AppendLine(message);
if (!baseItem.CustomTool.StartsWith("MSBuild:")) {
CustomToolContext.StaticMessageView.AppendLine(message);
}
if (showMessageBoxOnErrors) {
MessageService.ShowError(message);
}

Loading…
Cancel
Save