Skip to content

Instantly share code, notes, and snippets.

@kevingosse
Created January 2, 2018 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevingosse/e57b3121346f651d1268cf0d9a0af1d3 to your computer and use it in GitHub Desktop.
Save kevingosse/e57b3121346f651d1268cf0d9a0af1d3 to your computer and use it in GitHub Desktop.
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