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

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

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

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

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

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

@ -0,0 +1,28 @@ @@ -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 @@ @@ -1,12 +1,4 @@
/*
* 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;
using System.Collections.Generic;
using System.Text;
using System.Windows;

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

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

Loading…
Cancel
Save