8 changed files with 147 additions and 12 deletions
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
<gui:OptionPanel x:Class="MattEverson.SourceAnalysis.AnalysisIdeOptionsPanelXaml" |
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
xmlns:core="http://icsharpcode.net/sharpdevelop/core" |
||||
xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui;assembly=ICSharpCode.SharpDevelop" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
||||
|
||||
<GroupBox Header="StyleCop"> |
||||
<StackPanel> |
||||
<TextBlock Margin="3,5,3,20" x:Name="status" |
||||
HorizontalAlignment="Center" TextWrapping="Wrap" |
||||
Text="(showing current StyleCop path)"></TextBlock> |
||||
<Button Content="Find StyleCop path" |
||||
HorizontalAlignment="Center" |
||||
Click="FindStyleCopPath_Click" |
||||
Style="{x:Static core:GlobalStyles.ButtonStyle}"></Button> |
||||
|
||||
<Button Margin="0,15,0,0" IsEnabled="{Binding EnableModifyStyleCopSettings}" |
||||
Content="Modify Master StyleCop Settings" |
||||
HorizontalAlignment="Center" |
||||
Click="ModifyStyleCopSettings_Click" |
||||
Style="{x:Static core:GlobalStyles.ButtonStyle}"></Button> |
||||
</StackPanel> |
||||
</GroupBox> |
||||
|
||||
</gui:OptionPanel> |
@ -0,0 +1,103 @@
@@ -0,0 +1,103 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 23.07.2012 |
||||
* Time: 20:13 |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics; |
||||
using System.IO; |
||||
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.Core; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Gui.OptionPanels; |
||||
|
||||
namespace MattEverson.SourceAnalysis |
||||
{ |
||||
/// <summary>
|
||||
/// Interaction logic for AnalysisIdeOptionsPanelXaml.xaml
|
||||
/// </summary>
|
||||
public partial class AnalysisIdeOptionsPanelXaml : OptionPanel |
||||
{ |
||||
private bool enableModifyStyleCopSettings; |
||||
|
||||
public AnalysisIdeOptionsPanelXaml() |
||||
{ |
||||
InitializeComponent(); |
||||
DataContext = this; |
||||
ShowStatus(); |
||||
} |
||||
|
||||
|
||||
private void ShowStatus() |
||||
{ |
||||
string path = StyleCopWrapper.FindStyleCopPath(); |
||||
if (path == null) { |
||||
status.Text = StringParser.Parse("StyleCop not found in the given path."); |
||||
EnableModifyStyleCopSettings = false; |
||||
} else { |
||||
status.Text = StringParser.Parse("StyleCop was found in: ") + Environment.NewLine + path; |
||||
EnableModifyStyleCopSettings = true; |
||||
} |
||||
} |
||||
|
||||
|
||||
public bool EnableModifyStyleCopSettings { |
||||
get { return enableModifyStyleCopSettings; } |
||||
set { enableModifyStyleCopSettings = value; |
||||
base.RaisePropertyChanged("EnableModifyStyleCopSettings"); |
||||
} |
||||
} |
||||
|
||||
|
||||
private void FindStyleCopPath_Click(object sender, System.Windows.RoutedEventArgs e) |
||||
{ |
||||
string filter = StringParser.Parse("StyleCop|*" + StyleCopWrapper.STYLE_COP_FILE + "|${res:SharpDevelop.FileFilter.AllFiles}|*.*"); |
||||
string path = OptionsHelper.OpenFile(filter); |
||||
if (!String.IsNullOrEmpty(path)) { |
||||
if (StyleCopWrapper.IsStyleCopPath(path)) { |
||||
StyleCopPath = path; |
||||
} else { |
||||
MessageService.ShowError(string.Format("Directory does not contain StyleCop (*{0}).", StyleCopWrapper.STYLE_COP_FILE)); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
void ModifyStyleCopSettings_Click(object sender, RoutedEventArgs e) |
||||
{ |
||||
var executable = Path.Combine(Path.GetDirectoryName(StyleCopWrapper.FindStyleCopPath()), "StyleCopSettingsEditor.exe"); |
||||
var parameters = "\"" + StyleCopWrapper.GetMasterSettingsFile() + "\""; |
||||
|
||||
if (!File.Exists(executable)) { |
||||
LoggingService.Debug("StyleCopSettingsEditor.exe: " + executable); |
||||
MessageService.ShowWarning("Unable to find the StyleCop Settings editor. Please specify the StyleCop location in Tools Options."); |
||||
return; |
||||
} |
||||
|
||||
using(Process p = Process.Start("\"" + executable + "\"", parameters)) |
||||
{ |
||||
// No need to wait for the settings dialog to close - we can leave it open.
|
||||
} |
||||
} |
||||
|
||||
|
||||
public static string StyleCopPath { |
||||
get { |
||||
return PropertyService.Get("SourceAnalysis.StyleCopPath"); |
||||
} |
||||
set { |
||||
PropertyService.Set("SourceAnalysis.StyleCopPath", value); |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue