diff --git a/src/Artemis.Core/Services/Input/InputProvider.cs b/src/Artemis.Core/Services/Input/InputProvider.cs index b10db3d6f..5565fc0ec 100644 --- a/src/Artemis.Core/Services/Input/InputProvider.cs +++ b/src/Artemis.Core/Services/Input/InputProvider.cs @@ -95,6 +95,7 @@ namespace Artemis.Core.Services MouseMoveDataReceived?.Invoke(this, new InputProviderMouseMoveEventArgs(device, cursorX, cursorY, deltaX, deltaY)); } + // TODO: Remove this as the core should handle this in GetDeviceByIdentifier /// /// Invokes the event which the listens to as long as /// this provider is registered diff --git a/src/Artemis.Core/Services/Input/InputService.cs b/src/Artemis.Core/Services/Input/InputService.cs index 510b095f7..f47ac5d78 100644 --- a/src/Artemis.Core/Services/Input/InputService.cs +++ b/src/Artemis.Core/Services/Input/InputService.cs @@ -98,6 +98,7 @@ namespace Artemis.Core.Services BustIdentifierCache(); } + // TODO: Move the OnIdentifierReceived logic into here and get rid of OnIdentifierReceived, this and OnIdentifierReceived are always called in combination with each other public ArtemisDevice? GetDeviceByIdentifier(InputProvider provider, object identifier, InputDeviceType type) { if (provider == null) throw new ArgumentNullException(nameof(provider)); diff --git a/src/Avalonia/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs b/src/Avalonia/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs index a78ff19d5..1607738f0 100644 --- a/src/Avalonia/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs +++ b/src/Avalonia/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs @@ -4,6 +4,7 @@ using Artemis.Core; using Artemis.Core.Services; using Avalonia; using Avalonia.Controls; +using Avalonia.Data; using Avalonia.Input; using Avalonia.Interactivity; using Avalonia.Markup.Xaml; @@ -91,7 +92,7 @@ namespace Artemis.UI.Shared.Controls /// to an SVG /// public static readonly StyledProperty HotkeyProperty = - AvaloniaProperty.Register(nameof(Hotkey), notifying: HotkeyChanging); + AvaloniaProperty.Register(nameof(Hotkey), defaultBindingMode: BindingMode.TwoWay, notifying: HotkeyChanging); public static readonly StyledProperty WatermarkProperty = AvaloniaProperty.Register(nameof(Watermark)); diff --git a/src/Avalonia/Artemis.UI.Windows/App.axaml.cs b/src/Avalonia/Artemis.UI.Windows/App.axaml.cs index e37a0763f..6d5b42adc 100644 --- a/src/Avalonia/Artemis.UI.Windows/App.axaml.cs +++ b/src/Avalonia/Artemis.UI.Windows/App.axaml.cs @@ -1,5 +1,4 @@ using Artemis.Core.Services; -using Artemis.UI.Windows.Providers; using Artemis.UI.Windows.Providers.Input; using Avalonia; using Avalonia.Controls.ApplicationLifetimes; @@ -17,15 +16,17 @@ namespace Artemis.UI.Windows _kernel = ArtemisBootstrapper.Bootstrap(this); RxApp.MainThreadScheduler = AvaloniaScheduler.Instance; AvaloniaXamlLoader.Load(this); - - RegisterProviders(_kernel); } public override void OnFrameworkInitializationCompleted() { ArtemisBootstrapper.Initialize(); + if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) + { _applicationStateManager = new ApplicationStateManager(_kernel!, desktop.Args); + RegisterProviders(_kernel!); + } } private void RegisterProviders(StandardKernel standardKernel) diff --git a/src/Avalonia/Artemis.UI.Windows/Providers/Input/WindowsInputProvider.cs b/src/Avalonia/Artemis.UI.Windows/Providers/Input/WindowsInputProvider.cs index 4aca8e831..ef4f81bd9 100644 --- a/src/Avalonia/Artemis.UI.Windows/Providers/Input/WindowsInputProvider.cs +++ b/src/Avalonia/Artemis.UI.Windows/Providers/Input/WindowsInputProvider.cs @@ -185,7 +185,7 @@ namespace Artemis.UI.Windows.Providers.Input if (identifier != null) try { - device = _inputService.GetDeviceByIdentifier(this, identifier, InputDeviceType.Keyboard); + device = _inputService.GetDeviceByIdentifier(this, identifier, InputDeviceType.Mouse); } catch (Exception e) { diff --git a/src/Avalonia/Artemis.UI/Artemis.UI.csproj b/src/Avalonia/Artemis.UI/Artemis.UI.csproj index 39ccd647e..c8d210bf0 100644 --- a/src/Avalonia/Artemis.UI/Artemis.UI.csproj +++ b/src/Avalonia/Artemis.UI/Artemis.UI.csproj @@ -51,10 +51,10 @@ DebugSettingsView.axaml - + SidebarCategoryEditView.axaml - + ProfileConfigurationEditView.axaml diff --git a/src/Avalonia/Artemis.UI/Ninject/Factories/IVMFactory.cs b/src/Avalonia/Artemis.UI/Ninject/Factories/IVMFactory.cs index 2248b2bdc..64b6a1704 100644 --- a/src/Avalonia/Artemis.UI/Ninject/Factories/IVMFactory.cs +++ b/src/Avalonia/Artemis.UI/Ninject/Factories/IVMFactory.cs @@ -3,9 +3,11 @@ using Artemis.Core; using Artemis.UI.Screens.Device; using Artemis.UI.Screens.Device.Tabs; using Artemis.UI.Screens.Plugins; -using Artemis.UI.Screens.Root.Sidebar; +using Artemis.UI.Screens.ProfileEditor; using Artemis.UI.Screens.Settings.Tabs; +using Artemis.UI.Screens.Sidebar; using Artemis.UI.Screens.SurfaceEditor; +using Artemis.UI.Services; using ReactiveUI; namespace Artemis.UI.Ninject.Factories @@ -49,4 +51,9 @@ namespace Artemis.UI.Ninject.Factories { PluginPrerequisiteViewModel PluginPrerequisiteViewModel(PluginPrerequisite pluginPrerequisite, bool uninstall); } + + public interface IProfileEditorVmFactory : IVmFactory + { + ProfileEditorViewModel ProfileEditorViewModel(IScreen hostScreen); + } } \ No newline at end of file diff --git a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorView.axaml b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorView.axaml index 5770a7a23..f29ad78f3 100644 --- a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorView.axaml +++ b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorView.axaml @@ -4,5 +4,10 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="Artemis.UI.Screens.ProfileEditor.ProfileEditorView"> - Welcome to Avalonia! + + + + + + diff --git a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorViewModel.cs b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorViewModel.cs index 146bd4ed0..02c8b6734 100644 --- a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorViewModel.cs +++ b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/ProfileEditorViewModel.cs @@ -1,8 +1,28 @@ -using Artemis.UI.Shared; +using System; +using System.Reactive.Disposables; +using Artemis.Core; +using Artemis.UI.Services; +using ReactiveUI; namespace Artemis.UI.Screens.ProfileEditor { - public class ProfileEditorViewModel : ActivatableViewModelBase + public class ProfileEditorViewModel : MainScreenViewModel { + private ProfileConfiguration? _profile; + + /// + public ProfileEditorViewModel(IScreen hostScreen, IProfileEditorService profileEditorService) : base(hostScreen, "profile-editor") + { + this.WhenActivated(disposables => + { + profileEditorService.CurrentProfileConfiguration.WhereNotNull().Subscribe(p => Profile = p).DisposeWith(disposables); + }); + } + + public ProfileConfiguration? Profile + { + get => _profile; + set => this.RaiseAndSetIfChanged(ref _profile, value); + } } } \ No newline at end of file diff --git a/src/Avalonia/Artemis.UI/Screens/Root/RootViewModel.cs b/src/Avalonia/Artemis.UI/Screens/Root/RootViewModel.cs index 68c7cd9be..1301bb454 100644 --- a/src/Avalonia/Artemis.UI/Screens/Root/RootViewModel.cs +++ b/src/Avalonia/Artemis.UI/Screens/Root/RootViewModel.cs @@ -4,7 +4,7 @@ using System.Threading.Tasks; using Artemis.Core; using Artemis.Core.Services; using Artemis.UI.Ninject.Factories; -using Artemis.UI.Screens.Root.Sidebar; +using Artemis.UI.Screens.Sidebar; using Artemis.UI.Services.Interfaces; using Artemis.UI.Shared; using Artemis.UI.Shared.Services.Interfaces; diff --git a/src/Avalonia/Artemis.UI/Screens/Root/Sidebar/ContentDialogs/SidebarCategoryEditView.axaml b/src/Avalonia/Artemis.UI/Screens/Sidebar/ContentDialogs/SidebarCategoryEditView.axaml similarity index 87% rename from src/Avalonia/Artemis.UI/Screens/Root/Sidebar/ContentDialogs/SidebarCategoryEditView.axaml rename to src/Avalonia/Artemis.UI/Screens/Sidebar/ContentDialogs/SidebarCategoryEditView.axaml index 2553bf0cf..e75f36ba3 100644 --- a/src/Avalonia/Artemis.UI/Screens/Root/Sidebar/ContentDialogs/SidebarCategoryEditView.axaml +++ b/src/Avalonia/Artemis.UI/Screens/Sidebar/ContentDialogs/SidebarCategoryEditView.axaml @@ -3,7 +3,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" - x:Class="Artemis.UI.Screens.Root.Sidebar.Dialogs.SidebarCategoryEditView"> + x:Class="Artemis.UI.Screens.Sidebar.ContentDialogs.SidebarCategoryEditView"> diff --git a/src/Avalonia/Artemis.UI/Screens/Root/Sidebar/ContentDialogs/SidebarCategoryEditView.axaml.cs b/src/Avalonia/Artemis.UI/Screens/Sidebar/ContentDialogs/SidebarCategoryEditView.axaml.cs similarity index 90% rename from src/Avalonia/Artemis.UI/Screens/Root/Sidebar/ContentDialogs/SidebarCategoryEditView.axaml.cs rename to src/Avalonia/Artemis.UI/Screens/Sidebar/ContentDialogs/SidebarCategoryEditView.axaml.cs index 5ebe8080d..4b5d1814e 100644 --- a/src/Avalonia/Artemis.UI/Screens/Root/Sidebar/ContentDialogs/SidebarCategoryEditView.axaml.cs +++ b/src/Avalonia/Artemis.UI/Screens/Sidebar/ContentDialogs/SidebarCategoryEditView.axaml.cs @@ -3,7 +3,7 @@ using Avalonia.Markup.Xaml; using Avalonia.ReactiveUI; using ReactiveUI; -namespace Artemis.UI.Screens.Root.Sidebar.Dialogs +namespace Artemis.UI.Screens.Sidebar.ContentDialogs { public class SidebarCategoryEditView : ReactiveUserControl { diff --git a/src/Avalonia/Artemis.UI/Screens/Root/Sidebar/ContentDialogs/SidebarCategoryEditViewModel.cs b/src/Avalonia/Artemis.UI/Screens/Sidebar/ContentDialogs/SidebarCategoryEditViewModel.cs similarity index 97% rename from src/Avalonia/Artemis.UI/Screens/Root/Sidebar/ContentDialogs/SidebarCategoryEditViewModel.cs rename to src/Avalonia/Artemis.UI/Screens/Sidebar/ContentDialogs/SidebarCategoryEditViewModel.cs index 428fdc46f..009eb2c34 100644 --- a/src/Avalonia/Artemis.UI/Screens/Root/Sidebar/ContentDialogs/SidebarCategoryEditViewModel.cs +++ b/src/Avalonia/Artemis.UI/Screens/Sidebar/ContentDialogs/SidebarCategoryEditViewModel.cs @@ -6,7 +6,7 @@ using FluentAvalonia.UI.Controls; using ReactiveUI; using ReactiveUI.Validation.Extensions; -namespace Artemis.UI.Screens.Root.Sidebar.Dialogs +namespace Artemis.UI.Screens.Sidebar.ContentDialogs { public class SidebarCategoryEditViewModel : ContentDialogViewModelBase { diff --git a/src/Avalonia/Artemis.UI/Screens/Root/Sidebar/Dialogs/ProfileConfigurationEditView.axaml b/src/Avalonia/Artemis.UI/Screens/Sidebar/Dialogs/ProfileConfigurationEditView.axaml similarity index 71% rename from src/Avalonia/Artemis.UI/Screens/Root/Sidebar/Dialogs/ProfileConfigurationEditView.axaml rename to src/Avalonia/Artemis.UI/Screens/Sidebar/Dialogs/ProfileConfigurationEditView.axaml index ce58d9c59..b4733a770 100644 --- a/src/Avalonia/Artemis.UI/Screens/Root/Sidebar/Dialogs/ProfileConfigurationEditView.axaml +++ b/src/Avalonia/Artemis.UI/Screens/Sidebar/Dialogs/ProfileConfigurationEditView.axaml @@ -4,15 +4,16 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:core="clr-namespace:Artemis.Core;assembly=Artemis.Core" xmlns:controls="clr-namespace:Artemis.UI.Shared.Controls;assembly=Artemis.UI.Shared" - xmlns:local="clr-namespace:Artemis.UI.Screens.Root.Sidebar.Dialogs" xmlns:converters="clr-namespace:Artemis.UI.Shared.Converters;assembly=Artemis.UI.Shared" xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" xmlns:svg="clr-namespace:Avalonia.Svg.Skia;assembly=Avalonia.Svg.Skia" + xmlns:local="clr-namespace:Artemis.UI.Screens.Sidebar.Dialogs" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="850" - x:Class="Artemis.UI.Screens.Root.Sidebar.Dialogs.ProfileConfigurationEditView" + x:Class="Artemis.UI.Screens.Sidebar.Dialogs.ProfileConfigurationEditView" Title="{Binding DisplayName}" Icon="/Assets/Images/Logo/bow.ico" Width="800" + MinWidth="420" Height="850"> @@ -24,6 +25,14 @@ + + @@ -31,12 +40,10 @@ - General - Profile name - + Module @@ -71,7 +78,7 @@ Icon - +