mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Profile editor - Performance improvements
This commit is contained in:
parent
447112729d
commit
1d789bf23c
@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Artemis.Core
|
||||
{
|
||||
internal class PercentageOfModifierType : DataBindingModifierType
|
||||
{
|
||||
public PercentageOfModifierType()
|
||||
{
|
||||
PreferredParameterType = typeof(float);
|
||||
}
|
||||
|
||||
public override IReadOnlyCollection<Type> CompatibleTypes => Constants.NumberTypes;
|
||||
|
||||
public override string Description => "Percentage of";
|
||||
public override string Icon => "Percent";
|
||||
|
||||
public override object Apply(object currentValue, object parameterValue)
|
||||
{
|
||||
var parameter = Convert.ToSingle(parameterValue);
|
||||
// Ye ye none of that
|
||||
if (parameter == 0f)
|
||||
return 100f;
|
||||
|
||||
return 100f / Convert.ToSingle(parameterValue) * Convert.ToSingle(currentValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -42,6 +42,7 @@ namespace Artemis.Core.Services
|
||||
private void RegisterBuiltInModifiers()
|
||||
{
|
||||
RegisterModifierType(Constants.CorePluginInfo, new MultiplicationModifierType());
|
||||
RegisterModifierType(Constants.CorePluginInfo, new PercentageOfModifierType());
|
||||
RegisterModifierType(Constants.CorePluginInfo, new DivideModifierType());
|
||||
RegisterModifierType(Constants.CorePluginInfo, new FloorModifierType());
|
||||
}
|
||||
|
||||
@ -5,9 +5,10 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:modules="clr-namespace:Artemis.UI.Screens.Modules"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance module:ModuleRootViewModel}">
|
||||
d:DataContext="{d:DesignInstance modules:ModuleRootViewModel}">
|
||||
|
||||
<TabControl Margin="0 -1 0 0"
|
||||
ItemsSource="{Binding Items}"
|
||||
@ -17,7 +18,7 @@
|
||||
<TabControl.ContentTemplate>
|
||||
<DataTemplate>
|
||||
<materialDesign:TransitioningContent OpeningEffect="{materialDesign:TransitionEffect FadeIn}">
|
||||
<ContentControl s:View.Model="{Binding}" TextElement.Foreground="{DynamicResource MaterialDesignBody}" />
|
||||
<ContentControl s:View.Model="{Binding IsAsync=True}" TextElement.Foreground="{DynamicResource MaterialDesignBody}" />
|
||||
</materialDesign:TransitioningContent>
|
||||
</DataTemplate>
|
||||
</TabControl.ContentTemplate>
|
||||
|
||||
@ -102,7 +102,7 @@
|
||||
<ContentControl s:View.Model="{Binding TreeGroupViewModel}" />
|
||||
</HierarchicalDataTemplate>
|
||||
<DataTemplate DataType="{x:Type local:LayerPropertyViewModel}">
|
||||
<ContentControl s:View.Model="{Binding TreePropertyViewModel}" dd:DragDrop.DragSourceIgnore="True" />
|
||||
<ContentControl s:View.Model="{Binding TreePropertyViewModel, IsAsync=True}" dd:DragDrop.DragSourceIgnore="True" />
|
||||
</DataTemplate>
|
||||
</TreeView.Resources>
|
||||
</TreeView>
|
||||
|
||||
@ -86,7 +86,7 @@
|
||||
|
||||
<!-- Design area -->
|
||||
<materialDesign:Card Grid.Row="1" materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch">
|
||||
<ContentControl s:View.Model="{Binding ProfileViewModel}" />
|
||||
<ContentControl s:View.Model="{Binding ProfileViewModel, IsAsync=True}" />
|
||||
</materialDesign:Card>
|
||||
|
||||
<!-- Bottom panels resize -->
|
||||
@ -96,7 +96,7 @@
|
||||
<Grid Grid.Row="3">
|
||||
<!-- Layer elements -->
|
||||
<materialDesign:Card Grid.Column="0" materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch">
|
||||
<ContentControl s:View.Model="{Binding LayerPropertiesViewModel}" />
|
||||
<ContentControl s:View.Model="{Binding LayerPropertiesViewModel, IsAsync=True}" />
|
||||
</materialDesign:Card>
|
||||
</Grid>
|
||||
</Grid>
|
||||
@ -179,7 +179,7 @@
|
||||
|
||||
<!-- Profile elements -->
|
||||
<materialDesign:Card Grid.Row="1" materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch">
|
||||
<ContentControl s:View.Model="{Binding ProfileTreeViewModel}" Margin="0,-1,-0.2,1" />
|
||||
<ContentControl s:View.Model="{Binding ProfileTreeViewModel, IsAsync=True}" Margin="0,-1,-0.2,1" />
|
||||
</materialDesign:Card>
|
||||
|
||||
<!-- Conditions resize -->
|
||||
@ -187,7 +187,7 @@
|
||||
|
||||
<!-- Display conditions -->
|
||||
<materialDesign:Card Grid.Row="3" materialDesign:ShadowAssist.ShadowDepth="Depth1" VerticalAlignment="Stretch">
|
||||
<ContentControl s:View.Model="{Binding DisplayConditionsViewModel}" />
|
||||
<ContentControl s:View.Model="{Binding DisplayConditionsViewModel, IsAsync=True}" />
|
||||
</materialDesign:Card>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
@ -10,36 +10,6 @@
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="510.9" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance {x:Type visualization:ProfileViewModel}}">
|
||||
<UserControl.Resources>
|
||||
<Style TargetType="Grid" x:Key="InitializingFade">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsInitializing}" Value="False">
|
||||
<DataTrigger.EnterActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="1.0" To="0.0" Duration="0:0:0.5">
|
||||
<DoubleAnimation.EasingFunction>
|
||||
<QuadraticEase EasingMode="EaseInOut" />
|
||||
</DoubleAnimation.EasingFunction>
|
||||
</DoubleAnimation>
|
||||
<ObjectAnimationUsingKeyFrames BeginTime="0:0:0.5" Storyboard.TargetProperty="Visibility">
|
||||
<DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Hidden}" />
|
||||
</ObjectAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</DataTrigger.EnterActions>
|
||||
<DataTrigger.ExitActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="0.0" To="1.0" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</DataTrigger.ExitActions>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
@ -186,16 +156,6 @@
|
||||
<materialDesign:PackIcon Kind="ImageFilterCenterFocus" Height="24" Width="24" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Loading indicator -->
|
||||
<Grid Background="{StaticResource MaterialDesignPaper}" Style="{StaticResource InitializingFade}" d:IsHidden="True">
|
||||
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock FontSize="16" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
Initializing LED visualization...
|
||||
</TextBlock>
|
||||
<ProgressBar Style="{StaticResource MaterialDesignCircularProgressBar}" Value="0" IsIndeterminate="True" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
<DataTrigger.ExitActions>
|
||||
<BeginStoryboard>
|
||||
<Storyboard>
|
||||
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="0.0" To="1.0" Duration="0:0:0.4" />
|
||||
<DoubleAnimation Storyboard.TargetProperty="Opacity" From="0.0" To="1.0" Duration="0:0:0.25" />
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</DataTrigger.ExitActions>
|
||||
|
||||
@ -8,6 +8,7 @@ using System.Windows.Input;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Events;
|
||||
using Artemis.UI.Screens.Modules;
|
||||
using Artemis.UI.Screens.Settings.Tabs.General;
|
||||
using Artemis.UI.Screens.Sidebar;
|
||||
using Artemis.UI.Services;
|
||||
@ -139,8 +140,10 @@ namespace Artemis.UI.Screens
|
||||
if (e.PropertyName == nameof(SidebarViewModel.SelectedItem) && ActiveItem != SidebarViewModel.SelectedItem)
|
||||
{
|
||||
SidebarViewModel.IsSidebarOpen = false;
|
||||
ActiveItemReady = false;
|
||||
|
||||
// Don't do a fade when selecting a module because the editor is so bulky the animation slows things down
|
||||
if (!(SidebarViewModel.SelectedItem is ModuleRootViewModel))
|
||||
ActiveItemReady = false;
|
||||
|
||||
// Allow the menu to close, it's slower but feels more responsive, funny how that works right
|
||||
Execute.PostToUIThreadAsync(async () =>
|
||||
{
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
DisplayMemberPath="DisplayName">
|
||||
<TabControl.ContentTemplate>
|
||||
<DataTemplate>
|
||||
<ContentControl s:View.Model="{Binding}"
|
||||
<ContentControl s:View.Model="{Binding IsAsync=True}"
|
||||
VerticalContentAlignment="Stretch"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
IsTabStop="False"
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="0 12 0 0">
|
||||
<DockPanel Margin="15" MaxWidth="1230" HorizontalAlignment="Center">
|
||||
<TextBlock DockPanel.Dock="Top">Below you view and manage the devices that were detected by Artemis</TextBlock>
|
||||
<ItemsControl ItemsSource="{Binding DeviceSettingsViewModels}">
|
||||
<ItemsControl ItemsSource="{Binding Items}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel />
|
||||
@ -19,7 +19,7 @@
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ContentControl s:View.Model="{Binding}" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top" />
|
||||
<ContentControl s:View.Model="{Binding IsAsync=True}" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top" />
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
@ -6,7 +6,7 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.Settings.Tabs.Devices
|
||||
{
|
||||
public class DeviceSettingsTabViewModel : Screen
|
||||
public class DeviceSettingsTabViewModel : Conductor<DeviceSettingsViewModel>.Collection.AllActive
|
||||
{
|
||||
private readonly ISettingsVmFactory _settingsVmFactory;
|
||||
private readonly ISurfaceService _surfaceService;
|
||||
@ -18,25 +18,17 @@ namespace Artemis.UI.Screens.Settings.Tabs.Devices
|
||||
|
||||
_surfaceService = surfaceService;
|
||||
_settingsVmFactory = settingsVmFactory;
|
||||
|
||||
DeviceSettingsViewModels = new BindableCollection<DeviceSettingsViewModel>();
|
||||
}
|
||||
|
||||
public BindableCollection<DeviceSettingsViewModel> DeviceSettingsViewModels
|
||||
{
|
||||
get => _deviceSettingsViewModels;
|
||||
set => SetAndNotify(ref _deviceSettingsViewModels, value);
|
||||
}
|
||||
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
// Take it off the UI thread to avoid freezing on tab change
|
||||
Task.Run(() =>
|
||||
{
|
||||
DeviceSettingsViewModels.Clear();
|
||||
Items.Clear();
|
||||
var instances = _surfaceService.ActiveSurface.Devices.Select(d => _settingsVmFactory.CreateDeviceSettingsViewModel(d)).ToList();
|
||||
foreach (var deviceSettingsViewModel in instances)
|
||||
DeviceSettingsViewModels.Add(deviceSettingsViewModel);
|
||||
Items.Add(deviceSettingsViewModel);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,13 +5,14 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Artemis.UI.Screens.Settings.Tabs.Plugins"
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance local:PluginSettingsTabViewModel}">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="0 12 0 0">
|
||||
<DockPanel Margin="15" MaxWidth="1230" HorizontalAlignment="Center">
|
||||
<TextBlock DockPanel.Dock="Top">The list below shows all loaded plugins. If you're missing something, view your logs folder.</TextBlock>
|
||||
<ItemsControl ItemsSource="{Binding Plugins}">
|
||||
<ItemsControl ItemsSource="{Binding Items}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel />
|
||||
@ -19,7 +20,7 @@
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ContentControl s:View.Model="{Binding}" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top" />
|
||||
<ContentControl s:View.Model="{Binding IsAsync=True}" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top" />
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
|
||||
@ -6,7 +6,7 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
{
|
||||
public class PluginSettingsTabViewModel : Screen
|
||||
public class PluginSettingsTabViewModel : Conductor<PluginSettingsViewModel>.Collection.AllActive
|
||||
{
|
||||
private readonly IPluginService _pluginService;
|
||||
private readonly ISettingsVmFactory _settingsVmFactory;
|
||||
@ -18,26 +18,15 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
|
||||
_pluginService = pluginService;
|
||||
_settingsVmFactory = settingsVmFactory;
|
||||
|
||||
Plugins = new BindableCollection<PluginSettingsViewModel>();
|
||||
}
|
||||
|
||||
public BindableCollection<PluginSettingsViewModel> Plugins
|
||||
{
|
||||
get => _plugins;
|
||||
set => SetAndNotify(ref _plugins, value);
|
||||
}
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
// Take it off the UI thread to avoid freezing on tab change
|
||||
Task.Run(() =>
|
||||
{
|
||||
Plugins.Clear();
|
||||
var instances = _pluginService.GetAllPluginInfo().Select(p => _settingsVmFactory.CreatePluginSettingsViewModel(p.Instance)).ToList();
|
||||
foreach (var pluginSettingsViewModel in instances)
|
||||
Plugins.Add(pluginSettingsViewModel);
|
||||
});
|
||||
Items.Clear();
|
||||
var instances = _pluginService.GetAllPluginInfo().Select(p => _settingsVmFactory.CreatePluginSettingsViewModel(p.Instance)).ToList();
|
||||
foreach (var pluginSettingsViewModel in instances)
|
||||
Items.Add(pluginSettingsViewModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user