mirror of https://github.com/icsharpcode/ILSpy.git
55 changed files with 1472 additions and 716 deletions
@ -0,0 +1,83 @@
@@ -0,0 +1,83 @@
|
||||
// Copyright (c) 2019 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.Windows; |
||||
using System.Windows.Documents; |
||||
using System.Windows.Input; |
||||
using System.Windows.Navigation; |
||||
using System.Windows.Threading; |
||||
|
||||
using ICSharpCode.ILSpy.Properties; |
||||
using ICSharpCode.ILSpyX; |
||||
|
||||
using TomsToolbox.Composition; |
||||
|
||||
namespace ICSharpCode.ILSpy.AssemblyTree |
||||
{ |
||||
public partial class AssemblyTreeModel |
||||
{ |
||||
public AssemblyTreeModel(SettingsService settingsService, LanguageService languageService, IExportProvider exportProvider) |
||||
{ |
||||
this.settingsService = settingsService; |
||||
this.languageService = languageService; |
||||
this.exportProvider = exportProvider; |
||||
|
||||
Title = Resources.Assemblies; |
||||
ContentId = PaneContentId; |
||||
IsCloseable = false; |
||||
ShortcutKey = new KeyGesture(Key.F6); |
||||
|
||||
MessageBus<NavigateToReferenceEventArgs>.Subscribers += JumpToReference; |
||||
MessageBus<SettingsChangedEventArgs>.Subscribers += (sender, e) => Settings_PropertyChanged(sender, e); |
||||
MessageBus<ApplySessionSettingsEventArgs>.Subscribers += ApplySessionSettings; |
||||
MessageBus<ActiveTabPageChangedEventArgs>.Subscribers += ActiveTabPageChanged; |
||||
MessageBus<TabPagesCollectionChangedEventArgs>.Subscribers += (_, e) => history.RemoveAll(s => !DockWorkspace.TabPages.Contains(s.TabPage)); |
||||
MessageBus<ResetLayoutEventArgs>.Subscribers += ResetLayout; |
||||
MessageBus<NavigateToEventArgs>.Subscribers += (_, e) => NavigateTo(e.Request, e.InNewTabPage); |
||||
MessageBus<MainWindowLoadedEventArgs>.Subscribers += (_, _) => { |
||||
Initialize(); |
||||
Show(); |
||||
}; |
||||
|
||||
EventManager.RegisterClassHandler(typeof(Window), Hyperlink.RequestNavigateEvent, new RequestNavigateEventHandler((_, e) => NavigateTo(e))); |
||||
|
||||
refreshThrottle = new(DispatcherPriority.Background, RefreshInternal); |
||||
|
||||
AssemblyList = settingsService.CreateEmptyAssemblyList(); |
||||
} |
||||
|
||||
private static void LoadInitialAssemblies(AssemblyList assemblyList) |
||||
{ |
||||
// Called when loading an empty assembly list; so that
|
||||
// the user can see something initially.
|
||||
System.Reflection.Assembly[] initialAssemblies = { |
||||
typeof(object).Assembly, |
||||
typeof(Uri).Assembly, |
||||
typeof(System.Linq.Enumerable).Assembly, |
||||
typeof(System.Xml.XmlDocument).Assembly, |
||||
typeof(System.Windows.Markup.MarkupExtension).Assembly, |
||||
typeof(System.Windows.Rect).Assembly, |
||||
typeof(System.Windows.UIElement).Assembly, |
||||
typeof(System.Windows.FrameworkElement).Assembly |
||||
}; |
||||
foreach (System.Reflection.Assembly asm in initialAssemblies) |
||||
assemblyList.OpenAssembly(asm.Location); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,150 @@
@@ -0,0 +1,150 @@
|
||||
// Copyright (c) 2019 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.Linq; |
||||
using System.Reflection; |
||||
using System.Windows.Data; |
||||
using System.Windows.Threading; |
||||
|
||||
using AvalonDock; |
||||
using AvalonDock.Layout; |
||||
using AvalonDock.Layout.Serialization; |
||||
|
||||
using ICSharpCode.ILSpy.Analyzers; |
||||
using ICSharpCode.ILSpy.Search; |
||||
using ICSharpCode.ILSpy.ViewModels; |
||||
|
||||
namespace ICSharpCode.ILSpy.Docking |
||||
{ |
||||
/// <summary>
|
||||
/// WPF-specific extensions to <see cref="DockWorkspace"/>.
|
||||
/// </summary>
|
||||
partial class DockWorkspace |
||||
{ |
||||
private DockingManager DockingManager => exportProvider.GetExportedValue<DockingManager>(); |
||||
|
||||
void LayoutSerializationCallback(object sender, LayoutSerializationCallbackEventArgs e) |
||||
{ |
||||
switch (e.Model) |
||||
{ |
||||
case LayoutAnchorable la: |
||||
e.Content = this.ToolPanes.FirstOrDefault(p => p.ContentId == la.ContentId); |
||||
e.Cancel = e.Content == null; |
||||
la.CanDockAsTabbedDocument = false; |
||||
if (e.Content is ToolPaneModel toolPaneModel) |
||||
{ |
||||
e.Cancel = toolPaneModel.IsVisible; |
||||
toolPaneModel.IsVisible = true; |
||||
} |
||||
break; |
||||
default: |
||||
e.Cancel = true; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
|
||||
public PaneModel ActivePane { |
||||
get => DockingManager.ActiveContent as PaneModel; |
||||
set => DockingManager.ActiveContent = value; |
||||
} |
||||
|
||||
public void InitializeLayout() |
||||
{ |
||||
if (tabPages.Count == 0) |
||||
{ |
||||
// Make sure there is at least one tab open
|
||||
AddTabPage(); |
||||
} |
||||
|
||||
DockingManager.LayoutUpdateStrategy = this; |
||||
XmlLayoutSerializer serializer = new XmlLayoutSerializer(DockingManager); |
||||
serializer.LayoutSerializationCallback += LayoutSerializationCallback; |
||||
try |
||||
{ |
||||
sessionSettings.DockLayout.Deserialize(serializer); |
||||
} |
||||
finally |
||||
{ |
||||
serializer.LayoutSerializationCallback -= LayoutSerializationCallback; |
||||
} |
||||
|
||||
DockingManager.SetBinding(DockingManager.AnchorablesSourceProperty, new Binding(nameof(ToolPanes))); |
||||
DockingManager.SetBinding(DockingManager.DocumentsSourceProperty, new Binding(nameof(TabPages))); |
||||
} |
||||
|
||||
internal void ResetLayout() |
||||
{ |
||||
foreach (var pane in ToolPanes) |
||||
{ |
||||
pane.IsVisible = false; |
||||
} |
||||
CloseAllTabs(); |
||||
sessionSettings.DockLayout.Reset(); |
||||
InitializeLayout(); |
||||
|
||||
App.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, () => MessageBus.Send(this, new ResetLayoutEventArgs())); |
||||
} |
||||
|
||||
static readonly PropertyInfo previousContainerProperty = typeof(LayoutContent).GetProperty("PreviousContainer", BindingFlags.NonPublic | BindingFlags.Instance); |
||||
|
||||
public bool BeforeInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableToShow, ILayoutContainer destinationContainer) |
||||
{ |
||||
if (!(anchorableToShow.Content is LegacyToolPaneModel legacyContent)) |
||||
return false; |
||||
anchorableToShow.CanDockAsTabbedDocument = false; |
||||
|
||||
LayoutAnchorablePane previousContainer; |
||||
switch (legacyContent.Location) |
||||
{ |
||||
case LegacyToolPaneLocation.Top: |
||||
previousContainer = GetContainer<SearchPaneModel>(); |
||||
previousContainer.Children.Add(anchorableToShow); |
||||
return true; |
||||
case LegacyToolPaneLocation.Bottom: |
||||
previousContainer = GetContainer<AnalyzerTreeViewModel>(); |
||||
previousContainer.Children.Add(anchorableToShow); |
||||
return true; |
||||
default: |
||||
return false; |
||||
} |
||||
|
||||
LayoutAnchorablePane GetContainer<T>() |
||||
{ |
||||
var anchorable = layout.Descendents().OfType<LayoutAnchorable>().FirstOrDefault(x => x.Content is T) |
||||
?? layout.Hidden.First(x => x.Content is T); |
||||
return (LayoutAnchorablePane)previousContainerProperty.GetValue(anchorable) ?? (LayoutAnchorablePane)anchorable.Parent; |
||||
} |
||||
} |
||||
|
||||
public void AfterInsertAnchorable(LayoutRoot layout, LayoutAnchorable anchorableShown) |
||||
{ |
||||
anchorableShown.IsActive = true; |
||||
anchorableShown.IsSelected = true; |
||||
} |
||||
|
||||
public bool BeforeInsertDocument(LayoutRoot layout, LayoutDocument anchorableToShow, ILayoutContainer destinationContainer) |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
public void AfterInsertDocument(LayoutRoot layout, LayoutDocument anchorableShown) |
||||
{ |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,75 @@
@@ -0,0 +1,75 @@
|
||||
// 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.Windows; |
||||
using System.Windows.Controls; |
||||
|
||||
using ICSharpCode.Decompiler; |
||||
using ICSharpCode.Decompiler.Metadata; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
|
||||
/// <summary>
|
||||
/// C# decompiler integration into ILSpy.
|
||||
/// Note: if you're interested in using the decompiler without the ILSpy UI,
|
||||
/// please directly use the CSharpDecompiler class.
|
||||
/// </summary>
|
||||
partial class CSharpLanguage |
||||
{ |
||||
void AddWarningMessage(MetadataFile module, ITextOutput output, string line1, string line2 = null, |
||||
string buttonText = null, System.Windows.Media.ImageSource buttonImage = null, RoutedEventHandler buttonClickHandler = null) |
||||
{ |
||||
if (output is ISmartTextOutput fancyOutput) |
||||
{ |
||||
string text = line1; |
||||
if (!string.IsNullOrEmpty(line2)) |
||||
text += Environment.NewLine + line2; |
||||
fancyOutput.AddUIElement(() => new StackPanel { |
||||
Margin = new Thickness(5), |
||||
Orientation = Orientation.Horizontal, |
||||
Children = { |
||||
new Image { |
||||
Width = 32, |
||||
Height = 32, |
||||
Source = Images.Load(this, "Images/Warning") |
||||
}, |
||||
new TextBlock { |
||||
Margin = new Thickness(5, 0, 0, 0), |
||||
Text = text |
||||
} |
||||
} |
||||
}); |
||||
fancyOutput.WriteLine(); |
||||
if (buttonText != null && buttonClickHandler != null) |
||||
{ |
||||
fancyOutput.AddButton(buttonImage, buttonText, buttonClickHandler); |
||||
fancyOutput.WriteLine(); |
||||
} |
||||
} |
||||
else |
||||
{ |
||||
WriteCommentLine(output, line1); |
||||
if (!string.IsNullOrEmpty(line2)) |
||||
WriteCommentLine(output, line2); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,22 @@
@@ -0,0 +1,22 @@
|
||||
using DataGridExtensions; |
||||
|
||||
namespace ICSharpCode.ILSpy.Metadata |
||||
{ |
||||
public class FlagsContentFilter : IContentFilter |
||||
{ |
||||
public int Mask { get; } |
||||
|
||||
public FlagsContentFilter(int mask) |
||||
{ |
||||
this.Mask = mask; |
||||
} |
||||
|
||||
public bool IsMatch(object value) |
||||
{ |
||||
if (value == null) |
||||
return true; |
||||
|
||||
return Mask == -1 || (Mask & (int)value) != 0; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.Reflection; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Data; |
||||
using System.Windows.Documents; |
||||
|
||||
namespace ICSharpCode.ILSpy.Metadata |
||||
{ |
||||
static partial class Helpers |
||||
{ |
||||
private static DataTemplate GetOrCreateLinkCellTemplate(string name, PropertyDescriptor descriptor, Binding binding) |
||||
{ |
||||
if (linkCellTemplates.TryGetValue(name, out var template)) |
||||
{ |
||||
return template; |
||||
} |
||||
|
||||
var tb = new FrameworkElementFactory(typeof(TextBlock)); |
||||
var hyper = new FrameworkElementFactory(typeof(Hyperlink)); |
||||
tb.AppendChild(hyper); |
||||
hyper.AddHandler(Hyperlink.ClickEvent, new RoutedEventHandler(Hyperlink_Click)); |
||||
var run = new FrameworkElementFactory(typeof(Run)); |
||||
hyper.AppendChild(run); |
||||
run.SetBinding(Run.TextProperty, binding); |
||||
|
||||
DataTemplate dataTemplate = new DataTemplate() { VisualTree = tb }; |
||||
linkCellTemplates.Add(name, dataTemplate); |
||||
return dataTemplate; |
||||
|
||||
void Hyperlink_Click(object sender, RoutedEventArgs e) |
||||
{ |
||||
var hyperlink = (Hyperlink)sender; |
||||
var onClickMethod = descriptor.ComponentType.GetMethod("On" + name + "Click", BindingFlags.Instance | BindingFlags.Public); |
||||
if (onClickMethod != null) |
||||
{ |
||||
onClickMethod.Invoke(hyperlink.DataContext, Array.Empty<object>()); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
using System; |
||||
|
||||
using DataGridExtensions; |
||||
|
||||
namespace ICSharpCode.ILSpy.Metadata |
||||
{ |
||||
public partial class HexFilterControl |
||||
{ |
||||
class ContentFilter : IContentFilter |
||||
{ |
||||
readonly string filter; |
||||
|
||||
public ContentFilter(string filter) |
||||
{ |
||||
this.filter = filter; |
||||
} |
||||
|
||||
public bool IsMatch(object value) |
||||
{ |
||||
if (string.IsNullOrWhiteSpace(filter)) |
||||
return true; |
||||
if (value == null) |
||||
return false; |
||||
|
||||
return string.Format("{0:x8}", value).IndexOf(filter, StringComparison.OrdinalIgnoreCase) >= 0; |
||||
} |
||||
|
||||
public string Value => filter; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
using System.Windows.Controls; |
||||
using System.Windows.Threading; |
||||
|
||||
namespace ICSharpCode.ILSpy.Metadata |
||||
{ |
||||
partial class MetadataTableTreeNode |
||||
{ |
||||
|
||||
protected void ScrollRowIntoView(DataGrid view, int row) |
||||
{ |
||||
if (!view.IsLoaded) |
||||
{ |
||||
view.Loaded += View_Loaded; |
||||
} |
||||
else |
||||
{ |
||||
View_Loaded(view, new System.Windows.RoutedEventArgs()); |
||||
} |
||||
if (view.Items.Count > row && row >= 0) |
||||
view.Dispatcher.BeginInvoke(() => view.SelectItem(view.Items[row]), DispatcherPriority.Background); |
||||
} |
||||
|
||||
private void View_Loaded(object sender, System.Windows.RoutedEventArgs e) |
||||
{ |
||||
DataGrid view = (DataGrid)sender; |
||||
var sv = view.FindVisualChild<ScrollViewer>(); |
||||
sv.ScrollToVerticalOffset(scrollTarget - 1); |
||||
view.Loaded -= View_Loaded; |
||||
this.scrollTarget = default; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
// 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.Composition; |
||||
|
||||
namespace ICSharpCode.ILSpy.Options |
||||
{ |
||||
[MetadataAttribute] |
||||
[AttributeUsage(AttributeTargets.Class)] |
||||
public sealed class ExportOptionPageAttribute() : ExportAttribute("OptionPages", typeof(IOptionPage)), IOptionsMetadata |
||||
{ |
||||
public int Order { get; set; } |
||||
} |
||||
} |
||||
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
// 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.
|
||||
|
||||
namespace ICSharpCode.ILSpy.Options |
||||
{ |
||||
public interface IOptionPage |
||||
{ |
||||
string Title { get; } |
||||
|
||||
void Load(SettingsSnapshot settings); |
||||
|
||||
void LoadDefaults(); |
||||
} |
||||
} |
||||
@ -0,0 +1,25 @@
@@ -0,0 +1,25 @@
|
||||
// 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.
|
||||
|
||||
namespace ICSharpCode.ILSpy.Options |
||||
{ |
||||
public interface IOptionsMetadata |
||||
{ |
||||
int Order { get; } |
||||
} |
||||
} |
||||
@ -0,0 +1,56 @@
@@ -0,0 +1,56 @@
|
||||
// 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.Composition; |
||||
|
||||
using ICSharpCode.ILSpy.AssemblyTree; |
||||
using ICSharpCode.ILSpy.Properties; |
||||
|
||||
namespace ICSharpCode.ILSpy.Options |
||||
{ |
||||
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._View), Header = nameof(Resources._Options), MenuCategory = nameof(Resources.Options), MenuOrder = 999)] |
||||
[Shared] |
||||
sealed class ShowOptionsCommand(AssemblyTreeModel assemblyTreeModel, SettingsService settingsService, MainWindow mainWindow) : SimpleCommand |
||||
{ |
||||
public override void Execute(object parameter) |
||||
{ |
||||
OptionsDialog dlg = new(settingsService); |
||||
|
||||
#if CROSS_PLATFORM
|
||||
// On cross-platform schedule showing the dialog on the UI dispatcher
|
||||
// and await its result asynchronously. Do not block the calling thread.
|
||||
System.Windows.Threading.Dispatcher.CurrentDispatcher.BeginInvoke(async () => { |
||||
bool? asyncResult = await dlg.ShowDialogAsync(mainWindow); |
||||
if (asyncResult == true) |
||||
{ |
||||
System.Windows.Threading.Dispatcher.CurrentDispatcher.BeginInvoke(() => assemblyTreeModel.Refresh()); |
||||
} |
||||
}); |
||||
#else
|
||||
// WPF path: set owner and show dialog synchronously as before.
|
||||
dlg.Owner = mainWindow; |
||||
bool? result = dlg.ShowDialog(); |
||||
if (result == true) |
||||
{ |
||||
assemblyTreeModel.Refresh(); |
||||
} |
||||
#endif
|
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
// 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.Composition; |
||||
using System.Windows.Input; |
||||
|
||||
using ICSharpCode.ILSpy.Docking; |
||||
|
||||
namespace ICSharpCode.ILSpy.Search |
||||
{ |
||||
[ExportToolbarCommand(ToolTip = nameof(Properties.Resources.SearchCtrlShiftFOrCtrlE), ToolbarIcon = "Images/Search", ToolbarCategory = nameof(Properties.Resources.View), ToolbarOrder = 100)] |
||||
[Shared] |
||||
sealed class ShowSearchCommand : CommandWrapper |
||||
{ |
||||
private readonly DockWorkspace dockWorkspace; |
||||
|
||||
public ShowSearchCommand(DockWorkspace dockWorkspace) |
||||
: base(NavigationCommands.Search) |
||||
{ |
||||
this.dockWorkspace = dockWorkspace; |
||||
var gestures = NavigationCommands.Search.InputGestures; |
||||
|
||||
gestures.Clear(); |
||||
gestures.Add(new KeyGesture(Key.F, ModifierKeys.Control | ModifierKeys.Shift)); |
||||
gestures.Add(new KeyGesture(Key.E, ModifierKeys.Control)); |
||||
} |
||||
|
||||
protected override void OnExecute(object sender, ExecutedRoutedEventArgs e) |
||||
{ |
||||
Console.WriteLine($"ShowSearchCommand: Executing ShowToolPane for SearchPaneModel.PaneContentId using dockWorkspace type: {dockWorkspace?.GetType().FullName}"); |
||||
var result = dockWorkspace.ShowToolPane(SearchPaneModel.PaneContentId); |
||||
Console.WriteLine($"ShowSearchCommand: ShowToolPane returned: {result}"); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,61 @@
@@ -0,0 +1,61 @@
|
||||
// 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.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Input; |
||||
using System.Windows.Media; |
||||
|
||||
using ICSharpCode.ILSpy.Themes; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
public static class SmartTextOutputExtensions |
||||
{ |
||||
/// <summary>
|
||||
/// Creates a button.
|
||||
/// </summary>
|
||||
public static void AddButton(this ISmartTextOutput output, ImageSource icon, string text, RoutedEventHandler click) |
||||
{ |
||||
output.AddUIElement( |
||||
delegate { |
||||
Button button = ThemeManager.Current.CreateButton(); |
||||
button.Cursor = Cursors.Arrow; |
||||
button.Margin = new Thickness(2); |
||||
button.Padding = new Thickness(9, 1, 9, 1); |
||||
button.MinWidth = 73; |
||||
if (icon != null) |
||||
{ |
||||
button.Content = new StackPanel { |
||||
Orientation = Orientation.Horizontal, |
||||
Children = { |
||||
new Image { Width = 16, Height = 16, Source = icon, Margin = new Thickness(0, 0, 4, 0) }, |
||||
new TextBlock { Text = text } |
||||
} |
||||
}; |
||||
} |
||||
else |
||||
{ |
||||
button.Content = text; |
||||
} |
||||
button.Click += click; |
||||
return button; |
||||
}); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
// Copyright (c) 2014 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.
|
||||
|
||||
namespace ICSharpCode.ILSpy.TextView |
||||
{ |
||||
/// <summary>
|
||||
/// Describes a pair of matching brackets found by <see cref="IBracketSearcher"/>.
|
||||
/// </summary>
|
||||
public class BracketSearchResult |
||||
{ |
||||
public int OpeningBracketOffset { get; private set; } |
||||
|
||||
public int OpeningBracketLength { get; private set; } |
||||
|
||||
public int ClosingBracketOffset { get; private set; } |
||||
|
||||
public int ClosingBracketLength { get; private set; } |
||||
|
||||
public BracketSearchResult(int openingBracketOffset, int openingBracketLength, |
||||
int closingBracketOffset, int closingBracketLength) |
||||
{ |
||||
this.OpeningBracketOffset = openingBracketOffset; |
||||
this.OpeningBracketLength = openingBracketLength; |
||||
this.ClosingBracketOffset = closingBracketOffset; |
||||
this.ClosingBracketLength = closingBracketLength; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) 2014 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 ICSharpCode.AvalonEdit.Document; |
||||
|
||||
namespace ICSharpCode.ILSpy.TextView |
||||
{ |
||||
public class DefaultBracketSearcher : IBracketSearcher |
||||
{ |
||||
public static readonly DefaultBracketSearcher DefaultInstance = new DefaultBracketSearcher(); |
||||
|
||||
public BracketSearchResult SearchBracket(IDocument document, int offset) |
||||
{ |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
// Copyright (c) 2014 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 ICSharpCode.AvalonEdit.Document; |
||||
|
||||
namespace ICSharpCode.ILSpy.TextView |
||||
{ |
||||
/// <summary>
|
||||
/// Allows language specific search for matching brackets.
|
||||
/// </summary>
|
||||
public interface IBracketSearcher |
||||
{ |
||||
/// <summary>
|
||||
/// Searches for a matching bracket from the given offset to the start of the document.
|
||||
/// </summary>
|
||||
/// <returns>A BracketSearchResult that contains the positions and lengths of the brackets. Return null if there is nothing to highlight.</returns>
|
||||
BracketSearchResult SearchBracket(IDocument document, int offset); |
||||
} |
||||
} |
||||
@ -0,0 +1,56 @@
@@ -0,0 +1,56 @@
|
||||
// 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.
|
||||
|
||||
#nullable enable |
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics; |
||||
|
||||
using ICSharpCode.ILSpy.TreeNodes; |
||||
|
||||
namespace ICSharpCode.ILSpy.TextView |
||||
{ |
||||
[DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")] |
||||
public class ViewState : IEquatable<ViewState> |
||||
{ |
||||
public HashSet<ILSpyTreeNode>? DecompiledNodes; |
||||
public Uri? ViewedUri; |
||||
|
||||
public virtual bool Equals(ViewState? other) |
||||
{ |
||||
return other != null |
||||
&& ViewedUri == other.ViewedUri |
||||
&& NullSafeSetEquals(DecompiledNodes, other.DecompiledNodes); |
||||
|
||||
static bool NullSafeSetEquals(HashSet<ILSpyTreeNode>? a, HashSet<ILSpyTreeNode>? b) |
||||
{ |
||||
if (a == b) |
||||
return true; |
||||
if (a == null || b == null) |
||||
return false; |
||||
return a.SetEquals(b); |
||||
} |
||||
} |
||||
|
||||
protected virtual string GetDebuggerDisplay() |
||||
{ |
||||
return $"Nodes = {DecompiledNodes?.Count.ToString() ?? "<null>"}, ViewedUri = {ViewedUri?.ToString() ?? "<null>"}"; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,50 @@
@@ -0,0 +1,50 @@
|
||||
// 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.Windows.Input; |
||||
|
||||
using ICSharpCode.AvalonEdit.Rendering; |
||||
|
||||
namespace ICSharpCode.ILSpy.TextView |
||||
{ |
||||
/// <summary>
|
||||
/// VisualLineElement that represents a piece of text and is a clickable link.
|
||||
/// </summary>
|
||||
sealed partial class VisualLineReferenceText : VisualLineText |
||||
{ |
||||
readonly ReferenceElementGenerator parent; |
||||
readonly ReferenceSegment referenceSegment; |
||||
|
||||
/// <summary>
|
||||
/// Creates a visual line text element with the specified length.
|
||||
/// It uses the <see cref="ITextRunConstructionContext.VisualLine"/> and its
|
||||
/// <see cref="VisualLineElement.RelativeTextOffset"/> to find the actual text string.
|
||||
/// </summary>
|
||||
public VisualLineReferenceText(VisualLine parentVisualLine, int length, ReferenceElementGenerator parent, ReferenceSegment referenceSegment) : base(parentVisualLine, length) |
||||
{ |
||||
this.parent = parent; |
||||
this.referenceSegment = referenceSegment; |
||||
} |
||||
|
||||
/// <inheritdoc/>
|
||||
protected override VisualLineText CreateInstance(int length) |
||||
{ |
||||
return new VisualLineReferenceText(ParentVisualLine, length, parent, referenceSegment); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
// 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.Windows.Input; |
||||
|
||||
using ICSharpCode.AvalonEdit.Rendering; |
||||
|
||||
namespace ICSharpCode.ILSpy.TextView |
||||
{ |
||||
/// <summary>
|
||||
/// VisualLineElement that represents a piece of text and is a clickable link.
|
||||
/// </summary>
|
||||
partial class VisualLineReferenceText |
||||
{ |
||||
/// <inheritdoc/>
|
||||
protected override void OnQueryCursor(QueryCursorEventArgs e) |
||||
{ |
||||
e.Handled = true; |
||||
e.Cursor = referenceSegment.IsLocal ? Cursors.Arrow : Cursors.Hand; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,55 @@
@@ -0,0 +1,55 @@
|
||||
// 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.Windows.Controls; |
||||
using System.Windows.Media.Imaging; |
||||
|
||||
using ICSharpCode.ILSpy.Properties; |
||||
using ICSharpCode.ILSpy.TextView; |
||||
using ICSharpCode.ILSpy.ViewModels; |
||||
|
||||
namespace ICSharpCode.ILSpy.TreeNodes |
||||
{ |
||||
partial class ImageResourceEntryNode |
||||
{ |
||||
public override bool View(TabPageModel tabPage) |
||||
{ |
||||
try |
||||
{ |
||||
AvalonEditTextOutput output = new AvalonEditTextOutput(); |
||||
BitmapImage image = new BitmapImage(); |
||||
image.BeginInit(); |
||||
image.StreamSource = OpenStream(); |
||||
image.EndInit(); |
||||
output.AddUIElement(() => new Image { Source = image }); |
||||
output.WriteLine(); |
||||
output.AddButton(Images.Save, Resources.Save, delegate { |
||||
Save(null); |
||||
}); |
||||
tabPage.ShowTextView(textView => textView.ShowNode(output, this)); |
||||
tabPage.SupportsLanguageSwitching = false; |
||||
return true; |
||||
} |
||||
catch (Exception) |
||||
{ |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
// Copyright (c) 2024 Tom Englert 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.
|
||||
|
||||
namespace ICSharpCode.ILSpy.Util |
||||
{ |
||||
partial class GlobalUtils |
||||
{ |
||||
public static void OpenTerminalAt(string path) |
||||
{ |
||||
ExecuteCommand("cmd.exe", $"/k \"cd /d {path}\""); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
// Copyright (c) 2019 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.Windows; |
||||
|
||||
namespace ICSharpCode.ILSpy.ViewModels |
||||
{ |
||||
public static class Pane |
||||
{ |
||||
// Helper properties to enable binding state properties from the model to the view.
|
||||
|
||||
public static readonly DependencyProperty IsActiveProperty = DependencyProperty.RegisterAttached( |
||||
"IsActive", typeof(bool), typeof(Pane), new FrameworkPropertyMetadata(default(bool))); |
||||
public static void SetIsActive(DependencyObject element, bool value) |
||||
{ |
||||
element.SetValue(IsActiveProperty, value); |
||||
} |
||||
public static bool GetIsActive(DependencyObject element) |
||||
{ |
||||
return (bool)element.GetValue(IsActiveProperty); |
||||
} |
||||
|
||||
public static readonly DependencyProperty IsVisibleProperty = DependencyProperty.RegisterAttached( |
||||
"IsVisible", typeof(bool), typeof(Pane), new FrameworkPropertyMetadata(default(bool))); |
||||
public static void SetIsVisible(DependencyObject element, bool value) |
||||
{ |
||||
element.SetValue(IsVisibleProperty, value); |
||||
} |
||||
public static bool GetIsVisible(DependencyObject element) |
||||
{ |
||||
return (bool)element.GetValue(IsVisibleProperty); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,89 @@
@@ -0,0 +1,89 @@
|
||||
// Copyright (c) 2019 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.Threading.Tasks; |
||||
|
||||
using ICSharpCode.Decompiler; |
||||
using ICSharpCode.ILSpy.TextView; |
||||
|
||||
#nullable enable |
||||
|
||||
namespace ICSharpCode.ILSpy.ViewModels |
||||
{ |
||||
public static partial class TabPageModelExtensions |
||||
{ |
||||
public static Task<T> ShowTextViewAsync<T>(this TabPageModel tabPage, Func<DecompilerTextView, Task<T>> action) |
||||
{ |
||||
if (tabPage.Content is not DecompilerTextView textView) |
||||
{ |
||||
textView = new DecompilerTextView(tabPage.ExportProvider); |
||||
tabPage.Content = textView; |
||||
} |
||||
tabPage.Title = Properties.Resources.Decompiling; |
||||
return action(textView); |
||||
} |
||||
|
||||
public static Task ShowTextViewAsync(this TabPageModel tabPage, Func<DecompilerTextView, Task> action) |
||||
{ |
||||
if (tabPage.Content is not DecompilerTextView textView) |
||||
{ |
||||
textView = new DecompilerTextView(tabPage.ExportProvider); |
||||
tabPage.Content = textView; |
||||
} |
||||
string oldTitle = tabPage.Title; |
||||
tabPage.Title = Properties.Resources.Decompiling; |
||||
try |
||||
{ |
||||
return action(textView); |
||||
} |
||||
finally |
||||
{ |
||||
if (tabPage.Title == Properties.Resources.Decompiling) |
||||
{ |
||||
tabPage.Title = oldTitle; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static void ShowTextView(this TabPageModel tabPage, Action<DecompilerTextView> action) |
||||
{ |
||||
if (tabPage.Content is not DecompilerTextView textView) |
||||
{ |
||||
textView = new DecompilerTextView(tabPage.ExportProvider); |
||||
tabPage.Content = textView; |
||||
} |
||||
string oldTitle = tabPage.Title; |
||||
tabPage.Title = Properties.Resources.Decompiling; |
||||
action(textView); |
||||
if (tabPage.Title == Properties.Resources.Decompiling) |
||||
{ |
||||
tabPage.Title = oldTitle; |
||||
} |
||||
} |
||||
|
||||
public static DecompilationOptions CreateDecompilationOptions(this TabPageModel tabPage) |
||||
{ |
||||
var exportProvider = tabPage.ExportProvider; |
||||
var languageService = exportProvider.GetExportedValue<LanguageService>(); |
||||
var settingsService = exportProvider.GetExportedValue<SettingsService>(); |
||||
|
||||
return new(languageService.LanguageVersion, settingsService.DecompilerSettings, settingsService.DisplaySettings) { Progress = tabPage.Content as IProgress<DecompilationProgress> }; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
// Copyright (c) 2019 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.Linq; |
||||
using System.Windows; |
||||
|
||||
using TomsToolbox.Wpf; |
||||
|
||||
#nullable enable |
||||
|
||||
|
||||
namespace ICSharpCode.ILSpy.ViewModels |
||||
{ |
||||
public static partial class TabPageModelExtensions |
||||
{ |
||||
public static void Focus(this TabPageModel tabPage) |
||||
{ |
||||
if (tabPage.Content is not FrameworkElement content) |
||||
return; |
||||
|
||||
var focusable = content |
||||
.VisualDescendantsAndSelf() |
||||
.OfType<FrameworkElement>() |
||||
.FirstOrDefault(item => item.Focusable); |
||||
|
||||
focusable?.Focus(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,87 @@
@@ -0,0 +1,87 @@
|
||||
// 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.Text; |
||||
|
||||
using ICSharpCode.Decompiler.Metadata; |
||||
|
||||
namespace ICSharpCode.ILSpy |
||||
{ |
||||
public partial class OpenFromGacDialog |
||||
{ |
||||
sealed class GacEntry |
||||
{ |
||||
readonly AssemblyNameReference r; |
||||
readonly string fileName; |
||||
string formattedVersion; |
||||
|
||||
public GacEntry(AssemblyNameReference r, string fileName) |
||||
{ |
||||
this.r = r; |
||||
this.fileName = fileName; |
||||
} |
||||
|
||||
public string FullName { |
||||
get { return r.FullName; } |
||||
} |
||||
|
||||
public string ShortName { |
||||
get { return r.Name; } |
||||
} |
||||
|
||||
public string FileName { |
||||
get { return fileName; } |
||||
} |
||||
|
||||
public Version Version { |
||||
get { return r.Version; } |
||||
} |
||||
|
||||
public string FormattedVersion { |
||||
get { |
||||
if (formattedVersion == null) |
||||
formattedVersion = Version.ToString(); |
||||
return formattedVersion; |
||||
} |
||||
} |
||||
|
||||
public string Culture { |
||||
get { |
||||
if (string.IsNullOrEmpty(r.Culture)) |
||||
return "neutral"; |
||||
return r.Culture; |
||||
} |
||||
} |
||||
|
||||
public string PublicKeyToken { |
||||
get { |
||||
StringBuilder s = new StringBuilder(); |
||||
foreach (byte b in r.PublicKeyToken) |
||||
s.Append(b.ToString("x2")); |
||||
return s.ToString(); |
||||
} |
||||
} |
||||
|
||||
public override string ToString() |
||||
{ |
||||
return r.FullName; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue