mirror of https://github.com/icsharpcode/ILSpy.git
7 changed files with 129 additions and 0 deletions
@ -0,0 +1,26 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Diagnostics; |
||||||
|
using System.Diagnostics.Tracing; |
||||||
|
using System.IO; |
||||||
|
using System.Linq; |
||||||
|
using System.Text; |
||||||
|
using System.Threading.Tasks; |
||||||
|
using ICSharpCode.Decompiler.TypeSystem; |
||||||
|
using ICSharpCode.Decompiler.TypeSystem.Implementation; |
||||||
|
using Mono.Cecil; |
||||||
|
|
||||||
|
namespace ICSharpCode.Decompiler |
||||||
|
{ |
||||||
|
[EventSource(Name = "DecompilerEventSource")] |
||||||
|
public sealed class DecompilerEventSource : EventSource |
||||||
|
{ |
||||||
|
public static DecompilerEventSource Log = new DecompilerEventSource(); |
||||||
|
|
||||||
|
[Event(1, Level = EventLevel.Informational)] |
||||||
|
public void Info(string text) |
||||||
|
{ |
||||||
|
WriteEvent(1, text); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,13 @@ |
|||||||
|
<UserControl x:Class="ICSharpCode.ILSpy.LogWindow" |
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
||||||
|
xmlns:local="clr-namespace:ICSharpCode.ILSpy" |
||||||
|
xmlns:ae="http://icsharpcode.net/sharpdevelop/avalonedit" |
||||||
|
mc:Ignorable="d" |
||||||
|
d:DesignHeight="300" d:DesignWidth="300"> |
||||||
|
<Grid> |
||||||
|
<ae:TextEditor x:Name="log" FontFamily="Consolas" FontSize="10pt" IsReadOnly="True" /> |
||||||
|
</Grid> |
||||||
|
</UserControl> |
@ -0,0 +1,74 @@ |
|||||||
|
using System; |
||||||
|
using System.Collections.Generic; |
||||||
|
using System.Diagnostics.Tracing; |
||||||
|
using System.Linq; |
||||||
|
using System.Text; |
||||||
|
using System.Threading.Tasks; |
||||||
|
using System.Windows; |
||||||
|
using System.Windows.Controls; |
||||||
|
using ICSharpCode.AvalonEdit; |
||||||
|
|
||||||
|
namespace ICSharpCode.ILSpy |
||||||
|
{ |
||||||
|
partial class LogWindow : UserControl, IPane |
||||||
|
{ |
||||||
|
static LogWindow instance; |
||||||
|
|
||||||
|
public static LogWindow Instance { |
||||||
|
get { |
||||||
|
if (instance == null) { |
||||||
|
App.Current.VerifyAccess(); |
||||||
|
instance = new LogWindow(); |
||||||
|
} |
||||||
|
return instance; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
readonly AvalonEditEventListener listener; |
||||||
|
|
||||||
|
private LogWindow() |
||||||
|
{ |
||||||
|
InitializeComponent(); |
||||||
|
this.listener = new AvalonEditEventListener(this.log); |
||||||
|
} |
||||||
|
|
||||||
|
public void Show() |
||||||
|
{ |
||||||
|
if (!IsVisible) { |
||||||
|
MainWindow.Instance.ShowInBottomPane("Output", this); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void Closed() |
||||||
|
{ |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
class AvalonEditEventListener : EventListener |
||||||
|
{ |
||||||
|
private TextEditor editor; |
||||||
|
|
||||||
|
public AvalonEditEventListener(TextEditor editor) |
||||||
|
{ |
||||||
|
this.editor = editor ?? throw new ArgumentNullException(nameof(editor)); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void OnEventSourceCreated(EventSource eventSource) |
||||||
|
{ |
||||||
|
if (eventSource.Name == "DecompilerEventSource") |
||||||
|
EnableEvents(eventSource, EventLevel.LogAlways, EventKeywords.All); |
||||||
|
} |
||||||
|
|
||||||
|
protected override void OnEventWritten(EventWrittenEventArgs eventData) |
||||||
|
{ |
||||||
|
editor.Dispatcher.InvokeAsync(() => WriteToLog(eventData)); |
||||||
|
} |
||||||
|
|
||||||
|
private void WriteToLog(EventWrittenEventArgs eventData) |
||||||
|
{ |
||||||
|
editor.AppendText(eventData.Payload[0] + Environment.NewLine); |
||||||
|
editor.ScrollToEnd(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue