mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Fix settings apply for #205
This commit is contained in:
parent
ab82491137
commit
2482bdb7bd
@ -47,7 +47,7 @@
|
||||
VerticalAlignment="Top" Height="18" />
|
||||
<Slider x:Name="RotationSpeed" Grid.Row="0" Grid.Column="3" VerticalAlignment="Top"
|
||||
Value="{Binding Path=LayerModel.Properties.FadeSpeed, Mode=TwoWay}" Margin="10,12,10,2"
|
||||
Height="24" TickPlacement="BottomRight" TickFrequency="1" Minimum="1" Maximum="3" SmallChange="1"
|
||||
Height="24" TickPlacement="BottomRight" TickFrequency="0.1" Minimum="0.1" Maximum="1" SmallChange="0.1"
|
||||
IsSnapToTickEnabled="True" />
|
||||
|
||||
<!-- Colors -->
|
||||
|
||||
@ -28,7 +28,8 @@ namespace Artemis.Profiles.Layers.Types.Audio
|
||||
private readonly WasapiLoopbackCapture _waveIn;
|
||||
private DateTime _lastAudioUpdate;
|
||||
private int _lines;
|
||||
private AudioPropertiesModel _previousSettings;
|
||||
private string _previousSettings;
|
||||
private DateTime _lastUpdate;
|
||||
|
||||
public AudioType()
|
||||
{
|
||||
@ -223,7 +224,7 @@ namespace Artemis.Profiles.Layers.Types.Audio
|
||||
audioLayer.Properties.Width = settings.Width;
|
||||
audioLayer.Properties.Height = settings.Height;
|
||||
audioLayer.LayerAnimation?.Update(audioLayer, true);
|
||||
|
||||
|
||||
// Restore the height and width
|
||||
audioLayer.Properties.Height = oldHeight;
|
||||
audioLayer.Properties.Width = oldWidth;
|
||||
@ -235,20 +236,34 @@ namespace Artemis.Profiles.Layers.Types.Audio
|
||||
/// <param name="layerModel"></param>
|
||||
private void UpdateLayers(LayerModel layerModel)
|
||||
{
|
||||
// TODO: Animation
|
||||
var settings = (AudioPropertiesModel) layerModel.Properties;
|
||||
if ((settings.Direction == _previousSettings?.Direction) &&
|
||||
(settings.Sensitivity == _previousSettings.Sensitivity) &&
|
||||
(Math.Abs(settings.FadeSpeed - _previousSettings.FadeSpeed) < 0.001))
|
||||
return;
|
||||
// TODO: Animation every frame before checking settings
|
||||
|
||||
_previousSettings = GeneralHelpers.Clone((AudioPropertiesModel) layerModel.Properties);
|
||||
// Checking on settings update is expensive, only do it every second
|
||||
if (DateTime.Now - _lastUpdate < TimeSpan.FromSeconds(1))
|
||||
return;
|
||||
_lastUpdate = DateTime.Now;
|
||||
|
||||
var settings = (AudioPropertiesModel) layerModel.Properties;
|
||||
var currentSettings = JsonConvert.SerializeObject(settings, Formatting.Indented);
|
||||
if (currentSettings == _previousSettings)
|
||||
return;
|
||||
|
||||
_previousSettings = JsonConvert.SerializeObject(settings, Formatting.Indented);
|
||||
|
||||
_audioLayers.Clear();
|
||||
if ((settings.Direction == Direction.TopToBottom) || (settings.Direction == Direction.BottomToTop))
|
||||
SetupVertical(settings);
|
||||
else if ((settings.Direction == Direction.LeftToRight) || (settings.Direction == Direction.RightToLeft))
|
||||
SetupHorizontal(settings);
|
||||
switch (settings.Direction)
|
||||
{
|
||||
case Direction.TopToBottom:
|
||||
case Direction.BottomToTop:
|
||||
SetupVertical(settings);
|
||||
break;
|
||||
case Direction.LeftToRight:
|
||||
case Direction.RightToLeft:
|
||||
SetupHorizontal(settings);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
private void SetupVertical(AudioPropertiesModel settings)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user