Browse Source

Replace AboutDialog with AboutPage.

pull/1/head
Daniel Grunwald 15 years ago
parent
commit
2b55a46d4b
  1. 23
      ILSpy/AboutDialog.xaml
  2. 45
      ILSpy/AboutDialog.xaml.cs
  3. 114
      ILSpy/AboutPage.cs
  4. 10
      ILSpy/ILSpy.csproj
  5. 1
      ILSpy/Images/Images.cs
  6. BIN
      ILSpy/Images/OK.png
  7. 10
      ILSpy/MainWindow.xaml.cs
  8. 4
      ILSpy/TextView/DecompilerTextView.cs
  9. 9
      README.txt

23
ILSpy/AboutDialog.xaml

@ -1,23 +0,0 @@ @@ -1,23 +0,0 @@
<Window x:Class="ICSharpCode.ILSpy.AboutDialog" x:ClassModifier="internal"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ICSharpCode.ILSpy"
Title="About ILSpy"
Style="{DynamicResource DialogWindow}"
ResizeMode="NoResize"
WindowStartupLocation="CenterOwner"
SizeToContent="WidthAndHeight">
<StackPanel Margin="8">
<TextBlock TextWrapping="WrapWithOverflow" FontSize="12">
ILSpy version <Run Text="{x:Static local:AboutDialog.Version}"/>.<LineBreak/>
Copyright 2011 by AlphaSierraPapa for the SharpDevelop Team.<LineBreak/>
Website: <Hyperlink NavigateUri="http://www.ilspy.net/">http://www.ilspy.net/</Hyperlink><LineBreak/>
<LineBreak/>
This software makes use of the following open-source projects:<LineBreak/>
<Hyperlink NavigateUri="http://www.mono-project.com/Cecil">Mono.Cecil</Hyperlink> (reading IL)<LineBreak/>
<Hyperlink NavigateUri="http://www.avalonedit.net/">ICSharpCode.AvalonEdit</Hyperlink><LineBreak/>
<Hyperlink NavigateUri="http://www.sharpdevelop.net/">SharpDevelop</Hyperlink> components (SharpTreeView, NRefactory)<LineBreak/>
</TextBlock>
<Button IsCancel="True" HorizontalAlignment="Center">Close</Button>
</StackPanel>
</Window>

45
ILSpy/AboutDialog.xaml.cs

@ -1,45 +0,0 @@ @@ -1,45 +0,0 @@
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
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;
namespace ICSharpCode.ILSpy
{
/// <summary>
/// Interaction logic for AboutDialog.xaml
/// </summary>
partial class AboutDialog : Window
{
public AboutDialog()
{
InitializeComponent();
}
public static string Version {
get { return RevisionClass.FullVersion; }
}
}
}

114
ILSpy/AboutPage.cs

@ -0,0 +1,114 @@ @@ -0,0 +1,114 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
using System;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using ICSharpCode.Decompiler;
using ICSharpCode.ILSpy.TextView;
namespace ICSharpCode.ILSpy
{
static class AboutPage
{
static AvailableVersionInfo latestAvailableVersion;
public static void Display(DecompilerTextView textView)
{
AvalonEditTextOutput output = new AvalonEditTextOutput();
output.WriteLine("ILSpy version " + RevisionClass.FullVersion);
output.AddUIElement(
delegate {
StackPanel stackPanel = new StackPanel();
stackPanel.Orientation = Orientation.Horizontal;
if (latestAvailableVersion == null) {
Button button = new Button();
button.Content = "Check for updates";
button.Cursor = Cursors.Arrow;
stackPanel.Children.Add(button);
button.Click += delegate {
button.Content = "Checking...";
button.IsEnabled = false;
GetLatestVersion().ContinueWith(
delegate (Task<AvailableVersionInfo> task) {
try {
latestAvailableVersion = task.Result;
stackPanel.Children.Clear();
ShowAvailableVersion(latestAvailableVersion, stackPanel);
} catch (Exception ex) {
AvalonEditTextOutput exceptionOutput = new AvalonEditTextOutput();
exceptionOutput.WriteLine(ex.ToString());
textView.Show(exceptionOutput);
}
}, TaskScheduler.FromCurrentSynchronizationContext());
};
} else {
// we already retrieved the latest version sometime earlier
ShowAvailableVersion(latestAvailableVersion, stackPanel);
}
return stackPanel;
});
output.WriteLine();
output.WriteLine();
using (Stream s = typeof(AboutPage).Assembly.GetManifestResourceStream(typeof(AboutPage), "README.txt")) {
using (StreamReader r = new StreamReader(s)) {
string line;
while ((line = r.ReadLine()) != null)
output.WriteLine(line);
}
}
textView.Show(output);
}
static void ShowAvailableVersion(AvailableVersionInfo availableVersion, StackPanel stackPanel)
{
Version currentVersion = new Version(RevisionClass.Major + "." + RevisionClass.Minor + "." + RevisionClass.Build + "." + RevisionClass.Revision);
if (currentVersion == availableVersion.Version) {
stackPanel.Children.Add(new Image { Width = 16, Height = 16, Source = Images.OK, Margin = new Thickness(4,0,4,0) });
stackPanel.Children.Add(
new TextBlock { Text = "You are using the latest release.",
VerticalAlignment = VerticalAlignment.Bottom
});
} else if (currentVersion < availableVersion.Version) {
stackPanel.Children.Add(
new TextBlock {
Text = "Version " + availableVersion.Version + " is available.",
Margin = new Thickness(0,0,8,0),
VerticalAlignment = VerticalAlignment.Bottom
});
if (availableVersion.DownloadUrl.StartsWith("http://", StringComparison.OrdinalIgnoreCase)
|| availableVersion.DownloadUrl.StartsWith("https://", StringComparison.OrdinalIgnoreCase))
{
Button button = new Button();
button.Content = "Download";
button.Cursor = Cursors.Arrow;
button.Click += delegate {
Process.Start(availableVersion.DownloadUrl);
};
stackPanel.Children.Add(button);
}
} else {
stackPanel.Children.Add(new TextBlock { Text = "You are using a nightly builds newer than the latest release." });
}
}
static Task<AvailableVersionInfo> GetLatestVersion()
{
TaskCompletionSource<AvailableVersionInfo> tcs = new TaskCompletionSource<AvailableVersionInfo>();
tcs.SetException(new NotImplementedException());
//tcs.SetResult(new AvailableVersionInfo { Version = new Version(0,2,0,37), DownloadUrl = "http://www.ilspy.net/" });
return tcs.Task;
}
sealed class AvailableVersionInfo
{
public Version Version;
public string DownloadUrl;
}
}
}

10
ILSpy/ILSpy.csproj

@ -72,10 +72,7 @@ @@ -72,10 +72,7 @@
<ApplicationDefinition Include="App.xaml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AboutDialog.xaml.cs">
<DependentUpon>AboutDialog.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="AboutPage.cs" />
<Compile Include="App.xaml.cs">
<SubType>Code</SubType>
<DependentUpon>App.xaml</DependentUpon>
@ -101,10 +98,14 @@ @@ -101,10 +98,14 @@
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="..\README.txt">
<Link>README.txt</Link>
</EmbeddedResource>
<Resource Include="Images\AssemblyList.png" />
<Resource Include="Images\AssemblyWarning.png" />
<Resource Include="Images\ViewCode.png" />
<Resource Include="Images\SaveFile.png" />
<Resource Include="Images\OK.png" />
<None Include="Properties\AssemblyInfo.template.cs" />
<Compile Include="Properties\WPFAssemblyInfo.cs" />
<Compile Include="MainWindow.xaml.cs">
@ -136,7 +137,6 @@ @@ -136,7 +137,6 @@
<EmbeddedResource Include="TextView\ILAsm-Mode.xshd" />
</ItemGroup>
<ItemGroup>
<Page Include="AboutDialog.xaml" />
<Page Include="MainWindow.xaml" />
<Page Include="OpenFromGacDialog.xaml" />
<Page Include="TextView\DecompilerTextView.xaml">

1
ILSpy/Images/Images.cs

@ -17,6 +17,7 @@ namespace ICSharpCode.ILSpy @@ -17,6 +17,7 @@ namespace ICSharpCode.ILSpy
public static readonly BitmapImage ViewCode = LoadBitmap("ViewCode");
public static readonly BitmapImage Save = LoadBitmap("SaveFile");
public static readonly BitmapImage OK = LoadBitmap("OK");
public static readonly BitmapImage Assembly = LoadBitmap("Assembly");
public static readonly BitmapImage AssemblyWarning = LoadBitmap("AssemblyWarning");

BIN
ILSpy/Images/OK.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 958 B

10
ILSpy/MainWindow.xaml.cs

@ -87,7 +87,11 @@ namespace ICSharpCode.ILSpy @@ -87,7 +87,11 @@ namespace ICSharpCode.ILSpy
if (assemblyList.Assemblies.Count == 0)
LoadInitialAssemblies();
SelectNode(FindNodeByPath(sessionSettings.ActiveTreeViewPath, true));
SharpTreeNode node = FindNodeByPath(sessionSettings.ActiveTreeViewPath, true);
if (node != null)
SelectNode(node);
else
AboutPage.Display(decompilerTextView);
}
void ShowAssemblyList(AssemblyList assemblyList)
@ -293,9 +297,7 @@ namespace ICSharpCode.ILSpy @@ -293,9 +297,7 @@ namespace ICSharpCode.ILSpy
void AboutClick(object sender, RoutedEventArgs e)
{
AboutDialog dlg = new AboutDialog();
dlg.Owner = this;
dlg.ShowDialog();
AboutPage.Display(decompilerTextView);
}
void OpenFromGac_Click(object sender, RoutedEventArgs e)

4
ILSpy/TextView/DecompilerTextView.cs

@ -73,7 +73,7 @@ namespace ICSharpCode.ILSpy.TextView @@ -73,7 +73,7 @@ namespace ICSharpCode.ILSpy.TextView
textEditor.TextArea.TextView.ElementGenerators.Add(referenceElementGenerator);
this.uiElementGenerator = new UIElementGenerator();
textEditor.TextArea.TextView.ElementGenerators.Add(uiElementGenerator);
textEditor.Text = "Welcome to ILSpy!";
textEditor.Options.RequireControlModifierForHyperlinkClick = false;
}
#endregion
@ -134,7 +134,7 @@ namespace ICSharpCode.ILSpy.TextView @@ -134,7 +134,7 @@ namespace ICSharpCode.ILSpy.TextView
/// Shows the given output in the text view.
/// Cancels any currently running decompilation tasks.
/// </summary>
public void Show(AvalonEditTextOutput textOutput, IHighlightingDefinition highlighting)
public void Show(AvalonEditTextOutput textOutput, IHighlightingDefinition highlighting = null)
{
// Cancel the decompilation task:
if (currentCancellationTokenSource != null) {

9
README.txt

@ -1,12 +1,15 @@ @@ -1,12 +1,15 @@
ILSpy is the open-source .NET assembly browser and decompiler.
Website: http://www.ilspy.net/
Copyright 2011 AlphaSierraPapa for the SharpDevelop team
License: ILSpy is MIT/X11
Included open-source libraries:
Mono.Cecil: MIT/X11 (thanks to Jb Evain)
AvalonEdit: LGPL
Mono.Cecil: MIT/X11
SharpTreeView: LGPL
ICSharpCode.Decompiler: MIT/X11 (developed as part of ILSpy)
This early version was hastily created by Daniel Grunwald after RedGate announced that Reflector would no longer
be available for free.
ILSpy Contributors:
Daniel Grunwald
David Srbecky

Loading…
Cancel
Save