Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions EarTrumpet/UI/Converters/NegateConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Windows.Data;

namespace EarTrumpet.UI.Converters
{
public class NegateConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is double d) return -d;
if (value is float f) return (double)-f;
if (value is int i) return (double)-i;
throw new NotImplementedException();
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is double d) return -d;
throw new InvalidOperationException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ public class EarTrumpetCommunitySettingsPageViewModel : SettingsPageViewModel
public bool UseLogarithmicVolume
{
get => _settings.UseLogarithmicVolume;
set => _settings.UseLogarithmicVolume = value;
set
{
if (_settings.UseLogarithmicVolume != value)
{
_settings.UseLogarithmicVolume = value;
RaisePropertyChanged(nameof(UseLogarithmicVolume));
}
}
}

public double LogarithmicVolumeMinDb
Expand Down
76 changes: 32 additions & 44 deletions EarTrumpet/UI/Views/SettingsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
xmlns:local="clr-namespace:EarTrumpet"
xmlns:resx="clr-namespace:EarTrumpet.Properties"
xmlns:vm="clr-namespace:EarTrumpet.UI.ViewModels"
xmlns:conv="clr-namespace:EarTrumpet.UI.Converters"
Name="WindowRoot"
Title="{Binding Title}"
Width="800"
Expand All @@ -27,6 +28,8 @@
UseLayoutRounding="True"
WindowStartupLocation="CenterScreen">
<Window.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
<conv:NegateConverter x:Key="NegateConverter"/>
<DataTemplate DataType="{x:Type vm:EarTrumpetShortcutsPageViewModel}">
<StackPanel Orientation="Vertical">
<TextBlock Style="{StaticResource BodyText}" Text="{x:Static resx:Resources.SettingsOpenEarTrumpetText}" />
Expand Down Expand Up @@ -176,28 +179,30 @@
<CheckBox HorizontalAlignment="Left"
Content="{x:Static resx:Resources.SettingsUseLogarithmicVolume}"
IsChecked="{Binding UseLogarithmicVolume, Mode=TwoWay}" />
<!-- Localization required -->
<TextBlock VerticalAlignment="Center"
Style="{StaticResource BodyText}"
Text="Minimum dB in logarithmic slider" />
<StackPanel Orientation="Horizontal"
Margin="20,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Bottom">
<StackPanel Visibility="{Binding UseLogarithmicVolume, Converter={StaticResource BooleanToVisibilityConverter}}">
Comment thread
Dwscdv3 marked this conversation as resolved.
Outdated
<!-- Localization required -->
<TextBlock VerticalAlignment="Center"
Style="{StaticResource BodyText}"
Text="Minimum dB in logarithmic slider" />
Comment thread
riverar marked this conversation as resolved.
Outdated
<StackPanel Orientation="Horizontal"
Margin="12,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Bottom">
<!--
-96 dB is the min volume range of most devices
-12 dB is arbitrarily chosen
NegateConverter is used to flip the slider so that left is -12 and right is -96
-->
<Slider Minimum="-96"
Maximum="-12"
Width="200"
IsSnapToTickEnabled="True"
TickFrequency="1"
IsDirectionReversed="True"
Value="{Binding LogarithmicVolumeMinDb, Mode=TwoWay}" />
<TextBlock VerticalAlignment="Center"
Style="{StaticResource BodyText}"
Text="{Binding LogarithmicVolumeMinDb, StringFormat={}{0} dB}" />
<Slider Minimum="12"
Maximum="96"
Width="200"
IsSnapToTickEnabled="True"
TickFrequency="1"
Value="{Binding LogarithmicVolumeMinDb, Converter={StaticResource NegateConverter}, Mode=TwoWay}" />
<TextBlock VerticalAlignment="Center"
Style="{StaticResource BodyText}"
Text="{Binding LogarithmicVolumeMinDb, StringFormat=\{0\} dB}" />
</StackPanel>
</StackPanel>
<CheckBox HorizontalAlignment="Left"
Content="{x:Static resx:Resources.SettingsShowFullMixerWindowOnStartup}"
Expand Down Expand Up @@ -239,25 +244,10 @@
HorizontalAlignment="Left"
Content="{x:Static resx:Resources.PrivacyCheckboxText}"
IsChecked="{Binding IsTelemetryEnabled, Mode=TwoWay}" />
<TextBlock Style="{StaticResource HyperlinkBlock}">
<Hyperlink Command="{Binding OpenPrivacyPolicyCommand}">
<Run Text="{x:Static resx:Resources.PrivacyPolicyText}" />
</Hyperlink>
</TextBlock>
<TextBlock Style="{StaticResource HyperlinkBlock}"><Hyperlink Command="{Binding OpenAboutCommand}">
<Run Text="{x:Static resx:Resources.WebsiteText}" />
</Hyperlink>
</TextBlock>
<TextBlock Style="{StaticResource HyperlinkBlock}">
<Hyperlink Command="{Binding OpenFeedbackCommand}">
<Run Text="{x:Static resx:Resources.ContextMenuSendFeedback}" />
</Hyperlink>
</TextBlock>
<TextBlock Style="{StaticResource HyperlinkBlock}">
<Hyperlink Command="{Binding OpenDiagnosticsCommand}">
<Run Text="{x:Static resx:Resources.TroubleshootEarTrumpetText}" />
</Hyperlink>
</TextBlock>
<TextBlock Style="{StaticResource HyperlinkBlock}"><Hyperlink Command="{Binding OpenPrivacyPolicyCommand}"><Run Text="{x:Static resx:Resources.PrivacyPolicyText}" /></Hyperlink></TextBlock>
<TextBlock Style="{StaticResource HyperlinkBlock}"><Hyperlink Command="{Binding OpenAboutCommand}"><Run Text="{x:Static resx:Resources.WebsiteText}" /></Hyperlink></TextBlock>
<TextBlock Style="{StaticResource HyperlinkBlock}"><Hyperlink Command="{Binding OpenFeedbackCommand}"><Run Text="{x:Static resx:Resources.ContextMenuSendFeedback}" /></Hyperlink></TextBlock>
<TextBlock Style="{StaticResource HyperlinkBlock}"><Hyperlink Command="{Binding OpenDiagnosticsCommand}"><Run Text="{x:Static resx:Resources.TroubleshootEarTrumpetText}" /></Hyperlink></TextBlock>
</StackPanel>
</StackPanel>
</StackPanel>
Expand Down Expand Up @@ -303,9 +293,7 @@
Style="{StaticResource BodySubText}"
Text="{Binding Version}" />
</Grid>
<TextBlock Style="{StaticResource HyperlinkBlock}"><Hyperlink Command="{Binding OpenHelpLink}">
<Run Text="{x:Static resx:Resources.WebsiteText}" />
</Hyperlink></TextBlock>
<TextBlock Style="{StaticResource HyperlinkBlock}"><Hyperlink Command="{Binding OpenHelpLink}"><Run Text="{x:Static resx:Resources.WebsiteText}" /></Hyperlink></TextBlock>

<TextBlock Style="{StaticResource HeadingText}" Text="{x:Static resx:Resources.AddonUninstallTitle}" />
<TextBlock Style="{StaticResource BodyText}" Text="{x:Static resx:Resources.AddonUninstallDescriptionText}" />
Expand All @@ -315,7 +303,7 @@
<DataTemplate DataType="{x:Type vm:SettingsCategoryViewModel}">
<Grid PreviewMouseRightButtonDown="{Event:HandledBinding}">
<Grid.Style>
<Style TargetType="Grid">
<Style TargetType="{x:Type Grid}">
<Setter Property="Background" Value="Transparent" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsAd}" Value="True">
Expand All @@ -329,7 +317,7 @@
Theme:Brush.Fill="SystemAccent"
Points="0,0 40,0 40,40">
<Polygon.Style>
<Style TargetType="Polygon">
<Style TargetType="{x:Type Polygon}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsAd}" Value="False">
<Setter Property="Visibility" Value="Collapsed" />
Expand All @@ -346,7 +334,7 @@
FontSize="12"
Text="&#xE896;">
<TextBlock.Style>
<Style BasedOn="{StaticResource GlyphTextBlockStyle}" TargetType="TextBlock">
<Style BasedOn="{StaticResource GlyphTextBlockStyle}" TargetType="{x:Type TextBlock}">
<Style.Triggers>
<DataTrigger Binding="{Binding IsAd}" Value="False">
<Setter Property="Visibility" Value="Collapsed" />
Expand All @@ -372,7 +360,7 @@
FontSize="30"
Text="{Binding Glyph}">
<TextBlock.Style>
<Style BasedOn="{StaticResource GlyphTextBlockStyle}" TargetType="TextBlock">
<Style BasedOn="{StaticResource GlyphTextBlockStyle}" TargetType="{x:Type TextBlock}">
<Setter Property="Theme:Brush.Foreground" Value="SystemAccent" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsAd}" Value="True">
Expand Down