Browse Source

Merge branch 'master' of github.com:icsharpcode/SharpDevelop

pull/19/head
Tomas Linhart 14 years ago
parent
commit
2df005eb94
  1. 14
      src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml
  2. 26
      src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml.cs
  3. 131
      src/AddIns/Analysis/CodeQuality/Src/MainWindowTranslationModel.cs

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

@ -46,7 +46,7 @@ DataContext="{Binding RelativeSource={RelativeSource Self}}"
</ToolBar> </ToolBar>
</ToolBarTray> </ToolBarTray>
<TabControl Grid.Row="1" Name="mainTabs" IsEnabled="False"> <!-- It is enabled once assembly is loaded. --> <TabControl Grid.Row="1" IsEnabled="{Binding MainTabEnable}"> <!-- It is enabled once assembly is loaded. -->
<TabItem Header="{Binding DependencyGraph}"> <TabItem Header="{Binding DependencyGraph}">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>
@ -93,16 +93,16 @@ DataContext="{Binding RelativeSource={RelativeSource Self}}"
HighlightAlgorithmType="Simple" HighlightAlgorithmType="Simple"
VertexClick="graphLayout_VertexClick" VertexClick="graphLayout_VertexClick"
/> />
</Controls:ZoomControl> </Controls:ZoomControl>
<GridSplitter Grid.Column="3" <GridSplitter Grid.Column="3"
Grid.RowSpan="2" Grid.RowSpan="2"
ResizeDirection="Columns" ResizeDirection="Columns"
HorizontalAlignment="Stretch" Style="{DynamicResource GridSplitterStyle1}"></GridSplitter>
VerticalAlignment="Stretch"
Style="{DynamicResource GridSplitterStyle1}"></GridSplitter>
<TextBlock Name="txbTypeInfo" <TextBlock Name="txbTypeInfo"
Text="{Binding TypeInfo}"
Margin="2" Margin="2"
Grid.Column="4" Grid.RowSpan="2" Padding="5" Background="LightBlue"/> Grid.Column="4" Grid.RowSpan="2" Padding="5" Background="LightBlue"/>
</Grid> </Grid>
@ -154,15 +154,15 @@ DataContext="{Binding RelativeSource={RelativeSource Self}}"
</TabItem> </TabItem>
</TabControl> </TabControl>
<StatusBar Grid.Row="2"> <StatusBar Grid.Row="2">
<StatusBarItem HorizontalAlignment="Left" x:Name="progressBar" Visibility="Hidden"> <StatusBarItem HorizontalAlignment="Left" Visibility="{Binding ProgressbarVisible}">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Text="Loading " /> <TextBlock Text="Loading " />
<TextBlock x:Name="fileAssemblyLoading" /> <TextBlock Text="{Binding FileName}"></TextBlock>
<TextBlock Text="..." Margin="0, 0, 5, 0" /> <TextBlock Text="..." Margin="0, 0, 5, 0" />
<ProgressBar IsIndeterminate="True" Width="95" Height="15" /> <ProgressBar IsIndeterminate="True" Width="95" Height="15" />
</StackPanel> </StackPanel>
</StatusBarItem> </StatusBarItem>
<StatusBarItem HorizontalAlignment="Right" x:Name="assemblyStats" Visibility="Hidden"> <StatusBarItem HorizontalAlignment="Right" Visibility="{Binding AssemblyStatsVisible}">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<StatusBarItem> <StatusBarItem>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">

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

@ -26,8 +26,8 @@ namespace ICSharpCode.CodeQualityAnalysis
public partial class MainWindow : Window, INotifyPropertyChanged public partial class MainWindow : Window, INotifyPropertyChanged
{ {
private MetricsReader metricsReader; private MetricsReader metricsReader;
public event PropertyChangedEventHandler PropertyChanged;
public event PropertyChangedEventHandler PropertyChanged;
public MetricsReader MetricsReader public MetricsReader MetricsReader
{ {
@ -43,13 +43,12 @@ namespace ICSharpCode.CodeQualityAnalysis
} }
} }
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
} }
private void NotifyPropertyChanged(string propertyName) private void NotifyPropertyChanged(string propertyName)
{ {
if (PropertyChanged != null) if (PropertyChanged != null)
@ -58,6 +57,9 @@ namespace ICSharpCode.CodeQualityAnalysis
private void btnOpenAssembly_Click(object sender, RoutedEventArgs e) private void btnOpenAssembly_Click(object sender, RoutedEventArgs e)
{ {
var dc = this.DataContext as MainWindowTranslationViewModel;
var fileDialog = new OpenFileDialog var fileDialog = new OpenFileDialog
{ {
Filter = "Component Files (*.dll, *.exe)|*.dll;*.exe" Filter = "Component Files (*.dll, *.exe)|*.dll;*.exe"
@ -68,16 +70,18 @@ namespace ICSharpCode.CodeQualityAnalysis
if (String.IsNullOrEmpty(fileDialog.FileName)) if (String.IsNullOrEmpty(fileDialog.FileName))
return; return;
progressBar.Visibility = Visibility.Visible; dc.ProgressbarVisible = Visibility.Visible;
assemblyStats.Visibility = Visibility.Hidden; dc.AssemblyStatsVisible = Visibility.Hidden;
fileAssemblyLoading.Text = System.IO.Path.GetFileName(fileDialog.FileName); dc.FileName = System.IO.Path.GetFileName(fileDialog.FileName);
var worker = new BackgroundWorker(); var worker = new BackgroundWorker();
worker.DoWork += (source, args) => MetricsReader = new MetricsReader(fileDialog.FileName); worker.DoWork += (source, args) => MetricsReader = new MetricsReader(fileDialog.FileName);
worker.RunWorkerCompleted += (source, args) => { worker.RunWorkerCompleted += (source, args) => {
progressBar.Visibility = Visibility.Hidden;
assemblyStats.Visibility = Visibility.Visible; dc.ProgressbarVisible = Visibility.Hidden;
mainTabs.IsEnabled = true; dc.AssemblyStatsVisible = Visibility.Visible;
dc.MainTabEnable = true;
Helper.FillTree(definitionTree, metricsReader.MainModule); Helper.FillTree(definitionTree, metricsReader.MainModule);
FillMatrix(); FillMatrix();
}; };
@ -143,7 +147,8 @@ namespace ICSharpCode.CodeQualityAnalysis
var vertex = vertexControl.Vertex as DependencyVertex; var vertex = vertexControl.Vertex as DependencyVertex;
if (vertex != null) if (vertex != null)
{ {
txbTypeInfo.Text = vertex.Node.GetInfo(); var d = this.DataContext as MainWindowTranslationViewModel;
d.TypeInfo = vertex.Node.GetInfo();
} }
} }
} }
@ -155,6 +160,7 @@ namespace ICSharpCode.CodeQualityAnalysis
private void btnSaveImageGraph_Click(object sender, RoutedEventArgs e) private void btnSaveImageGraph_Click(object sender, RoutedEventArgs e)
{ {
var fileDialog = new SaveFileDialog() var fileDialog = new SaveFileDialog()
{ {
Filter = "PNG (*.png)|*.png|JPEG (*.jpg)|*.jpg|GIF (*.gif)|*.gif|BMP (*.bmp)|*.bmp|TIFF (.tiff)|*.tiff" Filter = "PNG (*.png)|*.png|JPEG (*.jpg)|*.jpg|GIF (*.gif)|*.gif|BMP (*.bmp)|*.bmp|TIFF (.tiff)|*.tiff"

131
src/AddIns/Analysis/CodeQuality/Src/MainWindowTranslationModel.cs

@ -9,7 +9,9 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media.Imaging;
using ICSharpCode.CodeQualityAnalysis.Controls; using ICSharpCode.CodeQualityAnalysis.Controls;
using ICSharpCode.CodeQualityAnalysis.Utility; using ICSharpCode.CodeQualityAnalysis.Utility;
@ -22,6 +24,9 @@ namespace ICSharpCode.CodeQualityAnalysis
/// </summary> /// </summary>
public class MainWindowTranslationViewModel :ViewModelBase public class MainWindowTranslationViewModel :ViewModelBase
{ {
string typeInfo;
public MainWindowTranslationViewModel():base() public MainWindowTranslationViewModel():base()
{ {
@ -37,71 +42,113 @@ namespace ICSharpCode.CodeQualityAnalysis
public string DependencyGraph {get; private set;} public string DependencyGraph {get; private set;}
private string fileName;
public string FileName {
get { return fileName; }
set { fileName = value;
base.RaisePropertyChanged(() =>FileName);}
}
private Visibility progressbarVisibly ;
public Visibility ProgressbarVisible {
get { return progressbarVisibly; }
set { progressbarVisibly = value;
base.RaisePropertyChanged(() =>ProgressbarVisible);
}
}
private Visibility assemblyStatsVisible;
public Visibility AssemblyStatsVisible {
get { return assemblyStatsVisible; }
set { assemblyStatsVisible = value;
base.RaisePropertyChanged(() => AssemblyStatsVisible);
}
}
bool mainTabEnable;
public bool MainTabEnable {
get { return mainTabEnable; }
set { mainTabEnable = value;
base.RaisePropertyChanged(() => MainTabEnable);
}
}
public string TypeInfo {
get { return typeInfo; }
set { typeInfo = value;
base.RaisePropertyChanged(() =>this.TypeInfo);
}
}
#region OpenAssembly
/* /*
#region OpenAssembly
public ICommand OpenAssemblyCommand public ICommand OpenAssemblyCommand
{ {
get { return new RelayCommand(OpenAssemblyExecute, CanOpenAssemblyExecute); } get { return new RelayCommand(SaveAssemblyExecute, CanSaveAssemblyExecute); }
} }
Boolean CanOpenAssemblyExecute() Boolean CanSaveAssemblyExecute()
{ {
return true; return true;
} }
void OpenAssemblyExecute() void SaveAssemblyExecute()
{ {
var fileDialog = new OpenFileDialog var fileDialog = new SaveFileDialog()
{ {
Filter = "Component Files (*.dll, *.exe)|*.dll;*.exe" Filter = "PNG (*.png)|*.png|JPEG (*.jpg)|*.jpg|GIF (*.gif)|*.gif|BMP (*.bmp)|*.bmp|TIFF (.tiff)|*.tiff"
}; };
fileDialog.ShowDialog(); fileDialog.ShowDialog();
if (String.IsNullOrEmpty(fileDialog.FileName)) if (String.IsNullOrEmpty(fileDialog.FileName))
return; return;
progressBar.Visibility = Visibility.Visible;
assemblyStats.Visibility = Visibility.Hidden;
fileAssemblyLoading.Text = System.IO.Path.GetFileName(fileDialog.FileName);
var worker = new BackgroundWorker();
worker.DoWork += (source, args) => MetricsReader = new MetricsReader(fileDialog.FileName);
worker.RunWorkerCompleted += (source, args) => {
progressBar.Visibility = Visibility.Hidden;
assemblyStats.Visibility = Visibility.Visible;
mainTabs.IsEnabled = true;
Helper.FillTree(definitionTree, metricsReader.MainModule);
FillMatrix();
};
worker.RunWorkerAsync();
}
private void FillMatrix()
{
var matrix = new DependencyMatrix();
foreach (var ns in metricsReader.MainModule.Namespaces) { // render it
matrix.HeaderRows.Add(new Cell<INode>(ns)); var renderBitmap = new RenderTargetBitmap((int)graphLayout.ActualWidth,
foreach (var type in ns.Types) { (int)graphLayout.ActualHeight,
matrix.HeaderRows.Add(new Cell<INode>(type)); 96d,
} 96d,
matrix.HeaderColumns.Add(new Cell<INode>(ns)); PixelFormats.Default);
foreach (var type in ns.Types) { renderBitmap.Render(graphLayout);
matrix.HeaderColumns.Add(new Cell<INode>(type));
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);
} }
}
//matrixControl.Matrix = matrix;
//matrixControl.DrawTree(metricsReader.MainModule);
}
*/
#endregion #endregion
*/
} }
} }

Loading…
Cancel
Save