Browse Source

add Reflector WPF Options panel and window

pull/2/head
eusebiu 15 years ago
parent
commit
d6534fb2e6
  1. 20
      data/resources/StringResources.resx
  2. 7
      src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/ReflectorAddIn.addin
  3. 35
      src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/ReflectorAddIn.csproj
  4. 22
      src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/OptionPanels/ChangeReflectorPath.xaml
  5. 35
      src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/OptionPanels/ChangeReflectorPath.xaml.cs
  6. 6
      src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/ReflectorController.cs
  7. 35
      src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/ReflectorSetupHelper.cs
  8. 3
      src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/TextEditorContextMenuCommand.cs
  9. 105
      src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/Windows/SetReflectorPath.xaml
  10. 79
      src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/Windows/SetReflectorPath.xaml.cs

20
data/resources/StringResources.resx

@ -6381,15 +6381,12 @@ Removed the end part of the original message ", reason '${Message}'" since this
<value>Delete all web references</value> <value>Delete all web references</value>
<comment>Title of the dialog box when the user tries to remove all web references.</comment> <comment>Title of the dialog box when the user tries to remove all web references.</comment>
</data> </data>
<data name="ReflectorAddIn.OpenReflectorCommand" xml:space="preserve">
<value>Open .NET Reflector</value>
</data>
<data name="ReflectorAddIn.ReflectorDoesNotExist" xml:space="preserve">
<value>Reflector could not be found at the specified location, or SharpDevelop does not have sufficient rights to access it.</value>
</data>
<data name="ReflectorAddIn.ReflectorPathNotSet" xml:space="preserve"> <data name="ReflectorAddIn.ReflectorPathNotSet" xml:space="preserve">
<value>The path to Reflector has not been set yet.</value> <value>The path to Reflector has not been set yet.</value>
</data> </data>
<data name="ReflectorAddIn.ReflectorChangePath" xml:space="preserve">
<value>Change Reflector path.</value>
</data>
<data name="ReflectorAddIn.ReflectorRemotingFailed" xml:space="preserve"> <data name="ReflectorAddIn.ReflectorRemotingFailed" xml:space="preserve">
<value>Failed to connect to Reflector.</value> <value>Failed to connect to Reflector.</value>
</data> </data>
@ -6402,6 +6399,17 @@ Removed the end part of the original message ", reason '${Message}'" since this
<data name="ReflectorAddIn.SetReflectorPathDialogTitle" xml:space="preserve"> <data name="ReflectorAddIn.SetReflectorPathDialogTitle" xml:space="preserve">
<value>Set path to Reflector</value> <value>Set path to Reflector</value>
</data> </data>
<data name="ReflectorAddIn.IdeOptions.ReflectorFoundInPath" xml:space="preserve">
<value>Reflector was found in the following directory:</value>
</data>
<data name="ReflectorAddIn.IdeOptions.ReflectorTitle" xml:space="preserve">
<value>Reflector</value>
<comment>Title of Reflector path choosing groupbox</comment>
</data>
<data name="ReflectorAddIn.IdeOptions.FindReflectorPath" xml:space="preserve">
<value>Select Reflector path</value>
<comment>Button to select the Reflector path</comment>
</data>
<data name="RegExpTk.MainDialog.Assemblies" xml:space="preserve"> <data name="RegExpTk.MainDialog.Assemblies" xml:space="preserve">
<value>Assemblies (*.dll)|*.dll</value> <value>Assemblies (*.dll)|*.dll</value>
</data> </data>

7
src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/ReflectorAddIn.addin

@ -30,5 +30,10 @@
<Path name = "/SharpDevelop/Pads/ClassBrowser/ClassContextMenu"> <Path name = "/SharpDevelop/Pads/ClassBrowser/ClassContextMenu">
<MenuItem id="Reflector" type="Item" label="${res:ReflectorAddIn.OpenReflectorCommand}" class="ReflectorAddIn.TextEditorContextMenuCommand"/> <MenuItem id="Reflector" type="Item" label="${res:ReflectorAddIn.OpenReflectorCommand}" class="ReflectorAddIn.TextEditorContextMenuCommand"/>
</Path> </Path>
<!-- Options panel -->
<Path name = "/SharpDevelop/Dialogs/OptionsDialog/ToolsOptions">
<OptionPanel id = "ChangeReflectorPathOptionPanel"
label = "${res:ReflectorAddIn.IdeOptions.ReflectorTitle}"
class = "ReflectorAddIn.OptionPanels.ChangeReflectorPath"/>
</Path>
</AddIn> </AddIn>

35
src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/ReflectorAddIn.csproj

@ -40,12 +40,18 @@
</PropertyGroup> </PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup> <ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core"> <Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="..\..\..\..\..\Main\GlobalAssemblyInfo.cs"> <Compile Include="..\..\..\..\..\Main\GlobalAssemblyInfo.cs">
@ -53,22 +59,25 @@
</Compile> </Compile>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Src\NativeMethods.cs" /> <Compile Include="Src\NativeMethods.cs" />
<Compile Include="Src\OptionPanels\ChangeReflectorPath.xaml.cs">
<DependentUpon>ChangeReflectorPath.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Src\ReflectorController.cs" /> <Compile Include="Src\ReflectorController.cs" />
<Compile Include="Src\ReflectorSetupHelper.cs" /> <Compile Include="Src\ReflectorSetupHelper.cs" />
<Compile Include="Src\SetReflectorPathDialog.cs" />
<Compile Include="Src\SetReflectorPathDialog.Designer.cs">
<DependentUpon>SetReflectorPathDialog.cs</DependentUpon>
</Compile>
<Compile Include="Src\TextEditorContextMenuCommand.cs" /> <Compile Include="Src\TextEditorContextMenuCommand.cs" />
<Compile Include="Src\Windows\SetReflectorPath.xaml.cs">
<DependentUpon>SetReflectorPath.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<None Include="ReflectorAddIn.addin"> <None Include="ReflectorAddIn.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
<EmbeddedResource Include="Src\SetReflectorPathDialog.resx">
<DependentUpon>SetReflectorPathDialog.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Src" /> <Folder Include="Src" />
<Folder Include="Src\Windows" />
<Folder Include="Src\OptionPanels" />
<ProjectReference Include="..\..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> <ProjectReference Include="..\..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> <Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name> <Name>ICSharpCode.SharpDevelop</Name>
@ -79,10 +88,22 @@
<Name>ICSharpCode.Core</Name> <Name>ICSharpCode.Core</Name>
<Private>False</Private> <Private>False</Private>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\..\..\..\Main\ICSharpCode.Core.Presentation\ICSharpCode.Core.Presentation.csproj">
<Project>{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}</Project>
<Name>ICSharpCode.Core.Presentation</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj"> <ProjectReference Include="..\..\..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj">
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project> <Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project>
<Name>ICSharpCode.SharpDevelop.Dom</Name> <Name>ICSharpCode.SharpDevelop.Dom</Name>
<Private>False</Private> <Private>False</Private>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\..\..\..\..\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj">
<Project>{8035765F-D51F-4A0C-A746-2FD100E19419}</Project>
<Name>ICSharpCode.SharpDevelop.Widgets</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Page Include="Src\OptionPanels\ChangeReflectorPath.xaml" />
<Page Include="Src\Windows\SetReflectorPath.xaml" />
</ItemGroup> </ItemGroup>
</Project> </Project>

22
src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/OptionPanels/ChangeReflectorPath.xaml

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<gui:OptionPanel
x:Class="ReflectorAddIn.OptionPanels.ChangeReflectorPath" xmlns:core="http://icsharpcode.net/sharpdevelop/core" xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets" xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui;assembly=ICSharpCode.SharpDevelop" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel
Orientation="Vertical">
<GroupBox
Header="{core:Localize ReflectorAddIn.SetReflectorPathDialogTitle}">
<widgets:StackPanelWithSpacing>
<TextBlock
TextWrapping="Wrap"
Height="46"
Name="StatusLabel" />
<Button
HorizontalAlignment="Center"
Style="{x:Static core:GlobalStyles.ButtonStyle}"
Name="OpenSearchPathButton"
Content="{core:Localize ReflectorAddIn.IdeOptions.FindReflectorPath}"
Click="FindReflectorPathClick" />
</widgets:StackPanelWithSpacing>
</GroupBox>
</StackPanel>
</gui:OptionPanel>

35
src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/OptionPanels/ChangeReflectorPath.xaml.cs

@ -0,0 +1,35 @@

using System;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
namespace ReflectorAddIn.OptionPanels
{
public partial class ChangeReflectorPath : OptionPanel
{
public ChangeReflectorPath()
{
InitializeComponent();
Loaded += delegate { ShowStatus(); };
}
void ShowStatus()
{
string path = PropertyService.Get(ReflectorSetupHelper.ReflectorExePathPropertyName);
if (string.IsNullOrEmpty(path)) {
StatusLabel.Text = StringParser.Parse("${res:ReflectorAddIn.ReflectorPathNotSet}");
} else {
StatusLabel.Text = StringParser.Parse("${res:ReflectorAddIn.IdeOptions.ReflectorFoundInPath}")
+ Environment.NewLine + path;
}
}
void FindReflectorPathClick(object sender, EventArgs e)
{
ReflectorSetupHelper.OpenReflectorExeFullPathInteractiver();
ShowStatus();
}
}
}

6
src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/ReflectorController.cs

@ -1,15 +1,13 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // 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) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.SharpDevelop.Dom;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Runtime.Remoting;
using System.Text;
using System.Threading; using System.Threading;
using System.Windows.Forms;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
namespace ReflectorAddIn namespace ReflectorAddIn

35
src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/ReflectorSetupHelper.cs

@ -1,12 +1,13 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // 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) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.SharpDevelop.Gui;
using System; using System;
using System.IO; using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Forms;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
using ReflectorAddIn.Windows;
namespace ReflectorAddIn namespace ReflectorAddIn
{ {
@ -31,19 +32,29 @@ namespace ReflectorAddIn
} }
if (askReason != null) { if (askReason != null) {
using(SetReflectorPathDialog dialog = new SetReflectorPathDialog(path, askReason)) { SetReflectorPath dialog = new SetReflectorPath(path, askReason);
bool? result = dialog.ShowDialog();
if (dialog.ShowDialog(WorkbenchSingleton.MainWin32Window) != DialogResult.OK || !File.Exists(dialog.SelectedFile)) { if (!result.HasValue || !result.Value || !File.Exists(dialog.SelectedFile))
return null; return null;
}
path = dialog.SelectedFile;
path = dialog.SelectedFile; PropertyService.Set(ReflectorExePathPropertyName, path);
PropertyService.Set(ReflectorExePathPropertyName, path);
}
} }
return path; return path;
} }
internal static void OpenReflectorExeFullPathInteractiver() {
string path = PropertyService.Get(ReflectorExePathPropertyName);
string askReason = ResourceService.GetString("ReflectorAddIn.ReflectorChangePath");
SetReflectorPath dialog = new SetReflectorPath(path, askReason);
bool? result = dialog.ShowDialog();
if (!result.HasValue || !result.Value || !File.Exists(dialog.SelectedFile))
return;
PropertyService.Set(ReflectorExePathPropertyName, dialog.SelectedFile);
}
} }
} }

3
src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/TextEditorContextMenuCommand.cs

@ -2,14 +2,11 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Bookmarks; using ICSharpCode.SharpDevelop.Bookmarks;
using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Gui.ClassBrowser; using ICSharpCode.SharpDevelop.Gui.ClassBrowser;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;

105
src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/Windows/SetReflectorPath.xaml

@ -0,0 +1,105 @@
<?xml version="1.0" encoding="utf-8"?>
<Window
x:Class="ReflectorAddIn.Windows.SetReflectorPath"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:core="http://icsharpcode.net/sharpdevelop/core" xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets"
WindowStartupLocation="CenterOwner"
Style="{x:Static core:GlobalStyles.DialogWindowStyle}"
ResizeMode="NoResize"
WindowStyle="ToolWindow"
ShowInTaskbar="False"
Height="230"
Width="446">
<Window.Resources>
<Style
x:Key="LinkButton"
TargetType="Button" BasedOn="{x:Static core:GlobalStyles.ButtonStyle}">
<Setter
Property="Template">
<Setter.Value>
<ControlTemplate
TargetType="Button">
<ControlTemplate.Resources>
<Style
TargetType="{x:Type TextBlock}">
<Setter
Property="TextDecorations"
Value="Underline" />
</Style>
</ControlTemplate.Resources>
<ContentPresenter />
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter
Property="Foreground"
Value="Blue" />
<Setter
Property="Cursor"
Value="Hand" />
<Style.Triggers>
<Trigger
Property="IsMouseOver"
Value="true">
<Setter
Property="Foreground"
Value="Red" />
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<StackPanel>
<widgets:StackPanelWithSpacing>
<TextBlock
Margin="12,12,12,0"
HorizontalAlignment="Left"
TextWrapping="Wrap"
Name="txtReason"/>
<TextBlock
Margin="12"
TextWrapping="Wrap"
HorizontalAlignment="Left"
Name="txtReflectorExplanation"
Text="{core:Localize ReflectorAddIn.SetReflectorPathDialog.ReflectorInfo}"/>
<Button Margin="20,0,0,15"
Name="OpenReflectorPageButton"
Content="http://reflector.red-gate.com/Download.aspx"
Style="{StaticResource LinkButton}"
Click="OpenReflectorPageButton_Click" />
<GroupBox Margin="12,0,0,15"
Header="{core:Localize ReflectorAddIn.SetReflectorPathDialog.PathToReflectorExe}">
<widgets:StackPanelWithSpacing
Orientation="Horizontal">
<TextBox
IsReadOnly="True"
Name="slePath"
Width="310"
Height="20" />
<Button Margin="15,0,0,0"
HorizontalAlignment="Right"
Name="BrowseButton"
Style="{x:Static core:GlobalStyles.ButtonStyle}"
Content="{core:Localize Global.BrowseButtonText}"
Click="BrowseButton_Click" />
</widgets:StackPanelWithSpacing>
</GroupBox>
<widgets:StackPanelWithSpacing
Orientation="Horizontal"
HorizontalAlignment="Right">
<Button
Name="OkButton"
IsDefault="False"
Content="{core:Localize Global.OKButtonText}"
Style="{x:Static core:GlobalStyles.ButtonStyle}"
Click="OkButton_Click"/>
<Button
Name="CancelButton"
IsDefault="False"
Content="{core:Localize Global.CancelButtonText}"
Click="CancelButton_Click"
Style="{x:Static core:GlobalStyles.ButtonStyle}" />
</widgets:StackPanelWithSpacing>
</widgets:StackPanelWithSpacing>
</StackPanel>
</Window>

79
src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/Src/Windows/SetReflectorPath.xaml.cs

@ -0,0 +1,79 @@

using System;
using System.Collections.Generic;
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 Microsoft.Win32;
namespace ReflectorAddIn.Windows
{
public partial class SetReflectorPath : Window
{
public SetReflectorPath(string oldPath, string reason)
{
InitializeComponent();
this.Title = ResourceService.GetString("ReflectorAddIn.SetReflectorPathDialogTitle");
this.txtReason.Text = reason;
if (!String.IsNullOrEmpty(oldPath)) {
this.slePath.Text = oldPath;
}
}
public string SelectedFile {
get {
return slePath.Text;
}
}
void OpenReflectorPageButton_Click(object sender, RoutedEventArgs e)
{
try {
using(System.Diagnostics.Process.Start("http://reflector.red-gate.com/Download.aspx")) {
}
} catch (Exception ex) {
MessageService.ShowError(ex.Message);
}
}
void OkButton_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = true;
Close();
}
void CancelButton_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = false;
Close();
}
void BrowseButton_Click(object sender, RoutedEventArgs e)
{
OpenFileDialog dialog = new OpenFileDialog();
dialog.Title = this.Title;
dialog.DefaultExt = "exe";
dialog.RestoreDirectory = true;
dialog.Filter = "Reflector.exe|Reflector.exe";
if (!String.IsNullOrEmpty(this.slePath.Text)) {
dialog.FileName = this.slePath.Text;
}
bool? result = dialog.ShowDialog(this);
if (result.HasValue && result.Value) {
this.slePath.Text = dialog.FileName;
}
}
}
}
Loading…
Cancel
Save