From 7d6fa17d34bd9b7a609c40e8ff7ca6ba2d28855b Mon Sep 17 00:00:00 2001 From: Robert Date: Thu, 28 Nov 2019 19:39:09 +0100 Subject: [PATCH] Started implementing EventAggregator --- src/Artemis.UI/Artemis.UI.csproj | 1 + .../Events/MainWindowFocusChangedEvent.cs | 14 +++++++++ src/Artemis.UI/Ninject/UiModule.cs | 2 +- .../Visualization/ProfileViewModel.cs | 10 +++++-- src/Artemis.UI/Screens/RootView.xaml | 12 ++++---- src/Artemis.UI/Screens/RootViewModel.cs | 29 ++++++++++++++++++- 6 files changed, 59 insertions(+), 9 deletions(-) create mode 100644 src/Artemis.UI/Events/MainWindowFocusChangedEvent.cs diff --git a/src/Artemis.UI/Artemis.UI.csproj b/src/Artemis.UI/Artemis.UI.csproj index e47df1dd8..d53c206a2 100644 --- a/src/Artemis.UI/Artemis.UI.csproj +++ b/src/Artemis.UI/Artemis.UI.csproj @@ -152,6 +152,7 @@ + diff --git a/src/Artemis.UI/Events/MainWindowFocusChangedEvent.cs b/src/Artemis.UI/Events/MainWindowFocusChangedEvent.cs new file mode 100644 index 000000000..690989da7 --- /dev/null +++ b/src/Artemis.UI/Events/MainWindowFocusChangedEvent.cs @@ -0,0 +1,14 @@ +using System; + +namespace Artemis.UI.Events +{ + public class MainWindowFocusChangedEvent : EventArgs + { + public MainWindowFocusChangedEvent(bool isFocused) + { + IsFocused = isFocused; + } + + public bool IsFocused { get; } + } +} \ No newline at end of file diff --git a/src/Artemis.UI/Ninject/UiModule.cs b/src/Artemis.UI/Ninject/UiModule.cs index df8ac1b34..ad577220c 100644 --- a/src/Artemis.UI/Ninject/UiModule.cs +++ b/src/Artemis.UI/Ninject/UiModule.cs @@ -20,7 +20,7 @@ namespace Artemis.UI.Ninject { if (Kernel == null) throw new ArgumentNullException("Kernel shouldn't be null here."); - + // Bind all built-in VMs Kernel.Bind(x => { diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileViewModel.cs index 4625f8c9c..9e24c1861 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileViewModel.cs @@ -9,6 +9,7 @@ using Artemis.Core.Models.Surface; using Artemis.Core.Plugins.Models; using Artemis.Core.Services; using Artemis.Core.Services.Storage.Interfaces; +using Artemis.UI.Events; using Artemis.UI.Extensions; using Artemis.UI.Screens.Shared; using Artemis.UI.Screens.SurfaceEditor; @@ -19,12 +20,12 @@ using Point = System.Windows.Point; namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization { - public class ProfileViewModel : ProfileEditorPanelViewModel + public class ProfileViewModel : ProfileEditorPanelViewModel, IHandle { private readonly ISettingsService _settingsService; private readonly TimerUpdateTrigger _updateTrigger; - public ProfileViewModel(ISurfaceService surfaceService, ISettingsService settingsService) + public ProfileViewModel(ISurfaceService surfaceService, ISettingsService settingsService, IEventAggregator eventAggregator) { _settingsService = settingsService; Devices = new ObservableCollection(); @@ -248,5 +249,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization } #endregion + + public void Handle(MainWindowFocusChangedEvent message) + { + Console.WriteLine(message); + } } } \ No newline at end of file diff --git a/src/Artemis.UI/Screens/RootView.xaml b/src/Artemis.UI/Screens/RootView.xaml index 024049d67..bc2b0ca91 100644 --- a/src/Artemis.UI/Screens/RootView.xaml +++ b/src/Artemis.UI/Screens/RootView.xaml @@ -9,15 +9,17 @@ xmlns:abstract="clr-namespace:Artemis.Core.Plugins.Abstract;assembly=Artemis.Core" xmlns:screens="clr-namespace:Artemis.UI.Screens" mc:Ignorable="d" + Icon="/Artemis.UI;component/Resources/logo-512.png" + Title="Artemis" GlowBrush="{DynamicResource AccentColorBrush}" FontFamily="{StaticResource DefaultFont}" - Title="Artemis" + SaveWindowPosition="True" + UseLayoutRounding="True" + Deactivated="{s:Action WindowDeactivated}" + Activated="{s:Action WindowActivated}" d:DesignHeight="640" d:DesignWidth="1200" - d:DataContext="{d:DesignInstance screens:RootViewModel}" - SaveWindowPosition="True" - Icon="/Artemis.UI;component/Resources/logo-512.png" - UseLayoutRounding="True"> + d:DataContext="{d:DesignInstance screens:RootViewModel}">