Browse Source

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

pull/20/merge
PeterForstmeier 14 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 @@ @@ -133,7 +133,7 @@
<Compile Include="Src\INode.cs" />
<Compile Include="Src\Instruction.cs" />
<Compile Include="Src\IValue.cs" />
<Compile Include="Src\MainWindowTranslationModel.cs" />
<Compile Include="Src\MainWindowModel.cs" />
<Compile Include="Src\NodeIconService.cs" />
<Compile Include="Src\IDependency.cs" />
<Compile Include="Src\MetricsReader.cs" />

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

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

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

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

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

@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Windows;
@ -22,30 +23,35 @@ namespace ICSharpCode.CodeQualityAnalysis @@ -22,30 +23,35 @@ namespace ICSharpCode.CodeQualityAnalysis
/// <summary>
/// Description of MainWindowViewModel.
/// </summary>
public class MainWindowTranslationViewModel :ViewModelBase
public class MainWindowViewModel :ViewModelBase
{
public MainWindowTranslationViewModel():base()
public MainWindowViewModel():base()
{
this.FrmTitle = "$Code Quality Analysis";
this.btnOpenAssembly = "$Open Assembly";
#region MainTab
this.TabDependencyGraph = "$Dependency Graph";
this.TabDependencyMatrix = "$Dependency Matrix";
this.TabMetrics = "$Metrics";
#endregion
MetrixTabEnable = false;
}
public string FrmTitle {get;private set;}
public string btnOpenAssembly {get; private set;}
#region Main TabControl
public string TabDependencyGraph {get; private set;}
public string TabDependencyMatrix {get; private set;}
public string TabMetrics {get;private set;}
#endregion
@ -57,6 +63,7 @@ namespace ICSharpCode.CodeQualityAnalysis @@ -57,6 +63,7 @@ namespace ICSharpCode.CodeQualityAnalysis
base.RaisePropertyChanged(() =>FileName);}
}
private Visibility progressbarVisibly = Visibility.Hidden;
public Visibility ProgressbarVisible {
@ -84,6 +91,13 @@ namespace ICSharpCode.CodeQualityAnalysis @@ -84,6 +91,13 @@ namespace ICSharpCode.CodeQualityAnalysis
}
}
bool metrixTabEnable;
public bool MetrixTabEnable {
get { return metrixTabEnable; }
set { metrixTabEnable = value;
base.RaisePropertyChanged(() => MetrixTabEnable);}
}
string typeInfo;
@ -99,76 +113,7 @@ namespace ICSharpCode.CodeQualityAnalysis @@ -99,76 +113,7 @@ namespace ICSharpCode.CodeQualityAnalysis
public Module MainModule {
get { return mainModule; }
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