mirror of
https://github.com/ZuneDev/ZuneUIXTools.git
synced 2026-07-27 13:11:59 -07:00
Add basic controls for starting/stopping UIX debugging
This commit is contained in:
@@ -1,17 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows;
|
||||
|
||||
namespace ZuneUIXTools
|
||||
namespace ZuneUIXTools;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
internal const string DEFAULT_DEBUG_URI = "tcp://127.0.0.1:5556";
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 400 B |
Binary file not shown.
|
After Width: | Height: | Size: 491 B |
Binary file not shown.
|
After Width: | Height: | Size: 122 B |
@@ -0,0 +1,24 @@
|
||||
using Gemini.Framework.Commands;
|
||||
using System;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace ZuneUIXTools.Modules.Shell.Commands;
|
||||
|
||||
[CommandDefinition]
|
||||
public class StartDebuggerCommandDefinition : CommandDefinition
|
||||
{
|
||||
public const string CommandName = "Debugger.Attach";
|
||||
|
||||
public override string Name => CommandName;
|
||||
|
||||
public override string Text => "Attach Debugger";
|
||||
|
||||
public override string ToolTip => "Starts the Iris debugger client.";
|
||||
|
||||
public override Uri IconSource => new("pack://application:,,,/ZuneUIXTools;component/Images/EnableDebugging_16x.png");
|
||||
|
||||
[Export]
|
||||
public static CommandKeyboardShortcut KeyGesture
|
||||
= new CommandKeyboardShortcut<StartDebuggerCommandDefinition>(new KeyGesture(Key.F5, ModifierKeys.Shift));
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using Gemini.Framework.Commands;
|
||||
using System;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace ZuneUIXTools.Modules.Shell.Commands;
|
||||
|
||||
[CommandDefinition]
|
||||
public class StopDebuggerCommandDefinition : CommandDefinition
|
||||
{
|
||||
public const string CommandName = "Debugger.Detach";
|
||||
|
||||
public override string Name => CommandName;
|
||||
|
||||
public override string Text => "Detach Debugger";
|
||||
|
||||
public override string ToolTip => "Stops the Iris debugger client.";
|
||||
|
||||
public override Uri IconSource => new("pack://application:,,,/ZuneUIXTools;component/Images/Stop_16x.png");
|
||||
|
||||
[Export]
|
||||
public static CommandKeyboardShortcut KeyGesture
|
||||
= new CommandKeyboardShortcut<StopDebuggerCommandDefinition>(new KeyGesture(Key.F5, ModifierKeys.Shift));
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Gemini.Framework.Menus;
|
||||
using System.ComponentModel.Composition;
|
||||
|
||||
namespace ZuneUIXTools.Modules.Shell;
|
||||
|
||||
public static class MenuDefinitions
|
||||
{
|
||||
[Export]
|
||||
public static readonly MenuDefinition DebugMenu = new(Gemini.Modules.MainMenu.MenuDefinitions.MainMenuBar, 4, "Debug");
|
||||
|
||||
[Export]
|
||||
public static readonly MenuItemGroupDefinition DebuggerMenuGroup = new(DebugMenu, 0);
|
||||
|
||||
[Export]
|
||||
public static readonly MenuItemDefinition StartDebuggerMenuItem
|
||||
= new CommandMenuItemDefinition<Commands.StartDebuggerCommandDefinition>(DebuggerMenuGroup, 0);
|
||||
}
|
||||
@@ -23,5 +23,12 @@ namespace ZuneUIXTools.Modules.Shell
|
||||
[Export]
|
||||
public static ToolBarItemDefinition DecompileToolBarItem = new CommandToolBarItemDefinition<DecompileCommandDefinition>(
|
||||
UIXFileToolBarGroup, 2);
|
||||
}
|
||||
|
||||
[Export]
|
||||
public static ToolBarItemGroupDefinition UIXDebuggerToolBarGroup = new(UIXToolBar, 9);
|
||||
|
||||
[Export]
|
||||
public static ToolBarItemDefinition StopDebuggerToolBarItem = new CommandToolBarItemDefinition<StopDebuggerCommandDefinition>(
|
||||
UIXDebuggerToolBarGroup, 0, ToolBarItemDisplay.IconOnly);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
using Gemini.Modules.Output;
|
||||
using Microsoft.Iris.Debug;
|
||||
using System;
|
||||
using System.ComponentModel.Composition;
|
||||
|
||||
namespace ZuneUIXTools.Modules.UIX;
|
||||
|
||||
[Export(typeof(DebuggerService))]
|
||||
public class DebuggerService
|
||||
{
|
||||
private readonly IOutput _output;
|
||||
private IDebuggerClient _client;
|
||||
|
||||
[ImportingConstructor]
|
||||
public DebuggerService(IOutput output)
|
||||
{
|
||||
_output = output;
|
||||
}
|
||||
|
||||
public bool IsRunning => _client != null;
|
||||
|
||||
public void Start(string connectionUri)
|
||||
{
|
||||
Stop();
|
||||
|
||||
_client = new ZmqDebuggerClient(connectionUri);
|
||||
_client.DispatcherStep += Client_DispatcherStep;
|
||||
}
|
||||
|
||||
private void Client_DispatcherStep(string obj)
|
||||
{
|
||||
_output?.AppendLine($"[Dispatcher] {obj}");
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (_client == null)
|
||||
return;
|
||||
|
||||
if (_client is IDisposable disposable)
|
||||
disposable.Dispose();
|
||||
|
||||
_client.DispatcherStep -= Client_DispatcherStep;
|
||||
_client = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using Gemini.Framework.Commands;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Threading.Tasks;
|
||||
using ZuneUIXTools.Modules.Shell.Commands;
|
||||
|
||||
namespace ZuneUIXTools.Modules.UIX;
|
||||
|
||||
[CommandHandler]
|
||||
public class StartDebuggerCommandHandler : CommandHandlerBase<StartDebuggerCommandDefinition>
|
||||
{
|
||||
private readonly DebuggerService _debuggerService;
|
||||
|
||||
[ImportingConstructor]
|
||||
public StartDebuggerCommandHandler(DebuggerService debuggerService)
|
||||
{
|
||||
_debuggerService = debuggerService;
|
||||
}
|
||||
|
||||
public override Task Run(Command command)
|
||||
{
|
||||
_debuggerService.Start(App.DEFAULT_DEBUG_URI);
|
||||
Update(command);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public override void Update(Command command)
|
||||
{
|
||||
base.Update(command);
|
||||
|
||||
command.Enabled = !_debuggerService.IsRunning;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using Gemini.Framework.Commands;
|
||||
using System.ComponentModel.Composition;
|
||||
using System.Threading.Tasks;
|
||||
using ZuneUIXTools.Modules.Shell.Commands;
|
||||
|
||||
namespace ZuneUIXTools.Modules.UIX;
|
||||
|
||||
[CommandHandler]
|
||||
public class StopDebuggerCommandHandler : CommandHandlerBase<StopDebuggerCommandDefinition>
|
||||
{
|
||||
private readonly DebuggerService _debuggerService;
|
||||
|
||||
[ImportingConstructor]
|
||||
public StopDebuggerCommandHandler(DebuggerService debuggerService)
|
||||
{
|
||||
_debuggerService = debuggerService;
|
||||
}
|
||||
|
||||
public override Task Run(Command command)
|
||||
{
|
||||
_debuggerService.Stop();
|
||||
Update(command);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public override void Update(Command command)
|
||||
{
|
||||
base.Update(command);
|
||||
|
||||
command.Visible = command.Enabled = _debuggerService.IsRunning;
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ namespace ZuneUIXTools.Modules.UIXSource
|
||||
private readonly IOutput _output = IoC.Get<IOutput>();
|
||||
private UIXSourceEditorView _view;
|
||||
private string _originalText;
|
||||
private string _debuggerConnectionUri = "tcp://127.0.0.1:5556";
|
||||
private string _debuggerConnectionUri = App.DEFAULT_DEBUG_URI;
|
||||
|
||||
public bool CanBuild => !string.IsNullOrWhiteSpace(_view.CodeEditor.Text);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user