diff --git a/src/Artemis.Core/Models/Surface/Layout/ArtemisLayout.cs b/src/Artemis.Core/Models/Surface/Layout/ArtemisLayout.cs index 5376779fa..130b8cba7 100644 --- a/src/Artemis.Core/Models/Surface/Layout/ArtemisLayout.cs +++ b/src/Artemis.Core/Models/Surface/Layout/ArtemisLayout.cs @@ -66,6 +66,44 @@ namespace Artemis.Core /// public LayoutCustomDeviceData LayoutCustomDeviceData { get; private set; } = null!; + /// + /// Applies the layout to the provided device + /// + public void ApplyTo(IRGBDevice device, bool createMissingLeds = false, bool removeExcessiveLeds = false) + { + device.Size = new Size(MathF.Round(RgbLayout.Width), MathF.Round(RgbLayout.Height)); + device.DeviceInfo.LayoutMetadata = RgbLayout.CustomData; + + HashSet ledIds = new(); + foreach (ILedLayout layoutLed in RgbLayout.Leds) + { + if (Enum.TryParse(layoutLed.Id, true, out LedId ledId)) + { + ledIds.Add(ledId); + + Led? led = device[ledId]; + if (led == null && createMissingLeds) + led = device.AddLed(ledId, new Point(), new Size()); + + if (led != null) + { + led.Location = new Point(MathF.Round(layoutLed.X), MathF.Round(layoutLed.Y)); + led.Size = new Size(MathF.Round(layoutLed.Width), MathF.Round(layoutLed.Height)); + led.Shape = layoutLed.Shape; + led.ShapeData = layoutLed.ShapeData; + led.LayoutMetadata = layoutLed.CustomData; + } + } + } + + if (removeExcessiveLeds) + { + List ledsToRemove = device.Select(led => led.Id).Where(id => !ledIds.Contains(id)).ToList(); + foreach (LedId led in ledsToRemove) + device.RemoveLed(led); + } + } + internal void ApplyDevice(ArtemisDevice artemisDevice) { Device = artemisDevice; @@ -108,44 +146,6 @@ namespace Artemis.Core else Image = null; } - - /// - /// Applies the layout to the provided device - /// - public void ApplyTo(IRGBDevice device, bool createMissingLeds = false, bool removeExcessiveLeds = false) - { - device.Size = new Size(MathF.Round(RgbLayout.Width), MathF.Round(RgbLayout.Height)); - device.DeviceInfo.LayoutMetadata = RgbLayout.CustomData; - - HashSet ledIds = new(); - foreach (ILedLayout layoutLed in RgbLayout.Leds) - { - if (Enum.TryParse(layoutLed.Id, true, out LedId ledId)) - { - ledIds.Add(ledId); - - Led? led = device[ledId]; - if ((led == null) && createMissingLeds) - led = device.AddLed(ledId, new Point(), new Size()); - - if (led != null) - { - led.Location = new Point(MathF.Round(layoutLed.X), MathF.Round(layoutLed.Y)); - led.Size = new Size(MathF.Round(layoutLed.Width), MathF.Round(layoutLed.Height)); - led.Shape = layoutLed.Shape; - led.ShapeData = layoutLed.ShapeData; - led.LayoutMetadata = layoutLed.CustomData; - } - } - } - - if (removeExcessiveLeds) - { - List ledsToRemove = device.Select(led => led.Id).Where(id => !ledIds.Contains(id)).ToList(); - foreach (LedId led in ledsToRemove) - device.RemoveLed(led); - } - } } /// diff --git a/src/Artemis.UI/Artemis.UI.csproj b/src/Artemis.UI/Artemis.UI.csproj index 114e65702..ce31292e3 100644 --- a/src/Artemis.UI/Artemis.UI.csproj +++ b/src/Artemis.UI/Artemis.UI.csproj @@ -85,6 +85,7 @@ + @@ -313,6 +314,7 @@ + diff --git a/src/Artemis.UI/Resources/Images/Logo/bow-black.ico b/src/Artemis.UI/Resources/Images/Logo/bow-black.ico new file mode 100644 index 000000000..9649063ce Binary files /dev/null and b/src/Artemis.UI/Resources/Images/Logo/bow-black.ico differ diff --git a/src/Artemis.UI/Screens/TrayView.xaml b/src/Artemis.UI/Screens/TrayView.xaml index 20863ad1f..de13735d3 100644 --- a/src/Artemis.UI/Screens/TrayView.xaml +++ b/src/Artemis.UI/Screens/TrayView.xaml @@ -7,7 +7,7 @@ xmlns:s="https://github.com/canton7/Stylet" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" mc:Ignorable="d"> - _icon; + set => SetAndNotify(ref _icon, value); + } + public void TrayActivateSidebarItem(string sidebarItem) { TrayBringToForeground(); @@ -168,9 +177,15 @@ namespace Artemis.UI.Screens private void ApplyWindowsTheme(ThemeWatcher.WindowsTheme windowsTheme) { + Execute.PostToUIThread(() => + { + Icon = windowsTheme == ThemeWatcher.WindowsTheme.Dark + ? new BitmapImage(new Uri("pack://application:,,,/Artemis.UI;component/Resources/Images/Logo/bow-white.ico")) + : new BitmapImage(new Uri("pack://application:,,,/Artemis.UI;component/Resources/Images/Logo/bow-black.ico")); + }); + if (_colorScheme.Value != ApplicationColorScheme.Automatic) return; - if (windowsTheme == ThemeWatcher.WindowsTheme.Dark) ChangeMaterialColors(ApplicationColorScheme.Dark); else