Browse Source

Change itemWithCommand to ItemWithAction

pull/21/merge
PeterForstmeier 14 years ago
parent
commit
8fd6c23877
  1. 34
      src/AddIns/Analysis/CodeQuality/Src/MainWindowModel.cs
  2. 49
      src/AddIns/Analysis/CodeQuality/Src/Utility/testclass.cs

34
src/AddIns/Analysis/CodeQuality/Src/MainWindowModel.cs

@ -297,12 +297,12 @@ namespace ICSharpCode.CodeQualityAnalysis @@ -297,12 +297,12 @@ namespace ICSharpCode.CodeQualityAnalysis
#region testregion
List<ItemWithCommand> itemsWithCommand;
List<ItemWithAction> itemsWithCommand;
public List<ItemWithCommand> ItemsWithCommand {
public List<ItemWithAction> ItemsWithCommand {
get {
if (itemsWithCommand == null) {
itemsWithCommand = new List<ItemWithCommand>();
itemsWithCommand = new List<ItemWithAction>();
}
return itemsWithCommand;
}
@ -324,31 +324,34 @@ namespace ICSharpCode.CodeQualityAnalysis @@ -324,31 +324,34 @@ namespace ICSharpCode.CodeQualityAnalysis
break;
case MetricsLevel.Method:
ItemsWithCommand.Add(new ItemWithCommand()
ItemsWithCommand.Add(new ItemWithAction()
{
Description = "IL Instructions",
Command = new RelayCommand (ExecuteMerhodIlInstructions)
Action = ExecuteMerhodIlInstructions
});
ItemsWithCommand.Add(new ItemWithCommand()
ItemsWithCommand.Add(new ItemWithAction()
{
Description = "Cyclomatic Complexity",
Command = new RelayCommand (ExecuteMethodComplexity)
Action = ExecuteMethodComplexity
});
ItemsWithCommand.Add(new ItemWithCommand()
ItemsWithCommand.Add(new ItemWithAction()
{
Description = "Variables",
Command = new RelayCommand (ExecuteMethodVariables)
Action = ExecuteMethodVariables
});
// var t = new testclass(MainModule);
// ItemsWithCommand = t.MethodList();
break;
default:
throw new Exception("Invalid value for MetricsLevel");
}
}
ItemWithCommand selectedItemWithCommand;
ItemWithAction selectedItemWithCommand;
public ItemWithCommand SelectedItemWithCommand {
public ItemWithAction SelectedItemWithCommand {
get { return selectedItemWithCommand; }
set { selectedItemWithCommand = value;
base.RaisePropertyChanged(() => SelectedItemWithCommand);}
@ -385,7 +388,8 @@ namespace ICSharpCode.CodeQualityAnalysis @@ -385,7 +388,8 @@ namespace ICSharpCode.CodeQualityAnalysis
void ExecuteSelectedItem()
{
SelectedItemWithCommand.Command.Execute(null);
//SelectedItemWithCommand.Command.Execute(null);
SelectedItemWithCommand.Action.Invoke();
}
@ -491,13 +495,13 @@ namespace ICSharpCode.CodeQualityAnalysis @@ -491,13 +495,13 @@ namespace ICSharpCode.CodeQualityAnalysis
}
public class ItemWithCommand
public class ItemWithAction
{
public ItemWithCommand()
public ItemWithAction()
{
}
public string Description {get; set;}
public ICommand Command {get; set;}
public Action Action {get; set;}
}
}

49
src/AddIns/Analysis/CodeQuality/Src/Utility/testclass.cs

@ -34,5 +34,54 @@ namespace ICSharpCode.CodeQualityAnalysis.Utility @@ -34,5 +34,54 @@ namespace ICSharpCode.CodeQualityAnalysis.Utility
select method;
return new ObservableCollection <INode>(list);
}
public List<ItemWithAction> MethodList()
{
List<ItemWithAction> itemsWithCommand = new List<ItemWithAction>();
itemsWithCommand.Add(new ItemWithAction()
{
Description = "IL Instructions",
Action = ExecuteMerhodIlInstructions
});
itemsWithCommand.Add(new ItemWithAction()
{
Description = "Cyclomatic Complexity",
Action = ExecuteMethodComplexity
});
itemsWithCommand.Add(new ItemWithAction()
{
Description = "Variables",
Action = ExecuteMethodVariables
});
return itemsWithCommand;
}
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();
}
}
}

Loading…
Cancel
Save