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