1
0
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:
SpoinkyNL 2020-02-23 12:37:30 +01:00
parent a79c56eaa1
commit 3ec90766aa
34 changed files with 344 additions and 57 deletions

View File

@ -36,6 +36,7 @@
<ProjectReference Include="..\Artemis.Storage\Artemis.Storage.csproj"> <ProjectReference Include="..\Artemis.Storage\Artemis.Storage.csproj">
<Private>true</Private> <Private>true</Private>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\Artemis.UI.Shared\Artemis.UI.Shared.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Ben.Demystifier" Version="0.1.6" /> <PackageReference Include="Ben.Demystifier" Version="0.1.6" />
@ -43,6 +44,7 @@
<PackageReference Include="LiteDB" Version="5.0.3" /> <PackageReference Include="LiteDB" Version="5.0.3" />
<PackageReference Include="McMaster.NETCore.Plugins" Version="1.1.0" /> <PackageReference Include="McMaster.NETCore.Plugins" Version="1.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> <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.ChildKernel" Version="3.3.0" />
<PackageReference Include="Ninject.Extensions.Conventions" Version="3.3.0" /> <PackageReference Include="Ninject.Extensions.Conventions" Version="3.3.0" />
<PackageReference Include="PropertyChanged.Fody" Version="3.2.6" /> <PackageReference Include="PropertyChanged.Fody" Version="3.2.6" />

View File

@ -6,7 +6,7 @@ namespace Artemis.Core
public static class Constants public static class Constants
{ {
public static readonly string DataFolder = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Artemis\\"; 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"}; public static readonly PluginInfo CorePluginInfo = new PluginInfo {Guid = Guid.Parse("ffffffff-ffff-ffff-ffff-ffffffffffff"), Name = "Artemis Core"};
} }
} }

View File

@ -4,6 +4,7 @@ using Artemis.Core.Models.Profile.KeyframeEngines;
using Artemis.Core.Plugins.Models; using Artemis.Core.Plugins.Models;
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using Artemis.Storage.Repositories.Interfaces; using Artemis.Storage.Repositories.Interfaces;
using Artemis.UI.Shared.Services.Interfaces;
using LiteDB; using LiteDB;
using Ninject.Activation; using Ninject.Activation;
using Ninject.Extensions.Conventions; using Ninject.Extensions.Conventions;
@ -29,6 +30,16 @@ namespace Artemis.Core.Ninject
.Configure(c => c.InSingletonScope()); .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 // Bind all protected services as singletons
Kernel.Bind(x => Kernel.Bind(x =>
{ {

View File

@ -19,9 +19,12 @@
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AvalonEdit" Version="6.0.1" />
<PackageReference Include="Humanizer.Core" Version="2.7.9" /> <PackageReference Include="Humanizer.Core" Version="2.7.9" />
<PackageReference Include="MaterialDesignThemes" Version="3.0.1" /> <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="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.Buffers" Version="4.5.0" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" /> <PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.7.0" /> <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.7.0" />

View File

@ -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="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:s="https://github.com/canton7/Stylet" xmlns:s="https://github.com/canton7/Stylet"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" 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" mc:Ignorable="d"
d:DesignHeight="163.274" d:DesignWidth="254.425" d:DesignHeight="163.274" d:DesignWidth="254.425"
d:DataContext="{d:DesignInstance dialogs:ConfirmDialogViewModel}"> d:DataContext="{d:DesignInstance dialogs:ConfirmDialogViewModel}">

View File

@ -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 public class ConfirmDialogViewModel : DialogViewModelBase
{ {

View File

@ -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>

View File

@ -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();
}
}
}

View File

@ -2,15 +2,14 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Artemis.UI.Screens.Dialogs; using Artemis.UI.Shared.Screens.Dialogs;
using Artemis.UI.Services.Interfaces; using Artemis.UI.Shared.Services.Interfaces;
using Artemis.UI.ViewModels.Dialogs;
using MaterialDesignThemes.Wpf; using MaterialDesignThemes.Wpf;
using Ninject; using Ninject;
using Ninject.Parameters; using Ninject.Parameters;
using Stylet; using Stylet;
namespace Artemis.UI.Services.Dialog namespace Artemis.UI.Shared.Services.Dialog
{ {
public class DialogService : IDialogService public class DialogService : IDialogService
{ {
@ -89,6 +88,16 @@ namespace Artemis.UI.Services.Dialog
return await ShowDialog(identifier, _kernel.Get<T>(parameters)); 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) private async Task<object> ShowDialog(string identifier, DialogViewModelBase viewModel)
{ {
var view = _viewManager.CreateViewForModel(viewModel); var view = _viewManager.CreateViewForModel(viewModel);

View File

@ -1,8 +1,7 @@
using Artemis.UI.ViewModels.Utilities; using MaterialDesignThemes.Wpf;
using MaterialDesignThemes.Wpf;
using Stylet; using Stylet;
namespace Artemis.UI.ViewModels.Dialogs namespace Artemis.UI.Shared.Services.Dialog
{ {
public abstract class DialogViewModelBase : ValidatingModelBase public abstract class DialogViewModelBase : ValidatingModelBase
{ {

View File

@ -1,8 +1,7 @@
using Artemis.UI.ViewModels.Dialogs; using MaterialDesignThemes.Wpf;
using MaterialDesignThemes.Wpf;
using Stylet; using Stylet;
namespace Artemis.UI.ViewModels.Utilities namespace Artemis.UI.Shared.Services.Dialog
{ {
public class DialogViewModelHost : PropertyChangedBase public class DialogViewModelHost : PropertyChangedBase
{ {

View File

@ -0,0 +1,7 @@
namespace Artemis.UI.Shared.Services.Interfaces
{
// ReSharper disable once InconsistentNaming
public interface IArtemisSharedUIService
{
}
}

View File

@ -1,12 +1,13 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Artemis.UI.ViewModels.Dialogs; using Artemis.UI.Shared.Services.Dialog;
using MaterialDesignThemes.Wpf; using MaterialDesignThemes.Wpf;
using Ninject.Parameters; using Ninject.Parameters;
namespace Artemis.UI.Services.Interfaces namespace Artemis.UI.Shared.Services.Interfaces
{ {
public interface IDialogService : IArtemisUIService public interface IDialogService : IArtemisSharedUIService
{ {
/// <summary> /// <summary>
/// Shows a confirm dialog on the dialog host provided in <see cref="identifier" />. /// 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> /// <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> /// <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; 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);
} }
} }

View File

@ -2,7 +2,8 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:s="https://github.com/canton7/Stylet" xmlns:s="https://github.com/canton7/Stylet"
xmlns:local="clr-namespace:Artemis.UI"> xmlns:local="clr-namespace:Artemis.UI"
ShutdownMode="OnExplicitShutdown">
<Application.Resources> <Application.Resources>
<ResourceDictionary> <ResourceDictionary>

View File

@ -61,6 +61,7 @@
<ProjectReference Include="..\Artemis.UI.Shared\Artemis.UI.Shared.csproj" /> <ProjectReference Include="..\Artemis.UI.Shared\Artemis.UI.Shared.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Resource Include="Resources\logo-512.ico" />
<Resource Include="Resources\logo-512.png" /> <Resource Include="Resources\logo-512.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -112,8 +113,10 @@
<PackageReference Include="Castle.Core" Version="4.4.0" /> <PackageReference Include="Castle.Core" Version="4.4.0" />
<PackageReference Include="FluentValidation" Version="8.6.1" /> <PackageReference Include="FluentValidation" Version="8.6.1" />
<PackageReference Include="gong-wpf-dragdrop" Version="2.2.0" /> <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="Humanizer.Core" Version="2.7.9" />
<PackageReference Include="MaterialDesignExtensions" Version="3.0.0" /> <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="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.19" />
<PackageReference Include="Ninject" Version="3.3.4" /> <PackageReference Include="Ninject" Version="3.3.4" />
<PackageReference Include="Ninject.Extensions.Conventions" Version="3.3.0" /> <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.cs" />
<Compile Remove="obj\x64\Debug\Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\SKSizePropertyInputView.g.i.cs" /> <Compile Remove="obj\x64\Debug\Screens\Module\ProfileEditor\LayerProperties\PropertyTree\PropertyInput\SKSizePropertyInputView.g.i.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Remove="Resources\logo-512.ico" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Update="Properties\Resources.Designer.cs"> <Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>

View File

@ -1,4 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Threading; using System.Windows.Threading;
@ -14,9 +16,10 @@ using Stylet;
namespace Artemis.UI namespace Artemis.UI
{ {
public class Bootstrapper : NinjectBootstrapper<RootViewModel> public class Bootstrapper : NinjectBootstrapper<TrayViewModel>
{ {
private ICoreService _core; private ICoreService _core;
public static List<string> StartupArguments { get; private set; }
protected override void OnExit(ExitEventArgs e) protected override void OnExit(ExitEventArgs e)
{ {
@ -28,9 +31,10 @@ namespace Artemis.UI
protected override void Launch() protected override void Launch()
{ {
var windowManager = (IWindowManager) GetInstance(typeof(IWindowManager)); StartupArguments = Args.ToList();
var splashViewModel = new SplashViewModel(Kernel);
windowManager.ShowWindow(splashViewModel); var windowManager = Kernel.Get<IWindowManager>();
windowManager.ShowWindow(RootViewModel);
Task.Run(() => Task.Run(() =>
{ {
@ -38,10 +42,6 @@ namespace Artemis.UI
{ {
// Start the Artemis core // Start the Artemis core
_core = Kernel.Get<ICoreService>(); _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) catch (Exception e)
{ {

View File

@ -4,8 +4,8 @@ using Artemis.UI.Screens;
using Artemis.UI.Screens.Module.ProfileEditor; using Artemis.UI.Screens.Module.ProfileEditor;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput; using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.PropertyTree.PropertyInput;
using Artemis.UI.Services.Interfaces; using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Dialog;
using Artemis.UI.Stylet; using Artemis.UI.Stylet;
using Artemis.UI.ViewModels.Dialogs;
using FluentValidation; using FluentValidation;
using Ninject.Extensions.Conventions; using Ninject.Extensions.Conventions;
using Ninject.Modules; using Ninject.Modules;

View File

@ -0,0 +1,8 @@
{
"profiles": {
"Artemis.UI": {
"commandName": "Project",
"commandLineArgs": "-autorun"
}
}
}

View File

@ -1,5 +1,5 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Artemis.UI.ViewModels.Dialogs; using Artemis.UI.Shared.Services.Dialog;
using FluentValidation; using FluentValidation;
using Stylet; using Stylet;

View File

@ -1,6 +1,6 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.UI.ViewModels.Dialogs; using Artemis.UI.Shared.Services.Dialog;
using FluentValidation; using FluentValidation;
using Stylet; using Stylet;

View File

@ -14,6 +14,7 @@ using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties;
using Artemis.UI.Screens.Module.ProfileEditor.ProfileTree; using Artemis.UI.Screens.Module.ProfileEditor.ProfileTree;
using Artemis.UI.Screens.Module.ProfileEditor.Visualization; using Artemis.UI.Screens.Module.ProfileEditor.Visualization;
using Artemis.UI.Services.Interfaces; using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces;
using Stylet; using Stylet;
namespace Artemis.UI.Screens.Module.ProfileEditor namespace Artemis.UI.Screens.Module.ProfileEditor

View File

@ -2,6 +2,7 @@
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using Artemis.UI.Ninject.Factories; using Artemis.UI.Ninject.Factories;
using Artemis.UI.Services.Interfaces; using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces;
namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
{ {

View File

@ -2,6 +2,7 @@
using Artemis.Core.Services.Interfaces; using Artemis.Core.Services.Interfaces;
using Artemis.UI.Ninject.Factories; using Artemis.UI.Ninject.Factories;
using Artemis.UI.Services.Interfaces; using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces;
namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
{ {

View File

@ -7,6 +7,7 @@ using Artemis.UI.Exceptions;
using Artemis.UI.Ninject.Factories; using Artemis.UI.Ninject.Factories;
using Artemis.UI.Screens.Module.ProfileEditor.Dialogs; using Artemis.UI.Screens.Module.ProfileEditor.Dialogs;
using Artemis.UI.Services.Interfaces; using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces;
using Stylet; using Stylet;
namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem

View File

@ -7,6 +7,7 @@
xmlns:s="https://github.com/canton7/Stylet" xmlns:s="https://github.com/canton7/Stylet"
xmlns:screens="clr-namespace:Artemis.UI.Screens" xmlns:screens="clr-namespace:Artemis.UI.Screens"
xmlns:mde="clr-namespace:MaterialDesignExtensions.Controls;assembly=MaterialDesignExtensions" xmlns:mde="clr-namespace:MaterialDesignExtensions.Controls;assembly=MaterialDesignExtensions"
xmlns:tb="http://www.hardcodet.net/taskbar"
mc:Ignorable="d" mc:Ignorable="d"
FadeContentIfInactive="False" FadeContentIfInactive="False"
Icon="/Artemis.UI;component/Resources/logo-512.png" Icon="/Artemis.UI;component/Resources/logo-512.png"
@ -55,7 +56,10 @@
<ContentControl s:View.Model="{Binding SidebarViewModel}" Width="220" ClipToBounds="False" /> <ContentControl s:View.Model="{Binding SidebarViewModel}" Width="220" ClipToBounds="False" />
</materialDesign:DrawerHost.LeftDrawerContent> </materialDesign:DrawerHost.LeftDrawerContent>
<DockPanel> <DockPanel>
<mde:AppBar Type="Dense" IsNavigationDrawerOpen="{Binding IsSidebarVisible, Mode=TwoWay}" Title="{Binding ActiveItem.DisplayName}" ShowNavigationDrawerButton="True" <mde:AppBar Type="Dense"
IsNavigationDrawerOpen="{Binding IsSidebarVisible, Mode=TwoWay}"
Title="{Binding ActiveItem.DisplayName}"
ShowNavigationDrawerButton="True"
DockPanel.Dock="Top" /> DockPanel.Dock="Top" />
<ContentControl s:View.Model="{Binding ActiveItem}" Style="{StaticResource InitializingFade}" /> <ContentControl s:View.Model="{Binding ActiveItem}" Style="{StaticResource InitializingFade}" />
</DockPanel> </DockPanel>

View File

@ -2,6 +2,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using Artemis.Core.Services;
using Artemis.UI.Events; using Artemis.UI.Events;
using Artemis.UI.Screens.Sidebar; using Artemis.UI.Screens.Sidebar;
using Artemis.UI.Utilities; using Artemis.UI.Utilities;

View File

@ -39,7 +39,7 @@
<TextBlock Style="{StaticResource MaterialDesignTextBlock}">Start up with Windows</TextBlock> <TextBlock Style="{StaticResource MaterialDesignTextBlock}">Start up with Windows</TextBlock>
</StackPanel> </StackPanel>
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center"> <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> </StackPanel>
</Grid> </Grid>
<Separator Style="{StaticResource MaterialDesignSeparator}" Margin="-15 5" /> <Separator Style="{StaticResource MaterialDesignSeparator}" Margin="-15 5" />
@ -57,7 +57,7 @@
<TextBlock Style="{StaticResource MaterialDesignTextBlock}">Start up with Windows minimized</TextBlock> <TextBlock Style="{StaticResource MaterialDesignTextBlock}">Start up with Windows minimized</TextBlock>
</StackPanel> </StackPanel>
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center"> <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> </StackPanel>
</Grid> </Grid>
<Separator Style="{StaticResource MaterialDesignSeparator}" Margin="-15 5" /> <Separator Style="{StaticResource MaterialDesignSeparator}" Margin="-15 5" />

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
using Artemis.Core; using Artemis.Core;
using Artemis.Core.Plugins.Abstract; using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Services; using Artemis.Core.Services;
@ -12,8 +13,10 @@ using Artemis.UI.Ninject.Factories;
using Artemis.UI.Screens.Settings.Debug; using Artemis.UI.Screens.Settings.Debug;
using Artemis.UI.Screens.Settings.Tabs.Devices; using Artemis.UI.Screens.Settings.Tabs.Devices;
using Artemis.UI.Screens.Settings.Tabs.Plugins; using Artemis.UI.Screens.Settings.Tabs.Plugins;
using Artemis.UI.Shared.Services.Interfaces;
using Artemis.UI.Shared.Utilities; using Artemis.UI.Shared.Utilities;
using MaterialDesignThemes.Wpf; using MaterialDesignThemes.Wpf;
using Microsoft.Win32;
using Ninject; using Ninject;
using Serilog.Events; using Serilog.Events;
using Stylet; using Stylet;
@ -23,6 +26,7 @@ namespace Artemis.UI.Screens.Settings
public class SettingsViewModel : MainScreenViewModel public class SettingsViewModel : MainScreenViewModel
{ {
private readonly IDeviceSettingsVmFactory _deviceSettingsVmFactory; private readonly IDeviceSettingsVmFactory _deviceSettingsVmFactory;
private readonly IDialogService _dialogService;
private readonly IKernel _kernel; private readonly IKernel _kernel;
private readonly IPluginService _pluginService; private readonly IPluginService _pluginService;
private readonly ISettingsService _settingsService; private readonly ISettingsService _settingsService;
@ -32,6 +36,7 @@ namespace Artemis.UI.Screens.Settings
public SettingsViewModel(IKernel kernel, public SettingsViewModel(IKernel kernel,
ISurfaceService surfaceService, ISurfaceService surfaceService,
IPluginService pluginService, IPluginService pluginService,
IDialogService dialogService,
IWindowManager windowManager, IWindowManager windowManager,
ISettingsService settingsService, ISettingsService settingsService,
IDeviceSettingsVmFactory deviceSettingsVmFactory) IDeviceSettingsVmFactory deviceSettingsVmFactory)
@ -43,6 +48,7 @@ namespace Artemis.UI.Screens.Settings
_kernel = kernel; _kernel = kernel;
_surfaceService = surfaceService; _surfaceService = surfaceService;
_pluginService = pluginService; _pluginService = pluginService;
_dialogService = dialogService;
_windowManager = windowManager; _windowManager = windowManager;
_settingsService = settingsService; _settingsService = settingsService;
_deviceSettingsVmFactory = deviceSettingsVmFactory; _deviceSettingsVmFactory = deviceSettingsVmFactory;
@ -65,12 +71,33 @@ namespace Artemis.UI.Screens.Settings
public List<Tuple<string, int>> TargetFrameRates { get; set; } public List<Tuple<string, int>> TargetFrameRates { get; set; }
public List<Tuple<string, double>> RenderScales { 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 List<int> SampleSizes { get; set; }
public BindableCollection<DeviceSettingsViewModel> DeviceSettingsViewModels { get; set; } public BindableCollection<DeviceSettingsViewModel> DeviceSettingsViewModels { get; set; }
public BindableCollection<PluginSettingsViewModel> Plugins { 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 public Tuple<string, double> SelectedRenderScale
{ {
get => RenderScales.FirstOrDefault(s => Math.Abs(s.Item2 - RenderScale) < 0.01); get => RenderScales.FirstOrDefault(s => Math.Abs(s.Item2 - RenderScale) < 0.01);
@ -138,8 +165,10 @@ namespace Artemis.UI.Screens.Settings
Process.Start(Constants.DataFolder); Process.Start(Constants.DataFolder);
} }
protected override void OnActivate() protected override void OnInitialActivate()
{ {
Task.Run(ApplyAutorun);
DeviceSettingsViewModels.Clear(); DeviceSettingsViewModels.Clear();
foreach (var device in _surfaceService.ActiveSurface.Devices) foreach (var device in _surfaceService.ActiveSurface.Devices)
DeviceSettingsViewModels.Add(_deviceSettingsVmFactory.Create(device)); DeviceSettingsViewModels.Add(_deviceSettingsVmFactory.Create(device));
@ -149,7 +178,34 @@ namespace Artemis.UI.Screens.Settings
foreach (var plugin in _pluginService.GetPluginsOfType<Plugin>()) foreach (var plugin in _pluginService.GetPluginsOfType<Plugin>())
Plugins.Add(new PluginSettingsViewModel(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;
}
} }
} }
} }

View File

@ -8,22 +8,26 @@ namespace Artemis.UI.Screens.Splash
{ {
public class SplashViewModel : Screen 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"; Status = "Initializing Core";
ListenToEvents();
} }
public string Status { get; set; } public string Status { get; set; }
public void ListenToEvents() public void ListenToEvents()
{ {
var pluginService = _kernel.Get<IPluginService>(); _coreService.Initialized += (sender, args) => Execute.OnUIThread(() => RequestClose());
pluginService.CopyingBuildInPlugins += (sender, args) => Status = "Updating built-in plugins"; _pluginService.CopyingBuildInPlugins += (sender, args) => Status = "Updating built-in plugins";
pluginService.PluginLoading += (sender, args) => Status = "Loading plugin: " + args.PluginInfo.Name; _pluginService.PluginLoading += (sender, args) => Status = "Loading plugin: " + args.PluginInfo.Name;
pluginService.PluginLoaded += (sender, args) => Status = "Initializing UI"; _pluginService.PluginLoaded += (sender, args) => Status = "Initializing UI";
} }
// ReSharper disable once UnusedMember.Global - Called from view // ReSharper disable once UnusedMember.Global - Called from view

View File

@ -1,5 +1,5 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Artemis.UI.ViewModels.Dialogs; using Artemis.UI.Shared.Services.Dialog;
using Stylet; using Stylet;
namespace Artemis.UI.Screens.SurfaceEditor.Dialogs namespace Artemis.UI.Screens.SurfaceEditor.Dialogs

View File

@ -1,6 +1,6 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Artemis.UI.Screens.SurfaceEditor.Visualization; using Artemis.UI.Screens.SurfaceEditor.Visualization;
using Artemis.UI.ViewModels.Dialogs; using Artemis.UI.Shared.Services.Dialog;
using Stylet; using Stylet;
namespace Artemis.UI.Screens.SurfaceEditor.Dialogs namespace Artemis.UI.Screens.SurfaceEditor.Dialogs

View File

@ -14,7 +14,7 @@ using Artemis.Core.Services.Storage.Interfaces;
using Artemis.UI.Screens.Shared; using Artemis.UI.Screens.Shared;
using Artemis.UI.Screens.SurfaceEditor.Dialogs; using Artemis.UI.Screens.SurfaceEditor.Dialogs;
using Artemis.UI.Screens.SurfaceEditor.Visualization; using Artemis.UI.Screens.SurfaceEditor.Visualization;
using Artemis.UI.Services.Interfaces; using Artemis.UI.Shared.Services.Interfaces;
using MaterialDesignThemes.Wpf; using MaterialDesignThemes.Wpf;
using Stylet; using Stylet;

View 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>

View 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;
}
}
}