mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 21:38:38 +00:00
Device visualizer - Fix framerate drop when processing mouse events
Profile tree - Fixed potential crash when dragging files over Artemis Module reorder - Fixed potential crash when dragging files over Artemis
This commit is contained in:
parent
c401bc6525
commit
7ffe8f3e5b
@ -3,12 +3,13 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Timers;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Threading;
|
||||
using Artemis.Core;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Shared
|
||||
{
|
||||
@ -37,7 +38,7 @@ namespace Artemis.UI.Shared
|
||||
|
||||
private readonly DrawingGroup _backingStore;
|
||||
private readonly List<DeviceVisualizerLed> _deviceVisualizerLeds;
|
||||
private readonly DispatcherTimer _timer;
|
||||
private readonly Timer _timer;
|
||||
private BitmapImage? _deviceImage;
|
||||
private ArtemisDevice? _oldDevice;
|
||||
|
||||
@ -50,8 +51,8 @@ namespace Artemis.UI.Shared
|
||||
_deviceVisualizerLeds = new List<DeviceVisualizerLed>();
|
||||
|
||||
// Run an update timer at 25 fps
|
||||
_timer = new DispatcherTimer {Interval = TimeSpan.FromMilliseconds(40)};
|
||||
_timer.Tick += TimerOnTick;
|
||||
_timer = new Timer(40);
|
||||
_timer.Elapsed += TimerOnTick;
|
||||
|
||||
Loaded += OnLoaded;
|
||||
Unloaded += OnUnloaded;
|
||||
@ -93,17 +94,7 @@ namespace Artemis.UI.Shared
|
||||
/// </param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
_timer.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
if (disposing) _timer.Stop();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -190,7 +181,7 @@ namespace Artemis.UI.Shared
|
||||
|
||||
if (_oldDevice != null)
|
||||
{
|
||||
if (Device != null)
|
||||
if (Device != null)
|
||||
Device.RgbDevice.PropertyChanged -= DevicePropertyChanged;
|
||||
_oldDevice = null;
|
||||
}
|
||||
@ -203,8 +194,11 @@ namespace Artemis.UI.Shared
|
||||
|
||||
private void TimerOnTick(object? sender, EventArgs e)
|
||||
{
|
||||
if (ShowColors && Visibility == Visibility.Visible)
|
||||
Render();
|
||||
Execute.PostToUIThread(() =>
|
||||
{
|
||||
if (ShowColors && Visibility == Visibility.Visible)
|
||||
Render();
|
||||
});
|
||||
}
|
||||
|
||||
private void UpdateTransform()
|
||||
@ -295,17 +289,20 @@ namespace Artemis.UI.Shared
|
||||
DrawingContext drawingContext = _backingStore.Open();
|
||||
|
||||
if (HighlightedLeds != null && HighlightedLeds.Any())
|
||||
{
|
||||
foreach (DeviceVisualizerLed deviceVisualizerLed in _deviceVisualizerLeds)
|
||||
deviceVisualizerLed.RenderColor(drawingContext, !HighlightedLeds.Contains(deviceVisualizerLed.Led));
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (DeviceVisualizerLed deviceVisualizerLed in _deviceVisualizerLeds)
|
||||
deviceVisualizerLed.RenderColor(drawingContext, false);
|
||||
}
|
||||
|
||||
drawingContext.Close();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,6 @@
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using Artemis.Core;
|
||||
using Artemis.Storage.Entities.Profile;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem;
|
||||
using Artemis.UI.Shared;
|
||||
@ -74,8 +73,8 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree
|
||||
|
||||
private static DragDropType GetDragDropType(IDropInfo dropInfo)
|
||||
{
|
||||
TreeItemViewModel source = (TreeItemViewModel)dropInfo.Data;
|
||||
TreeItemViewModel target = (TreeItemViewModel)dropInfo.TargetItem;
|
||||
if (!(dropInfo.Data is TreeItemViewModel source) || !(dropInfo.TargetItem is TreeItemViewModel target))
|
||||
return DragDropType.None;
|
||||
if (source == target)
|
||||
return DragDropType.None;
|
||||
|
||||
@ -121,14 +120,16 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree
|
||||
|
||||
public void Drop(IDropInfo dropInfo)
|
||||
{
|
||||
TreeItemViewModel source = (TreeItemViewModel)dropInfo.Data;
|
||||
TreeItemViewModel target = (TreeItemViewModel)dropInfo.TargetItem;
|
||||
if (!(dropInfo.Data is TreeItemViewModel source) || !(dropInfo.TargetItem is TreeItemViewModel target))
|
||||
return;
|
||||
if (source == target)
|
||||
return;
|
||||
|
||||
DragDropType dragDropType = GetDragDropType(dropInfo);
|
||||
switch (dragDropType)
|
||||
{
|
||||
case DragDropType.Add:
|
||||
((TreeItemViewModel)source.Parent).RemoveExistingElement(source);
|
||||
((TreeItemViewModel) source.Parent).RemoveExistingElement(source);
|
||||
target.AddExistingElement(source);
|
||||
break;
|
||||
case DragDropType.InsertBefore:
|
||||
|
||||
@ -53,8 +53,11 @@ namespace Artemis.UI.Screens.Settings.Tabs.Modules
|
||||
if (dropInfo.TargetItem == dropInfo.Data)
|
||||
return;
|
||||
|
||||
ModuleOrderModuleViewModel viewModel = (ModuleOrderModuleViewModel) dropInfo.Data;
|
||||
BindableCollection<ModuleOrderModuleViewModel> targetCollection = (BindableCollection<ModuleOrderModuleViewModel>) dropInfo.TargetCollection;
|
||||
if (!(dropInfo.Data is ModuleOrderModuleViewModel viewModel))
|
||||
return;
|
||||
if (!(dropInfo.TargetCollection is BindableCollection<ModuleOrderModuleViewModel> targetCollection))
|
||||
return;
|
||||
|
||||
int insertIndex = dropInfo.InsertIndex;
|
||||
|
||||
ModulePriorityCategory category;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user