Browse Source

Marking element

pull/19/head
PeterForstmeier 14 years ago
parent
commit
6393f518ec
  1. 21
      src/AddIns/Analysis/CodeQuality/Src/Controls/TreeMatrixControl.xaml.cs
  2. 10
      src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml
  3. 15
      src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml.cs
  4. 16
      src/AddIns/Analysis/CodeQuality/Src/MainWindowTranslationModel.cs
  5. 18
      src/AddIns/Analysis/CodeQuality/Src/Utility/Helper.cs

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

@ -16,7 +16,9 @@ using System.Windows.Forms; @@ -16,7 +16,9 @@ using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
using ICSharpCode.CodeQualityAnalysis.Utility;
using ICSharpCode.TreeView;
namespace ICSharpCode.CodeQualityAnalysis.Controls
{
@ -48,6 +50,7 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls @@ -48,6 +50,7 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
InitializeComponent();
matrixControl.Colorizer = new DependencyColorizer();
matrixControl.HoveredCellChanged += OnHoverChanged;
}
public void DrawTree(Module module)
@ -55,12 +58,19 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls @@ -55,12 +58,19 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
var leftCol = leftTree.Items.SourceCollection as INotifyCollectionChanged;
leftCol.CollectionChanged += BuildLeftINodeList;
Helper.FillTree(leftTree, module);
leftTree.MouseMove += (s,e)=>
{
var c = Helper.GetParent<SharpTreeViewItem>(e.OriginalSource as DependencyObject);
if (c != null){
};
var topCol = topTree.Items.SourceCollection as INotifyCollectionChanged;
topCol.CollectionChanged += BuildTopINodeList;
Helper.FillTree(topTree, module);
}
void Trees_Loaded (object sender, EventArgs e)
{
leftTree.ApplyTemplate();
@ -70,6 +80,8 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls @@ -70,6 +80,8 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
topScrollViewer = Helper.FindVisualChild<ScrollViewer>(topTree);
}
#region Update MatricControl
bool rebuildLeftNodeListRequested;
void BuildLeftINodeList(object sender,NotifyCollectionChangedEventArgs e)
@ -117,6 +129,9 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls @@ -117,6 +129,9 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
matrixControl.SetVisibleItems(HeaderType.Columns, topNodes);
}
#endregion
void OnHoverChanged(object sender ,HoveredCellEventArgs <Relationship> e)
{
if (e.HoveredCell.RowIndex < leftTree.Items.Count) {
@ -135,8 +150,8 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls @@ -135,8 +150,8 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
void LeftTree_ScrollChanged(object sender, ScrollChangedEventArgs e)
{
// Console.WriteLine("Left TreeScroll");
// scrollViewer.ScrollToVerticalOffset(e.VerticalOffset * matrixControl.CellHeight);
Console.WriteLine("Left TreeScroll {0} - {1}",e.VerticalOffset * matrixControl.CellHeight,leftTree.Items.Count);
scrollViewer.ScrollToVerticalOffset(e.VerticalOffset * matrixControl.CellHeight);
Console.WriteLine("--");
}
@ -144,7 +159,7 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls @@ -144,7 +159,7 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
{
// Console.WriteLine("Top TreeScroll ");
// scrollViewer.ScrollToHorizontalOffset(e.VerticalChange * matrixControl.CellHeight);
Console.WriteLine("--");
// Console.WriteLine("--");
}

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

@ -167,31 +167,31 @@ DataContext="{Binding RelativeSource={RelativeSource Self}}" @@ -167,31 +167,31 @@ DataContext="{Binding RelativeSource={RelativeSource Self}}"
<StatusBarItem>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Namespaces: " />
<TextBlock Text="{Binding Path=MetricsReader.MainModule.Namespaces.Count}" />
<TextBlock Text="{Binding Path=MainModule.Namespaces.Count}" />
</StackPanel>
</StatusBarItem>
<StatusBarItem>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Types: " />
<TextBlock Text="{Binding Path=MetricsReader.MainModule.TypesCount}" />
<TextBlock Text="{Binding Path=MainModule.TypesCount}" />
</StackPanel>
</StatusBarItem>
<StatusBarItem>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Methods: " />
<TextBlock Text="{Binding Path=MetricsReader.MainModule.MethodsCount}" />
<TextBlock Text="{Binding Path=MainModule.MethodsCount}" />
</StackPanel>
</StatusBarItem>
<StatusBarItem>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Fields: " />
<TextBlock Text="{Binding Path=MetricsReader.MainModule.FieldsCount}" />
<TextBlock Text="{Binding Path=MainModule.FieldsCount}" />
</StackPanel>
</StatusBarItem>
<StatusBarItem>
<StackPanel Orientation="Horizontal">
<TextBlock Text="IL instructions: " />
<TextBlock Text="{Binding Path=MetricsReader.MainModule.InstructionsCount}" />
<TextBlock Text="{Binding Path=MainModule.InstructionsCount}" />
</StackPanel>
</StatusBarItem>
</StackPanel>

15
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 dc = this.DataContext as MainWindowTranslationViewModel;
var dataContext = this.DataContext as MainWindowTranslationViewModel;
var fileDialog = new OpenFileDialog
{
@ -70,19 +70,20 @@ namespace ICSharpCode.CodeQualityAnalysis @@ -70,19 +70,20 @@ namespace ICSharpCode.CodeQualityAnalysis
if (String.IsNullOrEmpty(fileDialog.FileName))
return;
dc.ProgressbarVisible = Visibility.Visible;
dc.AssemblyStatsVisible = Visibility.Hidden;
dc.FileName = System.IO.Path.GetFileName(fileDialog.FileName);
dataContext.ProgressbarVisible = Visibility.Visible;
dataContext.AssemblyStatsVisible = Visibility.Hidden;
dataContext.FileName = System.IO.Path.GetFileName(fileDialog.FileName);
var worker = new BackgroundWorker();
worker.DoWork += (source, args) => MetricsReader = new MetricsReader(fileDialog.FileName);
worker.RunWorkerCompleted += (source, args) => {
dc.ProgressbarVisible = Visibility.Hidden;
dc.AssemblyStatsVisible = Visibility.Visible;
dc.MainTabEnable = true;
dataContext.ProgressbarVisible = Visibility.Hidden;
dataContext.AssemblyStatsVisible = Visibility.Visible;
dataContext.MainTabEnable = true;
Helper.FillTree(definitionTree, metricsReader.MainModule);
dataContext.MainModule = metricsReader.MainModule;
FillMatrix();
};

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

@ -24,9 +24,6 @@ namespace ICSharpCode.CodeQualityAnalysis @@ -24,9 +24,6 @@ namespace ICSharpCode.CodeQualityAnalysis
/// </summary>
public class MainWindowTranslationViewModel :ViewModelBase
{
string typeInfo;
public MainWindowTranslationViewModel():base()
{
@ -77,6 +74,9 @@ namespace ICSharpCode.CodeQualityAnalysis @@ -77,6 +74,9 @@ namespace ICSharpCode.CodeQualityAnalysis
}
}
string typeInfo;
public string TypeInfo {
get { return typeInfo; }
set { typeInfo = value;
@ -84,6 +84,16 @@ namespace ICSharpCode.CodeQualityAnalysis @@ -84,6 +84,16 @@ namespace ICSharpCode.CodeQualityAnalysis
}
}
private Module mainModule;
public Module MainModule {
get { return mainModule; }
set { mainModule = value;
base.RaisePropertyChanged(() =>this.MainModule);}
}
/*
#region OpenAssembly

18
src/AddIns/Analysis/CodeQuality/Src/Utility/Helper.cs

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace ICSharpCode.CodeQualityAnalysis
@ -66,7 +67,7 @@ namespace ICSharpCode.CodeQualityAnalysis @@ -66,7 +67,7 @@ namespace ICSharpCode.CodeQualityAnalysis
public static T FindVisualChild<T>( DependencyObject obj )
where T : DependencyObject
{
// Search immediate children first (breadth-first)
// depth-first Search
for( int i = 0; i < VisualTreeHelper.GetChildrenCount( obj ); i++ )
{
@ -89,5 +90,20 @@ namespace ICSharpCode.CodeQualityAnalysis @@ -89,5 +90,20 @@ namespace ICSharpCode.CodeQualityAnalysis
return null;
}
public static ItemContainer GetParent<ItemContainer>(this DependencyObject obj)
where ItemContainer : DependencyObject
{
if (obj == null)
return null;
while (VisualTreeHelper.GetParent(obj) != null && !(obj is ItemContainer))
{
obj = VisualTreeHelper.GetParent(obj);
}
// Will return null if not found
return obj as ItemContainer;
}
}
}

Loading…
Cancel
Save