diff --git a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs index eca232ba4..80c72b0a5 100644 --- a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs +++ b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs @@ -1,9 +1,10 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.IO; using System.Linq; using Artemis.Core; +using Artemis.Core.Services; using Artemis.UI.Shared.Events; using Avalonia; using Avalonia.Controls; @@ -13,6 +14,7 @@ using Avalonia.Media; using Avalonia.Media.Imaging; using Avalonia.Threading; using RGB.NET.Core; +using DryIoc; using Color = RGB.NET.Core.Color; using Point = Avalonia.Point; using Size = Avalonia.Size; @@ -24,20 +26,19 @@ namespace Artemis.UI.Shared; /// public class DeviceVisualizer : Control { - private const double UPDATE_FRAME_RATE = 25.0; + private readonly ICoreService _coreService; private readonly List _deviceVisualizerLeds; - private readonly DispatcherTimer _timer; private Rect _deviceBounds; private RenderTargetBitmap? _deviceImage; private ArtemisDevice? _oldDevice; private bool _loading; private Color[] _previousState = Array.Empty(); - + /// public DeviceVisualizer() { - _timer = new DispatcherTimer(DispatcherPriority.Background) {Interval = TimeSpan.FromMilliseconds(1000.0 / UPDATE_FRAME_RATE)}; + _coreService = UI.Locator.Resolve(); _deviceVisualizerLeds = new List(); PointerReleased += OnPointerReleased; @@ -120,23 +121,26 @@ public class DeviceVisualizer : Control if (Device == null) return false; - Color[] state = new Color[Device.RgbDevice.Count()]; - bool difference = _previousState.Length != state.Length; + bool difference = false; + + int newLedCount = Device.RgbDevice.Count(); + if (_previousState.Length != newLedCount) + { + _previousState = new Color[newLedCount]; + difference = true; + } // Check all LEDs for differences and copy the colors to a new state int index = 0; foreach (Led led in Device.RgbDevice) { - if (!difference && !led.Color.Equals(_previousState[index])) + if (_previousState[index] != led.Color) difference = true; - state[index] = led.Color; + _previousState[index] = led.Color; index++; } - // Store the new state for next time - _previousState = state; - return difference; } @@ -156,11 +160,14 @@ public class DeviceVisualizer : Control return geometry.Bounds; } - - private void TimerOnTick(object? sender, EventArgs e) + + private void OnFrameRendered(object? sender, FrameRenderedEventArgs e) { - if (IsDirty() && ShowColors && IsVisible && Opacity > 0) - Update(); + Dispatcher.UIThread.Post(() => + { + if (ShowColors && IsVisible && Opacity > 0 && IsDirty()) + Update(); + }, DispatcherPriority.Background); } private void OnPointerReleased(object? sender, PointerReleasedEventArgs e) @@ -250,16 +257,16 @@ public class DeviceVisualizer : Control /// protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { - _timer.Start(); - _timer.Tick += TimerOnTick; + _coreService.FrameRendered += OnFrameRendered; + base.OnAttachedToLogicalTree(e); } /// protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) { - _timer.Stop(); - _timer.Tick -= TimerOnTick; + _coreService.FrameRendered -= OnFrameRendered; + base.OnDetachedFromLogicalTree(e); } diff --git a/src/Artemis.UI/Screens/Debugger/Tabs/Performance/PerformanceDebugView.axaml b/src/Artemis.UI/Screens/Debugger/Tabs/Performance/PerformanceDebugView.axaml index af60e504b..c6b2108fc 100644 --- a/src/Artemis.UI/Screens/Debugger/Tabs/Performance/PerformanceDebugView.axaml +++ b/src/Artemis.UI/Screens/Debugger/Tabs/Performance/PerformanceDebugView.axaml @@ -17,7 +17,7 @@ These performance stats are rather basic, for advanced performance profiling check out the wiki. - + JetBrains Profiling Guide diff --git a/src/Artemis.UI/Screens/Device/Tabs/DeviceLayoutTabView.axaml b/src/Artemis.UI/Screens/Device/Tabs/DeviceLayoutTabView.axaml index 877afaaa4..d73cd4e43 100644 --- a/src/Artemis.UI/Screens/Device/Tabs/DeviceLayoutTabView.axaml +++ b/src/Artemis.UI/Screens/Device/Tabs/DeviceLayoutTabView.axaml @@ -79,7 +79,7 @@ diff --git a/src/Artemis.UI/Screens/Home/HomeView.axaml b/src/Artemis.UI/Screens/Home/HomeView.axaml index 2ce2016a0..0dd0458e4 100644 --- a/src/Artemis.UI/Screens/Home/HomeView.axaml +++ b/src/Artemis.UI/Screens/Home/HomeView.axaml @@ -43,7 +43,7 @@ Under Settings > Plugins you can find your currently installed plugins, these default plugins are created by Artemis developers. We're also keeping track of a list of third-party plugins on our wiki. - + @@ -75,7 +75,7 @@ GitHub - + Website @@ -110,7 +110,7 @@ + NavigateUri="https://wiki.artemis-rgb.com/en/donating?mtm_campaign=artemis&mtm_kwd=home"> Donate diff --git a/src/Artemis.UI/Screens/ProfileEditor/Panels/MenuBar/MenuBarView.axaml b/src/Artemis.UI/Screens/ProfileEditor/Panels/MenuBar/MenuBarView.axaml index bfc4ca9c7..384a367b1 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Panels/MenuBar/MenuBarView.axaml +++ b/src/Artemis.UI/Screens/ProfileEditor/Panels/MenuBar/MenuBarView.axaml @@ -164,44 +164,44 @@ - + - + - + - + - + - + - + - + diff --git a/src/Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/Dialogs/LayerHintsDialogView.axaml b/src/Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/Dialogs/LayerHintsDialogView.axaml index 95274a66e..9500aa143 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/Dialogs/LayerHintsDialogView.axaml +++ b/src/Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/Dialogs/LayerHintsDialogView.axaml @@ -25,7 +25,7 @@ + NavigateUri="https://wiki.artemis-rgb.com/guides/user/profiles/layers/adaption-hints?mtm_campaign=artemis&mtm_kwd=profile-editor"> Learn more about adaption hints diff --git a/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/DataBinding/DataBindingView.axaml b/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/DataBinding/DataBindingView.axaml index 7ef69ab69..f655b1201 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/DataBinding/DataBindingView.axaml +++ b/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/DataBinding/DataBindingView.axaml @@ -43,7 +43,7 @@ When you enable data bindings you can no longer use keyframes or normal values for this property. Learn more diff --git a/src/Artemis.UI/Screens/Settings/Tabs/AboutTabView.axaml b/src/Artemis.UI/Screens/Settings/Tabs/AboutTabView.axaml index 6d21dc30e..7782e9f30 100644 --- a/src/Artemis.UI/Screens/Settings/Tabs/AboutTabView.axaml +++ b/src/Artemis.UI/Screens/Settings/Tabs/AboutTabView.axaml @@ -24,13 +24,13 @@ - + - + diff --git a/src/Artemis.UI/Screens/Settings/Tabs/PluginsTabView.axaml b/src/Artemis.UI/Screens/Settings/Tabs/PluginsTabView.axaml index 0627e9f73..241d8379a 100644 --- a/src/Artemis.UI/Screens/Settings/Tabs/PluginsTabView.axaml +++ b/src/Artemis.UI/Screens/Settings/Tabs/PluginsTabView.axaml @@ -17,7 +17,7 @@ - + Get more plugins diff --git a/src/Artemis.UI/Screens/Settings/Tabs/ReleasesTabView.axaml b/src/Artemis.UI/Screens/Settings/Tabs/ReleasesTabView.axaml index c3dd00ae8..54f598d32 100644 --- a/src/Artemis.UI/Screens/Settings/Tabs/ReleasesTabView.axaml +++ b/src/Artemis.UI/Screens/Settings/Tabs/ReleasesTabView.axaml @@ -28,7 +28,7 @@ TextWrapping="Wrap" Text="{CompiledBinding Channel, StringFormat='Found no releases for the \'{0}\' channel.'}"> - Learn more about channels on the wiki diff --git a/src/Artemis.UI/Screens/Sidebar/SidebarView.axaml b/src/Artemis.UI/Screens/Sidebar/SidebarView.axaml index 1b1704472..630858120 100644 --- a/src/Artemis.UI/Screens/Sidebar/SidebarView.axaml +++ b/src/Artemis.UI/Screens/Sidebar/SidebarView.axaml @@ -47,7 +47,7 @@ ToolTip.Tip="View website" ToolTip.Placement="Top" ToolTip.VerticalOffset="-5" - NavigateUri="https://artemis-rgb.com"> + NavigateUri="https://artemis-rgb.com?mtm_campaign=artemis&mtm_kwd=sidebar"> + NavigateUri="https://wiki.artemis-rgb.com?mtm_campaign=artemis&mtm_kwd=sidebar"> + NavigateUri="https://wiki.artemis-rgb.com/en/donating?mtm_campaign=artemis&mtm_kwd=sidebar"> diff --git a/src/Artemis.UI/Screens/StartupWizard/Steps/FinishStep.axaml b/src/Artemis.UI/Screens/StartupWizard/Steps/FinishStep.axaml index 6ffc4c20b..44bc5da30 100644 --- a/src/Artemis.UI/Screens/StartupWizard/Steps/FinishStep.axaml +++ b/src/Artemis.UI/Screens/StartupWizard/Steps/FinishStep.axaml @@ -33,10 +33,10 @@ Discord - + https://wiki.artemis-rgb.com/ - + https://wiki.artemis-rgb.com/en/guides/user/introduction diff --git a/src/Artemis.UI/Screens/StartupWizard/Steps/WelcomeStep.axaml b/src/Artemis.UI/Screens/StartupWizard/Steps/WelcomeStep.axaml index 5c9df872f..d9fd7883b 100644 --- a/src/Artemis.UI/Screens/StartupWizard/Steps/WelcomeStep.axaml +++ b/src/Artemis.UI/Screens/StartupWizard/Steps/WelcomeStep.axaml @@ -16,13 +16,13 @@ - + - + diff --git a/src/Artemis.UI/Screens/VisualScripting/NodeScriptWindowView.axaml b/src/Artemis.UI/Screens/VisualScripting/NodeScriptWindowView.axaml index 491fcfb1e..4bac360e3 100644 --- a/src/Artemis.UI/Screens/VisualScripting/NodeScriptWindowView.axaml +++ b/src/Artemis.UI/Screens/VisualScripting/NodeScriptWindowView.axaml @@ -116,38 +116,38 @@ - + - + - + - + - + - + - + @@ -173,7 +173,7 @@ Grid.Column="1" VerticalAlignment="Top" HorizontalAlignment="Right" - NavigateUri="https://wiki.artemis-rgb.com/en/guides/user/profiles/nodes"> + NavigateUri="https://wiki.artemis-rgb.com/en/guides/user/profiles/nodes?mtm_campaign=artemis&mtm_kwd=script-editor"> Learn more about visual scripts diff --git a/src/Artemis.VisualScripting/Nodes/Mathematics/MathExpressionNode.cs b/src/Artemis.VisualScripting/Nodes/Mathematics/MathExpressionNode.cs index 305373b97..21d938865 100644 --- a/src/Artemis.VisualScripting/Nodes/Mathematics/MathExpressionNode.cs +++ b/src/Artemis.VisualScripting/Nodes/Mathematics/MathExpressionNode.cs @@ -5,7 +5,7 @@ using NoStringEvaluating.Models.FormulaChecker; namespace Artemis.VisualScripting.Nodes.Mathematics; -[Node("Math Expression", "Outputs the result of a math expression.", "Mathematics", "https://wiki.artemis-rgb.com/en/guides/user/profiles/nodes/mathematics/math-expression", InputType = typeof(Numeric), OutputType = typeof(Numeric))] +[Node("Math Expression", "Outputs the result of a math expression.", "Mathematics", "https://wiki.artemis-rgb.com/en/guides/user/profiles/nodes/mathematics/math-expression?mtm_campaign=artemis&mtm_kwd=node-help", InputType = typeof(Numeric), OutputType = typeof(Numeric))] public class MathExpressionNode : Node { private readonly IFormulaChecker _checker;