mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 21:38:38 +00:00
Implemented tray icon (wip)
This commit is contained in:
parent
f02c7b6f2c
commit
327bd928da
@ -216,6 +216,14 @@
|
||||
<assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.2.15.0" newVersion="1.2.15.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Caliburn.Micro" publicKeyToken="8e5891231f2ed21f" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Caliburn.Micro.Platform" publicKeyToken="8e5891231f2ed21f" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-2.0.2.0" newVersion="2.0.2.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
|
||||
|
||||
@ -3,12 +3,12 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Artemis"
|
||||
DispatcherUnhandledException="Application_DispatcherUnhandledException"
|
||||
Startup="Application_Startup">
|
||||
ShutdownMode="OnExplicitShutdown">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary>
|
||||
<local:ArtemisBootstrapper x:Key="bootstrapper" />
|
||||
<local:ArtemisBootstrapper x:Key="ArtemisBootstrapper" />
|
||||
</ResourceDictionary>
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
|
||||
|
||||
@ -77,10 +77,18 @@
|
||||
<ApplicationIcon>logo.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Autofac, Version=3.5.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Autofac.3.5.2\lib\net40\Autofac.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Caliburn.Micro, Version=2.0.2.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Caliburn.Micro.Core.2.0.2\lib\net45\Caliburn.Micro.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Caliburn.Micro.Autofac, Version=2.0.8.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Caliburn.Micro.AutofacBootstrap.2.0.8\lib\net40\Caliburn.Micro.Autofac.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Caliburn.Micro.Platform, Version=2.0.2.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Caliburn.Micro.2.0.2\lib\net45\Caliburn.Micro.Platform.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
@ -93,6 +101,10 @@
|
||||
<HintPath>..\packages\CUE.NET.1.0.0\lib\net45\CUE.NET.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Hardcodet.Wpf.TaskbarNotification, Version=1.0.5.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Hardcodet.NotifyIcon.Wpf.1.0.5\lib\net451\Hardcodet.Wpf.TaskbarNotification.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="log4net, Version=1.2.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\log4net.2.0.5\lib\net45-full\log4net.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
@ -278,6 +290,7 @@
|
||||
<Compile Include="ViewModels\OverlaysViewModel.cs" />
|
||||
<Compile Include="Modules\Overlays\VolumeDisplay\VolumeDisplayViewModel.cs" />
|
||||
<Compile Include="ViewModels\ShellViewModel.cs" />
|
||||
<Compile Include="ViewModels\SystemTrayViewModel.cs" />
|
||||
<Compile Include="Views\EffectsView.xaml.cs">
|
||||
<DependentUpon>EffectsView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -320,6 +333,9 @@
|
||||
<Compile Include="Views\ShellView.xaml.cs">
|
||||
<DependentUpon>ShellView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\SystemTrayView.xaml.cs">
|
||||
<DependentUpon>SystemTrayView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
@ -362,6 +378,7 @@
|
||||
<AppDesigner Include="Properties\" />
|
||||
<None Include="Resources\playerWitcher.txt" />
|
||||
<None Include="Resources\artemis.txt" />
|
||||
<Resource Include="logo-disabled.ico" />
|
||||
<Content Include="Resources\playerWitcher.ws" />
|
||||
<None Include="Settings\Offsets.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
@ -437,6 +454,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\SystemTrayView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
@ -447,7 +468,9 @@
|
||||
<Content Include="RzChromaSDK64.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Resource Include="logo.ico" />
|
||||
<Resource Include="logo.ico">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Resource>
|
||||
<Content Include="Resources\gamestateConfigFileCsGo.txt" />
|
||||
<Resource Include="Resources\Entypo-license.txt" />
|
||||
<Resource Include="Resources\WindowsIcons-license.txt" />
|
||||
|
||||
@ -1,19 +1,31 @@
|
||||
using System.Windows;
|
||||
using Artemis.ViewModels;
|
||||
using Autofac;
|
||||
using Caliburn.Micro;
|
||||
using Caliburn.Micro.Autofac;
|
||||
|
||||
namespace Artemis
|
||||
{
|
||||
public class ArtemisBootstrapper : BootstrapperBase
|
||||
public class ArtemisBootstrapper : AutofacBootstrapper<SystemTrayViewModel>
|
||||
{
|
||||
public ArtemisBootstrapper()
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
protected override void ConfigureContainer(ContainerBuilder builder)
|
||||
{
|
||||
base.ConfigureContainer(builder);
|
||||
|
||||
// create a window manager instance to be used by everyone asking for one (including Caliburn.Micro)
|
||||
builder.RegisterInstance<IWindowManager>(new WindowManager());
|
||||
builder.RegisterType<SystemTrayViewModel>();
|
||||
builder.RegisterType<ShellViewModel>();
|
||||
}
|
||||
|
||||
protected override void OnStartup(object sender, StartupEventArgs e)
|
||||
{
|
||||
DisplayRootViewFor<ShellViewModel>();
|
||||
DisplayRootViewFor<SystemTrayViewModel>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -7,7 +7,7 @@ using Caliburn.Micro;
|
||||
|
||||
namespace Artemis.ViewModels
|
||||
{
|
||||
internal sealed class ShellViewModel : Conductor<IScreen>.Collection.OneActive
|
||||
public sealed class ShellViewModel : Conductor<IScreen>.Collection.OneActive
|
||||
{
|
||||
public ShellViewModel()
|
||||
{
|
||||
|
||||
61
Artemis/Artemis/ViewModels/SystemTrayViewModel.cs
Normal file
61
Artemis/Artemis/ViewModels/SystemTrayViewModel.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using System.Windows;
|
||||
using Caliburn.Micro;
|
||||
|
||||
namespace Artemis.ViewModels
|
||||
{
|
||||
public class SystemTrayViewModel : Screen
|
||||
{
|
||||
private readonly ShellViewModel _shellViewModel;
|
||||
|
||||
private readonly IWindowManager _windowManager;
|
||||
/*
|
||||
* NOTE: In this sample the system tray view-model doesn't receive any notification
|
||||
* when the other window gets closed by pressing the top right 'x'.
|
||||
* Thus no property notification is invoked, and system tray context-menu appears
|
||||
* out of sync, still allowing 'Hide' and disabling 'Show'.
|
||||
* Given the purpose of the sample - integrating Caliburn.Micro with WPF NotifyIcon -
|
||||
* sync'ing the two view-models is not of interest here.
|
||||
* */
|
||||
|
||||
public SystemTrayViewModel(IWindowManager windowManager, ShellViewModel shellViewModel)
|
||||
{
|
||||
_windowManager = windowManager;
|
||||
_shellViewModel = shellViewModel;
|
||||
}
|
||||
|
||||
public bool CanShowWindow => !_shellViewModel.IsActive;
|
||||
|
||||
public bool CanHideWindow => _shellViewModel.IsActive;
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
base.OnActivate();
|
||||
|
||||
NotifyOfPropertyChange(() => CanShowWindow);
|
||||
NotifyOfPropertyChange(() => CanHideWindow);
|
||||
}
|
||||
|
||||
public void ShowWindow()
|
||||
{
|
||||
// manually show the next window view-model
|
||||
_windowManager.ShowWindow(_shellViewModel);
|
||||
|
||||
NotifyOfPropertyChange(() => CanShowWindow);
|
||||
NotifyOfPropertyChange(() => CanHideWindow);
|
||||
}
|
||||
|
||||
public void HideWindow()
|
||||
{
|
||||
_shellViewModel.TryClose();
|
||||
|
||||
NotifyOfPropertyChange(() => CanShowWindow);
|
||||
NotifyOfPropertyChange(() => CanHideWindow);
|
||||
}
|
||||
|
||||
public void ExitApplication()
|
||||
{
|
||||
_shellViewModel.MainModel.ShutdownEffects();
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6,7 +6,6 @@
|
||||
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
|
||||
xmlns:cal="http://www.caliburnproject.org"
|
||||
mc:Ignorable="d"
|
||||
cal:Message.Attach="[Event Closing] = [Action OnClose($eventArgs)]"
|
||||
Title="Artemis" Height="670" Width="690"
|
||||
MinWidth="500" MinHeight="400"
|
||||
GlowBrush="{DynamicResource AccentColorBrush}">
|
||||
|
||||
44
Artemis/Artemis/Views/SystemTrayView.xaml
Normal file
44
Artemis/Artemis/Views/SystemTrayView.xaml
Normal file
@ -0,0 +1,44 @@
|
||||
<Window x:Class="Artemis.Views.SystemTrayView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:cal="http://www.caliburnproject.org"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
Title="SystemTrayView"
|
||||
Height="0" Width="0"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent"
|
||||
Visibility="Hidden">
|
||||
|
||||
<Window.Resources>
|
||||
|
||||
<!-- NotifyIcon and related stuff here -->
|
||||
|
||||
<!-- The taskbar context menu -->
|
||||
<!--
|
||||
The "shared" directive is needed if we reopen the sample window a few times - WPF will otherwise
|
||||
reuse the same context menu (which is a resource) again (which will have its DataContext set to the old TaskbarIcon)
|
||||
-->
|
||||
<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="Disable all effects" cal:Message.Attach="DisableEffects" />
|
||||
<MenuItem Header="Exit" cal:Message.Attach="ExitApplication" />
|
||||
</ContextMenu>
|
||||
|
||||
<!-- the application main system tray icon -->
|
||||
<tb:TaskbarIcon x:Key="SystemTrayIcon"
|
||||
IconSource="../logo.ico"
|
||||
ToolTipText="Artemis"
|
||||
cal:Message.Attach="[Event TrayMouseDoubleClick] = [Action ShowWindow]"
|
||||
ContextMenu="{StaticResource MainSysTrayMenu}" />
|
||||
|
||||
</Window.Resources>
|
||||
|
||||
<Grid>
|
||||
<TextBlock>View + ViewModel started from bootstrapper. This should not be visible.</TextBlock>
|
||||
<ContentControl Content="{StaticResource SystemTrayIcon}" />
|
||||
</Grid>
|
||||
</Window>
|
||||
27
Artemis/Artemis/Views/SystemTrayView.xaml.cs
Normal file
27
Artemis/Artemis/Views/SystemTrayView.xaml.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Artemis.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for SystemTrayView.xaml
|
||||
/// </summary>
|
||||
public partial class SystemTrayView : Window
|
||||
{
|
||||
public SystemTrayView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Artemis/Artemis/logo-disabled.ico
Normal file
BIN
Artemis/Artemis/logo-disabled.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 361 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 361 KiB After Width: | Height: | Size: 361 KiB |
@ -1,10 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Autofac" version="3.5.2" targetFramework="net452" />
|
||||
<package id="Caliburn.Micro" version="2.0.2" targetFramework="net452" />
|
||||
<package id="Caliburn.Micro.AutofacBootstrap" version="2.0.8" targetFramework="net452" />
|
||||
<package id="Caliburn.Micro.Core" version="2.0.2" targetFramework="net452" />
|
||||
<package id="Colore" version="3.0.2" targetFramework="net452" />
|
||||
<package id="CUE.NET" version="1.0.0" targetFramework="net452" />
|
||||
<package id="Extended.Wpf.Toolkit" version="2.6" targetFramework="net452" />
|
||||
<package id="Hardcodet.NotifyIcon.Wpf" version="1.0.5" targetFramework="net452" />
|
||||
<package id="log4net" version="2.0.5" targetFramework="net452" />
|
||||
<package id="MahApps.Metro" version="1.3.0-ALPHA017" targetFramework="net452" />
|
||||
<package id="MahApps.Metro.Resources" version="0.4.0.0" targetFramework="net452" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user