Browse Source

Marking element

pull/19/head
PeterForstmeier 14 years ago
parent
commit
6393f518ec
  1. 25
      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

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

@ -16,7 +16,9 @@ using System.Windows.Forms;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Threading; using System.Windows.Threading;
using ICSharpCode.CodeQualityAnalysis.Utility; using ICSharpCode.CodeQualityAnalysis.Utility;
using ICSharpCode.TreeView;
namespace ICSharpCode.CodeQualityAnalysis.Controls namespace ICSharpCode.CodeQualityAnalysis.Controls
{ {
@ -48,19 +50,27 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
InitializeComponent(); InitializeComponent();
matrixControl.Colorizer = new DependencyColorizer(); matrixControl.Colorizer = new DependencyColorizer();
matrixControl.HoveredCellChanged += OnHoverChanged; matrixControl.HoveredCellChanged += OnHoverChanged;
} }
public void DrawTree(Module module) public void DrawTree(Module module)
{ {
var leftCol = leftTree.Items.SourceCollection as INotifyCollectionChanged; var leftCol = leftTree.Items.SourceCollection as INotifyCollectionChanged;
leftCol.CollectionChanged += BuildLeftINodeList; leftCol.CollectionChanged += BuildLeftINodeList;
Helper.FillTree(leftTree, module); 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; var topCol = topTree.Items.SourceCollection as INotifyCollectionChanged;
topCol.CollectionChanged += BuildTopINodeList; topCol.CollectionChanged += BuildTopINodeList;
Helper.FillTree(topTree, module); Helper.FillTree(topTree, module);
} }
void Trees_Loaded (object sender, EventArgs e) void Trees_Loaded (object sender, EventArgs e)
{ {
leftTree.ApplyTemplate(); leftTree.ApplyTemplate();
@ -70,6 +80,8 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
topScrollViewer = Helper.FindVisualChild<ScrollViewer>(topTree); topScrollViewer = Helper.FindVisualChild<ScrollViewer>(topTree);
} }
#region Update MatricControl
bool rebuildLeftNodeListRequested; bool rebuildLeftNodeListRequested;
void BuildLeftINodeList(object sender,NotifyCollectionChangedEventArgs e) void BuildLeftINodeList(object sender,NotifyCollectionChangedEventArgs e)
@ -117,6 +129,9 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
matrixControl.SetVisibleItems(HeaderType.Columns, topNodes); matrixControl.SetVisibleItems(HeaderType.Columns, topNodes);
} }
#endregion
void OnHoverChanged(object sender ,HoveredCellEventArgs <Relationship> e) void OnHoverChanged(object sender ,HoveredCellEventArgs <Relationship> e)
{ {
if (e.HoveredCell.RowIndex < leftTree.Items.Count) { if (e.HoveredCell.RowIndex < leftTree.Items.Count) {
@ -135,8 +150,8 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
void LeftTree_ScrollChanged(object sender, ScrollChangedEventArgs e) void LeftTree_ScrollChanged(object sender, ScrollChangedEventArgs e)
{ {
// Console.WriteLine("Left TreeScroll"); Console.WriteLine("Left TreeScroll {0} - {1}",e.VerticalOffset * matrixControl.CellHeight,leftTree.Items.Count);
// scrollViewer.ScrollToVerticalOffset(e.VerticalOffset * matrixControl.CellHeight); scrollViewer.ScrollToVerticalOffset(e.VerticalOffset * matrixControl.CellHeight);
Console.WriteLine("--"); Console.WriteLine("--");
} }
@ -144,7 +159,7 @@ namespace ICSharpCode.CodeQualityAnalysis.Controls
{ {
// Console.WriteLine("Top TreeScroll "); // Console.WriteLine("Top TreeScroll ");
// scrollViewer.ScrollToHorizontalOffset(e.VerticalChange * matrixControl.CellHeight); // 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}}"
<StatusBarItem> <StatusBarItem>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Text="Namespaces: " /> <TextBlock Text="Namespaces: " />
<TextBlock Text="{Binding Path=MetricsReader.MainModule.Namespaces.Count}" /> <TextBlock Text="{Binding Path=MainModule.Namespaces.Count}" />
</StackPanel> </StackPanel>
</StatusBarItem> </StatusBarItem>
<StatusBarItem> <StatusBarItem>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Text="Types: " /> <TextBlock Text="Types: " />
<TextBlock Text="{Binding Path=MetricsReader.MainModule.TypesCount}" /> <TextBlock Text="{Binding Path=MainModule.TypesCount}" />
</StackPanel> </StackPanel>
</StatusBarItem> </StatusBarItem>
<StatusBarItem> <StatusBarItem>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Text="Methods: " /> <TextBlock Text="Methods: " />
<TextBlock Text="{Binding Path=MetricsReader.MainModule.MethodsCount}" /> <TextBlock Text="{Binding Path=MainModule.MethodsCount}" />
</StackPanel> </StackPanel>
</StatusBarItem> </StatusBarItem>
<StatusBarItem> <StatusBarItem>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Text="Fields: " /> <TextBlock Text="Fields: " />
<TextBlock Text="{Binding Path=MetricsReader.MainModule.FieldsCount}" /> <TextBlock Text="{Binding Path=MainModule.FieldsCount}" />
</StackPanel> </StackPanel>
</StatusBarItem> </StatusBarItem>
<StatusBarItem> <StatusBarItem>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Text="IL instructions: " /> <TextBlock Text="IL instructions: " />
<TextBlock Text="{Binding Path=MetricsReader.MainModule.InstructionsCount}" /> <TextBlock Text="{Binding Path=MainModule.InstructionsCount}" />
</StackPanel> </StackPanel>
</StatusBarItem> </StatusBarItem>
</StackPanel> </StackPanel>

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

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

@ -24,9 +24,6 @@ namespace ICSharpCode.CodeQualityAnalysis
/// </summary> /// </summary>
public class MainWindowTranslationViewModel :ViewModelBase public class MainWindowTranslationViewModel :ViewModelBase
{ {
string typeInfo;
public MainWindowTranslationViewModel():base() public MainWindowTranslationViewModel():base()
{ {
@ -77,6 +74,9 @@ namespace ICSharpCode.CodeQualityAnalysis
} }
} }
string typeInfo;
public string TypeInfo { public string TypeInfo {
get { return typeInfo; } get { return typeInfo; }
set { typeInfo = value; set { typeInfo = value;
@ -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 #region OpenAssembly

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

@ -3,6 +3,7 @@
using System; using System;
using System.Windows; using System.Windows;
using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
namespace ICSharpCode.CodeQualityAnalysis namespace ICSharpCode.CodeQualityAnalysis
@ -66,7 +67,7 @@ namespace ICSharpCode.CodeQualityAnalysis
public static T FindVisualChild<T>( DependencyObject obj ) public static T FindVisualChild<T>( DependencyObject obj )
where T : DependencyObject where T : DependencyObject
{ {
// Search immediate children first (breadth-first) // depth-first Search
for( int i = 0; i < VisualTreeHelper.GetChildrenCount( obj ); i++ ) for( int i = 0; i < VisualTreeHelper.GetChildrenCount( obj ); i++ )
{ {
@ -89,5 +90,20 @@ namespace ICSharpCode.CodeQualityAnalysis
return null; 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