Browse Source

Rename ViewModel, set Enable for Metrix TabItem after *dll is selected from Tree

pull/20/merge
PeterForstmeier 15 years ago
parent
commit
b5063624c4
  1. 2
      src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj
  2. 30
      src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml
  3. 10
      src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml.cs
  4. 93
      src/AddIns/Analysis/CodeQuality/Src/MainWindowModel.cs

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

@ -133,7 +133,7 @@
<Compile Include="Src\INode.cs" /> <Compile Include="Src\INode.cs" />
<Compile Include="Src\Instruction.cs" /> <Compile Include="Src\Instruction.cs" />
<Compile Include="Src\IValue.cs" /> <Compile Include="Src\IValue.cs" />
<Compile Include="Src\MainWindowTranslationModel.cs" /> <Compile Include="Src\MainWindowModel.cs" />
<Compile Include="Src\NodeIconService.cs" /> <Compile Include="Src\NodeIconService.cs" />
<Compile Include="Src\IDependency.cs" /> <Compile Include="Src\IDependency.cs" />
<Compile Include="Src\MetricsReader.cs" /> <Compile Include="Src\MetricsReader.cs" />

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

@ -1,6 +1,7 @@
<Window x:Class="ICSharpCode.CodeQualityAnalysis.MainWindow" <Window x:Class="ICSharpCode.CodeQualityAnalysis.MainWindow"
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:GraphSharp="clr-namespace:GraphSharp.Controls;assembly=GraphSharp.Controls"
xmlns:Graph="clr-namespace:ICSharpCode.CodeQualityAnalysis.Controls" xmlns:Graph="clr-namespace:ICSharpCode.CodeQualityAnalysis.Controls"
@ -8,24 +9,21 @@
xmlns:debug="clr-namespace:System.Diagnostics;assembly=System" xmlns:debug="clr-namespace:System.Diagnostics;assembly=System"
xmlns:datavis="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit" xmlns:datavis="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
xmlns:tree="http://icsharpcode.net/sharpdevelop/treeview" xmlns:tree="http://icsharpcode.net/sharpdevelop/treeview"
xmlns:local="clr-namespace:ICSharpCode.CodeQualityAnalysis" xmlns:sys="clr-namespace:System;assembly=mscorlib"
Title="{Binding FrmTitle}" Title="{Binding FrmTitle}"
x:Name="root"> x:Name="root">
<!--
Title="Code Quality Analysis" <Window.DataContext>
DataContext="{Binding RelativeSource={RelativeSource Self}}" <src:MainWindowViewModel/>
--> </Window.DataContext>
<Window.DataContext>
<local:MainWindowTranslationViewModel />
</Window.DataContext>
<Window.Resources> <Window.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../Resources/GraphTemplate.xaml" /> <ResourceDictionary Source="../Resources/GraphTemplate.xaml" />
<ResourceDictionary Source="../Resources/GridSplitterTemplate.xaml" /> <ResourceDictionary Source="../Resources/GridSplitterTemplate.xaml" />
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </ResourceDictionary>
</Window.Resources> </Window.Resources>
@ -106,14 +104,14 @@ DataContext="{Binding RelativeSource={RelativeSource Self}}"
Text="{Binding TypeInfo}" Text="{Binding TypeInfo}"
Margin="2" MinWidth="30" Margin="2" MinWidth="30"
Grid.Column="4" Grid.Row="1" Grid.Column="4" Grid.Row="1"
Padding="5" Padding="5"
Background="LightBlue"/> Background="LightBlue"/>
</Grid> </Grid>
</TabItem> </TabItem>
<TabItem Header="{Binding TabDependencyMatrix}"> <TabItem Header="{Binding TabDependencyMatrix}">
<Graph:TreeMatrixControl x:Name="matrixControl"></Graph:TreeMatrixControl> <Graph:TreeMatrixControl x:Name="matrixControl"></Graph:TreeMatrixControl>
</TabItem> </TabItem>
<TabItem Header="{Binding TabMetrics}"> <TabItem Header="{Binding TabMetrics}" IsEnabled="{Binding MetrixTabEnable}">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto" /> <RowDefinition Height="Auto" />
@ -127,7 +125,10 @@ DataContext="{Binding RelativeSource={RelativeSource Self}}"
<ToolBarTray Background="White" Grid.Row="0" Grid.Column="0"> <ToolBarTray Background="White" Grid.Row="0" Grid.Column="0">
<ToolBar> <ToolBar>
<TextBlock Text="Level: " /> <TextBlock Text="Level: " />
<ComboBox IsEditable="False" x:Name="cbxMetrixLevel" IsDropDownOpen="True" Width="150" SelectionChanged="MetricLevel_SelectionChanged"> <ComboBox IsEditable="False"
x:Name="cbxMetrixLevel"
IsDropDownOpen="True"
Width="150" SelectionChanged="MetricLevel_SelectionChanged">
<ComboBoxItem Name="assembly">Assembly</ComboBoxItem> <ComboBoxItem Name="assembly">Assembly</ComboBoxItem>
<ComboBoxItem Name="namespace">Namespace</ComboBoxItem> <ComboBoxItem Name="namespace">Namespace</ComboBoxItem>
<ComboBoxItem Name="type">Type</ComboBoxItem> <ComboBoxItem Name="type">Type</ComboBoxItem>
@ -156,6 +157,7 @@ DataContext="{Binding RelativeSource={RelativeSource Self}}"
</Grid> </Grid>
</TabItem> </TabItem>
</TabControl> </TabControl>
<StatusBar Grid.Row="2"> <StatusBar Grid.Row="2">
<StatusBarItem HorizontalAlignment="Left" Visibility="{Binding ProgressbarVisible}"> <StatusBarItem HorizontalAlignment="Left" Visibility="{Binding ProgressbarVisible}">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">

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

@ -58,7 +58,7 @@ namespace ICSharpCode.CodeQualityAnalysis
private void btnOpenAssembly_Click(object sender, RoutedEventArgs e) private void btnOpenAssembly_Click(object sender, RoutedEventArgs e)
{ {
var dataContext = this.DataContext as MainWindowTranslationViewModel; var dataContext = this.DataContext as MainWindowViewModel;
var fileDialog = new OpenFileDialog var fileDialog = new OpenFileDialog
{ {
@ -137,6 +137,8 @@ namespace ICSharpCode.CodeQualityAnalysis
definitionTree.SelectedItem = item; definitionTree.SelectedItem = item;
var graph = item.INode.Dependency.BuildDependencyGraph(); var graph = item.INode.Dependency.BuildDependencyGraph();
graphLayout.ChangeGraph(graph); graphLayout.ChangeGraph(graph);
var d = this.DataContext as MainWindowViewModel;
d.MetrixTabEnable = true;
} }
} }
@ -149,7 +151,7 @@ namespace ICSharpCode.CodeQualityAnalysis
var vertex = vertexControl.Vertex as DependencyVertex; var vertex = vertexControl.Vertex as DependencyVertex;
if (vertex != null) if (vertex != null)
{ {
var d = this.DataContext as MainWindowTranslationViewModel; var d = this.DataContext as MainWindowViewModel;
d.TypeInfo = vertex.Node.GetInfo(); d.TypeInfo = vertex.Node.GetInfo();
} }
} }
@ -260,6 +262,10 @@ namespace ICSharpCode.CodeQualityAnalysis
} else if (level == "Field") { } else if (level == "Field") {
} else if (level == "Method") { } else if (level == "Method") {
var r = from ns in MetricsReader.MainModule.Namespaces
from type in ns.Types
from method in type.Methods
select method;
treemap.ItemsSource = from ns in MetricsReader.MainModule.Namespaces treemap.ItemsSource = from ns in MetricsReader.MainModule.Namespaces
from type in ns.Types from type in ns.Types
from method in type.Methods from method in type.Methods

93
src/AddIns/Analysis/CodeQuality/Src/MainWindowTranslationModel.cs → src/AddIns/Analysis/CodeQuality/Src/MainWindowModel.cs

@ -7,6 +7,7 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
using System; using System;
using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
@ -22,30 +23,35 @@ namespace ICSharpCode.CodeQualityAnalysis
/// <summary> /// <summary>
/// Description of MainWindowViewModel. /// Description of MainWindowViewModel.
/// </summary> /// </summary>
public class MainWindowTranslationViewModel :ViewModelBase
public class MainWindowViewModel :ViewModelBase
{ {
public MainWindowTranslationViewModel():base() public MainWindowViewModel():base()
{ {
this.FrmTitle = "$Code Quality Analysis"; this.FrmTitle = "$Code Quality Analysis";
this.btnOpenAssembly = "$Open Assembly"; this.btnOpenAssembly = "$Open Assembly";
#region MainTab #region MainTab
this.TabDependencyGraph = "$Dependency Graph"; this.TabDependencyGraph = "$Dependency Graph";
this.TabDependencyMatrix = "$Dependency Matrix"; this.TabDependencyMatrix = "$Dependency Matrix";
this.TabMetrics = "$Metrics"; this.TabMetrics = "$Metrics";
#endregion #endregion
MetrixTabEnable = false;
} }
public string FrmTitle {get;private set;} public string FrmTitle {get;private set;}
public string btnOpenAssembly {get; private set;} public string btnOpenAssembly {get; private set;}
#region Main TabControl #region Main TabControl
public string TabDependencyGraph {get; private set;} public string TabDependencyGraph {get; private set;}
public string TabDependencyMatrix {get; private set;} public string TabDependencyMatrix {get; private set;}
public string TabMetrics {get;private set;} public string TabMetrics {get;private set;}
#endregion #endregion
@ -57,6 +63,7 @@ namespace ICSharpCode.CodeQualityAnalysis
base.RaisePropertyChanged(() =>FileName);} base.RaisePropertyChanged(() =>FileName);}
} }
private Visibility progressbarVisibly = Visibility.Hidden; private Visibility progressbarVisibly = Visibility.Hidden;
public Visibility ProgressbarVisible { public Visibility ProgressbarVisible {
@ -84,6 +91,13 @@ namespace ICSharpCode.CodeQualityAnalysis
} }
} }
bool metrixTabEnable;
public bool MetrixTabEnable {
get { return metrixTabEnable; }
set { metrixTabEnable = value;
base.RaisePropertyChanged(() => MetrixTabEnable);}
}
string typeInfo; string typeInfo;
@ -99,76 +113,7 @@ namespace ICSharpCode.CodeQualityAnalysis
public Module MainModule { public Module MainModule {
get { return mainModule; } get { return mainModule; }
set { mainModule = value; set { mainModule = value;
base.RaisePropertyChanged(() =>this.MainModule);} base.RaisePropertyChanged(() =>this.MainModule);}
} }
/*
#region OpenAssembly
public ICommand OpenAssemblyCommand
{
get { return new RelayCommand(SaveAssemblyExecute, CanSaveAssemblyExecute); }
}
Boolean CanSaveAssemblyExecute()
{
return true;
}
void SaveAssemblyExecute()
{
var fileDialog = new SaveFileDialog()
{
Filter = "PNG (*.png)|*.png|JPEG (*.jpg)|*.jpg|GIF (*.gif)|*.gif|BMP (*.bmp)|*.bmp|TIFF (.tiff)|*.tiff"
};
fileDialog.ShowDialog();
if (String.IsNullOrEmpty(fileDialog.FileName))
return;
// render it
var renderBitmap = new RenderTargetBitmap((int)graphLayout.ActualWidth,
(int)graphLayout.ActualHeight,
96d,
96d,
PixelFormats.Default);
renderBitmap.Render(graphLayout);
using (var outStream = new FileStream(fileDialog.FileName, FileMode.Create))
{
BitmapEncoder encoder;
switch (fileDialog.FilterIndex)
{
case 1:
encoder = new PngBitmapEncoder();
break;
case 2:
encoder = new JpegBitmapEncoder();
break;
case 3:
encoder = new GifBitmapEncoder();
break;
case 4:
encoder = new BmpBitmapEncoder();
break;
case 5:
encoder = new TiffBitmapEncoder();
break;
default:
encoder = new PngBitmapEncoder();
break;
}
encoder.Frames.Add(BitmapFrame.Create(renderBitmap));
encoder.Save(outStream);
}
}
#endregion
*/
} }
} }
Loading…
Cancel
Save