1
0
mirror of synced 2024-11-16 21:43:50 +00:00
MassiveKnob/Windows/MassiveKnob.Plugin.VoiceMeeter/RunMacro/VoiceMeeterRunMacroAction.cs
Mark van Renswoude cae557e7e1 Implemented default device switching
Added VoiceMeeter plugin (run macro and get status)
Added Inno Setup script
Added Fusion 360 files for housing designs
2021-03-06 10:53:38 +01:00

81 lines
2.5 KiB
C#

using System;
using System.Threading.Tasks;
using System.Windows.Controls;
using Microsoft.Extensions.Logging;
using Voicemeeter;
namespace MassiveKnob.Plugin.VoiceMeeter.RunMacro
{
public class VoiceMeeterRunMacroAction : IMassiveKnobAction
{
public Guid ActionId { get; } = new Guid("3bf41e96-9418-4a0e-ba5f-580e0b94dcce");
public MassiveKnobActionType ActionType { get; } = MassiveKnobActionType.InputDigital;
public string Name { get; } = Strings.RunMacroName;
public string Description { get; } = Strings.RunMacroDescription;
public IMassiveKnobActionInstance Create(ILogger logger)
{
return new Instance();
}
private class Instance : IMassiveKnobDigitalAction, IVoiceMeeterAction
{
private IMassiveKnobActionContext actionContext;
private VoiceMeeterRunMacroActionSettings settings;
public void Initialize(IMassiveKnobActionContext context)
{
actionContext = context;
settings = context.GetSettings<VoiceMeeterRunMacroActionSettings>();
InstanceRegister.Register(this);
}
public void Dispose()
{
InstanceRegister.Unregister(this);
}
public UserControl CreateSettingsControl()
{
var viewModel = new VoiceMeeterRunMacroActionSettingsViewModel(settings);
viewModel.PropertyChanged += (sender, args) =>
{
if (!viewModel.IsSettingsProperty(args.PropertyName))
return;
actionContext.SetSettings(settings);
};
return new VoiceMeeterRunMacroActionSettingsView(viewModel);
}
public async ValueTask DigitalChanged(bool on)
{
if (!on)
return;
if (settings.Version == RunVoicemeeterParam.None || string.IsNullOrEmpty(settings.Script))
return;
await InstanceRegister.InitializeVoicemeeter();
global::VoiceMeeter.Remote.SetParameters(settings.Script);
}
public void VoiceMeeterVersionChanged()
{
// TODO update viewModel
actionContext.SetSettings(settings);
}
}
}
}