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

Conditions - Fixed static input border margin

Databinding modifiers - Fixed default parameter values for value types not being set
This commit is contained in:
SpoinkyNL 2020-11-02 23:27:05 +01:00
parent 0f5c2b80c4
commit f2e21bfe37
5 changed files with 22 additions and 10 deletions

View File

@ -109,6 +109,14 @@ namespace Artemis.Core
$"it does not support this data binding's type {targetType.Name}"); $"it does not support this data binding's type {targetType.Name}");
ModifierType = modifierType; ModifierType = modifierType;
// Ensure the right parameter static value is never null when the parameter type is a value type
if (ParameterType == ProfileRightSideType.Static && modifierType.ParameterType != null)
{
if (modifierType.ParameterType.IsValueType && ParameterStaticValue == null)
UpdateParameterStatic(modifierType.ParameterType.GetDefault());
}
ValidateParameter(); ValidateParameter();
} }
@ -200,7 +208,7 @@ namespace Artemis.Core
ParameterPath = new DataModelPath(null, Entity.ParameterPath); ParameterPath = new DataModelPath(null, Entity.ParameterPath);
} }
// Static parameter // Static parameter
else if (ParameterType == ProfileRightSideType.Static && Entity.ParameterStaticValue != null && ParameterStaticValue == null) else if (ParameterType == ProfileRightSideType.Static && Entity.ParameterStaticValue != null)
{ {
// Use the target type so JSON.NET has a better idea what to do // Use the target type so JSON.NET has a better idea what to do
Type parameterType = ModifierType?.ParameterType ?? DirectDataBinding.DataBinding.GetTargetType(); Type parameterType = ModifierType?.ParameterType ?? DirectDataBinding.DataBinding.GetTargetType();
@ -217,7 +225,14 @@ namespace Artemis.Core
staticValue = Activator.CreateInstance(parameterType); staticValue = Activator.CreateInstance(parameterType);
} }
UpdateParameterStatic(staticValue); try
{
UpdateParameterStatic(staticValue);
}
catch (Exception e)
{
DeserializationLogger.LogModifierDeserializationFailure(GetType().Name, new JsonSerializationException("The JSON deserialized into a mismatching type", e));
}
} }
} }

View File

@ -220,8 +220,7 @@ namespace Artemis.Core.Services
Type pluginType = pluginTypes.Single(); Type pluginType = pluginTypes.Single();
try try
{ {
IParameter[] parameters = new IParameter[] IParameter[] parameters = {
{
new Parameter("PluginInfo", pluginInfo, false) new Parameter("PluginInfo", pluginInfo, false)
}; };
pluginInfo.Kernel = new ChildKernel(_kernel); pluginInfo.Kernel = new ChildKernel(_kernel);

View File

@ -71,6 +71,7 @@
Visibility="{Binding InputViewModel, Converter={StaticResource NullToVisibilityConverter}}" Visibility="{Binding InputViewModel, Converter={StaticResource NullToVisibilityConverter}}"
CornerRadius="3" CornerRadius="3"
Padding="3" Padding="3"
Margin="0 -3"
HorizontalAlignment="Left" HorizontalAlignment="Left"
MinWidth="140"> MinWidth="140">
<ContentControl s:View.Model="{Binding InputViewModel}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" /> <ContentControl s:View.Model="{Binding InputViewModel}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />

View File

@ -220,8 +220,7 @@ namespace Artemis.UI.Shared.Services
if (initialValue != null && initialValue.GetType() != registration.SupportedType) if (initialValue != null && initialValue.GetType() != registration.SupportedType)
initialValue = Convert.ChangeType(initialValue, registration.SupportedType); initialValue = Convert.ChangeType(initialValue, registration.SupportedType);
IParameter[] parameters = new IParameter[] IParameter[] parameters = {
{
new ConstructorArgument("targetDescription", description), new ConstructorArgument("targetDescription", description),
new ConstructorArgument("initialValue", initialValue) new ConstructorArgument("initialValue", initialValue)
}; };

View File

@ -28,8 +28,7 @@ namespace Artemis.UI.Shared.Services
public async Task<bool> ShowConfirmDialog(string header, string text, string confirmText = "Confirm", string cancelText = "Cancel") public async Task<bool> ShowConfirmDialog(string header, string text, string confirmText = "Confirm", string cancelText = "Cancel")
{ {
IParameter[] arguments = new IParameter[] IParameter[] arguments = {
{
new ConstructorArgument("header", header), new ConstructorArgument("header", header),
new ConstructorArgument("text", text), new ConstructorArgument("text", text),
new ConstructorArgument("confirmText", confirmText.ToUpper()), new ConstructorArgument("confirmText", confirmText.ToUpper()),
@ -41,8 +40,7 @@ namespace Artemis.UI.Shared.Services
public async Task<bool> ShowConfirmDialogAt(string identifier, string header, string text, string confirmText = "Confirm", string cancelText = "Cancel") public async Task<bool> ShowConfirmDialogAt(string identifier, string header, string text, string confirmText = "Confirm", string cancelText = "Cancel")
{ {
IParameter[] arguments = new IParameter[] IParameter[] arguments = {
{
new ConstructorArgument("header", header), new ConstructorArgument("header", header),
new ConstructorArgument("text", text), new ConstructorArgument("text", text),
new ConstructorArgument("confirmText", confirmText.ToUpper()), new ConstructorArgument("confirmText", confirmText.ToUpper()),