1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Merge branch 'development'

This commit is contained in:
Robert 2021-04-29 00:36:42 +02:00
commit 5943190158
5 changed files with 33 additions and 15 deletions

View File

@ -148,8 +148,23 @@ namespace Artemis.Core.Services
foreach (ArtemisDevice device in toRemove) foreach (ArtemisDevice device in toRemove)
RemoveDevice(device); RemoveDevice(device);
deviceProvider.Initialize(RGBDeviceType.All, true); List<Exception> providerExceptions = new();
void DeviceProviderOnException(object? sender, ExceptionEventArgs e)
{
if (e.IsCritical)
providerExceptions.Add(e.Exception);
else
_logger.Warning(e.Exception, "Device provider {deviceProvider} threw non-critical exception", deviceProvider.GetType().Name);
}
deviceProvider.Exception += DeviceProviderOnException;
deviceProvider.Initialize();
Surface.Attach(deviceProvider.Devices); Surface.Attach(deviceProvider.Devices);
deviceProvider.Exception -= DeviceProviderOnException;
if (providerExceptions.Count == 1)
throw new ArtemisPluginException("RGB.NET threw exception: " + providerExceptions.First().Message, providerExceptions.First());
if (providerExceptions.Count > 1)
throw new ArtemisPluginException("RGB.NET threw multiple exceptions", new AggregateException(providerExceptions));
if (!deviceProvider.Devices.Any()) if (!deviceProvider.Devices.Any())
{ {

View File

@ -25,7 +25,7 @@ namespace Artemis.Core
internal static void Emit(LogEvent logEvent) internal static void Emit(LogEvent logEvent)
{ {
LinkedList.AddLast(logEvent); LinkedList.AddLast(logEvent);
if (LinkedList.Count > 500) while (LinkedList.Count > 500)
LinkedList.RemoveFirst(); LinkedList.RemoveFirst();
OnEventAdded(new LogEventEventArgs(logEvent)); OnEventAdded(new LogEventEventArgs(logEvent));

View File

@ -178,21 +178,17 @@ namespace Artemis.UI.Screens
if (!PinSidebar.Value) if (!PinSidebar.Value)
_sidebarViewModel.IsSidebarOpen = false; _sidebarViewModel.IsSidebarOpen = false;
// Don't do a fade when selecting a module because the editor is so bulky the animation slows things down ActiveItemReady = false;
if (!(_sidebarViewModel.SelectedItem is ModuleRootViewModel))
ActiveItemReady = false;
// Allow the menu to close, it's slower but feels more responsive, funny how that works right // Allow the menu to close, it's slower but feels more responsive, funny how that works right
Execute.PostToUIThreadAsync(async () => Execute.PostToUIThread(async () =>
{ {
if (PinSidebar.Value) await Task.Delay(400);
await Task.Delay(200);
else
await Task.Delay(400);
ActiveItem = _sidebarViewModel.SelectedItem; ActiveItem = _sidebarViewModel.SelectedItem;
await Task.Delay(200);
ActiveItemReady = true; ActiveItemReady = true;
}); });
} }
} }

View File

@ -69,8 +69,7 @@
<TreeView Grid.Row="1" <TreeView Grid.Row="1"
ItemsSource="{Binding MainDataModel.Children}" ItemsSource="{Binding MainDataModel.Children}"
HorizontalContentAlignment="Stretch" HorizontalContentAlignment="Stretch"
VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.IsVirtualizing="True">
VirtualizingStackPanel.VirtualizationMode="Recycling">
<TreeView.Resources> <TreeView.Resources>
<Style TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource MaterialDesignTreeViewItem}"> <Style TargetType="{x:Type TreeViewItem}" BasedOn="{StaticResource MaterialDesignTreeViewItem}">
<Setter Property="IsExpanded" Value="{Binding IsVisualizationExpanded, Mode=TwoWay}" /> <Setter Property="IsExpanded" Value="{Binding IsVisualizationExpanded, Mode=TwoWay}" />

View File

@ -9,6 +9,7 @@ using Artemis.Core.Services;
using Artemis.UI.Events; using Artemis.UI.Events;
using Artemis.UI.Ninject.Factories; using Artemis.UI.Ninject.Factories;
using Artemis.UI.Screens.Home; using Artemis.UI.Screens.Home;
using Artemis.UI.Screens.Modules;
using Artemis.UI.Screens.News; using Artemis.UI.Screens.News;
using Artemis.UI.Screens.Settings; using Artemis.UI.Screens.Settings;
using Artemis.UI.Screens.SurfaceEditor; using Artemis.UI.Screens.SurfaceEditor;
@ -200,12 +201,19 @@ namespace Artemis.UI.Screens.Sidebar
private void ActivateViewModel<T>() private void ActivateViewModel<T>()
{ {
if (SelectedItem != null && SelectedItem.GetType() == typeof(T))
return;
SelectedItem = (IScreen) _kernel.Get<T>(); SelectedItem = (IScreen) _kernel.Get<T>();
} }
private void ActivateModule(INavigationItem sidebarItem) private void ActivateModule(INavigationItem sidebarItem)
{ {
SelectedItem = SidebarModules.ContainsKey(sidebarItem) ? _moduleVmFactory.CreateModuleRootViewModel(SidebarModules[sidebarItem]) : null; if (!SidebarModules.ContainsKey(sidebarItem))
return;
if (SelectedItem is ModuleRootViewModel moduleRootViewModel && moduleRootViewModel.Module == SidebarModules[sidebarItem])
return;
SelectedItem = _moduleVmFactory.CreateModuleRootViewModel(SidebarModules[sidebarItem]);
} }
#region IDisposable #region IDisposable