2021-03-07 09:38:56 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Reactive.Linq;
|
|
|
|
|
using System.Reactive.Subjects;
|
|
|
|
|
using MassiveKnob.Plugin.VoiceMeeter.Base;
|
2021-03-06 09:53:38 +00:00
|
|
|
|
|
|
|
|
|
namespace MassiveKnob.Plugin.VoiceMeeter.RunMacro
|
|
|
|
|
{
|
2021-03-07 09:38:56 +00:00
|
|
|
|
public class VoiceMeeterRunMacroActionSettingsViewModel : BaseVoiceMeeterSettingsViewModel<VoiceMeeterRunMacroActionSettings>, IDisposable
|
2021-03-06 09:53:38 +00:00
|
|
|
|
{
|
2021-03-07 09:38:56 +00:00
|
|
|
|
private readonly Subject<bool> throttledScriptChanged = new Subject<bool>();
|
|
|
|
|
private readonly IDisposable scriptChangedSubscription;
|
|
|
|
|
|
|
|
|
|
// ReSharper disable UnusedMember.Global - used by WPF Binding
|
2021-03-06 09:53:38 +00:00
|
|
|
|
public string Script
|
|
|
|
|
{
|
|
|
|
|
get => Settings.Script;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value == Settings.Script)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Settings.Script = value;
|
2021-03-07 09:38:56 +00:00
|
|
|
|
throttledScriptChanged.OnNext(true);
|
2021-03-06 09:53:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// ReSharper restore UnusedMember.Global
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ReSharper disable once SuggestBaseTypeForParameter - by design
|
|
|
|
|
public VoiceMeeterRunMacroActionSettingsViewModel(VoiceMeeterRunMacroActionSettings settings) : base(settings)
|
|
|
|
|
{
|
2021-03-07 09:38:56 +00:00
|
|
|
|
scriptChangedSubscription = throttledScriptChanged
|
|
|
|
|
.Throttle(TimeSpan.FromSeconds(1))
|
|
|
|
|
.Subscribe(b =>
|
|
|
|
|
{
|
|
|
|
|
OnDependantPropertyChanged(nameof(Script));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override void Dispose()
|
|
|
|
|
{
|
|
|
|
|
scriptChangedSubscription?.Dispose();
|
|
|
|
|
throttledScriptChanged?.Dispose();
|
2021-03-06 09:53:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|