17 changed files with 362 additions and 98 deletions
@ -0,0 +1,42 @@ |
|||||||
|
<gui:OptionPanel x:Class="CSharpBinding.Refactoring.IssueOptions" |
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||||
|
xmlns:sd="http://icsharpcode.net/sharpdevelop/core" |
||||||
|
xmlns:nr="clr-namespace:ICSharpCode.NRefactory.CSharp;assembly=ICSharpCode.NRefactory.CSharp" |
||||||
|
xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui;assembly=ICSharpCode.SharpDevelop"> |
||||||
|
<DockPanel> |
||||||
|
<!-- TODO: Translate --> |
||||||
|
<CheckBox Name="featureEnabledCheckBox" DockPanel.Dock="Top" |
||||||
|
IsEnabled="False" |
||||||
|
IsChecked="True" Content="Enable code inspection" /> |
||||||
|
<sd:RestrictDesiredSize Margin="0, 4, 0, 0"> |
||||||
|
<ListBox Name="listBox" |
||||||
|
HorizontalContentAlignment="Stretch" |
||||||
|
IsEnabled="{Binding IsChecked, ElementName=featureEnabledCheckBox}"> |
||||||
|
<ListBox.ItemTemplate> |
||||||
|
<DataTemplate> |
||||||
|
<DockPanel> |
||||||
|
<ComboBox DockPanel.Dock="Right" |
||||||
|
MinWidth="85" |
||||||
|
VerticalAlignment="Center" |
||||||
|
gui:EnumBinding.EnumType="{x:Type nr:Severity}" |
||||||
|
SelectedValue="{Binding Severity}"/> |
||||||
|
<sd:RestrictDesiredSize RestrictHeight="False" MinWidth="150"> |
||||||
|
<TextBlock Text="{Binding DisplayName}" ToolTip="{Binding ToolTip}" TextWrapping="WrapWithOverflow" /> |
||||||
|
</sd:RestrictDesiredSize> |
||||||
|
</DockPanel> |
||||||
|
</DataTemplate> |
||||||
|
</ListBox.ItemTemplate> |
||||||
|
<ListBox.GroupStyle> |
||||||
|
<GroupStyle> |
||||||
|
<GroupStyle.HeaderTemplate> |
||||||
|
<DataTemplate DataType="Group"> |
||||||
|
<TextBlock FontWeight="Bold" Text="{Binding Name}" /> |
||||||
|
</DataTemplate> |
||||||
|
</GroupStyle.HeaderTemplate> |
||||||
|
</GroupStyle> |
||||||
|
</ListBox.GroupStyle> |
||||||
|
</ListBox> |
||||||
|
</sd:RestrictDesiredSize> |
||||||
|
</DockPanel> |
||||||
|
</gui:OptionPanel> |
@ -0,0 +1,64 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Collections.ObjectModel; |
||||||
|
using System.ComponentModel; |
||||||
|
using System.Linq; |
||||||
|
using System.Text; |
||||||
|
using System.Windows; |
||||||
|
using System.Windows.Controls; |
||||||
|
using System.Windows.Data; |
||||||
|
using System.Windows.Documents; |
||||||
|
using System.Windows.Input; |
||||||
|
using System.Windows.Media; |
||||||
|
using ICSharpCode.NRefactory.CSharp; |
||||||
|
using ICSharpCode.SharpDevelop.Gui; |
||||||
|
using ICSharpCode.SharpDevelop.Refactoring; |
||||||
|
|
||||||
|
namespace CSharpBinding.Refactoring |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for IssueOptions.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class IssueOptions : OptionPanel |
||||||
|
{ |
||||||
|
ObservableCollection<IssueOptionsViewModel> viewModels; |
||||||
|
|
||||||
|
public IssueOptions() |
||||||
|
{ |
||||||
|
InitializeComponent(); |
||||||
|
viewModels = new ObservableCollection<IssueOptionsViewModel>( |
||||||
|
from p in IssueManager.IssueProviders |
||||||
|
where p.Attribute != null |
||||||
|
select new IssueOptionsViewModel(p.ProviderType, p.Attribute) |
||||||
|
); |
||||||
|
ICollectionView view = CollectionViewSource.GetDefaultView(viewModels); |
||||||
|
if (viewModels.Any(p => !string.IsNullOrEmpty(p.Category))) |
||||||
|
view.GroupDescriptions.Add(new PropertyGroupDescription("Category")); |
||||||
|
listBox.ItemsSource = view; |
||||||
|
} |
||||||
|
|
||||||
|
public override void LoadOptions() |
||||||
|
{ |
||||||
|
base.LoadOptions(); |
||||||
|
var settings = IssueManager.GetIssueSeveritySettings(); |
||||||
|
foreach (var m in viewModels) { |
||||||
|
Severity severity; |
||||||
|
if (settings.TryGetValue(m.ProviderType, out severity)) |
||||||
|
m.Severity = severity; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public override bool SaveOptions() |
||||||
|
{ |
||||||
|
Dictionary<Type, Severity> dict = new Dictionary<Type, Severity>(); |
||||||
|
foreach (var m in viewModels) { |
||||||
|
dict[m.ProviderType] = m.Severity; |
||||||
|
} |
||||||
|
IssueManager.SetIssueSeveritySettings(dict); |
||||||
|
return base.SaveOptions(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,47 @@ |
|||||||
|
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||||
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||||
|
|
||||||
|
using System; |
||||||
|
using System.ComponentModel; |
||||||
|
using ICSharpCode.NRefactory.CSharp; |
||||||
|
using ICSharpCode.SharpDevelop.Widgets; |
||||||
|
|
||||||
|
namespace CSharpBinding.Refactoring |
||||||
|
{ |
||||||
|
public class IssueOptionsViewModel : ViewModelBase |
||||||
|
{ |
||||||
|
readonly Type providerType; |
||||||
|
readonly IssueDescriptionAttribute attribute; |
||||||
|
|
||||||
|
public IssueOptionsViewModel(Type providerType, IssueDescriptionAttribute attribute) |
||||||
|
{ |
||||||
|
this.providerType = providerType; |
||||||
|
this.attribute = attribute; |
||||||
|
this.Severity = attribute.Severity; |
||||||
|
} |
||||||
|
|
||||||
|
public Type ProviderType { |
||||||
|
get { return providerType; } |
||||||
|
} |
||||||
|
|
||||||
|
// TODO: Translate
|
||||||
|
public string DisplayName { |
||||||
|
get { return attribute.Title; } |
||||||
|
} |
||||||
|
|
||||||
|
public string ToolTip { |
||||||
|
get { return attribute.Description; } |
||||||
|
} |
||||||
|
|
||||||
|
public string Category { |
||||||
|
get { return attribute.Category; } |
||||||
|
} |
||||||
|
|
||||||
|
Severity severity; |
||||||
|
|
||||||
|
public Severity Severity { |
||||||
|
get { return severity; } |
||||||
|
set { SetAndNotifyPropertyChanged(ref severity, value); } |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue