diff --git a/src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj b/src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj
index 21764851b7f..7d0ebf7d3b2 100644
--- a/src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj
+++ b/src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj
@@ -151,6 +151,7 @@
+
diff --git a/src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml b/src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml
index 3579da50831..8a8577a663c 100644
--- a/src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml
+++ b/src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml
@@ -307,7 +307,7 @@
-
+
+
+
+
+
+
+
+
diff --git a/src/AddIns/Analysis/CodeQuality/Src/MainWindowModel.cs b/src/AddIns/Analysis/CodeQuality/Src/MainWindowModel.cs
index 1fe97131de5..3d64b785418 100644
--- a/src/AddIns/Analysis/CodeQuality/Src/MainWindowModel.cs
+++ b/src/AddIns/Analysis/CodeQuality/Src/MainWindowModel.cs
@@ -16,6 +16,7 @@
using System.Windows.Input;
using ICSharpCode.CodeQualityAnalysis.Utility.Localizeable;
+using ICSharpCode.CodeQualityAnalysis.Utility;
using ICSharpCode.SharpDevelop.Widgets;
namespace ICSharpCode.CodeQualityAnalysis
@@ -64,6 +65,8 @@ public MainWindowViewModel():base()
ActivateMetrics = new RelayCommand(ActivateMetricsExecute);
ShowTreeMap = new RelayCommand(ShowTreemapExecute,CanActivateTreemap);
+
+ ExecuteSelectedItemWithCommand = new RelayCommand (ExecuteSelectedItem);
}
@@ -193,7 +196,13 @@ string UpdateToolStrip()
private ObservableCollection nodes;
public ObservableCollection Nodes {
- get { return nodes; }
+ get {
+ if (nodes == null)
+ {
+ nodes = new ObservableCollection();
+ }
+ return nodes;
+ }
set { nodes = value;
base.RaisePropertyChanged(() =>this.Nodes);}
}
@@ -219,7 +228,6 @@ string UpdateToolStrip()
public MetricsLevel SelectedMetricsLevel {
get { return selectedMetricsLevel; }
set { selectedMetricsLevel = value;
- SelectedMetricsIndex = 0;
base.RaisePropertyChanged(() =>this.SelectedMetricsLevel);
ResetTreeMap();
}
@@ -227,7 +235,7 @@ string UpdateToolStrip()
#endregion
- #region Metrics Combo > Right Combobox
+ #region Metrics Combo > Right Combobox
public Metrics Metrics
{
@@ -243,6 +251,7 @@ public Metrics Metrics
}
}
+ /*
int selectedMetricsIndex;
public int SelectedMetricsIndex {
@@ -251,6 +260,7 @@ public Metrics Metrics
selectedMetricsIndex = value;
base.RaisePropertyChanged(() =>this.SelectedMetricsIndex);}
}
+ */
#endregion
@@ -259,7 +269,7 @@ public Metrics Metrics
public ICommand ActivateMetrics {get;private set;}
bool metricsIsActive;
-
+ /*
void ActivateMetricsExecute ()
{
@@ -280,18 +290,117 @@ void ActivateMetricsExecute ()
throw new Exception("Invalid value for MetricsLevel");
}
}
+ */
#endregion
+ #region testregion
+
+ List itemsWithCommand;
+
+ public List ItemsWithCommand {
+ get {
+ if (itemsWithCommand == null) {
+ itemsWithCommand = new List();
+ }
+ return itemsWithCommand;
+ }
+ set { itemsWithCommand = value;
+ base.RaisePropertyChanged(() => ItemsWithCommand);}
+ }
+
+ void ActivateMetricsExecute ()
+ {
+ itemsWithCommand.Clear();
+ switch (SelectedMetricsLevel) {
+ case MetricsLevel.Assembly:
+
+ break;
+ case MetricsLevel.Namespace:
+
+ break;
+ case MetricsLevel.Type:
+
+ break;
+ case MetricsLevel.Method:
+ ItemsWithCommand.Add(new ItemWithCommand()
+ {
+ Description = "IL Instructions",
+ Command = new RelayCommand (ExecuteMerhodIlInstructions)
+ });
+ ItemsWithCommand.Add(new ItemWithCommand()
+ {
+ Description = "Cyclomatic Complexity",
+ Command = new RelayCommand (ExecuteMethodComplexity)
+ });
+ ItemsWithCommand.Add(new ItemWithCommand()
+ {
+ Description = "Variables",
+ Command = new RelayCommand (ExecuteMethodVariables)
+ });
+
+ break;
+ default:
+ throw new Exception("Invalid value for MetricsLevel");
+ }
+ }
+
+ ItemWithCommand selectedItemWithCommand;
+
+ public ItemWithCommand SelectedItemWithCommand {
+ get { return selectedItemWithCommand; }
+ set { selectedItemWithCommand = value;
+ base.RaisePropertyChanged(() => SelectedItemWithCommand);}
+ }
+
+ private void ExecuteMerhodIlInstructions()
+ {
+ var t = new testclass(MainModule);
+ TreeValueProperty = "Instructions.Count";
+ Nodes = t.QueryMethod();
+ }
+
+ private void ExecuteMethodComplexity ()
+ {
+ var t = new testclass(MainModule);
+ TreeValueProperty = Metrics.CyclomaticComplexity.ToString();
+ var tt = t.QueryMethod();
+ foreach (var element in tt) {
+ var m = element as Method;
+ Console.WriteLine("{0} - {1}",m.Name,m.CyclomaticComplexity);
+ }
+ Nodes = t.QueryMethod();
+ }
+
+
+ private void ExecuteMethodVariables ()
+ {
+ var t = new testclass(MainModule);
+ TreeValueProperty = Metrics.Variables.ToString();
+ Nodes = t.QueryMethod();
+ }
+
+ public ICommand ExecuteSelectedItemWithCommand {get; private set;}
+
+ void ExecuteSelectedItem()
+ {
+ SelectedItemWithCommand.Command.Execute(null);
+ }
+
+
+ #endregion
#region ShowTreeMap Treemap
void ResetTreeMap()
{
- if (Nodes != null) {
- Nodes.Clear();
- }
+
+ Nodes.Clear();
+ ItemsWithCommand.Clear();
+
+ base.RaisePropertyChanged(() => Nodes);
+ base.RaisePropertyChanged(() => ItemsWithCommand);
metricsIsActive = false;
}
@@ -379,8 +488,16 @@ ObservableCollection PrepareNodes()
}
#endregion
+ }
+
+
+ public class ItemWithCommand
+ {
+ public ItemWithCommand()
+ {
+ }
-
-
+ public string Description {get; set;}
+ public ICommand Command {get; set;}
}
}
diff --git a/src/AddIns/Analysis/CodeQuality/Src/Utility/testclass.cs b/src/AddIns/Analysis/CodeQuality/Src/Utility/testclass.cs
new file mode 100644
index 00000000000..881a0fdb80d
--- /dev/null
+++ b/src/AddIns/Analysis/CodeQuality/Src/Utility/testclass.cs
@@ -0,0 +1,38 @@
+/*
+ * Created by SharpDevelop.
+ * User: Peter Forstmeier
+ * Date: 25.12.2011
+ * Time: 19:07
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+using System;
+using System.Linq;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+
+namespace ICSharpCode.CodeQualityAnalysis.Utility
+{
+ ///
+ /// Description of testclass.
+ ///
+ public class testclass
+ {
+ public testclass(Module mainModule)
+ {
+ MainModule = mainModule;
+ }
+
+ public Module MainModule {get; private set;}
+
+ public ObservableCollection QueryMethod()
+ {
+ IEnumerable list = new List();
+ list = from ns in MainModule.Namespaces
+ from type in ns.Types
+ from method in type.Methods
+ select method;
+ return new ObservableCollection (list);
+ }
+ }
+}