mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
FINALLY fixed dissapearing views after debugging all day
This commit is contained in:
parent
4c766f29b4
commit
917bb88241
@ -116,7 +116,7 @@ namespace Artemis
|
||||
|
||||
protected override void OnStartup(object sender, StartupEventArgs e)
|
||||
{
|
||||
DisplayRootViewFor<SystemTrayViewModel>();
|
||||
DisplayRootViewFor<ShellViewModel>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -14,7 +14,8 @@ namespace Artemis.InjectionModules
|
||||
public override void Load()
|
||||
{
|
||||
// ViewModels
|
||||
Bind<ShellViewModel>().ToSelf();
|
||||
Bind<ShellViewModel>().ToSelf().InSingletonScope();
|
||||
Bind<SystemTrayViewModel>().ToSelf().InSingletonScope();
|
||||
Bind<ProfileViewModel>().ToSelf();
|
||||
Bind<ProfileEditorViewModel>().ToSelf();
|
||||
Bind<DebugViewModel>().ToSelf().InSingletonScope();
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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<FlyoutBaseViewModel> Flyouts { get; set; }
|
||||
|
||||
private MetroWindow Window => (MetroWindow) GetView();
|
||||
|
||||
public override void CanClose(Action<bool> 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();
|
||||
|
||||
@ -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}">
|
||||
<!-- Bit of extra code to use a different icon than in the taskbar -->
|
||||
<Controls:MetroWindow.Resources>
|
||||
<DrawingImage x:Key="BowIcon">
|
||||
@ -45,6 +48,22 @@
|
||||
</DrawingGroup>
|
||||
</DrawingImage.Drawing>
|
||||
</DrawingImage>
|
||||
|
||||
<!-- Tray icon -->
|
||||
<ContextMenu x:Shared="false" x:Key="MainSysTrayMenu">
|
||||
<MenuItem Header="Show Artemis" cal:Message.Attach="ShowWindow" />
|
||||
<MenuItem Header="Hide Artemis" cal:Message.Attach="HideWindow" />
|
||||
<Separator />
|
||||
<MenuItem Header="{Binding Path=ToggleText, Mode=OneWay}" cal:Message.Attach="ToggleEnabled" />
|
||||
<MenuItem Header="Exit" cal:Message.Attach="ExitApplication" />
|
||||
</ContextMenu>
|
||||
|
||||
<!-- the application main system tray icon -->
|
||||
<tb:TaskbarIcon x:Key="SystemTrayIcon"
|
||||
IconSource="{Binding Path=ActiveIcon, Mode=OneWay}"
|
||||
ToolTipText="Artemis"
|
||||
cal:Message.Attach="[Event TrayMouseDoubleClick] = [Action ShowWindow]"
|
||||
ContextMenu="{StaticResource MainSysTrayMenu}" />
|
||||
</Controls:MetroWindow.Resources>
|
||||
<Controls:MetroWindow.IconTemplate>
|
||||
<DataTemplate>
|
||||
@ -105,5 +124,7 @@
|
||||
</DataTemplate>
|
||||
</TabControl.ItemTemplate>
|
||||
</TabControl>
|
||||
|
||||
<ContentControl Content="{StaticResource SystemTrayIcon}" />
|
||||
</Grid>
|
||||
</Controls:MetroWindow>
|
||||
Loading…
x
Reference in New Issue
Block a user