mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Data bindings - Fix crash when removing color gradient stops
This commit is contained in:
parent
91ad9b7bae
commit
eaa1f15ac3
@ -64,5 +64,15 @@ namespace Artemis.Core
|
|||||||
DataBinding = new DataBinding<TLayerProperty, TProperty>(LayerProperty, dataBinding);
|
DataBinding = new DataBinding<TLayerProperty, TProperty>(LayerProperty, dataBinding);
|
||||||
return DataBinding;
|
return DataBinding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public void ClearDataBinding()
|
||||||
|
{
|
||||||
|
if (DataBinding == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// The related entity is left behind, just in case the data binding is added back later
|
||||||
|
LayerProperty.DisableDataBinding(DataBinding);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -20,5 +20,10 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
IDataBinding? CreateDataBinding();
|
IDataBinding? CreateDataBinding();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If present, removes the current data binding
|
||||||
|
/// </summary>
|
||||||
|
void ClearDataBinding();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -420,6 +420,14 @@ namespace Artemis.Core
|
|||||||
DataBindingRegistration<T, TProperty> registration = new(this, converter, getter, setter, displayName);
|
DataBindingRegistration<T, TProperty> registration = new(this, converter, getter, setter, displayName);
|
||||||
_dataBindingRegistrations.Add(registration);
|
_dataBindingRegistrations.Add(registration);
|
||||||
|
|
||||||
|
// If not yet initialized, load the data binding related to the registration if available
|
||||||
|
if (_isInitialized)
|
||||||
|
{
|
||||||
|
IDataBinding? dataBinding = registration.CreateDataBinding();
|
||||||
|
if (dataBinding != null)
|
||||||
|
_dataBindings.Add(dataBinding);
|
||||||
|
}
|
||||||
|
|
||||||
OnDataBindingPropertyRegistered();
|
OnDataBindingPropertyRegistered();
|
||||||
return registration;
|
return registration;
|
||||||
}
|
}
|
||||||
@ -432,7 +440,10 @@ namespace Artemis.Core
|
|||||||
if (_disposed)
|
if (_disposed)
|
||||||
throw new ObjectDisposedException("LayerProperty");
|
throw new ObjectDisposedException("LayerProperty");
|
||||||
|
|
||||||
|
foreach (IDataBindingRegistration dataBindingRegistration in _dataBindingRegistrations)
|
||||||
|
dataBindingRegistration.ClearDataBinding();
|
||||||
_dataBindingRegistrations.Clear();
|
_dataBindingRegistrations.Clear();
|
||||||
|
|
||||||
OnDataBindingPropertiesCleared();
|
OnDataBindingPropertiesCleared();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -295,7 +295,7 @@ namespace Artemis.UI.Shared
|
|||||||
{
|
{
|
||||||
Execute.PostToUIThread(SetupForDevice);
|
Execute.PostToUIThread(SetupForDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Render()
|
private void Render()
|
||||||
{
|
{
|
||||||
DrawingContext drawingContext = _backingStore.Open();
|
DrawingContext drawingContext = _backingStore.Open();
|
||||||
|
|||||||
@ -51,7 +51,6 @@ namespace Artemis.UI.Shared
|
|||||||
byte g = Led.RgbLed.Color.GetG();
|
byte g = Led.RgbLed.Color.GetG();
|
||||||
byte b = Led.RgbLed.Color.GetB();
|
byte b = Led.RgbLed.Color.GetB();
|
||||||
|
|
||||||
_renderColor.A = (byte) (isDimmed ? 100 : 255);
|
|
||||||
_renderColor.A = isDimmed ? Dimmed : NonDimmed;
|
_renderColor.A = isDimmed ? Dimmed : NonDimmed;
|
||||||
_renderColor.R = r;
|
_renderColor.R = r;
|
||||||
_renderColor.G = g;
|
_renderColor.G = g;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user