Browse Source

Read-Write settings from AnalysisProjectOptionsPanelXaml

pull/30/head
PeterForstmeier 14 years ago
parent
commit
84e21490a0
  1. 36
      src/AddIns/Analysis/CodeAnalysis/Src/AnalysisProjectOptionsPanelXaml.xaml
  2. 113
      src/AddIns/Analysis/CodeAnalysis/Src/AnalysisProjectOptionsPanelXaml.xaml.cs
  3. 1
      src/AddIns/Analysis/CodeCoverage/Project/CodeCoverage.csproj

36
src/AddIns/Analysis/CodeAnalysis/Src/AnalysisProjectOptionsPanelXaml.xaml

@ -33,6 +33,7 @@
<Button Grid.Row="1" VerticalAlignment="Center" Grid.ColumnSpan="2" Margin="0,3,0,3" <Button Grid.Row="1" VerticalAlignment="Center" Grid.ColumnSpan="2" Margin="0,3,0,3"
Style="{x:Static core:GlobalStyles.ButtonStyle}" Style="{x:Static core:GlobalStyles.ButtonStyle}"
Click="ChangeRuleAssembliesButtonClick"
Content="{core:Localize ICSharpCode.CodeAnalysis.ProjectOptions.AddRemoveRuleAssembly}"></Button> Content="{core:Localize ICSharpCode.CodeAnalysis.ProjectOptions.AddRemoveRuleAssembly}"></Button>
<tv:SharpTreeView x:Name="ruleTreeView" ShowRoot="False" ShowLines="False" IsSynchronizedWithCurrentItem="True" <tv:SharpTreeView x:Name="ruleTreeView" ShowRoot="False" ShowLines="False" IsSynchronizedWithCurrentItem="True"
@ -49,27 +50,32 @@
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </GridViewColumn>
<GridViewColumn Width="25">
<GridViewColumn Header="Action">
<GridViewColumn.CellTemplate> <GridViewColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<Image Source="{Binding Path=RuleIcon, Converter={StaticResource imageConverter}}"></Image> <ComboBox Background="Transparent" Width="100"
</DataTemplate> HorizontalAlignment="Center" VerticalAlignment="Center"
</GridViewColumn.CellTemplate> ItemsSource="{Binding Path=RuleState}"
</GridViewColumn> SelectedIndex="{Binding Index}">
<ComboBox.ItemTemplate>
<DataTemplate>
<GridViewColumn Header="Action" Width="100"> <StackPanel Orientation="Horizontal">
<GridViewColumn.CellTemplate> <Image VerticalAlignment="Center" Height="15" Margin="3,0,5,0"
<DataTemplate> Source="{Binding Item1,
<ComboBox Width="70" Background="Transparent" Converter={StaticResource imageConverter}}"></Image>
ItemsSource="{Binding Path=RuleState}" <TextBlock VerticalAlignment="Center" Text="{Binding Item2}"></TextBlock>
SelectedIndex="{Binding Index}" </StackPanel>
DisplayMemberPath="DisplayValue">
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox> </ComboBox>
</DataTemplate> </DataTemplate>
</GridViewColumn.CellTemplate> </GridViewColumn.CellTemplate>
</GridViewColumn> </GridViewColumn>
</tv:SharpGridView.Columns> </tv:SharpGridView.Columns>
</tv:SharpGridView> </tv:SharpGridView>
</ListView.View> </ListView.View>

113
src/AddIns/Analysis/CodeAnalysis/Src/AnalysisProjectOptionsPanelXaml.xaml.cs

@ -44,16 +44,15 @@ namespace ICSharpCode.CodeAnalysis
private bool userCheck; private bool userCheck;
private Dictionary<string, RuleTreeNode> rules = new Dictionary<string, RuleTreeNode>(); private Dictionary<string, RuleTreeNode> rules = new Dictionary<string, RuleTreeNode>();
private List<KeyItemPair> bla = new List<KeyItemPair>(); private List<Tuple<Icon,string>> bla = new List<Tuple<Icon,string>>();
public AnalysisProjectOptionsPanelXaml() public AnalysisProjectOptionsPanelXaml()
{ {
InitializeComponent(); InitializeComponent();
DataContext = this; DataContext = this;
bla.Add(Tuple.Create<Icon,string>(SystemIcons.Warning,"Warning"));
bla.Add(new KeyItemPair("Warning","Warning")); bla.Add(Tuple.Create<Icon,string>(SystemIcons.Error,"Error"));
bla.Add(new KeyItemPair("Error","Error")); // bla.Add(Tuple.Create<Icon,string>(null,"None"));
bla.Add(new KeyItemPair("None","None"));
} }
@ -69,6 +68,7 @@ namespace ICSharpCode.CodeAnalysis
public ProjectProperty<string> CodeAnalysisRules { public ProjectProperty<string> CodeAnalysisRules {
get { return GetProperty("CodeAnalysisRules","",TextBoxEditMode.EditEvaluatedProperty); } get { return GetProperty("CodeAnalysisRules","",TextBoxEditMode.EditEvaluatedProperty); }
} }
#region Rule Assemblies Property #region Rule Assemblies Property
string ruleAssemblies; string ruleAssemblies;
@ -113,6 +113,8 @@ namespace ICSharpCode.CodeAnalysis
b.Append('!'); b.Append('!');
b.Append(rule.Identifier); b.Append(rule.Identifier);
} }
Console.WriteLine("");
Console.WriteLine(b.ToString());
} }
} }
return b.ToString(); return b.ToString();
@ -148,6 +150,7 @@ namespace ICSharpCode.CodeAnalysis
ruleNode.isError = error; ruleNode.isError = error;
} }
} }
/*
foreach (SharpTreeNode cat in ruleTreeView.Root.Children) { foreach (SharpTreeNode cat in ruleTreeView.Root.Children) {
bool noneChecked = true; bool noneChecked = true;
foreach (RuleTreeNode rtn in cat.Children) { foreach (RuleTreeNode rtn in cat.Children) {
@ -157,7 +160,7 @@ namespace ICSharpCode.CodeAnalysis
} }
} }
cat.IsChecked = !noneChecked; cat.IsChecked = !noneChecked;
} } */
userCheck = true; userCheck = true;
} }
@ -190,6 +193,11 @@ namespace ICSharpCode.CodeAnalysis
ReloadRuleList(); ReloadRuleList();
} }
protected override bool Save(MSBuildBasedProject project, string configuration, string platform)
{
this.CodeAnalysisRules.Value = RuleString;
return base.Save(project, configuration, platform);
}
#endregion #endregion
@ -228,11 +236,23 @@ namespace ICSharpCode.CodeAnalysis
} }
initSuccess = true; initSuccess = true;
ReadRuleString(); ReadRuleString();
foreach (var element in ruleTreeView.Root.Children) {
element.PropertyChanged += delegate {
base.IsDirty = true;
};
}
} }
} }
} }
string[] GetRuleAssemblyList(bool replacePath)
private void OnPropertyChanged(object sender,System.ComponentModel.PropertyChangedEventArgs e)
{
base.IsDirty = true;
}
private string[] GetRuleAssemblyList(bool replacePath)
{ {
List<string> list = new List<string>(); List<string> list = new List<string>();
string fxCopPath = FxCopWrapper.FindFxCopPath(); string fxCopPath = FxCopWrapper.FindFxCopPath();
@ -250,6 +270,11 @@ namespace ICSharpCode.CodeAnalysis
return list.ToArray(); return list.ToArray();
} }
private void ChangeRuleAssembliesButtonClick object sender, RoutedEventArgs e)
{
}
#endregion #endregion
@ -258,45 +283,35 @@ namespace ICSharpCode.CodeAnalysis
class BaseTree:SharpTreeNode class BaseTree:SharpTreeNode
{ {
private Icon ruleIcon;
private int index; private int index;
public BaseTree(IEnumerable<KeyItemPair> ruleState) public BaseTree(IEnumerable<Tuple<Icon,string>> ruleState)
{ {
this.RuleState = ruleState; this.RuleState = ruleState;
RuleIcon = SystemIcons.Warning;
} }
public IEnumerable<KeyItemPair> RuleState {get;set;} public IEnumerable<Tuple<Icon,string>> RuleState {get;set;}
public Icon RuleIcon {
get { return ruleIcon; }
set { ruleIcon = value;
base.RaisePropertyChanged("RuleIcon");
}
}
public virtual int Index {
public int Index {
get { return index; } get { return index; }
set { index = value; set {
switch (index) { if (index != value) {
case 0: index = value;
RuleIcon = SystemIcons.Warning; switch (index) {
break; case 0:
case 1: break;
RuleIcon = SystemIcons.Error; case 1:
break; break;
case 2: case 2:
RuleIcon = null; break;
break; default:
default: break;
}
break; base.RaisePropertyChanged("Index");
} }
base.RaisePropertyChanged("Index");
} }
} }
} }
@ -305,13 +320,12 @@ namespace ICSharpCode.CodeAnalysis
{ {
internal FxCopCategory category; internal FxCopCategory category;
public CategoryTreeNode(FxCopCategory category,IEnumerable<KeyItemPair> bla):base(bla) public CategoryTreeNode(FxCopCategory category,IEnumerable<Tuple<Icon,string>> bla):base(bla)
{ {
this.category = category; this.category = category;
foreach (FxCopRule rule in category.Rules) { foreach (FxCopRule rule in category.Rules) {
this.Children.Add(new RuleTreeNode(rule,bla)); this.Children.Add(new RuleTreeNode(rule,bla));
} }
} }
@ -348,9 +362,19 @@ namespace ICSharpCode.CodeAnalysis
class RuleTreeNode :BaseTree class RuleTreeNode :BaseTree
{ {
internal FxCopRule rule; internal FxCopRule rule;
internal bool isError; // internal bool isError;
bool error;
internal bool isError {
get { return error; }
set { error = value;
if (error) {
base.Index = 1;
}
}
}
public RuleTreeNode(FxCopRule rule,IEnumerable<KeyItemPair> ruleState):base(ruleState) public RuleTreeNode(FxCopRule rule,IEnumerable<Tuple<Icon,string>> ruleState):base(ruleState)
{ {
this.rule = rule; this.rule = rule;
} }
@ -368,6 +392,15 @@ namespace ICSharpCode.CodeAnalysis
return rule.CategoryName + "#" + rule.CheckId; return rule.CategoryName + "#" + rule.CheckId;
} }
} }
public override int Index {
get { return base.Index; }
set { base.Index = value;
if (Index == 1) {
error = true;
}
}
}
} }
class MessageNode : SharpTreeNode class MessageNode : SharpTreeNode
@ -384,7 +417,9 @@ namespace ICSharpCode.CodeAnalysis
} }
} }
#endregion #endregion
} }
[ValueConversion(typeof(System.Drawing.Icon), typeof(System.Windows.Media.ImageSource))] [ValueConversion(typeof(System.Drawing.Icon), typeof(System.Windows.Media.ImageSource))]
public class ImageConverter : IValueConverter public class ImageConverter : IValueConverter

1
src/AddIns/Analysis/CodeCoverage/Project/CodeCoverage.csproj

@ -19,6 +19,7 @@
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile> <TargetFrameworkProfile>
</TargetFrameworkProfile> </TargetFrameworkProfile>
<RunCodeAnalysis>False</RunCodeAnalysis>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>..\..\..\..\..\AddIns\Analysis\CodeCoverage\</OutputPath> <OutputPath>..\..\..\..\..\AddIns\Analysis\CodeCoverage\</OutputPath>

Loading…
Cancel
Save