1
0
mirror of synced 2024-11-21 15:43:49 +00:00

Implemented toggle and inverted settings for muted actions

This commit is contained in:
Mark van Renswoude 2021-02-28 13:55:47 +01:00
parent 0183d50c46
commit de27a6ccee
6 changed files with 55 additions and 12 deletions

View File

@ -5,12 +5,15 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:getMuted="clr-namespace:MassiveKnob.Plugin.CoreAudio.GetMuted"
xmlns:base="clr-namespace:MassiveKnob.Plugin.CoreAudio.Base"
xmlns:coreAudio="clr-namespace:MassiveKnob.Plugin.CoreAudio"
mc:Ignorable="d"
d:DesignHeight="200" d:DesignWidth="800"
d:DataContext="{d:DesignInstance getMuted:DeviceGetMutedActionSettingsViewModel}">
<StackPanel Orientation="Vertical">
<base:BaseDeviceSettingsView />
<!-- TODO Inverted -->
<CheckBox Margin="0,8,0,0" IsChecked="{Binding Inverted}">
<TextBlock Text="{x:Static coreAudio:Strings.SettingGetMutedInverted}" />
</CheckBox>
</StackPanel>
</UserControl>

View File

@ -1,4 +1,5 @@
using System.Threading;
using System;
using System.Threading;
using System.Windows;
using AudioSwitcher.AudioApi;
@ -20,6 +21,7 @@ namespace MassiveKnob.Plugin.CoreAudio.OSD
{
windowViewModel = new OSDWindowViewModel();
window = new OSDWindow(windowViewModel);
window.Closed += WindowOnClosed;
hideTimer = new Timer(state =>
{
@ -34,9 +36,17 @@ namespace MassiveKnob.Plugin.CoreAudio.OSD
});
}
private static void WindowOnClosed(object sender, EventArgs e)
{
hideTimer?.Dispose();
hideTimer = null;
}
private static void Hide()
{
Application.Current.Dispatcher.Invoke(() =>
Application.Current?.Dispatcher.Invoke(() =>
{
window?.Close();
window = null;

View File

@ -5,13 +5,23 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:setMuted="clr-namespace:MassiveKnob.Plugin.CoreAudio.SetMuted"
xmlns:base="clr-namespace:MassiveKnob.Plugin.CoreAudio.Base"
xmlns:coreAudio="clr-namespace:MassiveKnob.Plugin.CoreAudio"
mc:Ignorable="d"
d:DesignHeight="200" d:DesignWidth="800"
d:DataContext="{d:DesignInstance setMuted:DeviceSetMutedActionSettingsViewModel}">
<StackPanel Orientation="Vertical">
<base:BaseDeviceSettingsView />
<!-- TODO Toggle -->
<!-- TODO SetInverted -->
<RadioButton Margin="0,8,0,0" IsChecked="{Binding ToggleTrue}">
<TextBlock Text="{x:Static coreAudio:Strings.SettingSetMutedToggleTrue}" />
</RadioButton>
<RadioButton Margin="0,8,0,0" IsChecked="{Binding ToggleFalse}">
<TextBlock Text="{x:Static coreAudio:Strings.SettingSetMutedToggleFalse}" />
</RadioButton>
<CheckBox Margin="24,8,0,0" IsChecked="{Binding SetInverted}">
<TextBlock Text="{x:Static coreAudio:Strings.SettingSetMutedSetInverted}" />
</CheckBox>
</StackPanel>
</UserControl>

View File

@ -5,15 +5,35 @@ namespace MassiveKnob.Plugin.CoreAudio.SetMuted
public class DeviceSetMutedActionSettingsViewModel : BaseDeviceSettingsViewModel<DeviceSetMutedActionSettings>
{
// ReSharper disable UnusedMember.Global - used by WPF Binding
public bool Toggle
public bool ToggleTrue
{
get => Settings.Toggle;
set
{
if (value == Settings.Toggle)
if (!value)
return;
Settings.Toggle = value;
if (Settings.Toggle)
return;
Settings.Toggle = true;
OnPropertyChanged();
}
}
public bool ToggleFalse
{
get => !Settings.Toggle;
set
{
if (!value)
return;
if (!Settings.Toggle)
return;
Settings.Toggle = false;
OnPropertyChanged();
}
}

View File

@ -178,7 +178,7 @@ namespace MassiveKnob.Plugin.CoreAudio {
}
/// <summary>
/// Looks up a localized string similar to Inverted (muted is off).
/// Looks up a localized string similar to Inverted (off when muted).
/// </summary>
public static string SettingGetMutedInverted {
get {
@ -205,7 +205,7 @@ namespace MassiveKnob.Plugin.CoreAudio {
}
/// <summary>
/// Looks up a localized string similar to Inverted (off is muted).
/// Looks up a localized string similar to Inverted (muted when off).
/// </summary>
public static string SettingSetMutedSetInverted {
get {

View File

@ -157,7 +157,7 @@
<value>Mute / unmute</value>
</data>
<data name="SettingGetMutedInverted" xml:space="preserve">
<value>Inverted (muted is off)</value>
<value>Inverted (off when muted)</value>
</data>
<data name="SettingOSD" xml:space="preserve">
<value>Show On-Screen Display</value>
@ -166,7 +166,7 @@
<value>Playback device</value>
</data>
<data name="SettingSetMutedSetInverted" xml:space="preserve">
<value>Inverted (off is muted)</value>
<value>Inverted (muted when off)</value>
</data>
<data name="SettingSetMutedToggleFalse" xml:space="preserve">
<value>Set mute depending on value (eg. switch)</value>