Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
17 changes: 14 additions & 3 deletions LiveSPICE/LiveSimulation.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
<xctk:IntegerUpDown Value="{Binding Iterations, Delay=1000}" Minimum="1" Maximum="64" />

<Separator />

<ls:ImageButton CommandImage="{x:Static ls:Commands.Simulate}" ImageHeight="16" />
</ToolBar>
<!-- View -->
Expand All @@ -121,14 +121,25 @@
<xcad:LayoutAnchorable x:Name="audio" Title="Audio" AutoHideWidth="240">
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel Orientation="Vertical">
<StackPanel.Resources>
<Style TargetType="{x:Type TextBox}">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip"
Value="{Binding RelativeSource={x:Static RelativeSource.Self},
Path=(Validation.Errors)/ErrorContent}" />
</Trigger>
</Style.Triggers>
</Style>
</StackPanel.Resources>
<DockPanel Margin="5">
<TextBlock DockPanel.Dock="Left" Width="40"
Text="Input" FontWeight="Bold" VerticalAlignment="Center" />
<TextBlock DockPanel.Dock="Left" Width="40"
Text="Gain: "
TextAlignment="Right" VerticalAlignment="Center" />
<TextBox DockPanel.Dock="Left" Width="50"
Text="{Binding InputGain, Converter={StaticResource dBConverter}, StringFormat={}{0:+#;-#;+0} dB}"
Text="{Binding InputGain, Converter={StaticResource dBConverter}, StringFormat={}{0:+#;-#;+0} dB, ValidatesOnExceptions=True}"
TextAlignment="Left" VerticalAlignment="Center" />
<Slider DockPanel.Dock="Right"
Value="{Binding InputGain, Converter={StaticResource dBConverter}}" Minimum="-40" Maximum="40" />
Expand Down Expand Up @@ -160,7 +171,7 @@
</xcad:LayoutAnchorable>
</xcad:LayoutAnchorablePane>
</xcad:LayoutPanel>

<xcad:LayoutPanel Orientation="Vertical" DockWidth="*">
<xcad:LayoutDocumentPane DockHeight="*">
<!-- Schematic -->
Expand Down
6 changes: 5 additions & 1 deletion LiveSPICE/Utils/dBConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return Math.Pow(10, (double)value / 20);
if (value is string s && double.TryParse(s, out var dbValue))
{
return Math.Pow(10, dbValue / 20);
}
return value;
}
}
}