Improve SNR view

This commit is contained in:
Morten Nielsen 2020-07-29 20:23:20 -07:00
parent 7e8eca2431
commit d5397a3c49
3 changed files with 23 additions and 3 deletions

View file

@ -35,7 +35,7 @@
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="100" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<local:SatelliteView MaxWidth="{Binding ActualHeight, ElementName=satView}"
Grid.Column="1" x:Name="satView" />

View file

@ -6,7 +6,7 @@
xmlns:local="clr-namespace:SampleApp.WinDesktop"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid Height="100">
<Grid Height="125">
<Grid >
<Grid.RowDefinitions>
@ -27,6 +27,7 @@
Stretch="Fill"
Data="M0,0 L 1,0 M 0,1 L 1,1 M 0,2 L 1,2 M 0,3 L 1,3 M 0,4 L 1,4" />
</Grid>
<ScrollViewer VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Auto">
<ItemsControl x:Name="satellites"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
@ -37,6 +38,7 @@
</ItemsControl.ItemsPanel>
<ItemsControl.Resources>
<local:SatelliteVechicleColorConverter x:Key="conv" />
<local:SnrToHeightConverter x:Key="heightconv" />
</ItemsControl.Resources>
<ItemsControl.ItemTemplate>
<DataTemplate>
@ -48,7 +50,7 @@
<SolidColorBrush Color="{Binding Converter={StaticResource conv}}" />
</TextBlock.Foreground>
</TextBlock>
<Border Height="{Binding SignalToNoiseRatio, FallbackValue=10, NotifyOnValidationError=False}"
<Border Height="{Binding Converter={StaticResource heightconv}}"
BorderBrush="Black"
Margin="5,0" Width="20"
BorderThickness="1"
@ -62,5 +64,6 @@
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</UserControl>

View file

@ -2,6 +2,7 @@
using NmeaParser.Messages;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -43,4 +44,20 @@ namespace SampleApp.WinDesktop
satellites.ItemsSource = messages.Values.SelectMany(g => g.SVs);
}
}
public class SnrToHeightConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if(value is SatelliteVehicle sv)
{
return Math.Max(10, sv.SignalToNoiseRatio * 2);
}
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}