mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Debugger - Added quick access button to main window
Debugger - Bring debugger to front if already open instead of creating a new one
This commit is contained in:
parent
2b7a507725
commit
28bcfcc95a
@ -16,28 +16,23 @@ namespace Artemis.Core.Plugins.Abstract.DataModels.Attributes
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the an optional input prefix to show before input elements in the UI.
|
||||
/// Gets or sets the an optional prefix to show before displaying elements in the UI.
|
||||
/// </summary>
|
||||
public string InputPrefix { get; set; }
|
||||
public string Prefix { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an optional input affix to show behind input elements in the UI.
|
||||
/// Gets or sets an optional affix to show behind displaying elements in the UI.
|
||||
/// </summary>
|
||||
public string InputAffix { get; set; }
|
||||
public string Affix { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an optional maximum input value, only enforced in the UI.
|
||||
/// Gets or sets an optional maximum value, this value is not enforced but used for percentage calculations.
|
||||
/// </summary>
|
||||
public object MaxInputValue { get; set; }
|
||||
public object MaxValue { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the input drag step size, used in the UI.
|
||||
/// Gets or sets an optional minimum value, this value is not enforced but used for percentage calculations.
|
||||
/// </summary>
|
||||
public float InputStepSize { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an optional minimum input value, only enforced in the UI.
|
||||
/// </summary>
|
||||
public object MinInputValue { get; set; }
|
||||
public object MinValue { get; set; }
|
||||
}
|
||||
}
|
||||
@ -57,7 +57,15 @@
|
||||
IsNavigationDrawerOpen="{Binding IsSidebarVisible, Mode=TwoWay}"
|
||||
Title="{Binding ActiveItem.DisplayName}"
|
||||
ShowNavigationDrawerButton="True"
|
||||
DockPanel.Dock="Top" />
|
||||
DockPanel.Dock="Top">
|
||||
<StackPanel>
|
||||
<!-- Bug: materialDesign:RippleAssist.RippleOnTop doesn't look as nice but otherwise it doesn't work at all, not sure why -->
|
||||
<Button Style="{StaticResource MaterialDesignIconForegroundButton}" ToolTip="Open debugger" Command="{s:Action ShowDebugger}"
|
||||
materialDesign:RippleAssist.RippleOnTop="True">
|
||||
<materialDesign:PackIcon Kind="Matrix" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</mde:AppBar>
|
||||
<ContentControl s:View.Model="{Binding ActiveItem}" Style="{StaticResource InitializingFade}" />
|
||||
</DockPanel>
|
||||
</materialDesign:DrawerHost>
|
||||
|
||||
@ -10,6 +10,7 @@ using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.UI.Events;
|
||||
using Artemis.UI.Screens.Settings;
|
||||
using Artemis.UI.Screens.Sidebar;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Artemis.UI.Utilities;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Stylet;
|
||||
@ -20,16 +21,19 @@ namespace Artemis.UI.Screens
|
||||
{
|
||||
private readonly PluginSetting<ApplicationColorScheme> _colorScheme;
|
||||
private readonly ICoreService _coreService;
|
||||
private readonly IDebugService _debugService;
|
||||
private readonly IEventAggregator _eventAggregator;
|
||||
private readonly ThemeWatcher _themeWatcher;
|
||||
private bool _lostFocus;
|
||||
private readonly Timer _titleUpdateTimer;
|
||||
private bool _lostFocus;
|
||||
|
||||
public RootViewModel(IEventAggregator eventAggregator, SidebarViewModel sidebarViewModel, ISettingsService settingsService, ICoreService coreService)
|
||||
public RootViewModel(IEventAggregator eventAggregator, SidebarViewModel sidebarViewModel, ISettingsService settingsService, ICoreService coreService,
|
||||
IDebugService debugService)
|
||||
{
|
||||
SidebarViewModel = sidebarViewModel;
|
||||
_eventAggregator = eventAggregator;
|
||||
_coreService = coreService;
|
||||
_debugService = debugService;
|
||||
|
||||
_titleUpdateTimer = new Timer(500);
|
||||
_titleUpdateTimer.Elapsed += (sender, args) => UpdateWindowTitle();
|
||||
@ -69,6 +73,11 @@ namespace Artemis.UI.Screens
|
||||
_eventAggregator.Publish(new MainWindowFocusChangedEvent(true));
|
||||
}
|
||||
|
||||
public void ShowDebugger()
|
||||
{
|
||||
_debugService.ShowDebugger();
|
||||
}
|
||||
|
||||
public void WindowKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
_eventAggregator.Publish(new MainWindowKeyEvent(true, e));
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
DockPanel.Dock="Top"
|
||||
Margin="-18 0 0 0">
|
||||
<mde:AppBar.AppIcon>
|
||||
<materialDesign:PackIcon Kind="BugReport" Width="20" Height="28" />
|
||||
<materialDesign:PackIcon Kind="Matrix" Width="20" Height="28" />
|
||||
</mde:AppBar.AppIcon>
|
||||
|
||||
<materialDesign:PopupBox DockPanel.Dock="Right" PlacementMode="BottomAndAlignRightEdges" StaysOpen="False">
|
||||
|
||||
@ -10,12 +10,11 @@ using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Core.Services.Storage.Interfaces;
|
||||
using Artemis.Core.Utilities;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Screens.Settings.Debug;
|
||||
using Artemis.UI.Screens.Settings.Tabs.Devices;
|
||||
using Artemis.UI.Screens.Settings.Tabs.Plugins;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using Artemis.UI.Shared.Utilities;
|
||||
using Ninject;
|
||||
using Serilog.Events;
|
||||
using Stylet;
|
||||
|
||||
@ -23,29 +22,24 @@ namespace Artemis.UI.Screens.Settings
|
||||
{
|
||||
public class SettingsViewModel : MainScreenViewModel
|
||||
{
|
||||
private readonly IDebugService _debugService;
|
||||
private readonly IDeviceSettingsVmFactory _deviceSettingsVmFactory;
|
||||
private readonly IDialogService _dialogService;
|
||||
private readonly IKernel _kernel;
|
||||
private readonly IPluginService _pluginService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
private readonly ISurfaceService _surfaceService;
|
||||
private readonly IWindowManager _windowManager;
|
||||
|
||||
public SettingsViewModel(IKernel kernel,
|
||||
ISurfaceService surfaceService,
|
||||
IPluginService pluginService,
|
||||
IDialogService dialogService,
|
||||
IWindowManager windowManager,
|
||||
ISettingsService settingsService,
|
||||
IDeviceSettingsVmFactory deviceSettingsVmFactory)
|
||||
public SettingsViewModel(ISurfaceService surfaceService, IPluginService pluginService, IDialogService dialogService, IWindowManager windowManager,
|
||||
IDebugService debugService, ISettingsService settingsService, IDeviceSettingsVmFactory deviceSettingsVmFactory)
|
||||
{
|
||||
DisplayName = "Settings";
|
||||
|
||||
_kernel = kernel;
|
||||
_surfaceService = surfaceService;
|
||||
_pluginService = pluginService;
|
||||
_dialogService = dialogService;
|
||||
_windowManager = windowManager;
|
||||
_debugService = debugService;
|
||||
_settingsService = settingsService;
|
||||
_deviceSettingsVmFactory = deviceSettingsVmFactory;
|
||||
|
||||
@ -160,7 +154,7 @@ namespace Artemis.UI.Screens.Settings
|
||||
|
||||
public void ShowDebugger()
|
||||
{
|
||||
_windowManager.ShowWindow(_kernel.Get<DebugViewModel>());
|
||||
_debugService.ShowDebugger();
|
||||
}
|
||||
|
||||
public async Task ShowLogsFolder()
|
||||
|
||||
62
src/Artemis.UI/Services/DebugService.cs
Normal file
62
src/Artemis.UI/Services/DebugService.cs
Normal file
@ -0,0 +1,62 @@
|
||||
using System.Windows;
|
||||
using Artemis.UI.Screens.Settings.Debug;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using MaterialDesignExtensions.Controls;
|
||||
using Ninject;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Services
|
||||
{
|
||||
public class DebugService : IDebugService
|
||||
{
|
||||
private readonly IKernel _kernel;
|
||||
private readonly IWindowManager _windowManager;
|
||||
private DebugViewModel _debugViewModel;
|
||||
|
||||
public DebugService(IKernel kernel, IWindowManager windowManager)
|
||||
{
|
||||
_kernel = kernel;
|
||||
_windowManager = windowManager;
|
||||
}
|
||||
|
||||
public void ShowDebugger()
|
||||
{
|
||||
if (_debugViewModel != null)
|
||||
BringDebuggerToForeground();
|
||||
else
|
||||
CreateDebugger();
|
||||
}
|
||||
|
||||
private void CreateDebugger()
|
||||
{
|
||||
_debugViewModel = _kernel.Get<DebugViewModel>();
|
||||
_debugViewModel.Closed += DebugViewModelOnClosed;
|
||||
|
||||
_windowManager.ShowWindow(_debugViewModel);
|
||||
}
|
||||
|
||||
private void DebugViewModelOnClosed(object sender, CloseEventArgs e)
|
||||
{
|
||||
_debugViewModel.Closed -= DebugViewModelOnClosed;
|
||||
_debugViewModel = null;
|
||||
}
|
||||
|
||||
private void BringDebuggerToForeground()
|
||||
{
|
||||
var materialWindow = (MaterialWindow) _debugViewModel.View;
|
||||
|
||||
// Not as straightforward as you might think, this ensures the window always shows, even if it's behind another window etc.
|
||||
// https://stackoverflow.com/a/4831839/5015269
|
||||
if (!materialWindow.IsVisible)
|
||||
materialWindow.Show();
|
||||
|
||||
if (materialWindow.WindowState == WindowState.Minimized)
|
||||
materialWindow.WindowState = WindowState.Normal;
|
||||
|
||||
materialWindow.Activate();
|
||||
materialWindow.Topmost = true; // important
|
||||
materialWindow.Topmost = false; // important
|
||||
materialWindow.Focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
7
src/Artemis.UI/Services/Interfaces/IDebugService.cs
Normal file
7
src/Artemis.UI/Services/Interfaces/IDebugService.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace Artemis.UI.Services.Interfaces
|
||||
{
|
||||
public interface IDebugService : IArtemisUIService
|
||||
{
|
||||
void ShowDebugger();
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user