mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Data bindings UI - Update evaluation status of conditional data bindings
Profiles - Don't fail to activate a module when its last profile fails to load
This commit is contained in:
parent
12227b3530
commit
1a7a7e0582
@ -20,14 +20,14 @@ namespace Artemis.Core.JsonConverters
|
||||
{
|
||||
JValue? jsonValue = serializer.Deserialize<JValue>(reader);
|
||||
if (jsonValue == null)
|
||||
throw new FormatException();
|
||||
throw new JsonReaderException("Failed to deserialize forgiving int value");
|
||||
|
||||
if (jsonValue.Type == JTokenType.Float)
|
||||
return (int) Math.Round(jsonValue.Value<double>());
|
||||
if (jsonValue.Type == JTokenType.Integer)
|
||||
return jsonValue.Value<int>();
|
||||
|
||||
throw new FormatException();
|
||||
throw new JsonReaderException("Failed to deserialize forgiving int value");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -47,15 +47,20 @@ namespace Artemis.Core.Services
|
||||
{
|
||||
module.Activate(false);
|
||||
|
||||
// If this is a profile module, activate the last active profile after module activation
|
||||
if (module is ProfileModule profileModule)
|
||||
await _profileService.ActivateLastProfileAnimated(profileModule);
|
||||
try
|
||||
{
|
||||
// If this is a profile module, activate the last active profile after module activation
|
||||
if (module is ProfileModule profileModule)
|
||||
await _profileService.ActivateLastProfileAnimated(profileModule);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.Warning(e, $"Failed to activate last profile on module {module}");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.Error(new ArtemisPluginFeatureException(
|
||||
module, "Failed to activate module and last profile.", e), "Failed to activate module and last profile"
|
||||
);
|
||||
_logger.Error(new ArtemisPluginFeatureException(module, "Failed to activate module.", e), "Failed to activate module");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<Grid Margin="5 10 0 0">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
@ -26,7 +26,8 @@
|
||||
Background="{StaticResource PrimaryHueMidBrush}"
|
||||
BorderBrush="{StaticResource PrimaryHueMidBrush}"
|
||||
HorizontalAlignment="Right"
|
||||
Command="{s:Action AddCondition}">
|
||||
Command="{s:Action AddCondition}"
|
||||
Margin="0 5">
|
||||
ADD CONDITION
|
||||
</Button>
|
||||
|
||||
@ -38,7 +39,7 @@
|
||||
dd:DragDrop.UseDefaultDragAdorner="True"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
VirtualizingPanel.ScrollUnit="Pixel"
|
||||
Margin="0 5 0 0">
|
||||
Margin="-10 0 -10 -5">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ContentControl s:View.Model="{Binding}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" IsTabStop="False" />
|
||||
|
||||
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Extensions;
|
||||
using Artemis.UI.Ninject.Factories;
|
||||
using Artemis.UI.Shared.Services;
|
||||
@ -10,16 +11,20 @@ using Stylet;
|
||||
|
||||
namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.ConditionalDataBinding
|
||||
{
|
||||
public sealed class ConditionalDataBindingModeViewModel<TLayerProperty, TProperty> : Conductor<DataBindingConditionViewModel<TLayerProperty, TProperty>>.Collection.AllActive, IDataBindingModeViewModel
|
||||
public sealed class ConditionalDataBindingModeViewModel<TLayerProperty, TProperty> : Conductor<DataBindingConditionViewModel<TLayerProperty, TProperty>>.Collection.AllActive,
|
||||
IDataBindingModeViewModel
|
||||
{
|
||||
private readonly IDataBindingsVmFactory _dataBindingsVmFactory;
|
||||
private readonly ICoreService _coreService;
|
||||
private readonly IProfileEditorService _profileEditorService;
|
||||
private bool _updating;
|
||||
|
||||
public ConditionalDataBindingModeViewModel(ConditionalDataBinding<TLayerProperty, TProperty> conditionalDataBinding,
|
||||
ICoreService coreService,
|
||||
IProfileEditorService profileEditorService,
|
||||
IDataBindingsVmFactory dataBindingsVmFactory)
|
||||
{
|
||||
_coreService = coreService;
|
||||
_profileEditorService = profileEditorService;
|
||||
_dataBindingsVmFactory = dataBindingsVmFactory;
|
||||
|
||||
@ -41,8 +46,21 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.Conditio
|
||||
|
||||
protected override void OnInitialActivate()
|
||||
{
|
||||
base.OnInitialActivate();
|
||||
Initialize();
|
||||
_coreService.FrameRendered += CoreServiceOnFrameRendered;
|
||||
base.OnInitialActivate();
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
_coreService.FrameRendered -= CoreServiceOnFrameRendered;
|
||||
base.OnClose();
|
||||
}
|
||||
|
||||
private void CoreServiceOnFrameRendered(object? sender, FrameRenderedEventArgs e)
|
||||
{
|
||||
foreach (DataBindingConditionViewModel<TLayerProperty, TProperty> dataBindingConditionViewModel in Items)
|
||||
dataBindingConditionViewModel.Evaluate();
|
||||
}
|
||||
|
||||
private void UpdateItems()
|
||||
@ -109,7 +127,7 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.Conditio
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
@ -56,6 +56,11 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties.DataBindings.Conditio
|
||||
_profileEditorService.UpdateSelectedProfileElement();
|
||||
}
|
||||
|
||||
public void Evaluate()
|
||||
{
|
||||
ActiveItem?.Evaluate();
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user