mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Profile editor - Fixed new profile elements not always appearing
UI - Fixed all the memory leaks I could find, closing the UI now frees a lot of RAM Noise brush - Decreased memory usage by removing unused 4D noise Layout editor - Fixed device properties not always applying
This commit is contained in:
1 parent
8cd9c8a5f8
commit
dab11cb3e7
25 files changed
+336
-381
No files matched your search
@@ -3,15 +3,12 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Threading;
|
||||
using Artemis.Core.Models.Surface;
|
||||
using RGB.NET.Core;
|
||||
using Size = System.Windows.Size;
|
||||
|
||||
namespace Artemis.UI.Shared.Controls
|
||||
{
|
||||
@@ -28,9 +25,9 @@ namespace Artemis.UI.Shared.Controls
|
||||
|
||||
private readonly DrawingGroup _backingStore;
|
||||
private readonly List<DeviceVisualizerLed> _deviceVisualizerLeds;
|
||||
private readonly DispatcherTimer _timer;
|
||||
private BitmapImage _deviceImage;
|
||||
private ArtemisDevice _oldDevice;
|
||||
private readonly DispatcherTimer _timer;
|
||||
|
||||
public DeviceVisualizer()
|
||||
{
|
||||
@@ -41,8 +38,8 @@ namespace Artemis.UI.Shared.Controls
|
||||
_timer = new DispatcherTimer {Interval = TimeSpan.FromMilliseconds(40)};
|
||||
_timer.Tick += TimerOnTick;
|
||||
|
||||
Loaded += (sender, args) => _timer.Start();
|
||||
Unloaded += (sender, args) => _timer.Stop();
|
||||
Loaded += OnLoaded;
|
||||
Unloaded += OnUnloaded;
|
||||
}
|
||||
|
||||
public ArtemisDevice Device
|
||||
@@ -117,12 +114,28 @@ namespace Artemis.UI.Shared.Controls
|
||||
return rotationRect.Size;
|
||||
}
|
||||
|
||||
private void OnUnloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_timer.Stop();
|
||||
|
||||
if (_oldDevice != null)
|
||||
{
|
||||
Device.RgbDevice.PropertyChanged -= DevicePropertyChanged;
|
||||
_oldDevice = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_timer.Start();
|
||||
}
|
||||
|
||||
private void TimerOnTick(object sender, EventArgs e)
|
||||
{
|
||||
if (ShowColors && Visibility == Visibility.Visible)
|
||||
Render();
|
||||
}
|
||||
|
||||
|
||||
private void UpdateTransform()
|
||||
{
|
||||
InvalidateVisual();
|
||||
@@ -204,7 +217,7 @@ namespace Artemis.UI.Shared.Controls
|
||||
if (e.PropertyName == nameof(Device.RgbDevice.Scale) || e.PropertyName == nameof(Device.RgbDevice.Rotation))
|
||||
UpdateTransform();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void Render()
|
||||
{
|
||||
|
||||
@@ -23,8 +23,9 @@ namespace Artemis.UI.Shared.Services
|
||||
private readonly ILogger _logger;
|
||||
private readonly List<PropertyInputRegistration> _registeredPropertyEditors;
|
||||
private TimeSpan _currentTime;
|
||||
private TimeSpan _lastUpdateTime;
|
||||
private int _pixelsPerSecond;
|
||||
private object _selectedProfileLock = new object();
|
||||
private object _selectedProfileElementLock = new object();
|
||||
|
||||
public ProfileEditorService(ICoreService coreService, IProfileService profileService, IKernel kernel, ILogger logger)
|
||||
{
|
||||
@@ -69,43 +70,55 @@ namespace Artemis.UI.Shared.Services
|
||||
|
||||
public void ChangeSelectedProfile(Profile profile)
|
||||
{
|
||||
if (SelectedProfile == profile)
|
||||
return;
|
||||
lock (_selectedProfileLock)
|
||||
{
|
||||
if (SelectedProfile == profile)
|
||||
return;
|
||||
|
||||
_logger.Verbose("ChangeSelectedProfile {profile}", profile);
|
||||
ChangeSelectedProfileElement(null);
|
||||
_logger.Verbose("ChangeSelectedProfile {profile}", profile);
|
||||
ChangeSelectedProfileElement(null);
|
||||
|
||||
var profileElementEvent = new ProfileEventArgs(profile, SelectedProfile);
|
||||
SelectedProfile = profile;
|
||||
UpdateProfilePreview();
|
||||
OnSelectedProfileChanged(profileElementEvent);
|
||||
var profileElementEvent = new ProfileEventArgs(profile, SelectedProfile);
|
||||
SelectedProfile = profile;
|
||||
UpdateProfilePreview();
|
||||
OnSelectedProfileChanged(profileElementEvent);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateSelectedProfile()
|
||||
{
|
||||
_logger.Verbose("UpdateSelectedProfile {profile}", SelectedProfile);
|
||||
_profileService.UpdateProfile(SelectedProfile, true);
|
||||
UpdateProfilePreview();
|
||||
OnSelectedProfileChanged(new ProfileEventArgs(SelectedProfile));
|
||||
lock (_selectedProfileLock)
|
||||
{
|
||||
_logger.Verbose("UpdateSelectedProfile {profile}", SelectedProfile);
|
||||
_profileService.UpdateProfile(SelectedProfile, true);
|
||||
UpdateProfilePreview();
|
||||
OnSelectedProfileChanged(new ProfileEventArgs(SelectedProfile));
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeSelectedProfileElement(RenderProfileElement profileElement)
|
||||
{
|
||||
if (SelectedProfileElement == profileElement)
|
||||
return;
|
||||
lock (_selectedProfileElementLock)
|
||||
{
|
||||
if (SelectedProfileElement == profileElement)
|
||||
return;
|
||||
|
||||
_logger.Verbose("ChangeSelectedProfileElement {profile}", profileElement);
|
||||
var profileElementEvent = new RenderProfileElementEventArgs(profileElement, SelectedProfileElement);
|
||||
SelectedProfileElement = profileElement;
|
||||
OnSelectedProfileElementChanged(profileElementEvent);
|
||||
_logger.Verbose("ChangeSelectedProfileElement {profile}", profileElement);
|
||||
var profileElementEvent = new RenderProfileElementEventArgs(profileElement, SelectedProfileElement);
|
||||
SelectedProfileElement = profileElement;
|
||||
OnSelectedProfileElementChanged(profileElementEvent);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateSelectedProfileElement()
|
||||
{
|
||||
_logger.Verbose("UpdateSelectedProfileElement {profile}", SelectedProfileElement);
|
||||
_profileService.UpdateProfile(SelectedProfile, true);
|
||||
UpdateProfilePreview();
|
||||
OnSelectedProfileElementUpdated(new RenderProfileElementEventArgs(SelectedProfileElement));
|
||||
lock (_selectedProfileElementLock)
|
||||
{
|
||||
_logger.Verbose("UpdateSelectedProfileElement {profile}", SelectedProfileElement);
|
||||
_profileService.UpdateProfile(SelectedProfile, true);
|
||||
UpdateProfilePreview();
|
||||
OnSelectedProfileElementUpdated(new RenderProfileElementEventArgs(SelectedProfileElement));
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateProfilePreview()
|
||||
@@ -114,12 +127,11 @@ namespace Artemis.UI.Shared.Services
|
||||
return;
|
||||
|
||||
// Stick to the main segment for any element that is not currently selected
|
||||
foreach (var folder in SelectedProfile.GetAllFolders())
|
||||
foreach (var folder in SelectedProfile.GetAllFolders())
|
||||
folder.OverrideProgress(CurrentTime, folder != SelectedProfileElement);
|
||||
foreach (var layer in SelectedProfile.GetAllLayers())
|
||||
foreach (var layer in SelectedProfile.GetAllLayers())
|
||||
layer.OverrideProgress(CurrentTime, layer != SelectedProfileElement);
|
||||
|
||||
_lastUpdateTime = CurrentTime;
|
||||
OnProfilePreviewUpdated();
|
||||
}
|
||||
|
||||
@@ -225,7 +237,7 @@ namespace Artemis.UI.Shared.Services
|
||||
{
|
||||
// Get all visible keyframes
|
||||
var keyframes = SelectedProfileElement.GetAllKeyframes()
|
||||
.Where(k => SelectedProfileElement.IsPropertyGroupExpanded(k.BaseLayerProperty.Parent))
|
||||
.Where(k => k != excludedKeyframe && SelectedProfileElement.IsPropertyGroupExpanded(k.BaseLayerProperty.Parent))
|
||||
.ToList();
|
||||
|
||||
// Find the closest keyframe
|
||||
|
||||
Reference in new issue
Block a user