diff --git a/Artemis/Artemis/ArtemisBootstrapper.cs b/Artemis/Artemis/ArtemisBootstrapper.cs index 9623a74d6..23efdc1bf 100644 --- a/Artemis/Artemis/ArtemisBootstrapper.cs +++ b/Artemis/Artemis/ArtemisBootstrapper.cs @@ -116,7 +116,7 @@ namespace Artemis protected override void OnStartup(object sender, StartupEventArgs e) { - DisplayRootViewFor(); + DisplayRootViewFor(); } } } \ No newline at end of file diff --git a/Artemis/Artemis/InjectionModules/BaseModules.cs b/Artemis/Artemis/InjectionModules/BaseModules.cs index 4aa9b6494..cbe1f7980 100644 --- a/Artemis/Artemis/InjectionModules/BaseModules.cs +++ b/Artemis/Artemis/InjectionModules/BaseModules.cs @@ -14,7 +14,8 @@ namespace Artemis.InjectionModules public override void Load() { // ViewModels - Bind().ToSelf(); + Bind().ToSelf().InSingletonScope(); + Bind().ToSelf().InSingletonScope(); Bind().ToSelf(); Bind().ToSelf(); Bind().ToSelf().InSingletonScope(); diff --git a/Artemis/Artemis/Modules/Games/GtaV/GtaVModel.cs b/Artemis/Artemis/Modules/Games/GtaV/GtaVModel.cs index f3b3d1943..20c185ee9 100644 --- a/Artemis/Artemis/Modules/Games/GtaV/GtaVModel.cs +++ b/Artemis/Artemis/Modules/Games/GtaV/GtaVModel.cs @@ -59,17 +59,17 @@ namespace Artemis.Modules.Games.GtaV private void PipeServerOnPipeMessage(string reply) { -// if (!Initialized) -// return; -// -// // Convert the given string to a list of ints -// var stringParts = reply.Split(' '); -// var parts = new string[stringParts.Length]; -// for (var i = 0; i < stringParts.Length; i++) -// parts[i] = stringParts[i]; -// -// if (parts[0] == "0") -// InterpertrateLighting(parts); + if (!Initialized) + return; + + // Convert the given string to a list of ints + var stringParts = reply.Split(' '); + var parts = new string[stringParts.Length]; + for (var i = 0; i < stringParts.Length; i++) + parts[i] = stringParts[i]; + + if (parts[0] == "0") + InterpertrateLighting(parts); } private void InterpertrateLighting(string[] parts) diff --git a/Artemis/Artemis/ViewModels/ShellViewModel.cs b/Artemis/Artemis/ViewModels/ShellViewModel.cs index c4fc3a190..fd56ee14c 100644 --- a/Artemis/Artemis/ViewModels/ShellViewModel.cs +++ b/Artemis/Artemis/ViewModels/ShellViewModel.cs @@ -1,8 +1,12 @@ using System; using System.Linq; +using System.Windows; +using Artemis.Managers; +using Artemis.Services; using Artemis.ViewModels.Abstract; using Artemis.ViewModels.Flyouts; using Caliburn.Micro; +using MahApps.Metro.Controls; using Ninject; namespace Artemis.ViewModels @@ -11,10 +15,12 @@ namespace Artemis.ViewModels { private readonly IKernel _kernel; - public ShellViewModel(IKernel kernel, FlyoutSettingsViewModel flyoutSettings) + public ShellViewModel(IKernel kernel, MainManager mainManager, MetroDialogService metroDialogService, + FlyoutSettingsViewModel flyoutSettings) { _kernel = kernel; + // Setup UI DisplayName = "Artemis"; @@ -22,10 +28,52 @@ namespace Artemis.ViewModels { flyoutSettings }; + + + MainManager = mainManager; + MetroDialogService = metroDialogService; + MainManager.EnableProgram(); } + public SystemTrayViewModel SystemTrayViewModel { get; set; } + public MainManager MainManager { get; set; } + public MetroDialogService MetroDialogService { get; set; } public IObservableCollection Flyouts { get; set; } + private MetroWindow Window => (MetroWindow) GetView(); + + public override void CanClose(Action callback) + { + if (Window.IsVisible) + HideWindow(); + else + ShowWindow(); + + // ShellView is a strong and independent view who won't let herself get closed by the likes of anyone! + callback(false); + } + + public bool CanShowWindow => !Window.IsVisible; + public bool CanHideWindow => Window.IsVisible; + + public void ShowWindow() + { + if (!Window.IsVisible) + Window.Show(); + + NotifyOfPropertyChange(() => CanShowWindow); + NotifyOfPropertyChange(() => CanHideWindow); + } + + public void HideWindow() + { + if (Window.IsVisible) + Window.Hide(); + + NotifyOfPropertyChange(() => CanShowWindow); + NotifyOfPropertyChange(() => CanHideWindow); + } + protected override void OnActivate() { base.OnActivate(); diff --git a/Artemis/Artemis/Views/ShellView.xaml b/Artemis/Artemis/Views/ShellView.xaml index 2e86ff657..9697d638b 100644 --- a/Artemis/Artemis/Views/ShellView.xaml +++ b/Artemis/Artemis/Views/ShellView.xaml @@ -6,11 +6,14 @@ xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro" xmlns:cal="http://www.caliburnproject.org" xmlns:dialogs="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro" + xmlns:viewModels="clr-namespace:Artemis.ViewModels" + xmlns:tb="http://www.hardcodet.net/taskbar" dialogs:DialogParticipation.Register="{Binding RelativeSource={RelativeSource Self}, Path=DataContext}" mc:Ignorable="d" Title="Artemis" Height="800" Width="1210" MinHeight="800" MinWidth="1210" - GlowBrush="{DynamicResource AccentColorBrush}" Icon="../logo.ico"> + GlowBrush="{DynamicResource AccentColorBrush}" Icon="../logo.ico" + d:DataContext="{d:DesignInstance viewModels:ShellViewModel}"> @@ -45,6 +48,22 @@ + + + + + + + + + + + + @@ -105,5 +124,7 @@ + + \ No newline at end of file