Browse Source

Added an icon to nodes in Dependency Graph.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@6261 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Tomáš Linhart 16 years ago
parent
commit
e0b462ce3a
  1. 1
      src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj
  2. 451
      src/AddIns/Analysis/CodeQuality/Resources/GraphTemplate.xaml
  3. 594
      src/AddIns/Analysis/CodeQuality/Src/Controls/DependencyGraphLayout.cs
  4. 28
      src/AddIns/Analysis/CodeQuality/Src/Controls/DependencyIconVertexConverter.cs
  5. 10
      src/AddIns/Analysis/CodeQuality/Src/Controls/TreeMatrixControl.xaml.cs
  6. 37
      src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml

1
src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj

@ -113,6 +113,7 @@
<Compile Include="Src\Controls\DependencyMatrixControl.cs" /> <Compile Include="Src\Controls\DependencyMatrixControl.cs" />
<Compile Include="Src\Controls\DependencyMatrix.cs" /> <Compile Include="Src\Controls\DependencyMatrix.cs" />
<Compile Include="Src\Controls\DependencyVertex.cs" /> <Compile Include="Src\Controls\DependencyVertex.cs" />
<Compile Include="Src\Controls\DependencyIconVertexConverter.cs" />
<Compile Include="Src\Controls\Matrix.cs" /> <Compile Include="Src\Controls\Matrix.cs" />
<Compile Include="Src\Controls\MatrixControl.cs" /> <Compile Include="Src\Controls\MatrixControl.cs" />
<Compile Include="Src\Controls\TreeMatrixControl.xaml.cs"> <Compile Include="Src\Controls\TreeMatrixControl.xaml.cs">

451
src/AddIns/Analysis/CodeQuality/Resources/GraphTemplate.xaml

@ -1,290 +1,163 @@
<ResourceDictionary <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Controls="clr-namespace:ICSharpCode.CodeQualityAnalysis.Controls"
xmlns:GraphSharp_Controls="clr-namespace:GraphSharp.Controls;assembly=GraphSharp.Controls" xmlns:GraphSharp_Controls="clr-namespace:GraphSharp.Controls;assembly=GraphSharp.Controls"
xmlns:Converters="clr-namespace:GraphSharp.Converters;assembly=GraphSharp.Controls" xmlns:Converters="clr-namespace:GraphSharp.Converters;assembly=GraphSharp.Controls"
xmlns:WPFExtensions_AttachedBehaviours="clr-namespace:WPFExtensions.AttachedBehaviours;assembly=WPFExtensions"> xmlns:WPFExtensions_AttachedBehaviours="clr-namespace:WPFExtensions.AttachedBehaviours;assembly=WPFExtensions"
>
<Converters:EdgeRouteToPathConverter x:Key="routeToPathConverter" /> <Converters:EdgeRouteToPathConverter x:Key="routeToPathConverter" />
<Controls:DependencyIconVertexConverter x:Key="IconConverter"/>
<SolidColorBrush x:Key="HighlightedVertexBorderBrush" Color="Transparent" />
<SolidColorBrush x:Key="HighlightedVertexBackgroundBrush" Color="{DynamicResource {x:Static SystemColors.HighlightColorKey}}" /> <SolidColorBrush x:Key="HighlightedVertexBorderBrush" Color="Transparent" />
<SolidColorBrush x:Key="HighlightedVertexForegroundBrush" Color="{DynamicResource {x:Static SystemColors.ControlLightLightColorKey}}" /> <SolidColorBrush x:Key="HighlightedVertexBackgroundBrush" Color="{DynamicResource {x:Static SystemColors.HighlightColorKey}}" />
<SolidColorBrush x:Key="SemiHighlightedSourceVertexBorderBrush" Color="Transparent" /> <SolidColorBrush x:Key="HighlightedVertexForegroundBrush" Color="{DynamicResource {x:Static SystemColors.ControlLightLightColorKey}}" />
<SolidColorBrush x:Key="SemiHighlightedSourceVertexBackgroundBrush" Color="#FF1DBA00" /> <SolidColorBrush x:Key="SemiHighlightedSourceVertexBorderBrush" Color="Transparent" />
<SolidColorBrush x:Key="SemiHighlightedTargetVertexBorderBrush" Color="Transparent" /> <SolidColorBrush x:Key="SemiHighlightedSourceVertexBackgroundBrush" Color="#FF1DBA00" />
<SolidColorBrush x:Key="SemiHighlightedTargetVertexBackgroundBrush" Color="#FFD6A51C" /> <SolidColorBrush x:Key="SemiHighlightedTargetVertexBorderBrush" Color="Transparent" />
<SolidColorBrush x:Key="HighlightedEdgeBrush" Color="{DynamicResource {x:Static SystemColors.HighlightColorKey}}" /> <SolidColorBrush x:Key="SemiHighlightedTargetVertexBackgroundBrush" Color="#FFD6A51C" />
<SolidColorBrush x:Key="SemiHighlightedInEdgeBrush" Color="#FF1DBA00" /> <SolidColorBrush x:Key="HighlightedEdgeBrush" Color="{DynamicResource {x:Static SystemColors.HighlightColorKey}}" />
<SolidColorBrush x:Key="SemiHighlightedOutEdgeBrush" Color="#FFD6A51C" /> <SolidColorBrush x:Key="SemiHighlightedInEdgeBrush" Color="#FF1DBA00" />
<SolidColorBrush x:Key="SemiHighlightedOutEdgeBrush" Color="#FFD6A51C" />
<!-- VERTEX CONTROL -->
<Style TargetType="{x:Type GraphSharp_Controls:VertexControl}"> <!-- VERTEX CONTROL -->
<Setter Property="Template"> <Style TargetType="{x:Type GraphSharp_Controls:VertexControl}">
<Setter.Value> <Setter Property="Template">
<ControlTemplate TargetType="{x:Type GraphSharp_Controls:VertexControl}"> <Setter.Value>
<Border Background="{TemplateBinding Background}" <ControlTemplate TargetType="{x:Type GraphSharp_Controls:VertexControl}">
BorderBrush="{TemplateBinding BorderBrush}" <Border Background="{TemplateBinding Background}"
BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}"
CornerRadius="10,10,10,10" BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}"> CornerRadius="10,10,10,10"
<ContentPresenter Content="{TemplateBinding Vertex}"/> Padding="{TemplateBinding Padding}">
</Border> <StackPanel Orientation="Horizontal">
</ControlTemplate> <Image Margin="0, 1, 5, 0" Source="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type GraphSharp_Controls:VertexControl}}, Path=Vertex, Converter={StaticResource IconConverter}}" />
</Setter.Value> <ContentPresenter Content="{TemplateBinding Vertex}"/>
</Setter> </StackPanel>
<Setter Property="GraphSharp_Controls:GraphElementBehaviour.HighlightTrigger" Value="{Binding Path=IsMouseOver, RelativeSource={RelativeSource Self}}"/> </Border>
<Setter Property="WPFExtensions_AttachedBehaviours:DragBehaviour.IsDragEnabled" Value="True"/> </ControlTemplate>
<Setter Property="WPFExtensions_AttachedBehaviours:DragBehaviour.X" Value="{Binding Path=(GraphSharp_Controls:GraphCanvas.X), Mode=TwoWay, RelativeSource={RelativeSource Self}}"/> </Setter.Value>
<Setter Property="WPFExtensions_AttachedBehaviours:DragBehaviour.Y" Value="{Binding Path=(GraphSharp_Controls:GraphCanvas.Y), Mode=TwoWay, RelativeSource={RelativeSource Self}}"/> </Setter>
<Setter Property="Background" Value="#FFE3E3E3"/> <Setter Property="GraphSharp_Controls:GraphElementBehaviour.HighlightTrigger" Value="{Binding Path=IsMouseOver, RelativeSource={RelativeSource Self}}"/>
<Setter Property="BorderThickness" Value="5,3,5,3"/> <Setter Property="WPFExtensions_AttachedBehaviours:DragBehaviour.IsDragEnabled" Value="True"/>
<Setter Property="Padding" Value="10,5,10,5"/> <Setter Property="WPFExtensions_AttachedBehaviours:DragBehaviour.X" Value="{Binding Path=(GraphSharp_Controls:GraphCanvas.X), Mode=TwoWay, RelativeSource={RelativeSource Self}}"/>
<Setter Property="BorderBrush" Value="#FF393939"/> <Setter Property="WPFExtensions_AttachedBehaviours:DragBehaviour.Y" Value="{Binding Path=(GraphSharp_Controls:GraphCanvas.Y), Mode=TwoWay, RelativeSource={RelativeSource Self}}"/>
<Style.Triggers> <Setter Property="Background" Value="#FFE3E3E3"/>
<Trigger Property="GraphSharp_Controls:GraphElementBehaviour.IsHighlighted" Value="True"> <Setter Property="BorderThickness" Value="5,3,5,3"/>
<Setter Property="BorderBrush" Value="{StaticResource HighlightedVertexBorderBrush}"/> <Setter Property="Padding" Value="10,5,10,5"/>
<Setter Property="Background" Value="{StaticResource HighlightedVertexBackgroundBrush}"/> <Setter Property="BorderBrush" Value="#FF393939"/>
<Setter Property="Foreground" Value="{StaticResource HighlightedVertexForegroundBrush}"/> <Style.Triggers>
</Trigger> <Trigger Property="GraphSharp_Controls:GraphElementBehaviour.IsHighlighted" Value="True">
<Trigger Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted" Value="True"> <Setter Property="BorderBrush" Value="{StaticResource HighlightedVertexBorderBrush}"/>
<Setter Property="BorderBrush" Value="{StaticResource HighlightedVertexBorderBrush}"/> <Setter Property="Background" Value="{StaticResource HighlightedVertexBackgroundBrush}"/>
<Setter Property="Background" Value="{StaticResource HighlightedVertexBackgroundBrush}"/> <Setter Property="Foreground" Value="{StaticResource HighlightedVertexForegroundBrush}"/>
<Setter Property="Foreground" Value="{StaticResource HighlightedVertexForegroundBrush}"/> </Trigger>
</Trigger> <Trigger Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted" Value="True">
<MultiTrigger> <Setter Property="BorderBrush" Value="{StaticResource HighlightedVertexBorderBrush}"/>
<MultiTrigger.Conditions> <Setter Property="Background" Value="{StaticResource HighlightedVertexBackgroundBrush}"/>
<Condition Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted" Value="True"/> <Setter Property="Foreground" Value="{StaticResource HighlightedVertexForegroundBrush}"/>
<Condition Property="GraphSharp_Controls:GraphElementBehaviour.SemiHighlightInfo" Value="Source"/> </Trigger>
</MultiTrigger.Conditions> <MultiTrigger>
<Setter Property="BorderBrush" Value="{StaticResource SemiHighlightedSourceVertexBorderBrush}"/> <MultiTrigger.Conditions>
<Setter Property="Background" Value="{StaticResource SemiHighlightedSourceVertexBackgroundBrush}"/> <Condition Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted" Value="True"/>
</MultiTrigger> <Condition Property="GraphSharp_Controls:GraphElementBehaviour.SemiHighlightInfo" Value="Source"/>
<MultiTrigger> </MultiTrigger.Conditions>
<MultiTrigger.Conditions> <Setter Property="BorderBrush" Value="{StaticResource SemiHighlightedSourceVertexBorderBrush}"/>
<Condition Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted" Value="True"/> <Setter Property="Background" Value="{StaticResource SemiHighlightedSourceVertexBackgroundBrush}"/>
<Condition Property="GraphSharp_Controls:GraphElementBehaviour.SemiHighlightInfo" Value="Target"/> </MultiTrigger>
</MultiTrigger.Conditions> <MultiTrigger>
<Setter Property="BorderBrush" Value="{StaticResource SemiHighlightedTargetVertexBorderBrush}"/> <MultiTrigger.Conditions>
<Setter Property="Background" Value="{StaticResource SemiHighlightedTargetVertexBackgroundBrush}"/> <Condition Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted" Value="True"/>
</MultiTrigger> <Condition Property="GraphSharp_Controls:GraphElementBehaviour.SemiHighlightInfo" Value="Target"/>
</Style.Triggers> </MultiTrigger.Conditions>
</Style> <Setter Property="BorderBrush" Value="{StaticResource SemiHighlightedTargetVertexBorderBrush}"/>
<Setter Property="Background" Value="{StaticResource SemiHighlightedTargetVertexBackgroundBrush}"/>
<!-- EDGE CONTROL --> </MultiTrigger>
<Style TargetType="{x:Type GraphSharp_Controls:EdgeControl}"> </Style.Triggers>
<Setter Property="Template"> </Style>
<Setter.Value>
<ControlTemplate TargetType="{x:Type GraphSharp_Controls:EdgeControl}"> <!-- EDGE CONTROL -->
<Path Stroke="{TemplateBinding Foreground}" <Style TargetType="{x:Type GraphSharp_Controls:EdgeControl}">
MinWidth="1" <Setter Property="Template">
MinHeight="1" <Setter.Value>
ToolTip="{TemplateBinding ToolTip}" <ControlTemplate TargetType="{x:Type GraphSharp_Controls:EdgeControl}">
x:Name="edgePath"> <Path Stroke="{TemplateBinding Foreground}"
<Path.Data> MinWidth="1"
<PathGeometry> MinHeight="1"
<PathGeometry.Figures> ToolTip="{TemplateBinding ToolTip}"
<MultiBinding Converter="{StaticResource routeToPathConverter}"> x:Name="edgePath">
<Binding RelativeSource="{RelativeSource TemplatedParent}" <Path.Data>
Path="Source.(GraphSharp_Controls:GraphCanvas.X)" /> <PathGeometry>
<Binding RelativeSource="{RelativeSource TemplatedParent}" <PathGeometry.Figures>
Path="Source.(GraphSharp_Controls:GraphCanvas.Y)" /> <MultiBinding Converter="{StaticResource routeToPathConverter}">
<Binding RelativeSource="{RelativeSource TemplatedParent}" <Binding RelativeSource="{RelativeSource TemplatedParent}"
Path="Source.ActualWidth" /> Path="Source.(GraphSharp_Controls:GraphCanvas.X)" />
<Binding RelativeSource="{RelativeSource TemplatedParent}" <Binding RelativeSource="{RelativeSource TemplatedParent}"
Path="Source.ActualHeight" /> Path="Source.(GraphSharp_Controls:GraphCanvas.Y)" />
<Binding RelativeSource="{RelativeSource TemplatedParent}" <Binding RelativeSource="{RelativeSource TemplatedParent}"
Path="Target.(GraphSharp_Controls:GraphCanvas.X)" /> Path="Source.ActualWidth" />
<Binding RelativeSource="{RelativeSource TemplatedParent}" <Binding RelativeSource="{RelativeSource TemplatedParent}"
Path="Target.(GraphSharp_Controls:GraphCanvas.Y)" /> Path="Source.ActualHeight" />
<Binding RelativeSource="{RelativeSource TemplatedParent}" <Binding RelativeSource="{RelativeSource TemplatedParent}"
Path="Target.ActualWidth" /> Path="Target.(GraphSharp_Controls:GraphCanvas.X)" />
<Binding RelativeSource="{RelativeSource TemplatedParent}" <Binding RelativeSource="{RelativeSource TemplatedParent}"
Path="Target.ActualHeight" /> Path="Target.(GraphSharp_Controls:GraphCanvas.Y)" />
<Binding RelativeSource="{RelativeSource TemplatedParent}" <Binding RelativeSource="{RelativeSource TemplatedParent}"
Path="RoutePoints" /> Path="Target.ActualWidth" />
</MultiBinding> <Binding RelativeSource="{RelativeSource TemplatedParent}"
</PathGeometry.Figures> Path="Target.ActualHeight" />
</PathGeometry> <Binding RelativeSource="{RelativeSource TemplatedParent}"
</Path.Data> Path="RoutePoints" />
</Path> </MultiBinding>
</ControlTemplate> </PathGeometry.Figures>
</Setter.Value> </PathGeometry>
</Setter> </Path.Data>
<Setter Property="GraphSharp_Controls:GraphElementBehaviour.HighlightTrigger" </Path>
Value="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}" /> </ControlTemplate>
<Setter Property="MinWidth" </Setter.Value>
Value="1" /> </Setter>
<Setter Property="MinHeight" <Setter Property="GraphSharp_Controls:GraphElementBehaviour.HighlightTrigger"
Value="1" /> Value="{Binding RelativeSource={RelativeSource Self}, Path=IsMouseOver}" />
<Setter Property="Background" <Setter Property="MinWidth"
Value="Red" /> Value="1" />
<Setter Property="Foreground" <Setter Property="MinHeight"
Value="Silver" /> Value="1" />
<Setter Property="Opacity" <Setter Property="Background"
Value="0.5" /> Value="Red" />
<Style.Triggers> <Setter Property="Foreground"
<Trigger Property="GraphSharp_Controls:GraphElementBehaviour.IsHighlighted" Value="Silver" />
Value="True"> <Setter Property="Opacity"
<Setter Property="Foreground" Value="0.5" />
Value="{DynamicResource HighlightedEdgeBrush}" /> <Style.Triggers>
</Trigger> <Trigger Property="GraphSharp_Controls:GraphElementBehaviour.IsHighlighted"
<Trigger Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted" Value="True">
Value="True"> <Setter Property="Foreground"
<Setter Property="Foreground" Value="{DynamicResource HighlightedEdgeBrush}" />
Value="{DynamicResource HighlightedEdgeBrush}" /> </Trigger>
</Trigger> <Trigger Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted"
<MultiTrigger> Value="True">
<MultiTrigger.Conditions> <Setter Property="Foreground"
<Condition Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted" Value="{DynamicResource HighlightedEdgeBrush}" />
Value="True" /> </Trigger>
<Condition Property="GraphSharp_Controls:GraphElementBehaviour.SemiHighlightInfo" <MultiTrigger>
Value="InEdge" /> <MultiTrigger.Conditions>
</MultiTrigger.Conditions> <Condition Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted"
<Setter Property="Foreground" Value="True" />
Value="{DynamicResource SemiHighlightedInEdgeBrush}" /> <Condition Property="GraphSharp_Controls:GraphElementBehaviour.SemiHighlightInfo"
</MultiTrigger> Value="InEdge" />
<MultiTrigger> </MultiTrigger.Conditions>
<MultiTrigger.Conditions> <Setter Property="Foreground"
<Condition Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted" Value="{DynamicResource SemiHighlightedInEdgeBrush}" />
Value="True" /> </MultiTrigger>
<Condition Property="GraphSharp_Controls:GraphElementBehaviour.SemiHighlightInfo" <MultiTrigger>
Value="OutEdge" /> <MultiTrigger.Conditions>
</MultiTrigger.Conditions> <Condition Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted"
<Setter Property="Foreground" Value="True" />
Value="{DynamicResource SemiHighlightedOutEdgeBrush}" /> <Condition Property="GraphSharp_Controls:GraphElementBehaviour.SemiHighlightInfo"
</MultiTrigger> Value="OutEdge" />
</Style.Triggers> </MultiTrigger.Conditions>
</Style> <Setter Property="Foreground"
Value="{DynamicResource SemiHighlightedOutEdgeBrush}" />
<Style TargetType="{x:Type GraphSharp_Controls:CompoundVertexControl}"> </MultiTrigger>
<Setter Property="Template"> </Style.Triggers>
<Setter.Value> </Style>
<ControlTemplate TargetType="{x:Type GraphSharp_Controls:CompoundVertexControl}">
<Border BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
Padding="10">
<GroupBox>
<GroupBox.Header>
adfajkdsfklad
</GroupBox.Header>
<ItemsControl x:Name="PART_InnerCanvas"
ItemsSource="{TemplateBinding Vertices}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</GroupBox>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="GraphSharp_Controls:GraphElementBehaviour.HighlightTrigger"
Value="{Binding RelativeSource={RelativeSource Self},Path=IsMouseOver}" />
<Setter Property="WPFExtensions_AttachedBehaviours:DragBehaviour.IsDragEnabled"
Value="True" />
<Setter Property="WPFExtensions_AttachedBehaviours:DragBehaviour.X"
Value="{Binding RelativeSource={RelativeSource Self},Path=(GraphSharp_Controls:GraphCanvas.X),Mode=TwoWay}" />
<Setter Property="WPFExtensions_AttachedBehaviours:DragBehaviour.Y"
Value="{Binding RelativeSource={RelativeSource Self},Path=(GraphSharp_Controls:GraphCanvas.Y),Mode=TwoWay}" />
<Setter Property="BorderThickness"
Value="22" />
<Setter Property="BorderBrush"
Value="Silver" />
<Setter Property="Background">
<Setter.Value>
<LinearGradientBrush StartPoint="0,0"
EndPoint="1,1">
<GradientStop Color="White"
Offset="0" />
<GradientStop Color="BurlyWood"
Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="LayoutMode"
Value="Automatic">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GraphSharp_Controls:CompoundVertexControl}">
<Border BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
Padding="10">
<GroupBox>
<GroupBox.Header>
wdawew
</GroupBox.Header>
<ItemsControl x:Name="PART_InnerCanvas"
ItemsSource="{TemplateBinding Vertices}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<GraphSharp_Controls:GraphCanvas Background="White"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</GroupBox>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Background">
<Setter.Value>
<LinearGradientBrush StartPoint="0,0"
EndPoint="1,1">
<GradientStop Color="White"
Offset="0" />
<GradientStop Color="Silver"
Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="GraphSharp_Controls:GraphElementBehaviour.IsHighlighted"
Value="True">
<Setter Property="BorderBrush"
Value="Orange" />
<Setter Property="BorderThickness"
Value="2" />
</Trigger>
<Trigger Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted"
Value="True">
<Setter Property="BorderBrush"
Value="Yellow" />
<Setter Property="BorderThickness"
Value="2" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted"
Value="True" />
<Condition Property="GraphSharp_Controls:GraphElementBehaviour.SemiHighlightInfo"
Value="Source" />
</MultiTrigger.Conditions>
<Setter Property="BorderBrush"
Value="Red" />
<Setter Property="BorderThickness"
Value="2" />
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="GraphSharp_Controls:GraphElementBehaviour.IsSemiHighlighted"
Value="True" />
<Condition Property="GraphSharp_Controls:GraphElementBehaviour.SemiHighlightInfo"
Value="Target" />
</MultiTrigger.Conditions>
<Setter Property="BorderBrush"
Value="Blue" />
<Setter Property="BorderThickness"
Value="2" />
</MultiTrigger>
</Style.Triggers>
</Style>
</ResourceDictionary> </ResourceDictionary>

594
src/AddIns/Analysis/CodeQuality/Src/Controls/DependencyGraphLayout.cs

@ -11,301 +11,301 @@ using QuickGraph;
namespace ICSharpCode.CodeQualityAnalysis.Controls namespace ICSharpCode.CodeQualityAnalysis.Controls
{ {
public class DependencyGraphLayout : GraphLayout<DependencyVertex, DependencyEdge, DependencyGraph> public class DependencyGraphLayout : GraphLayout<DependencyVertex, DependencyEdge, DependencyGraph>
{ {
private Style _defaultVertexControlStyle; private Style _defaultVertexControlStyle;
public event MouseButtonEventHandler VertexClick; public event MouseButtonEventHandler VertexClick;
public event MouseButtonEventHandler VertexRightClick; public event MouseButtonEventHandler VertexRightClick;
public VertexControl SelectedVertexControl { get; set; } public VertexControl SelectedVertexControl { get; set; }
public void ChangeGraph(DependencyGraph graph) public void ChangeGraph(DependencyGraph graph)
{ {
try { try {
if (graph != null && graph.VertexCount > 0) if (graph != null && graph.VertexCount > 0)
Graph = graph; Graph = graph;
} catch {} // ignore it if it fails } catch {} // ignore it if it fails
AttachEvents(); AttachEvents();
} }
private void AttachEvents() private void AttachEvents()
{ {
foreach (UIElement element in Children) foreach (UIElement element in Children)
{ {
var vertex = element as VertexControl; var vertex = element as VertexControl;
if (vertex != null) if (vertex != null)
{ {
// Preview because otherwise is LeftButtonDown blocked // Preview because otherwise is LeftButtonDown blocked
vertex.PreviewMouseLeftButtonDown += vertex_MouseLeftButtonDown; vertex.PreviewMouseLeftButtonDown += vertex_MouseLeftButtonDown;
vertex.MouseRightButtonDown += vertex_MouseRightButtonDown; vertex.MouseRightButtonDown += vertex_MouseRightButtonDown;
vertex.MouseDoubleClick += vertex_MouseDoubleClick; vertex.MouseDoubleClick += vertex_MouseDoubleClick;
} }
} }
} }
void vertex_MouseRightButtonDown(object sender, MouseButtonEventArgs e) void vertex_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
{ {
if (VertexRightClick != null) if (VertexRightClick != null)
VertexRightClick(sender, e); VertexRightClick(sender, e);
var vertexControl = sender as VertexControl; var vertexControl = sender as VertexControl;
if (vertexControl != null) if (vertexControl != null)
CreateContextMenu(vertexControl); CreateContextMenu(vertexControl);
} }
private void CreateContextMenu(VertexControl vertexControl) private void CreateContextMenu(VertexControl vertexControl)
{ {
var menu = new ContextMenu(); var menu = new ContextMenu();
// internal dependencies // internal dependencies
var iternalDependency = new MenuItem { Header = "View internal dependencies on graph" }; var iternalDependency = new MenuItem { Header = "View internal dependencies on graph" };
iternalDependency.Click += (sender, e) => iternalDependency.Click += (sender, e) =>
{ {
var vc = var vc =
((ContextMenu) ((MenuItem) sender).Parent).PlacementTarget as ((ContextMenu) ((MenuItem) sender).Parent).PlacementTarget as
VertexControl; VertexControl;
if (vc != null) if (vc != null)
{ {
var vertex = vertexControl.Vertex as DependencyVertex; var vertex = vertexControl.Vertex as DependencyVertex;
if (vertex != null && vertex.Node.Dependency != null) if (vertex != null && vertex.Node.Dependency != null)
{ {
ChangeGraph(vertex.Node.Dependency.BuildDependencyGraph()); ChangeGraph(vertex.Node.Dependency.BuildDependencyGraph());
} }
} }
}; };
menu.Items.Add(iternalDependency); menu.Items.Add(iternalDependency);
menu.Items.Add(new Separator()); menu.Items.Add(new Separator());
// remove // remove
var remove = new MenuItem { Header = "Remove" }; var remove = new MenuItem { Header = "Remove" };
remove.Click += (sender, e) => remove.Click += (sender, e) =>
{ {
// no nested menus for now so this is ok // no nested menus for now so this is ok
var vc = var vc =
((ContextMenu)((MenuItem)sender).Parent).PlacementTarget as ((ContextMenu)((MenuItem)sender).Parent).PlacementTarget as
VertexControl; VertexControl;
if (vc != null) if (vc != null)
{ {
var vertex = vertexControl.Vertex as DependencyVertex; var vertex = vertexControl.Vertex as DependencyVertex;
if (vertex != null) if (vertex != null)
{ {
RemoveVertexWithEdges(vertex); RemoveVertexWithEdges(vertex);
} }
} }
}; };
menu.Items.Add(remove); menu.Items.Add(remove);
// keep only nodes that use this // keep only nodes that use this
var useThis = new MenuItem { Header = "Keep only nodes that use this" }; var useThis = new MenuItem { Header = "Keep only nodes that use this" };
useThis.Click += (sender, e) => useThis.Click += (sender, e) =>
{ {
// no nested menus for now so this is ok // no nested menus for now so this is ok
var vc = var vc =
((ContextMenu)((MenuItem)sender).Parent).PlacementTarget as ((ContextMenu)((MenuItem)sender).Parent).PlacementTarget as
VertexControl; VertexControl;
if (vc != null) if (vc != null)
{ {
var vertex = vertexControl.Vertex as DependencyVertex; var vertex = vertexControl.Vertex as DependencyVertex;
if (vertex != null) if (vertex != null)
{ {
ISet<DependencyVertex> vertices = new HashSet<DependencyVertex>(); ISet<DependencyVertex> vertices = new HashSet<DependencyVertex>();
vertices.Add(vertex); // original vertex shouldnt be removed vertices.Add(vertex); // original vertex shouldnt be removed
foreach (KeyValuePair<DependencyEdge,EdgeControl> pair in _edgeControls) foreach (KeyValuePair<DependencyEdge,EdgeControl> pair in _edgeControls)
{ {
if (pair.Key.Target.Equals(vertex)) if (pair.Key.Target.Equals(vertex))
{ {
vertices.Add(pair.Key.Source); vertices.Add(pair.Key.Source);
} }
} }
foreach (var v in _vertexControls.Keys.Except(vertices).ToList()) foreach (var v in _vertexControls.Keys.Except(vertices).ToList())
{ {
RemoveVertexWithEdges(v); RemoveVertexWithEdges(v);
} }
} }
} }
}; };
menu.Items.Add(useThis); menu.Items.Add(useThis);
var thisUse = new MenuItem { Header = "Keep only nodes that this use" }; var thisUse = new MenuItem { Header = "Keep only nodes that this use" };
thisUse.Click += (sender, e) => thisUse.Click += (sender, e) =>
{ {
// no nested menus for now so this is ok // no nested menus for now so this is ok
var vc = var vc =
((ContextMenu)((MenuItem)sender).Parent).PlacementTarget as ((ContextMenu)((MenuItem)sender).Parent).PlacementTarget as
VertexControl; VertexControl;
if (vc != null) if (vc != null)
{ {
var vertex = vertexControl.Vertex as DependencyVertex; var vertex = vertexControl.Vertex as DependencyVertex;
if (vertex != null) if (vertex != null)
{ {
ISet<DependencyVertex> vertices = new HashSet<DependencyVertex>(); ISet<DependencyVertex> vertices = new HashSet<DependencyVertex>();
vertices.Add(vertex); // original vertex shouldnt be removed vertices.Add(vertex); // original vertex shouldnt be removed
foreach (KeyValuePair<DependencyEdge, EdgeControl> pair in _edgeControls) foreach (KeyValuePair<DependencyEdge, EdgeControl> pair in _edgeControls)
{ {
if (pair.Key.Source.Equals(vertex)) if (pair.Key.Source.Equals(vertex))
{ {
vertices.Add(pair.Key.Target); vertices.Add(pair.Key.Target);
} }
} }
foreach (var v in _vertexControls.Keys.Except(vertices).ToList()) foreach (var v in _vertexControls.Keys.Except(vertices).ToList())
{ {
RemoveVertexWithEdges(v); RemoveVertexWithEdges(v);
} }
} }
} }
}; };
menu.Items.Add(thisUse); menu.Items.Add(thisUse);
// keep only nodes users and used // keep only nodes users and used
var usersUsed = new MenuItem { Header = "Keep only nodes users and used" }; var usersUsed = new MenuItem { Header = "Keep only nodes users and used" };
usersUsed.Click += (sender, e) => usersUsed.Click += (sender, e) =>
{ {
// no nested menus for now so this is ok // no nested menus for now so this is ok
var vc = var vc =
((ContextMenu)((MenuItem)sender).Parent).PlacementTarget as ((ContextMenu)((MenuItem)sender).Parent).PlacementTarget as
VertexControl; VertexControl;
if (vc != null) if (vc != null)
{ {
var vertex = vertexControl.Vertex as DependencyVertex; var vertex = vertexControl.Vertex as DependencyVertex;
if (vertex != null) if (vertex != null)
{ {
ISet<DependencyVertex> vertices = new HashSet<DependencyVertex>(); ISet<DependencyVertex> vertices = new HashSet<DependencyVertex>();
vertices.Add(vertex); // original vertex shouldnt be removed vertices.Add(vertex); // original vertex shouldnt be removed
foreach (KeyValuePair<DependencyEdge, EdgeControl> pair in _edgeControls) foreach (KeyValuePair<DependencyEdge, EdgeControl> pair in _edgeControls)
{ {
if (pair.Key.Source.Equals(vertex)) if (pair.Key.Source.Equals(vertex))
{ {
vertices.Add(pair.Key.Target); vertices.Add(pair.Key.Target);
} }
if (pair.Key.Target.Equals(vertex)) if (pair.Key.Target.Equals(vertex))
{ {
vertices.Add(pair.Key.Source); vertices.Add(pair.Key.Source);
} }
} }
foreach (var v in _vertexControls.Keys.Except(vertices).ToList()) foreach (var v in _vertexControls.Keys.Except(vertices).ToList())
{ {
RemoveVertexWithEdges(v); RemoveVertexWithEdges(v);
} }
} }
} }
}; };
menu.Items.Add(usersUsed); menu.Items.Add(usersUsed);
vertexControl.ContextMenu = menu; vertexControl.ContextMenu = menu;
vertexControl.ContextMenu.PlacementTarget = this; vertexControl.ContextMenu.PlacementTarget = this;
} }
private void RemoveVertexWithEdges(DependencyVertex vertex) private void RemoveVertexWithEdges(DependencyVertex vertex)
{ {
IList<DependencyEdge> edges = new List<DependencyEdge>(); IList<DependencyEdge> edges = new List<DependencyEdge>();
foreach (KeyValuePair<DependencyEdge,EdgeControl> pair in _edgeControls) foreach (KeyValuePair<DependencyEdge,EdgeControl> pair in _edgeControls)
{ {
if (pair.Key.Source.Equals(vertex) || pair.Key.Target.Equals(vertex)) if (pair.Key.Source.Equals(vertex) || pair.Key.Target.Equals(vertex))
edges.Add(pair.Key); edges.Add(pair.Key);
} }
foreach (DependencyEdge edge in edges) foreach (DependencyEdge edge in edges)
{ {
RemoveEdgeControl(edge); RemoveEdgeControl(edge);
} }
RemoveVertexControl(vertex); RemoveVertexControl(vertex);
} }
private void vertex_MouseDoubleClick(object sender, MouseButtonEventArgs e) private void vertex_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{ {
var vertexControl = sender as VertexControl; var vertexControl = sender as VertexControl;
if (vertexControl != null) if (vertexControl != null)
{ {
var vertex = vertexControl.Vertex as DependencyVertex; var vertex = vertexControl.Vertex as DependencyVertex;
if (vertex != null && vertex.Node.Dependency != null) if (vertex != null && vertex.Node.Dependency != null)
{ {
ChangeGraph(vertex.Node.Dependency.BuildDependencyGraph()); ChangeGraph(vertex.Node.Dependency.BuildDependencyGraph());
} }
} }
} }
private void vertex_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) private void vertex_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{ {
if (VertexClick != null) if (VertexClick != null)
VertexClick(sender, e); VertexClick(sender, e);
var vertex = sender as VertexControl; var vertex = sender as VertexControl;
if (vertex != null) if (vertex != null)
{ {
if (SelectedVertexControl == vertex) if (SelectedVertexControl == vertex)
{ {
SelectedVertexControl.Style = _defaultVertexControlStyle; SelectedVertexControl.Style = _defaultVertexControlStyle;
SelectedVertexControl = null; SelectedVertexControl = null;
return; return;
} }
if (SelectedVertexControl != null) if (SelectedVertexControl != null)
{ {
SelectedVertexControl.Style = vertex.Style; SelectedVertexControl.Style = vertex.Style;
} }
SelectedVertexControl = vertex; SelectedVertexControl = vertex;
_defaultVertexControlStyle = vertex.Style; _defaultVertexControlStyle = vertex.Style;
// workaround which doesnt brake triggers of highlighting // workaround which doesnt brake triggers of highlighting
var style = new Style(); var style = new Style();
foreach (Setter setter in vertex.Style.Setters) foreach (Setter setter in vertex.Style.Setters)
{ {
style.Setters.Add(setter); style.Setters.Add(setter);
} }
foreach (var trigger in vertex.Style.Triggers) foreach (var trigger in vertex.Style.Triggers)
{ {
style.Triggers.Add(trigger); style.Triggers.Add(trigger);
} }
style.Setters.Add(new Setter style.Setters.Add(new Setter
{ {
Property = Control.BackgroundProperty, Property = Control.BackgroundProperty,
Value = new SolidColorBrush(Color.FromRgb(255, 165, 0)) // orange Value = new SolidColorBrush(Color.FromRgb(255, 165, 0)) // orange
}); });
SelectedVertexControl.Style = style; SelectedVertexControl.Style = style;
} }
} }
public void ResetGraph() public void ResetGraph()
{ {
RecreateGraphElements(false); RecreateGraphElements(false);
Relayout(); Relayout();
AttachEvents(); AttachEvents();
} }
public override void Relayout() public override void Relayout()
{ {
if (_vertexControls.Count > 0) if (_vertexControls.Count > 0)
base.Relayout(); base.Relayout();
} }
public override void ContinueLayout() public override void ContinueLayout()
{ {
if (_vertexControls.Count > 0) if (_vertexControls.Count > 0)
base.ContinueLayout(); base.ContinueLayout();
} }
} }
} }

28
src/AddIns/Analysis/CodeQuality/Src/Controls/DependencyIconVertexConverter.cs

@ -0,0 +1,28 @@
using System;
using System.Windows.Data;
using System.Globalization;
using System.Windows.Media.Imaging;
namespace ICSharpCode.CodeQualityAnalysis.Controls
{
/// <summary>
/// Description of DependencyVertexConverter.
/// </summary>
[ValueConversion(typeof(object), typeof(BitmapSource))]
public class DependencyIconVertexConverter : IValueConverter
{
public object Convert(object value, System.Type targetType, object parameter, CultureInfo culture)
{
var vertex = value as DependencyVertex;
if (value != null)
return vertex.Node.Icon;
else
return null;
}
public object ConvertBack(object value, System.Type targetType, object parameter, CultureInfo culture)
{
return value;
}
}
}

10
src/AddIns/Analysis/CodeQuality/Src/Controls/TreeMatrixControl.xaml.cs

@ -1,12 +1,4 @@
/* using System;
* Created by SharpDevelop.
* User: Tomas
* Date: 26.7.2010
* Time: 10:08
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Windows; using System.Windows;

37
src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml

@ -2,6 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls;assembly=ICSharpCode.WpfDesign.Designer" xmlns:Controls="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls;assembly=ICSharpCode.WpfDesign.Designer"
xmlns:GraphSharp="clr-namespace:GraphSharp.Controls;assembly=GraphSharp.Controls"
xmlns:Graph="clr-namespace:ICSharpCode.CodeQualityAnalysis.Controls" xmlns:Graph="clr-namespace:ICSharpCode.CodeQualityAnalysis.Controls"
xmlns:src="clr-namespace:ICSharpCode.CodeQualityAnalysis" xmlns:src="clr-namespace:ICSharpCode.CodeQualityAnalysis"
Title="Code Quality Analysis" Title="Code Quality Analysis"
@ -14,37 +15,37 @@
<DataTemplate x:Key="MemberTemplate"> <DataTemplate x:Key="MemberTemplate">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Image Source="{Binding Path=Icon}" Margin="0, 0, 0, 3" /> <Image Source="{Binding Path=Icon}" Margin="0, 0, 5, 0" />
<TextBlock Text="{Binding Path=Name}" /> <TextBlock Text="{Binding Path=Name}" />
</StackPanel> </StackPanel>
</DataTemplate> </DataTemplate>
<HierarchicalDataTemplate x:Key="TypeTemplate" <HierarchicalDataTemplate x:Key="TypeTemplate"
ItemTemplate="{StaticResource MemberTemplate}" ItemTemplate="{StaticResource MemberTemplate}"
ItemsSource="{Binding Members}"> ItemsSource="{Binding Members}">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Image Source="{Binding Path=Icon}" /> <Image Source="{Binding Path=Icon}" Margin="0, 0, 5, 0" />
<TextBlock Text="{Binding Path=Name}" /> <TextBlock Text="{Binding Path=Name}" />
</StackPanel> </StackPanel>
</HierarchicalDataTemplate> </HierarchicalDataTemplate>
<HierarchicalDataTemplate x:Key="NamespaceTemplate" <HierarchicalDataTemplate x:Key="NamespaceTemplate"
ItemsSource="{Binding Types}" ItemsSource="{Binding Types}"
ItemTemplate="{StaticResource TypeTemplate}"> ItemTemplate="{StaticResource TypeTemplate}">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Image Source="{Binding Path=Icon}" /> <Image Source="{Binding Path=Icon}" Margin="0, 0, 5, 0" />
<TextBlock Text="{Binding Path=Name}" /> <TextBlock Text="{Binding Path=Name}" />
</StackPanel> </StackPanel>
</HierarchicalDataTemplate> </HierarchicalDataTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Namespaces}" <HierarchicalDataTemplate ItemsSource="{Binding Namespaces}"
ItemTemplate="{StaticResource NamespaceTemplate}" ItemTemplate="{StaticResource NamespaceTemplate}"
x:Key="ModuleTemplate"> x:Key="ModuleTemplate">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Image Source="{Binding Path=Icon}" /> <Image Source="{Binding Path=Icon}" Margin="0, 0, 5, 0" />
<TextBlock Text="{Binding Path=Name}" /> <TextBlock Text="{Binding Path=Name}" />
</StackPanel> </StackPanel>
</HierarchicalDataTemplate> </HierarchicalDataTemplate>
</ResourceDictionary> </ResourceDictionary>
</Window.Resources> </Window.Resources>
@ -73,9 +74,9 @@
</ToolBarTray> </ToolBarTray>
<TreeView Name="definitionTree" Grid.Row="1" Grid.Column="0" <TreeView Name="definitionTree" Grid.Row="1" Grid.Column="0"
SelectedItemChanged="definitionTree_SelectedItemChanged" SelectedItemChanged="definitionTree_SelectedItemChanged"
ItemsSource="{Binding}" ItemsSource="{Binding}"
ItemTemplate="{StaticResource ModuleTemplate}"> ItemTemplate="{StaticResource ModuleTemplate}">
</TreeView> </TreeView>
<Controls:ZoomControl Grid.Row="1" Grid.Column="1" Name="zoom" AlwaysShowZoomButtons="True" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible"> <Controls:ZoomControl Grid.Row="1" Grid.Column="1" Name="zoom" AlwaysShowZoomButtons="True" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible">

Loading…
Cancel
Save