mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 21:38:38 +00:00
Profile editor - Added back hotkeys for the tools
Profile editor - Fixed hotkeys not always working
This commit is contained in:
parent
f985682e78
commit
543b62a715
@ -1,4 +1,5 @@
|
|||||||
using Artemis.Core.Services;
|
using System;
|
||||||
|
using Artemis.Core.Services;
|
||||||
using Artemis.Storage.Entities.Profile;
|
using Artemis.Storage.Entities.Profile;
|
||||||
|
|
||||||
namespace Artemis.Core;
|
namespace Artemis.Core;
|
||||||
@ -16,6 +17,14 @@ public class Hotkey : CorePropertyChanged, IStorageModel
|
|||||||
Entity = new ProfileConfigurationHotkeyEntity();
|
Entity = new ProfileConfigurationHotkeyEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public Hotkey(KeyboardKey? key, KeyboardModifierKey? modifiers)
|
||||||
|
{
|
||||||
|
Key = key;
|
||||||
|
Modifiers = modifiers;
|
||||||
|
Entity = new ProfileConfigurationHotkeyEntity();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new instance of <see cref="Hotkey" /> based on the provided entity
|
/// Creates a new instance of <see cref="Hotkey" /> based on the provided entity
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -46,7 +55,7 @@ public class Hotkey : CorePropertyChanged, IStorageModel
|
|||||||
/// <returns><see langword="true" /> if the event args match the hotkey; otherwise <see langword="false" /></returns>
|
/// <returns><see langword="true" /> if the event args match the hotkey; otherwise <see langword="false" /></returns>
|
||||||
public bool MatchesEventArgs(ArtemisKeyboardKeyEventArgs eventArgs)
|
public bool MatchesEventArgs(ArtemisKeyboardKeyEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
return eventArgs.Key == Key && eventArgs.Modifiers == Modifiers;
|
return eventArgs.Key == Key && (eventArgs.Modifiers == Modifiers || (eventArgs.Modifiers == KeyboardModifierKey.None && Modifiers == null));
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Implementation of IStorageModel
|
#region Implementation of IStorageModel
|
||||||
|
|||||||
@ -34,4 +34,13 @@ public class ArtemisKeyboardKeyEventArgs : EventArgs
|
|||||||
/// Gets the modifiers that are pressed
|
/// Gets the modifiers that are pressed
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public KeyboardModifierKey Modifiers { get; }
|
public KeyboardModifierKey Modifiers { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a hotkey matching the event.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The resulting hotkey.</returns>
|
||||||
|
public Hotkey ToHotkey()
|
||||||
|
{
|
||||||
|
return new Hotkey {Key = Key, Modifiers = Modifiers};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -11,7 +11,12 @@ public interface IMainWindowService : IArtemisSharedUIService
|
|||||||
/// Gets a boolean indicating whether the main window is currently open
|
/// Gets a boolean indicating whether the main window is currently open
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool IsMainWindowOpen { get; }
|
bool IsMainWindowOpen { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a boolean indicating whether the main window is currently focused
|
||||||
|
/// </summary>
|
||||||
|
bool IsMainWindowFocused { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets up the main window provider that controls the state of the main window
|
/// Sets up the main window provider that controls the state of the main window
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -10,6 +10,9 @@ internal class MainWindowService : IMainWindowService
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public bool IsMainWindowOpen { get; private set; }
|
public bool IsMainWindowOpen { get; private set; }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public bool IsMainWindowFocused { get; private set; }
|
||||||
|
|
||||||
protected virtual void OnMainWindowOpened()
|
protected virtual void OnMainWindowOpened()
|
||||||
{
|
{
|
||||||
MainWindowOpened?.Invoke(this, EventArgs.Empty);
|
MainWindowOpened?.Invoke(this, EventArgs.Empty);
|
||||||
@ -24,11 +27,13 @@ internal class MainWindowService : IMainWindowService
|
|||||||
protected virtual void OnMainWindowFocused()
|
protected virtual void OnMainWindowFocused()
|
||||||
{
|
{
|
||||||
MainWindowFocused?.Invoke(this, EventArgs.Empty);
|
MainWindowFocused?.Invoke(this, EventArgs.Empty);
|
||||||
|
IsMainWindowFocused = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OnMainWindowUnfocused()
|
protected virtual void OnMainWindowUnfocused()
|
||||||
{
|
{
|
||||||
MainWindowUnfocused?.Invoke(this, EventArgs.Empty);
|
MainWindowUnfocused?.Invoke(this, EventArgs.Empty);
|
||||||
|
IsMainWindowFocused = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SyncWithManager()
|
private void SyncWithManager()
|
||||||
|
|||||||
@ -1,4 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using Artemis.Core;
|
||||||
|
using Avalonia.Input;
|
||||||
using Material.Icons;
|
using Material.Icons;
|
||||||
|
|
||||||
namespace Artemis.UI.Shared.Services.ProfileEditor;
|
namespace Artemis.UI.Shared.Services.ProfileEditor;
|
||||||
@ -43,6 +45,11 @@ public interface IToolViewModel : IDisposable
|
|||||||
/// Gets the tooltip which this tool should show in the toolbar.
|
/// Gets the tooltip which this tool should show in the toolbar.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ToolTip { get; }
|
public string ToolTip { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the keyboard hotkey that activates the tool.
|
||||||
|
/// </summary>
|
||||||
|
Hotkey? Hotkey { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc cref="IToolViewModel" />
|
/// <inheritdoc cref="IToolViewModel" />
|
||||||
@ -98,5 +105,8 @@ public abstract class ToolViewModel : ActivatableViewModelBase, IToolViewModel
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public abstract string ToolTip { get; }
|
public abstract string ToolTip { get; }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public abstract Hotkey? Hotkey { get; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@ -22,10 +22,11 @@ public static class UI
|
|||||||
|
|
||||||
static UI()
|
static UI()
|
||||||
{
|
{
|
||||||
KeyBindingsEnabled = InputElement.GotFocusEvent.Raised.Select(e => e.Item2.Source is not TextBox).StartWith(true);
|
CurrentKeyBindingsEnabled = InputElement.GotFocusEvent.Raised.Select(e => e.Item2.Source is not TextBox).StartWith(true);
|
||||||
|
CurrentKeyBindingsEnabled.Subscribe(b => KeyBindingsEnabled = b);
|
||||||
MicaEnabled = MicaEnabledSubject.AsObservable();
|
MicaEnabled = MicaEnabledSubject.AsObservable();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the current IoC locator.
|
/// Gets the current IoC locator.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -36,10 +37,15 @@ public static class UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static IClipboard Clipboard { get; set; } = null!;
|
public static IClipboard Clipboard { get; set; } = null!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets an observable boolean indicating whether hotkeys are to be disabled.
|
||||||
|
/// </summary>
|
||||||
|
public static IObservable<bool> CurrentKeyBindingsEnabled { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a boolean indicating whether hotkeys are to be disabled.
|
/// Gets a boolean indicating whether hotkeys are to be disabled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static IObservable<bool> KeyBindingsEnabled { get; }
|
public static bool KeyBindingsEnabled { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a boolean indicating whether the Mica effect should be enabled.
|
/// Gets a boolean indicating whether the Mica effect should be enabled.
|
||||||
|
|||||||
@ -58,7 +58,7 @@ public class MenuBarViewModel : ActivatableViewModelBase
|
|||||||
_focusNone = profileEditorService.FocusMode.Select(f => f == ProfileEditorFocusMode.None).ToProperty(this, vm => vm.FocusNone).DisposeWith(d);
|
_focusNone = profileEditorService.FocusMode.Select(f => f == ProfileEditorFocusMode.None).ToProperty(this, vm => vm.FocusNone).DisposeWith(d);
|
||||||
_focusFolder = profileEditorService.FocusMode.Select(f => f == ProfileEditorFocusMode.Folder).ToProperty(this, vm => vm.FocusFolder).DisposeWith(d);
|
_focusFolder = profileEditorService.FocusMode.Select(f => f == ProfileEditorFocusMode.Folder).ToProperty(this, vm => vm.FocusFolder).DisposeWith(d);
|
||||||
_focusSelection = profileEditorService.FocusMode.Select(f => f == ProfileEditorFocusMode.Selection).ToProperty(this, vm => vm.FocusSelection).DisposeWith(d);
|
_focusSelection = profileEditorService.FocusMode.Select(f => f == ProfileEditorFocusMode.Selection).ToProperty(this, vm => vm.FocusSelection).DisposeWith(d);
|
||||||
_keyBindingsEnabled = Shared.UI.KeyBindingsEnabled.ToProperty(this, vm => vm.KeyBindingsEnabled).DisposeWith(d);
|
_keyBindingsEnabled = Shared.UI.CurrentKeyBindingsEnabled.ToProperty(this, vm => vm.KeyBindingsEnabled).DisposeWith(d);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddFolder = ReactiveCommand.Create(ExecuteAddFolder);
|
AddFolder = ReactiveCommand.Create(ExecuteAddFolder);
|
||||||
|
|||||||
@ -53,7 +53,7 @@ public class PlaybackViewModel : ActivatableViewModelBase
|
|||||||
_currentTime = _profileEditorService.Time.ToProperty(this, vm => vm.CurrentTime).DisposeWith(d);
|
_currentTime = _profileEditorService.Time.ToProperty(this, vm => vm.CurrentTime).DisposeWith(d);
|
||||||
_formattedCurrentTime = _profileEditorService.Time.Select(t => $"{Math.Floor(t.TotalSeconds):00}.{t.Milliseconds:000}").ToProperty(this, vm => vm.FormattedCurrentTime).DisposeWith(d);
|
_formattedCurrentTime = _profileEditorService.Time.Select(t => $"{Math.Floor(t.TotalSeconds):00}.{t.Milliseconds:000}").ToProperty(this, vm => vm.FormattedCurrentTime).DisposeWith(d);
|
||||||
_playing = _profileEditorService.Playing.ToProperty(this, vm => vm.Playing).DisposeWith(d);
|
_playing = _profileEditorService.Playing.ToProperty(this, vm => vm.Playing).DisposeWith(d);
|
||||||
_keyBindingsEnabled = Shared.UI.KeyBindingsEnabled.ToProperty(this, vm => vm.KeyBindingsEnabled).DisposeWith(d);
|
_keyBindingsEnabled = Shared.UI.CurrentKeyBindingsEnabled.ToProperty(this, vm => vm.KeyBindingsEnabled).DisposeWith(d);
|
||||||
|
|
||||||
// Update timer
|
// Update timer
|
||||||
Timer updateTimer = new(TimeSpan.FromMilliseconds(60.0 / 1000));
|
Timer updateTimer = new(TimeSpan.FromMilliseconds(60.0 / 1000));
|
||||||
|
|||||||
@ -46,7 +46,7 @@ public class ProfileTreeViewModel : TreeItemViewModel
|
|||||||
_focusNone = profileEditorService.FocusMode.Select(f => f == ProfileEditorFocusMode.None).ToProperty(this, vm => vm.FocusNone).DisposeWith(d);
|
_focusNone = profileEditorService.FocusMode.Select(f => f == ProfileEditorFocusMode.None).ToProperty(this, vm => vm.FocusNone).DisposeWith(d);
|
||||||
_focusFolder = profileEditorService.FocusMode.Select(f => f == ProfileEditorFocusMode.Folder).ToProperty(this, vm => vm.FocusFolder).DisposeWith(d);
|
_focusFolder = profileEditorService.FocusMode.Select(f => f == ProfileEditorFocusMode.Folder).ToProperty(this, vm => vm.FocusFolder).DisposeWith(d);
|
||||||
_focusSelection = profileEditorService.FocusMode.Select(f => f == ProfileEditorFocusMode.Selection).ToProperty(this, vm => vm.FocusSelection).DisposeWith(d);
|
_focusSelection = profileEditorService.FocusMode.Select(f => f == ProfileEditorFocusMode.Selection).ToProperty(this, vm => vm.FocusSelection).DisposeWith(d);
|
||||||
_keyBindingsEnabled = Shared.UI.KeyBindingsEnabled.ToProperty(this, vm => vm.KeyBindingsEnabled).DisposeWith(d);
|
_keyBindingsEnabled = Shared.UI.CurrentKeyBindingsEnabled.ToProperty(this, vm => vm.KeyBindingsEnabled).DisposeWith(d);
|
||||||
});
|
});
|
||||||
|
|
||||||
ClearSelection = ReactiveCommand.Create(() => profileEditorService.ChangeCurrentProfileElement(null), this.WhenAnyValue(vm => vm.KeyBindingsEnabled));
|
ClearSelection = ReactiveCommand.Create(() => profileEditorService.ChangeCurrentProfileElement(null), this.WhenAnyValue(vm => vm.KeyBindingsEnabled));
|
||||||
|
|||||||
@ -7,6 +7,7 @@ using Artemis.Core;
|
|||||||
using Artemis.Core.Services;
|
using Artemis.Core.Services;
|
||||||
using Artemis.UI.Shared.Services.ProfileEditor;
|
using Artemis.UI.Shared.Services.ProfileEditor;
|
||||||
using Artemis.UI.Shared.Services.ProfileEditor.Commands;
|
using Artemis.UI.Shared.Services.ProfileEditor.Commands;
|
||||||
|
using Avalonia.Input;
|
||||||
using Material.Icons;
|
using Material.Icons;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using SkiaSharp;
|
using SkiaSharp;
|
||||||
@ -45,9 +46,12 @@ public class SelectionAddToolViewModel : ToolViewModel
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override MaterialIconKind Icon => MaterialIconKind.SelectionDrag;
|
public override MaterialIconKind Icon => MaterialIconKind.SelectionDrag;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override Hotkey? Hotkey { get; } = new(KeyboardKey.OemPlus, KeyboardModifierKey.Control);
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string ToolTip => "Add LEDs to the current layer";
|
public override string ToolTip => "Add LEDs to the current layer (Ctrl + +)";
|
||||||
|
|
||||||
public void AddLedsInRectangle(SKRect rect, bool expand, bool inverse)
|
public void AddLedsInRectangle(SKRect rect, bool expand, bool inverse)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -4,8 +4,10 @@ using System.Linq;
|
|||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using Artemis.Core;
|
using Artemis.Core;
|
||||||
|
using Artemis.Core.Services;
|
||||||
using Artemis.UI.Shared.Services.ProfileEditor;
|
using Artemis.UI.Shared.Services.ProfileEditor;
|
||||||
using Artemis.UI.Shared.Services.ProfileEditor.Commands;
|
using Artemis.UI.Shared.Services.ProfileEditor.Commands;
|
||||||
|
using Avalonia.Input;
|
||||||
using Material.Icons;
|
using Material.Icons;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using SkiaSharp;
|
using SkiaSharp;
|
||||||
@ -38,12 +40,15 @@ public class SelectionRemoveToolViewModel : ToolViewModel
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override int Order => 3;
|
public override int Order => 3;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override Hotkey? Hotkey { get; } = new(KeyboardKey.OemMinus, KeyboardModifierKey.Control);
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override MaterialIconKind Icon => MaterialIconKind.SelectOff;
|
public override MaterialIconKind Icon => MaterialIconKind.SelectOff;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string ToolTip => "Remove LEDs from the current layer";
|
public override string ToolTip => "Remove LEDs from the current layer (Ctrl + -)";
|
||||||
|
|
||||||
public void RemoveLedsInRectangle(SKRect rect)
|
public void RemoveLedsInRectangle(SKRect rect)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -3,11 +3,13 @@ using System.Reactive;
|
|||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using Artemis.Core;
|
using Artemis.Core;
|
||||||
|
using Artemis.Core.Services;
|
||||||
using Artemis.UI.Exceptions;
|
using Artemis.UI.Exceptions;
|
||||||
using Artemis.UI.Shared.Extensions;
|
using Artemis.UI.Shared.Extensions;
|
||||||
using Artemis.UI.Shared.Services.ProfileEditor;
|
using Artemis.UI.Shared.Services.ProfileEditor;
|
||||||
using Artemis.UI.Shared.Services.ProfileEditor.Commands;
|
using Artemis.UI.Shared.Services.ProfileEditor.Commands;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
|
using Avalonia.Input;
|
||||||
using Material.Icons;
|
using Material.Icons;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using SkiaSharp;
|
using SkiaSharp;
|
||||||
@ -95,12 +97,15 @@ public class TransformToolViewModel : ToolViewModel
|
|||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override int Order => 3;
|
public override int Order => 3;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public override Hotkey? Hotkey { get; } = new(KeyboardKey.T, KeyboardModifierKey.Control);
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override MaterialIconKind Icon => MaterialIconKind.TransitConnectionVariant;
|
public override MaterialIconKind Icon => MaterialIconKind.TransitConnectionVariant;
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override string ToolTip => "Transform the shape of the current layer";
|
public override string ToolTip => "Transform the shape of the current layer (Ctrl+T)";
|
||||||
|
|
||||||
public Rect ShapeBounds
|
public Rect ShapeBounds
|
||||||
{
|
{
|
||||||
|
|||||||
@ -8,19 +8,11 @@
|
|||||||
xmlns:shared="clr-namespace:Artemis.UI.Shared.Services.ProfileEditor;assembly=Artemis.UI.Shared"
|
xmlns:shared="clr-namespace:Artemis.UI.Shared.Services.ProfileEditor;assembly=Artemis.UI.Shared"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
x:Class="Artemis.UI.Screens.ProfileEditor.ProfileEditorView"
|
x:Class="Artemis.UI.Screens.ProfileEditor.ProfileEditorView"
|
||||||
x:DataType="profileEditor:ProfileEditorViewModel">
|
x:DataType="profileEditor:ProfileEditorViewModel"
|
||||||
|
Focusable="True">
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<converters:DoubleToGridLengthConverter x:Key="DoubleToGridLengthConverter" />
|
<converters:DoubleToGridLengthConverter x:Key="DoubleToGridLengthConverter" />
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
<UserControl.KeyBindings>
|
|
||||||
<KeyBinding Command="{CompiledBinding History.Undo}" Gesture="Ctrl+Z" />
|
|
||||||
<KeyBinding Command="{CompiledBinding History.Redo}" Gesture="Ctrl+Y" />
|
|
||||||
<KeyBinding Command="{CompiledBinding ToggleSuspend}" Gesture="F5" />
|
|
||||||
<KeyBinding Command="{CompiledBinding ToggleAutoSuspend}" Gesture="Shift+F5" />
|
|
||||||
<KeyBinding Command="{CompiledBinding PropertiesViewModel.PlaybackViewModel.TogglePlay}" Gesture="Space" />
|
|
||||||
<KeyBinding Command="{CompiledBinding PropertiesViewModel.PlaybackViewModel.PlayFromStart}" Gesture="Shift+Space" />
|
|
||||||
<KeyBinding Command="{Binding TitleBarViewModel.MenuBarViewModel.CycleFocusMode}" Gesture="F" />
|
|
||||||
</UserControl.KeyBindings>
|
|
||||||
<UserControl.Styles>
|
<UserControl.Styles>
|
||||||
<Style Selector="Border.suspended-editing">
|
<Style Selector="Border.suspended-editing">
|
||||||
<Setter Property="Margin" Value="-10" />
|
<Setter Property="Margin" Value="-10" />
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
using Avalonia;
|
|
||||||
using Avalonia.Markup.Xaml;
|
|
||||||
using Avalonia.ReactiveUI;
|
using Avalonia.ReactiveUI;
|
||||||
|
|
||||||
namespace Artemis.UI.Screens.ProfileEditor;
|
namespace Artemis.UI.Screens.ProfileEditor;
|
||||||
@ -10,16 +8,4 @@ public partial class ProfileEditorView : ReactiveUserControl<ProfileEditorViewMo
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Overrides of Visual
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
|
|
||||||
{
|
|
||||||
base.OnAttachedToVisualTree(e);
|
|
||||||
Focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -28,6 +28,7 @@ public class ProfileEditorViewModel : RoutableScreen<ProfileEditorViewModelParam
|
|||||||
private readonly IProfileEditorService _profileEditorService;
|
private readonly IProfileEditorService _profileEditorService;
|
||||||
private readonly IProfileService _profileService;
|
private readonly IProfileService _profileService;
|
||||||
private readonly ISettingsService _settingsService;
|
private readonly ISettingsService _settingsService;
|
||||||
|
private readonly IMainWindowService _mainWindowService;
|
||||||
private readonly SourceList<IToolViewModel> _tools;
|
private readonly SourceList<IToolViewModel> _tools;
|
||||||
private ObservableAsPropertyHelper<ProfileEditorHistory?>? _history;
|
private ObservableAsPropertyHelper<ProfileEditorHistory?>? _history;
|
||||||
private ProfileConfiguration? _profileConfiguration;
|
private ProfileConfiguration? _profileConfiguration;
|
||||||
@ -44,11 +45,13 @@ public class ProfileEditorViewModel : RoutableScreen<ProfileEditorViewModelParam
|
|||||||
DisplayConditionScriptViewModel displayConditionScriptViewModel,
|
DisplayConditionScriptViewModel displayConditionScriptViewModel,
|
||||||
StatusBarViewModel statusBarViewModel,
|
StatusBarViewModel statusBarViewModel,
|
||||||
IEnumerable<IToolViewModel> toolViewModels,
|
IEnumerable<IToolViewModel> toolViewModels,
|
||||||
IMainWindowService mainWindowService)
|
IMainWindowService mainWindowService,
|
||||||
|
IInputService inputService)
|
||||||
{
|
{
|
||||||
_profileService = profileService;
|
_profileService = profileService;
|
||||||
_profileEditorService = profileEditorService;
|
_profileEditorService = profileEditorService;
|
||||||
_settingsService = settingsService;
|
_settingsService = settingsService;
|
||||||
|
_mainWindowService = mainWindowService;
|
||||||
|
|
||||||
_tools = new SourceList<IToolViewModel>();
|
_tools = new SourceList<IToolViewModel>();
|
||||||
_tools.AddRange(toolViewModels);
|
_tools.AddRange(toolViewModels);
|
||||||
@ -72,11 +75,13 @@ public class ProfileEditorViewModel : RoutableScreen<ProfileEditorViewModelParam
|
|||||||
_history = profileEditorService.History.ToProperty(this, vm => vm.History).DisposeWith(d);
|
_history = profileEditorService.History.ToProperty(this, vm => vm.History).DisposeWith(d);
|
||||||
_suspendedEditing = profileEditorService.SuspendedEditing.ToProperty(this, vm => vm.SuspendedEditing).DisposeWith(d);
|
_suspendedEditing = profileEditorService.SuspendedEditing.ToProperty(this, vm => vm.SuspendedEditing).DisposeWith(d);
|
||||||
|
|
||||||
|
inputService.KeyboardKeyDown += InputServiceOnKeyboardKeyDown;
|
||||||
mainWindowService.MainWindowFocused += MainWindowServiceOnMainWindowFocused;
|
mainWindowService.MainWindowFocused += MainWindowServiceOnMainWindowFocused;
|
||||||
mainWindowService.MainWindowUnfocused += MainWindowServiceOnMainWindowUnfocused;
|
mainWindowService.MainWindowUnfocused += MainWindowServiceOnMainWindowUnfocused;
|
||||||
|
|
||||||
Disposable.Create(() =>
|
Disposable.Create(() =>
|
||||||
{
|
{
|
||||||
|
inputService.KeyboardKeyDown -= InputServiceOnKeyboardKeyDown;
|
||||||
mainWindowService.MainWindowFocused -= MainWindowServiceOnMainWindowFocused;
|
mainWindowService.MainWindowFocused -= MainWindowServiceOnMainWindowFocused;
|
||||||
mainWindowService.MainWindowUnfocused -= MainWindowServiceOnMainWindowUnfocused;
|
mainWindowService.MainWindowUnfocused -= MainWindowServiceOnMainWindowUnfocused;
|
||||||
foreach (IToolViewModel toolViewModel in _tools.Items)
|
foreach (IToolViewModel toolViewModel in _tools.Items)
|
||||||
@ -139,6 +144,33 @@ public class ProfileEditorViewModel : RoutableScreen<ProfileEditorViewModelParam
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void InputServiceOnKeyboardKeyDown(object? sender, ArtemisKeyboardKeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (!Shared.UI.KeyBindingsEnabled || !_mainWindowService.IsMainWindowFocused)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (e.Modifiers == KeyboardModifierKey.Control && e.Key == KeyboardKey.Z)
|
||||||
|
History?.Undo.Execute().Subscribe();
|
||||||
|
else if (e.Modifiers == KeyboardModifierKey.Control && e.Key == KeyboardKey.Y)
|
||||||
|
History?.Redo.Execute().Subscribe();
|
||||||
|
else if (e.Modifiers == KeyboardModifierKey.None && e.Key == KeyboardKey.F5)
|
||||||
|
ToggleSuspend.Execute().Subscribe();
|
||||||
|
else if (e.Modifiers == KeyboardModifierKey.Shift && e.Key == KeyboardKey.F5)
|
||||||
|
ToggleAutoSuspend.Execute().Subscribe();
|
||||||
|
else if (e.Modifiers == KeyboardModifierKey.None && e.Key == KeyboardKey.Space)
|
||||||
|
PropertiesViewModel?.PlaybackViewModel.TogglePlay.Execute().Subscribe();
|
||||||
|
else if (e.Modifiers == KeyboardModifierKey.Shift && e.Key == KeyboardKey.Space)
|
||||||
|
PropertiesViewModel?.PlaybackViewModel.PlayFromStart.Execute().Subscribe();
|
||||||
|
else if (e.Modifiers == KeyboardModifierKey.None && e.Key == KeyboardKey.F)
|
||||||
|
(TitleBarViewModel as ProfileEditorTitleBarViewModel)?.MenuBarViewModel.CycleFocusMode.Execute().Subscribe();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IToolViewModel? tool = Tools.FirstOrDefault(t => t.Hotkey != null && t.Hotkey.MatchesEventArgs(e));
|
||||||
|
if (tool != null)
|
||||||
|
tool.IsSelected = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void MainWindowServiceOnMainWindowFocused(object? sender, EventArgs e)
|
private void MainWindowServiceOnMainWindowFocused(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_settingsService.GetSetting("ProfileEditor.AutoSuspend", true).Value)
|
if (_settingsService.GetSetting("ProfileEditor.AutoSuspend", true).Value)
|
||||||
|
|||||||
@ -64,7 +64,7 @@ public class NodeScriptWindowViewModel : NodeScriptWindowViewModelBase
|
|||||||
|
|
||||||
this.WhenActivated(d =>
|
this.WhenActivated(d =>
|
||||||
{
|
{
|
||||||
_keyBindingsEnabled = Shared.UI.KeyBindingsEnabled.ToProperty(this, vm => vm.KeyBindingsEnabled).DisposeWith(d);
|
_keyBindingsEnabled = Shared.UI.CurrentKeyBindingsEnabled.ToProperty(this, vm => vm.KeyBindingsEnabled).DisposeWith(d);
|
||||||
|
|
||||||
Timer updateTimer = new(TimeSpan.FromMilliseconds(25.0 / 1000));
|
Timer updateTimer = new(TimeSpan.FromMilliseconds(25.0 / 1000));
|
||||||
Timer saveTimer = new(TimeSpan.FromMinutes(2));
|
Timer saveTimer = new(TimeSpan.FromMinutes(2));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user