diff --git a/src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj b/src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj
index a9bd8864f6..0206ac53ba 100644
--- a/src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj
+++ b/src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj
@@ -142,11 +142,12 @@
+
-
-
+
+
@@ -270,7 +271,7 @@
-
+
-
+
+
+
-
-
-
+
+
+
-
-
+
+
+
-
diff --git a/src/AddIns/Analysis/CodeQuality/Src/MainWindowModel.cs b/src/AddIns/Analysis/CodeQuality/Src/MainWindowModel.cs
index dae1d48c1c..78c68ad25a 100644
--- a/src/AddIns/Analysis/CodeQuality/Src/MainWindowModel.cs
+++ b/src/AddIns/Analysis/CodeQuality/Src/MainWindowModel.cs
@@ -16,7 +16,7 @@ using System.Windows.Media.Imaging;
using ICSharpCode.CodeQualityAnalysis.Controls;
using ICSharpCode.CodeQualityAnalysis.Utility;
-using ICSharpCode.CodeQualityAnalysis.Utility.LocalizeableCombo;
+using ICSharpCode.CodeQualityAnalysis.Utility.Localizeable;
using Microsoft.Win32;
namespace ICSharpCode.CodeQualityAnalysis
@@ -50,16 +50,19 @@ namespace ICSharpCode.CodeQualityAnalysis
public MainWindowViewModel():base()
{
- this.FrmTitle = "$Code Quality Analysis";
- this.btnOpenAssembly = "$Open Assembly";
+ this.FrmTitle = "Code Quality Analysis";
+ this.btnOpenAssembly = "Open Assembly";
#region MainTab
- this.TabDependencyGraph = "$Dependency Graph";
- this.TabDependencyMatrix = "$Dependency Matrix";
- this.TabMetrics = "$Metrics";
+ this.TabDependencyGraph = "Dependency Graph";
+ this.TabDependencyMatrix = "Dependency Matrix";
+ this.TabMetrics = "Metrics";
#endregion
MetrixTabEnable = false;
+
+ ActivateMetrics = new RelayCommand(ActivateMetricsExecute);
+ ShowTreeMap = new RelayCommand(ShowTreemapExecute,CanActivateTreemap);
}
@@ -147,10 +150,6 @@ namespace ICSharpCode.CodeQualityAnalysis
base.RaisePropertyChanged(() =>this.Nodes);}
}
-//http://stackoverflow.com/questions/58743/databinding-an-enum-property-to-a-combobox-in-wpf#62032 http://stackoverflow.com/questions/58743/databinding-an-enum-property-to-a-combobox-in-wpf#62032
-
- //http://www.ageektrapped.com/blog/the-missing-net-7-displaying-enums-in-wpf/
-// http://www.codeproject.com/KB/WPF/FriendlyEnums.aspx
private string treeValueProperty ;
@@ -160,22 +159,27 @@ namespace ICSharpCode.CodeQualityAnalysis
base.RaisePropertyChanged(() =>this.TreeValueProperty);}
}
- // First Combo
+ // MetricsLevel Combo
public MetricsLevel MetricsLevel {
get {return MetricsLevel;}
}
-// MetricsLevel metricsLevelSelectedItem = MetricsLevel.Assembly;
-//
-// public MetricsLevel MetricsLevelSelectedItem {
-// get { return metricsLevelSelectedItem; }
-// set { metricsLevelSelectedItem = value;
-// base.RaisePropertyChanged(() =>this.MetricsLevelSelectedItem);
-// }
-// }
+ #region ActivateMetrics
+
+ public ICommand ActivateMetrics {get;private set;}
+
+ bool metricsIsActive;
+
+ void ActivateMetricsExecute ()
+ {
+ metricsIsActive = true;
+ }
+
+ #endregion
+
- // Second Combo
+ // Metrics Combo
public Metrics Metrics
{
@@ -188,12 +192,19 @@ namespace ICSharpCode.CodeQualityAnalysis
get { return selectedMetrics; }
set { selectedMetrics = value;
base.RaisePropertyChanged(() =>this.SelectedMetrics);
- ActivateTreemap();
}
}
+ #region ShowTreeMap Treemap
+
+ public ICommand ShowTreeMap {get;private set;}
+
+ bool CanActivateTreemap()
+ {
+ return metricsIsActive;
+ }
- void ActivateTreemap()
+ void ShowTreemapExecute()
{
var r = from ns in MainModule.Namespaces
from type in ns.Types
@@ -217,5 +228,7 @@ namespace ICSharpCode.CodeQualityAnalysis
throw new Exception("Invalid value for Metrics");
}
}
+
+ #endregion
}
}
diff --git a/src/AddIns/Analysis/CodeQuality/Src/Utility/ComboBoxWithCommand.cs b/src/AddIns/Analysis/CodeQuality/Src/Utility/ComboBoxWithCommand.cs
new file mode 100644
index 0000000000..7e3c2c52b3
--- /dev/null
+++ b/src/AddIns/Analysis/CodeQuality/Src/Utility/ComboBoxWithCommand.cs
@@ -0,0 +1,164 @@
+/*
+ * Created by SharpDevelop.
+ * User: Peter Forstmeier
+ * Date: 21.09.2011
+ * Time: 19:23
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+using System;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+
+namespace ICSharpCode.CodeQualityAnalysis.Utility
+{
+ ///
+ /// Description of ComboBoxWithCommand.
+ /// http://stackoverflow.com/questions/2222430/wpf-command-support-in-combobox
+ ///
+ public class ComboBoxWithCommand : ComboBox, ICommandSource
+ {
+ private static EventHandler canExecuteChangedHandler;
+
+ public static readonly DependencyProperty CommandProperty = DependencyProperty.Register("Command",
+ typeof(ICommand),
+ typeof(ComboBoxWithCommand),
+ new PropertyMetadata((ICommand)null,
+ new PropertyChangedCallback(CommandChanged)));
+
+ public ICommand Command
+ {
+ get
+ {
+ return (ICommand)GetValue(CommandProperty);
+ }
+ set
+ {
+ SetValue(CommandProperty, value);
+ }
+
+ }
+
+ public static readonly DependencyProperty CommandTargetProperty = DependencyProperty.Register("CommandTarget",
+ typeof(IInputElement),
+ typeof(ComboBoxWithCommand),
+ new PropertyMetadata((IInputElement)null));
+
+ public IInputElement CommandTarget
+ {
+ get
+ {
+ return (IInputElement)GetValue(CommandTargetProperty);
+ }
+ set
+ {
+ SetValue(CommandTargetProperty, value);
+ }
+ }
+
+ public static readonly DependencyProperty CommandParameterProperty = DependencyProperty.Register("CommandParameter",
+ typeof(object),
+ typeof(ComboBoxWithCommand),
+ new PropertyMetadata((object)null));
+
+ public object CommandParameter
+ {
+ get
+ {
+ return (object)GetValue(CommandParameterProperty);
+ }
+ set
+ {
+ SetValue(CommandParameterProperty, value);
+ }
+ }
+
+ public ComboBoxWithCommand() : base() { }
+
+
+ private static void CommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ ComboBoxWithCommand cb = (ComboBoxWithCommand)d;
+ cb.HookUpCommand((ICommand)e.OldValue, (ICommand)e.NewValue);
+ }
+
+ private void HookUpCommand(ICommand oldCommand, ICommand newCommand)
+ {
+ if (oldCommand != null)
+ {
+ RemoveCommand(oldCommand, newCommand);
+ }
+ AddCommand(oldCommand, newCommand);
+ }
+
+ private void RemoveCommand(ICommand oldCommand, ICommand newCommand)
+ {
+ EventHandler handler = CanExecuteChanged;
+ oldCommand.CanExecuteChanged -= handler;
+ }
+
+ private void AddCommand(ICommand oldCommand, ICommand newCommand)
+ {
+ EventHandler handler = new EventHandler(CanExecuteChanged);
+ canExecuteChangedHandler = handler;
+ if (newCommand != null)
+ {
+ newCommand.CanExecuteChanged += canExecuteChangedHandler;
+ }
+ }
+ private void CanExecuteChanged(object sender, EventArgs e)
+ {
+
+ if (this.Command != null)
+ {
+ RoutedCommand command = this.Command as RoutedCommand;
+
+ // If a RoutedCommand.
+ if (command != null)
+ {
+ if (command.CanExecute(this.CommandParameter, this.CommandTarget))
+ {
+ this.IsEnabled = true;
+ }
+ else
+ {
+ this.IsEnabled = false;
+ }
+ }
+ // If a not RoutedCommand.
+ else
+ {
+ if (Command.CanExecute(CommandParameter))
+ {
+ this.IsEnabled = true;
+ }
+ else
+ {
+ this.IsEnabled = false;
+ }
+ }
+ }
+ }
+
+ protected override void OnSelectionChanged(SelectionChangedEventArgs e)
+ {
+ base.OnSelectionChanged(e);
+
+ if (this.Command != null)
+ {
+ RoutedCommand command = this.Command as RoutedCommand;
+
+ if (command != null)
+ {
+ command.Execute(this.CommandParameter, this.CommandTarget);
+ }
+ else
+ {
+ ((ICommand)Command).Execute(CommandParameter);
+ }
+ }
+ }
+ }
+
+}
diff --git a/src/AddIns/Analysis/CodeQuality/Src/Utility/LocalizeableCombo/EnumToFriendlyNameConverter.cs b/src/AddIns/Analysis/CodeQuality/Src/Utility/Localizeable/EnumToFriendlyNameConverter.cs
similarity index 96%
rename from src/AddIns/Analysis/CodeQuality/Src/Utility/LocalizeableCombo/EnumToFriendlyNameConverter.cs
rename to src/AddIns/Analysis/CodeQuality/Src/Utility/Localizeable/EnumToFriendlyNameConverter.cs
index 0d8232054b..7edd11bd21 100644
--- a/src/AddIns/Analysis/CodeQuality/Src/Utility/LocalizeableCombo/EnumToFriendlyNameConverter.cs
+++ b/src/AddIns/Analysis/CodeQuality/Src/Utility/Localizeable/EnumToFriendlyNameConverter.cs
@@ -12,7 +12,7 @@ using System.Globalization;
using System.Reflection;
using System.Runtime.Serialization;
-namespace ICSharpCode.CodeQualityAnalysis.Utility.LocalizeableCombo
+namespace ICSharpCode.CodeQualityAnalysis.Utility.Localizeable
{
///
/// Description of EnumToFriendlyNameConverter.
diff --git a/src/AddIns/Analysis/CodeQuality/Src/Utility/LocalizeableCombo/LocalizableDescriptionAttribute.cs b/src/AddIns/Analysis/CodeQuality/Src/Utility/Localizeable/LocalizableDescriptionAttribute.cs
similarity index 97%
rename from src/AddIns/Analysis/CodeQuality/Src/Utility/LocalizeableCombo/LocalizableDescriptionAttribute.cs
rename to src/AddIns/Analysis/CodeQuality/Src/Utility/Localizeable/LocalizableDescriptionAttribute.cs
index 29e46b4c14..3eccc47f1f 100644
--- a/src/AddIns/Analysis/CodeQuality/Src/Utility/LocalizeableCombo/LocalizableDescriptionAttribute.cs
+++ b/src/AddIns/Analysis/CodeQuality/Src/Utility/Localizeable/LocalizableDescriptionAttribute.cs
@@ -9,7 +9,7 @@
using System;
using System.ComponentModel;
-namespace ICSharpCode.CodeQualityAnalysis.Utility.LocalizeableCombo
+namespace ICSharpCode.CodeQualityAnalysis.Utility.Localizeable
{
///
/// Description of LocalizableDescriptionAttribute.