Created
January 2, 2018 15:25
-
-
Save kevingosse/e57b3121346f651d1268cf0d9a0af1d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.ObjectModel; | |
using System.ComponentModel.Composition; | |
using System.Text; | |
using System.Windows.Controls; | |
using DbgX.Interfaces; | |
using DbgX.Interfaces.Listeners; | |
using DbgX.Interfaces.Services; | |
namespace WinDbgExt.History | |
{ | |
[NamedPartMetadata("CommandHistoryWindow"), Export(typeof(IDbgToolWindow))] | |
[Export(typeof(IDbgDmlOutputListener))] | |
[Export(typeof(IDbgCommandExecutionListener))] | |
[Export(typeof(IDbgEngineStatusListener))] | |
public class CommandHistoryWindow : IDbgToolWindow, IDbgDmlOutputListener, IDbgCommandExecutionListener, IDbgEngineStatusListener | |
{ | |
private StringBuilder _output = new StringBuilder(); | |
private string _currentCommand; | |
[Import] | |
private IDbgConsole _console; | |
public CommandHistoryWindow() | |
{ | |
History = new ObservableCollection<Tuple<string, string>>(); | |
} | |
public ObservableCollection<Tuple<string, string>> History { get; } | |
public Control GetToolWindowView(object parameter) | |
{ | |
return new HistoryControl { DataContext = this }; | |
} | |
public void OnDmlOutput(string text) | |
{ | |
_output.Append(text); | |
} | |
public void OnCommandExecuted(string command) | |
{ | |
_output.Clear(); | |
_currentCommand = command; | |
} | |
public void OnEngineStatusChanged(bool busy) | |
{ | |
if (!busy && _currentCommand != null) | |
{ | |
LogCommand(_currentCommand, _output.ToString()); | |
} | |
} | |
public void LogCommand(string command, string output) | |
{ | |
History.Add(Tuple.Create(command, output)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment