Browse Source

TreeMatrixControl, add Treeview at Top

pull/19/head
PeterForstmeier 15 years ago
parent
commit
1c3754a2f2
  1. 73
      src/AddIns/Analysis/CodeQuality/Src/Controls/TreeMatrixControl.xaml
  2. 54
      src/AddIns/Analysis/CodeQuality/Src/Controls/TreeMatrixControl.xaml.cs
  3. 1
      src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml.cs

73
src/AddIns/Analysis/CodeQuality/Src/Controls/TreeMatrixControl.xaml

@ -1,38 +1,73 @@
<UserControl x:Class="ICSharpCode.CodeQualityAnalysis.Controls.TreeMatrixControl" <?xml version="1.0" encoding="utf-8"?>
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" <UserControl
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="ICSharpCode.CodeQualityAnalysis.Controls.TreeMatrixControl" 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:Controls="clr-namespace:ICSharpCode.CodeQualityAnalysis.Controls">
<UserControl.Resources> <UserControl.Resources>
<Style TargetType="{x:Type TreeViewItem}"> <Style
<Setter Property="BorderBrush" Value="Red" /> TargetType="{x:Type TreeViewItem}">
<Setter Property="Header" Value="test" /> <Setter
Property="BorderBrush"
Value="Red" />
<Setter
Property="Header"
Value="test" />
</Style> </Style>
</UserControl.Resources> </UserControl.Resources>
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition
<RowDefinition Height="*" /> Height="Auto" />
<RowDefinition
Height="3" />
<RowDefinition
Height="*" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition
<ColumnDefinition Width="*" /> Width="Auto" />
<ColumnDefinition
Width="3" />
<ColumnDefinition
Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<TreeView Name="leftTree" Grid.Row="1" Grid.Column="0"> <TreeView
<TreeView.Resources> Name="leftTree"
Grid.Row="2"
</TreeView.Resources> Grid.Column="0">
<TreeView.Resources></TreeView.Resources>
</TreeView> </TreeView>
<GridSplitter Grid.Column="1" Width="3"
Grid.RowSpan="3"
ResizeDirection="Columns"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"></GridSplitter>
<TreeView Name="topTree" Grid.Row="0" Grid.Column="1"> <TreeView
Name="topTree"
Grid.Row="0"
Grid.Column="2">
<TreeView.LayoutTransform> <TreeView.LayoutTransform>
<RotateTransform Angle="-90" /> <RotateTransform
Angle="-90" />
</TreeView.LayoutTransform> </TreeView.LayoutTransform>
</TreeView> </TreeView>
<ScrollViewer Grid.Column="1" Grid.Row="1" CanContentScroll="True" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Visible"> <GridSplitter Grid.Row="1"
<Controls:DependencyMatrixControl x:Name="matrixControl" /> Grid.Column="2"
Height="3"
ResizeDirection="Rows"
HorizontalAlignment="Stretch"></GridSplitter>
<ScrollViewer
Grid.Column="2"
Grid.Row="2"
CanContentScroll="True"
VerticalScrollBarVisibility="Visible"
HorizontalScrollBarVisibility="Visible">
<Controls:DependencyMatrixControl
x:Name="matrixControl" />
</ScrollViewer> </ScrollViewer>
</Grid> </Grid>
</UserControl> </UserControl>

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

@ -12,6 +12,7 @@ using System.Windows.Documents;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Forms; using System.Windows.Forms;
using System.Linq;
namespace ICSharpCode.CodeQualityAnalysis.Controls namespace ICSharpCode.CodeQualityAnalysis.Controls
{ {
@ -38,52 +39,53 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
InitializeComponent(); InitializeComponent();
} }
public void DrawMatrix()
public void DrawTree(Module module)
{ {
// matrixControl.DrawMatrix(); FillTree (leftTree,module);
FillTree (topTree,module);
} }
public void DrawTree(Module module) private void FillTree (System.Windows.Controls.TreeView tree,Module module)
{ {
foreach (var ns in module.Namespaces) foreach (var ns in module.Namespaces)
{ {
var nsType = new TreeViewItem var leftType = CreateTreeItem(ns.Name);
{
Header = ns.Name
};
leftTree.Items.Add(nsType); tree.Items.Add(leftType);
foreach (var type in ns.Types) foreach (var type in ns.Types)
{ {
var itemType = new TreeViewItem var lType = CreateTreeItem(type.Name);
{
Header = type.Name leftType.Items.Add(lType);
};
nsType.Items.Add(itemType);
foreach (var method in type.Methods) foreach (var method in type.Methods)
{ {
var itemMethod = new TreeViewItem var leftMethod = CreateTreeItem(method.Name);
{ leftType.Items.Add(leftMethod);
Header = method.Name
};
itemType.Items.Add(itemMethod);
} }
foreach (var field in type.Fields) foreach (var field in type.Fields)
{ {
var itemField = new TreeViewItem var leftField = CreateTreeItem(field.Name);
{ leftType.Items.Add(leftField);
Header = field.Name
};
itemType.Items.Add(itemField);
} }
} }
} }
} }
private TreeViewItem CreateTreeItem (string ns)
{
var nsType = new TreeViewItem
{
Header = ns,
ToolTip = ns
};
// nsType.Height = matrixControl.CellHeight;
return nsType;
}
} }
} }

1
src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml.cs

@ -104,7 +104,6 @@ namespace ICSharpCode.CodeQualityAnalysis
} }
matrixControl.Matrix = matrix; matrixControl.Matrix = matrix;
matrixControl.DrawMatrix();
matrixControl.DrawTree(metricsReader.MainModule); matrixControl.DrawTree(metricsReader.MainModule);
} }

Loading…
Cancel
Save