mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
UI - Implemented tray icon
UI - Moved dialog service to the shared UI project UI - Implemented autorun
This commit is contained in:
parent
a79c56eaa1
commit
3ec90766aa
@ -36,6 +36,7 @@
|
||||
<ProjectReference Include="..\Artemis.Storage\Artemis.Storage.csproj">
|
||||
<Private>true</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Artemis.UI.Shared\Artemis.UI.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Ben.Demystifier" Version="0.1.6" />
|
||||
@ -43,6 +44,7 @@
|
||||
<PackageReference Include="LiteDB" Version="5.0.3" />
|
||||
<PackageReference Include="McMaster.NETCore.Plugins" Version="1.1.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="Ninject" Version="3.3.4" />
|
||||
<PackageReference Include="Ninject.Extensions.ChildKernel" Version="3.3.0" />
|
||||
<PackageReference Include="Ninject.Extensions.Conventions" Version="3.3.0" />
|
||||
<PackageReference Include="PropertyChanged.Fody" Version="3.2.6" />
|
||||
|
||||
@ -6,7 +6,7 @@ namespace Artemis.Core
|
||||
public static class Constants
|
||||
{
|
||||
public static readonly string DataFolder = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Artemis\\";
|
||||
public static readonly string ConnectionString = $"FileName={DataFolder}\\database.db;Mode=Exclusive";
|
||||
public static readonly string ConnectionString = $"FileName={DataFolder}\\database.db";
|
||||
public static readonly PluginInfo CorePluginInfo = new PluginInfo {Guid = Guid.Parse("ffffffff-ffff-ffff-ffff-ffffffffffff"), Name = "Artemis Core"};
|
||||
}
|
||||
}
|
||||
@ -4,6 +4,7 @@ using Artemis.Core.Models.Profile.KeyframeEngines;
|
||||
using Artemis.Core.Plugins.Models;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.Storage.Repositories.Interfaces;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using LiteDB;
|
||||
using Ninject.Activation;
|
||||
using Ninject.Extensions.Conventions;
|
||||
@ -29,6 +30,16 @@ namespace Artemis.Core.Ninject
|
||||
.Configure(c => c.InSingletonScope());
|
||||
});
|
||||
|
||||
// Bind all shared UI services as singletons
|
||||
Kernel.Bind(x =>
|
||||
{
|
||||
x.FromAssemblyContaining<IArtemisSharedUIService>()
|
||||
.SelectAllClasses()
|
||||
.InheritedFrom<IArtemisSharedUIService>()
|
||||
.BindAllInterfaces()
|
||||
.Configure(c => c.InSingletonScope());
|
||||
});
|
||||
|
||||
// Bind all protected services as singletons
|
||||
Kernel.Bind(x =>
|
||||
{
|
||||
|
||||
@ -19,9 +19,12 @@
|
||||
<DebugType>pdbonly</DebugType>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AvalonEdit" Version="6.0.1" />
|
||||
<PackageReference Include="Humanizer.Core" Version="2.7.9" />
|
||||
<PackageReference Include="MaterialDesignThemes" Version="3.0.1" />
|
||||
<PackageReference Include="Ninject" Version="3.3.4" />
|
||||
<PackageReference Include="SkiaSharp" Version="1.68.2-preview.29" />
|
||||
<PackageReference Include="Stylet" Version="1.3.1" />
|
||||
<PackageReference Include="System.Buffers" Version="4.5.0" />
|
||||
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
|
||||
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.7.0" />
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
<UserControl x:Class="Artemis.UI.Screens.Dialogs.ConfirmDialogView"
|
||||
<UserControl x:Class="Artemis.UI.Shared.Screens.Dialogs.ConfirmDialogView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:dialogs="clr-namespace:Artemis.UI.Screens.Dialogs"
|
||||
xmlns:dialogs="clr-namespace:Artemis.UI.Shared.Screens.Dialogs"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="163.274" d:DesignWidth="254.425"
|
||||
d:DataContext="{d:DesignInstance dialogs:ConfirmDialogViewModel}">
|
||||
@ -1,6 +1,6 @@
|
||||
using Artemis.UI.ViewModels.Dialogs;
|
||||
using Artemis.UI.Shared.Services.Dialog;
|
||||
|
||||
namespace Artemis.UI.Screens.Dialogs
|
||||
namespace Artemis.UI.Shared.Screens.Dialogs
|
||||
{
|
||||
public class ConfirmDialogViewModel : DialogViewModelBase
|
||||
{
|
||||
@ -0,0 +1,34 @@
|
||||
<UserControl x:Class="Artemis.UI.Shared.Screens.Dialogs.ExceptionDialogView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:dialogs="clr-namespace:Artemis.UI.Shared.Screens.Dialogs"
|
||||
xmlns:avalonedit="http://icsharpcode.net/sharpdevelop/avalonedit"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="163.274" d:DesignWidth="254.425"
|
||||
d:DataContext="{d:DesignInstance dialogs:ExceptionDialogViewModel}">
|
||||
<StackPanel Margin="16">
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadline6TextBlock}" Text="{Binding Header}" TextWrapping="Wrap" />
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" Margin="0 20 0 20" Text="{Binding Exception.Message}" TextWrapping="Wrap" />
|
||||
|
||||
<Separator></Separator>
|
||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" Text="Stack trace" TextWrapping="Wrap" FontWeight="Bold" Margin="20 5 0 0"/>
|
||||
<avalonedit:TextEditor SyntaxHighlighting="C#"
|
||||
FontFamily="Consolas"
|
||||
FontSize="10pt"
|
||||
IsReadOnly="True"
|
||||
Document="{Binding Document}"
|
||||
HorizontalScrollBarVisibility="Auto"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
Margin="0 10"/>
|
||||
<Separator></Separator>
|
||||
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Button Style="{StaticResource MaterialDesignFlatButton}" IsDefault="True" Margin="0 8 0 0"
|
||||
Command="{s:Action Close}" Content="Close" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using Artemis.UI.Shared.Services.Dialog;
|
||||
using ICSharpCode.AvalonEdit;
|
||||
using ICSharpCode.AvalonEdit.Document;
|
||||
|
||||
namespace Artemis.UI.Shared.Screens.Dialogs
|
||||
{
|
||||
public class ExceptionDialogViewModel : DialogViewModelBase
|
||||
{
|
||||
public ExceptionDialogViewModel(string message, Exception exception)
|
||||
{
|
||||
Header = message;
|
||||
Exception = exception;
|
||||
Document = new TextDocument(new StringTextSource(exception.StackTrace));
|
||||
}
|
||||
|
||||
public string Header { get; }
|
||||
public Exception Exception { get; }
|
||||
|
||||
public IDocument Document { get; set; }
|
||||
|
||||
public void Close()
|
||||
{
|
||||
Session.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,15 +2,14 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.UI.Screens.Dialogs;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Artemis.UI.ViewModels.Dialogs;
|
||||
using Artemis.UI.Shared.Screens.Dialogs;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Ninject;
|
||||
using Ninject.Parameters;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Services.Dialog
|
||||
namespace Artemis.UI.Shared.Services.Dialog
|
||||
{
|
||||
public class DialogService : IDialogService
|
||||
{
|
||||
@ -89,6 +88,16 @@ namespace Artemis.UI.Services.Dialog
|
||||
return await ShowDialog(identifier, _kernel.Get<T>(parameters));
|
||||
}
|
||||
|
||||
public async Task ShowExceptionDialog(string message, Exception exception)
|
||||
{
|
||||
var arguments = new IParameter[]
|
||||
{
|
||||
new ConstructorArgument("message", message),
|
||||
new ConstructorArgument("exception", exception)
|
||||
};
|
||||
await Execute.OnUIThreadAsync(async () => await ShowDialog<ExceptionDialogViewModel>(arguments));
|
||||
}
|
||||
|
||||
private async Task<object> ShowDialog(string identifier, DialogViewModelBase viewModel)
|
||||
{
|
||||
var view = _viewManager.CreateViewForModel(viewModel);
|
||||
@ -1,8 +1,7 @@
|
||||
using Artemis.UI.ViewModels.Utilities;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.ViewModels.Dialogs
|
||||
namespace Artemis.UI.Shared.Services.Dialog
|
||||
{
|
||||
public abstract class DialogViewModelBase : ValidatingModelBase
|
||||
{
|
||||
@ -1,8 +1,7 @@
|
||||
using Artemis.UI.ViewModels.Dialogs;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.ViewModels.Utilities
|
||||
namespace Artemis.UI.Shared.Services.Dialog
|
||||
{
|
||||
public class DialogViewModelHost : PropertyChangedBase
|
||||
{
|
||||
@ -0,0 +1,7 @@
|
||||
namespace Artemis.UI.Shared.Services.Interfaces
|
||||
{
|
||||
// ReSharper disable once InconsistentNaming
|
||||
public interface IArtemisSharedUIService
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.UI.ViewModels.Dialogs;
|
||||
using Artemis.UI.Shared.Services.Dialog;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Ninject.Parameters;
|
||||
|
||||
namespace Artemis.UI.Services.Interfaces
|
||||
namespace Artemis.UI.Shared.Services.Interfaces
|
||||
{
|
||||
public interface IDialogService : IArtemisUIService
|
||||
public interface IDialogService : IArtemisSharedUIService
|
||||
{
|
||||
/// <summary>
|
||||
/// Shows a confirm dialog on the dialog host provided in <see cref="identifier" />.
|
||||
@ -93,5 +94,13 @@ namespace Artemis.UI.Services.Interfaces
|
||||
/// <param name="parameters">An array of Ninject <see cref="IParameter" /> to pass to the view model during activation</param>
|
||||
/// <returns>A task resolving to the result of the dialog's <see cref="DialogSession" /></returns>
|
||||
Task<object> ShowDialogAt<T>(string identifier, IParameter[] parameters) where T : DialogViewModelBase;
|
||||
|
||||
/// <summary>
|
||||
/// Shows a dialog displaying the provided message and exception. Does not handle, log or throw the exception.
|
||||
/// </summary>
|
||||
/// <param name="message">The message to display in the dialog title</param>
|
||||
/// <param name="exception">The exception to display. The exception message and stacktrace will be shown.</param>
|
||||
/// <returns>A task resolving when the dialog is closed</returns>
|
||||
Task ShowExceptionDialog(string message, Exception exception);
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,8 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:local="clr-namespace:Artemis.UI">
|
||||
xmlns:local="clr-namespace:Artemis.UI"
|
||||
ShutdownMode="OnExplicitShutdown">
|
||||
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
|
||||
@ -61,6 +61,7 @@
|
||||
<ProjectReference Include="..\Artemis.UI.Shared\Artemis.UI.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Resources\logo-512.ico" />
|
||||
<Resource Include="Resources\logo-512.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -112,8 +113,10 @@
|
||||
<PackageReference Include="Castle.Core" Version="4.4.0" />
|
||||
<PackageReference Include="FluentValidation" Version="8.6.1" />
|
||||
<PackageReference Include="gong-wpf-dragdrop" Version="2.2.0" />
|
||||
<PackageReference Include="Hardcodet.NotifyIcon.Wpf.NetCore" Version="1.0.10" />
|
||||
<PackageReference Include="Humanizer.Core" Version="2.7.9" />
|
||||
<PackageReference Include="MaterialDesignExtensions" Version="3.0.0" />
|
||||
<PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" />
|
||||
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.19" />
|
||||
<PackageReference Include="Ninject" Version="3.3.4" />
|
||||
<PackageReference Include="Ninject.Extensions.Conventions" Version="3.3.0" />
|
||||
@ -276,6 +279,9 @@
|
||||
<Compile Remove="obj\x64\Debug\Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\SKSizePropertyInputView.g.cs" />
|
||||
<Compile Remove="obj\x64\Debug\Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\SKSizePropertyInputView.g.i.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Remove="Resources\logo-512.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Threading;
|
||||
@ -14,9 +16,10 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI
|
||||
{
|
||||
public class Bootstrapper : NinjectBootstrapper<RootViewModel>
|
||||
public class Bootstrapper : NinjectBootstrapper<TrayViewModel>
|
||||
{
|
||||
private ICoreService _core;
|
||||
public static List<string> StartupArguments { get; private set; }
|
||||
|
||||
protected override void OnExit(ExitEventArgs e)
|
||||
{
|
||||
@ -28,9 +31,10 @@ namespace Artemis.UI
|
||||
|
||||
protected override void Launch()
|
||||
{
|
||||
var windowManager = (IWindowManager) GetInstance(typeof(IWindowManager));
|
||||
var splashViewModel = new SplashViewModel(Kernel);
|
||||
windowManager.ShowWindow(splashViewModel);
|
||||
StartupArguments = Args.ToList();
|
||||
|
||||
var windowManager = Kernel.Get<IWindowManager>();
|
||||
windowManager.ShowWindow(RootViewModel);
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
@ -38,10 +42,6 @@ namespace Artemis.UI
|
||||
{
|
||||
// Start the Artemis core
|
||||
_core = Kernel.Get<ICoreService>();
|
||||
// When the core is done, hide the splash and show the main window
|
||||
_core.Initialized += (sender, args) => ShowMainWindow(windowManager, splashViewModel);
|
||||
// While the core is instantiated, start listening for events on the splash
|
||||
splashViewModel.ListenToEvents();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@ -4,8 +4,8 @@ using Artemis.UI.Screens;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Artemis.UI.Shared.Services.Dialog;
|
||||
using Artemis.UI.Stylet;
|
||||
using Artemis.UI.ViewModels.Dialogs;
|
||||
using FluentValidation;
|
||||
using Ninject.Extensions.Conventions;
|
||||
using Ninject.Modules;
|
||||
|
||||
8
src/Artemis.UI/Properties/launchSettings.json
Normal file
8
src/Artemis.UI/Properties/launchSettings.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"profiles": {
|
||||
"Artemis.UI": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "-autorun"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.UI.ViewModels.Dialogs;
|
||||
using Artemis.UI.Shared.Services.Dialog;
|
||||
using FluentValidation;
|
||||
using Stylet;
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core.Models.Profile;
|
||||
using Artemis.UI.ViewModels.Dialogs;
|
||||
using Artemis.UI.Shared.Services.Dialog;
|
||||
using FluentValidation;
|
||||
using Stylet;
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.ProfileTree;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.Visualization;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
|
||||
{
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
|
||||
{
|
||||
|
||||
@ -7,6 +7,7 @@ using Artemis.UI.Exceptions;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Screens.Module.ProfileEditor.Dialogs;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:screens="clr-namespace:Artemis.UI.Screens"
|
||||
xmlns:mde="clr-namespace:MaterialDesignExtensions.Controls;assembly=MaterialDesignExtensions"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
mc:Ignorable="d"
|
||||
FadeContentIfInactive="False"
|
||||
Icon="/Artemis.UI;component/Resources/logo-512.png"
|
||||
@ -50,15 +51,18 @@
|
||||
</Style>
|
||||
</mde:MaterialWindow.Resources>
|
||||
<materialDesign:DialogHost Identifier="RootDialog">
|
||||
<materialDesign:DrawerHost IsLeftDrawerOpen="{Binding IsSidebarVisible}">
|
||||
<materialDesign:DrawerHost.LeftDrawerContent>
|
||||
<ContentControl s:View.Model="{Binding SidebarViewModel}" Width="220" ClipToBounds="False" />
|
||||
</materialDesign:DrawerHost.LeftDrawerContent>
|
||||
<DockPanel>
|
||||
<mde:AppBar Type="Dense" IsNavigationDrawerOpen="{Binding IsSidebarVisible, Mode=TwoWay}" Title="{Binding ActiveItem.DisplayName}" ShowNavigationDrawerButton="True"
|
||||
DockPanel.Dock="Top" />
|
||||
<ContentControl s:View.Model="{Binding ActiveItem}" Style="{StaticResource InitializingFade}" />
|
||||
</DockPanel>
|
||||
</materialDesign:DrawerHost>
|
||||
</materialDesign:DialogHost>
|
||||
<materialDesign:DrawerHost IsLeftDrawerOpen="{Binding IsSidebarVisible}">
|
||||
<materialDesign:DrawerHost.LeftDrawerContent>
|
||||
<ContentControl s:View.Model="{Binding SidebarViewModel}" Width="220" ClipToBounds="False" />
|
||||
</materialDesign:DrawerHost.LeftDrawerContent>
|
||||
<DockPanel>
|
||||
<mde:AppBar Type="Dense"
|
||||
IsNavigationDrawerOpen="{Binding IsSidebarVisible, Mode=TwoWay}"
|
||||
Title="{Binding ActiveItem.DisplayName}"
|
||||
ShowNavigationDrawerButton="True"
|
||||
DockPanel.Dock="Top" />
|
||||
<ContentControl s:View.Model="{Binding ActiveItem}" Style="{StaticResource InitializingFade}" />
|
||||
</DockPanel>
|
||||
</materialDesign:DrawerHost>
|
||||
</materialDesign:DialogHost>
|
||||
</mde:MaterialWindow>
|
||||
@ -2,6 +2,7 @@
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Events;
|
||||
using Artemis.UI.Screens.Sidebar;
|
||||
using Artemis.UI.Utilities;
|
||||
|
||||
@ -39,7 +39,7 @@
|
||||
<TextBlock Style="{StaticResource MaterialDesignTextBlock}">Start up with Windows</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||
<ToggleButton Style="{StaticResource MaterialDesignSwitchToggleButton}" ToolTip="Default ToggleButton Style" />
|
||||
<ToggleButton Style="{StaticResource MaterialDesignSwitchToggleButton}" IsChecked="{Binding StartWithWindows}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Separator Style="{StaticResource MaterialDesignSeparator}" Margin="-15 5" />
|
||||
@ -57,7 +57,7 @@
|
||||
<TextBlock Style="{StaticResource MaterialDesignTextBlock}">Start up with Windows minimized</TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||
<ToggleButton Style="{StaticResource MaterialDesignSwitchToggleButton}" ToolTip="Default ToggleButton Style" />
|
||||
<ToggleButton Style="{StaticResource MaterialDesignSwitchToggleButton}" IsChecked="{Binding StartMinimized}" IsEnabled="{Binding StartWithWindows}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Separator Style="{StaticResource MaterialDesignSeparator}" Margin="-15 5" />
|
||||
|
||||
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Plugins.Abstract;
|
||||
using Artemis.Core.Services;
|
||||
@ -12,8 +13,10 @@ using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Screens.Settings.Debug;
|
||||
using Artemis.UI.Screens.Settings.Tabs.Devices;
|
||||
using Artemis.UI.Screens.Settings.Tabs.Plugins;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using Artemis.UI.Shared.Utilities;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Microsoft.Win32;
|
||||
using Ninject;
|
||||
using Serilog.Events;
|
||||
using Stylet;
|
||||
@ -23,6 +26,7 @@ namespace Artemis.UI.Screens.Settings
|
||||
public class SettingsViewModel : MainScreenViewModel
|
||||
{
|
||||
private readonly IDeviceSettingsVmFactory _deviceSettingsVmFactory;
|
||||
private readonly IDialogService _dialogService;
|
||||
private readonly IKernel _kernel;
|
||||
private readonly IPluginService _pluginService;
|
||||
private readonly ISettingsService _settingsService;
|
||||
@ -32,6 +36,7 @@ namespace Artemis.UI.Screens.Settings
|
||||
public SettingsViewModel(IKernel kernel,
|
||||
ISurfaceService surfaceService,
|
||||
IPluginService pluginService,
|
||||
IDialogService dialogService,
|
||||
IWindowManager windowManager,
|
||||
ISettingsService settingsService,
|
||||
IDeviceSettingsVmFactory deviceSettingsVmFactory)
|
||||
@ -43,6 +48,7 @@ namespace Artemis.UI.Screens.Settings
|
||||
_kernel = kernel;
|
||||
_surfaceService = surfaceService;
|
||||
_pluginService = pluginService;
|
||||
_dialogService = dialogService;
|
||||
_windowManager = windowManager;
|
||||
_settingsService = settingsService;
|
||||
_deviceSettingsVmFactory = deviceSettingsVmFactory;
|
||||
@ -65,12 +71,33 @@ namespace Artemis.UI.Screens.Settings
|
||||
|
||||
public List<Tuple<string, int>> TargetFrameRates { get; set; }
|
||||
public List<Tuple<string, double>> RenderScales { get; set; }
|
||||
public IEnumerable<ValueDescription> LogLevels { get; private set; }
|
||||
public IEnumerable<ValueDescription> LogLevels { get; }
|
||||
|
||||
public List<int> SampleSizes { get; set; }
|
||||
public BindableCollection<DeviceSettingsViewModel> DeviceSettingsViewModels { get; set; }
|
||||
public BindableCollection<PluginSettingsViewModel> Plugins { get; set; }
|
||||
|
||||
public bool StartWithWindows
|
||||
{
|
||||
get => _settingsService.GetSetting("UI.AutoRun", false).Value;
|
||||
set
|
||||
{
|
||||
_settingsService.GetSetting("UI.AutoRun", false).Value = value;
|
||||
_settingsService.GetSetting("UI.AutoRun", false).Save();
|
||||
Task.Run(ApplyAutorun);
|
||||
}
|
||||
}
|
||||
|
||||
public bool StartMinimized
|
||||
{
|
||||
get => !_settingsService.GetSetting("UI.ShowOnStartup", true).Value;
|
||||
set
|
||||
{
|
||||
_settingsService.GetSetting("UI.ShowOnStartup", true).Value = !value;
|
||||
_settingsService.GetSetting("UI.ShowOnStartup", true).Save();
|
||||
}
|
||||
}
|
||||
|
||||
public Tuple<string, double> SelectedRenderScale
|
||||
{
|
||||
get => RenderScales.FirstOrDefault(s => Math.Abs(s.Item2 - RenderScale) < 0.01);
|
||||
@ -138,8 +165,10 @@ namespace Artemis.UI.Screens.Settings
|
||||
Process.Start(Constants.DataFolder);
|
||||
}
|
||||
|
||||
protected override void OnActivate()
|
||||
protected override void OnInitialActivate()
|
||||
{
|
||||
Task.Run(ApplyAutorun);
|
||||
|
||||
DeviceSettingsViewModels.Clear();
|
||||
foreach (var device in _surfaceService.ActiveSurface.Devices)
|
||||
DeviceSettingsViewModels.Add(_deviceSettingsVmFactory.Create(device));
|
||||
@ -149,7 +178,34 @@ namespace Artemis.UI.Screens.Settings
|
||||
foreach (var plugin in _pluginService.GetPluginsOfType<Plugin>())
|
||||
Plugins.Add(new PluginSettingsViewModel(plugin));
|
||||
|
||||
base.OnActivate();
|
||||
base.OnInitialActivate();
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
DeviceSettingsViewModels.Clear();
|
||||
Plugins.Clear();
|
||||
base.OnClose();
|
||||
}
|
||||
|
||||
private async Task ApplyAutorun()
|
||||
{
|
||||
try
|
||||
{
|
||||
var key = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
|
||||
if (key == null)
|
||||
key = Registry.CurrentUser.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
|
||||
|
||||
if (StartWithWindows)
|
||||
key.SetValue("Artemis", $"\"{Process.GetCurrentProcess().MainModule.FileName}\" -autorun");
|
||||
else
|
||||
key.DeleteValue("Artemis", false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
await _dialogService.ShowExceptionDialog("An exception occured while trying to apply the auto run setting", e);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8,22 +8,26 @@ namespace Artemis.UI.Screens.Splash
|
||||
{
|
||||
public class SplashViewModel : Screen
|
||||
{
|
||||
private readonly IKernel _kernel;
|
||||
private readonly ICoreService _coreService;
|
||||
private readonly IPluginService _pluginService;
|
||||
|
||||
public SplashViewModel(IKernel kernel)
|
||||
public SplashViewModel(ICoreService coreService, IPluginService pluginService)
|
||||
{
|
||||
_kernel = kernel;
|
||||
_coreService = coreService;
|
||||
_pluginService = pluginService;
|
||||
Status = "Initializing Core";
|
||||
|
||||
ListenToEvents();
|
||||
}
|
||||
|
||||
public string Status { get; set; }
|
||||
|
||||
public void ListenToEvents()
|
||||
{
|
||||
var pluginService = _kernel.Get<IPluginService>();
|
||||
pluginService.CopyingBuildInPlugins += (sender, args) => Status = "Updating built-in plugins";
|
||||
pluginService.PluginLoading += (sender, args) => Status = "Loading plugin: " + args.PluginInfo.Name;
|
||||
pluginService.PluginLoaded += (sender, args) => Status = "Initializing UI";
|
||||
_coreService.Initialized += (sender, args) => Execute.OnUIThread(() => RequestClose());
|
||||
_pluginService.CopyingBuildInPlugins += (sender, args) => Status = "Updating built-in plugins";
|
||||
_pluginService.PluginLoading += (sender, args) => Status = "Loading plugin: " + args.PluginInfo.Name;
|
||||
_pluginService.PluginLoaded += (sender, args) => Status = "Initializing UI";
|
||||
}
|
||||
|
||||
// ReSharper disable once UnusedMember.Global - Called from view
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.UI.ViewModels.Dialogs;
|
||||
using Artemis.UI.Shared.Services.Dialog;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.SurfaceEditor.Dialogs
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
using System.Threading.Tasks;
|
||||
using Artemis.UI.Screens.SurfaceEditor.Visualization;
|
||||
using Artemis.UI.ViewModels.Dialogs;
|
||||
using Artemis.UI.Shared.Services.Dialog;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.SurfaceEditor.Dialogs
|
||||
|
||||
@ -14,7 +14,7 @@ using Artemis.Core.Services.Storage.Interfaces;
|
||||
using Artemis.UI.Screens.Shared;
|
||||
using Artemis.UI.Screens.SurfaceEditor.Dialogs;
|
||||
using Artemis.UI.Screens.SurfaceEditor.Visualization;
|
||||
using Artemis.UI.Services.Interfaces;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using MaterialDesignThemes.Wpf;
|
||||
using Stylet;
|
||||
|
||||
|
||||
36
src/Artemis.UI/Screens/TrayView.xaml
Normal file
36
src/Artemis.UI/Screens/TrayView.xaml
Normal file
@ -0,0 +1,36 @@
|
||||
<Window x:Class="Artemis.UI.Screens.TrayView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
mc:Ignorable="d"
|
||||
Title="Artemis"
|
||||
Height="1"
|
||||
Width="1"
|
||||
Visibility="Hidden">
|
||||
<tb:TaskbarIcon x:Name="TrayIcon"
|
||||
IconSource="/Resources/logo-512.ico"
|
||||
MenuActivation="LeftOrRightClick"
|
||||
PopupActivation="DoubleClick"
|
||||
ToolTipText="Artemis"
|
||||
DoubleClickCommand="{s:Action TrayBringToForeground}">
|
||||
<tb:TaskbarIcon.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="Bring to foreground" Command="{s:Action TrayBringToForeground}">
|
||||
<MenuItem.Icon>
|
||||
<materialDesign:PackIcon Kind="ArrangeBringToFront" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
<Separator />
|
||||
<MenuItem Header="Exit" Command="{s:Action TrayExit}">
|
||||
<MenuItem.Icon>
|
||||
<materialDesign:PackIcon Kind="Close" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</ContextMenu>
|
||||
</tb:TaskbarIcon.ContextMenu>
|
||||
</tb:TaskbarIcon>
|
||||
</Window>
|
||||
67
src/Artemis.UI/Screens/TrayViewModel.cs
Normal file
67
src/Artemis.UI/Screens/TrayViewModel.cs
Normal file
@ -0,0 +1,67 @@
|
||||
using System.Windows;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.UI.Screens.Splash;
|
||||
using Ninject;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens
|
||||
{
|
||||
public class TrayViewModel : Screen
|
||||
{
|
||||
private readonly ICoreService _coreService;
|
||||
private readonly IKernel _kernel;
|
||||
private readonly IWindowManager _windowManager;
|
||||
|
||||
public TrayViewModel(IKernel kernel, IWindowManager windowManager, ICoreService coreService, ISettingsService settingsService)
|
||||
{
|
||||
_kernel = kernel;
|
||||
_windowManager = windowManager;
|
||||
_coreService = coreService;
|
||||
CanShowRootViewModel = true;
|
||||
|
||||
var autoRunning = Bootstrapper.StartupArguments.Contains("-autorun");
|
||||
var showOnAutoRun = settingsService.GetSetting("UI.ShowOnStartup", true).Value;
|
||||
if (!autoRunning || showOnAutoRun)
|
||||
{
|
||||
ShowSplashScreen();
|
||||
_coreService.Initialized += (sender, args) => TrayBringToForeground();
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanShowRootViewModel { get; set; }
|
||||
|
||||
public void TrayBringToForeground()
|
||||
{
|
||||
if (!CanShowRootViewModel)
|
||||
return;
|
||||
CanShowRootViewModel = false;
|
||||
|
||||
Execute.OnUIThread(() =>
|
||||
{
|
||||
var rootViewModel = _kernel.Get<RootViewModel>();
|
||||
rootViewModel.Closed += RootViewModelOnClosed;
|
||||
_windowManager.ShowWindow(rootViewModel);
|
||||
});
|
||||
}
|
||||
|
||||
public void TrayExit()
|
||||
{
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
|
||||
private void ShowSplashScreen()
|
||||
{
|
||||
Execute.OnUIThread(() =>
|
||||
{
|
||||
var splashViewModel = _kernel.Get<SplashViewModel>();
|
||||
_windowManager.ShowWindow(splashViewModel);
|
||||
});
|
||||
}
|
||||
|
||||
private void RootViewModelOnClosed(object sender, CloseEventArgs e)
|
||||
{
|
||||
CanShowRootViewModel = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user