Skip to content

Commit

Permalink
Merge pull request #35 from davewalker5/BSR-66-Auto-Size-Columns
Browse files Browse the repository at this point in the history
BSR-66-Auto-Size-Columns
  • Loading branch information
davewalker5 authored Sep 25, 2023
2 parents 1b29093 + 8e1585f commit c9407cb
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 76 deletions.
4 changes: 2 additions & 2 deletions src/BaseStationReader.Data/BaseStationReader.Data.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>BaseStationReader.Data</PackageId>
<PackageVersion>1.26.0.0</PackageVersion>
<PackageVersion>1.27.0.0</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2023</Copyright>
<Owners>Dave Walker</Owners>
Expand All @@ -17,7 +17,7 @@
<PackageProjectUrl>https://github.com/davewalker5/ADS-B-BaseStationReader</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<ReleaseVersion>1.26.0.0</ReleaseVersion>
<ReleaseVersion>1.27.0.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>BaseStationReader.Entities</PackageId>
<PackageVersion>1.26.0.0</PackageVersion>
<PackageVersion>1.27.0.0</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2023</Copyright>
<Owners>Dave Walker</Owners>
Expand All @@ -17,7 +17,7 @@
<PackageProjectUrl>https://github.com/davewalker5/ADS-B-BaseStationReader</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<ReleaseVersion>1.26.0.0</ReleaseVersion>
<ReleaseVersion>1.27.0.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/BaseStationReader.Entities/Config/TrackerColumn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class TrackerColumn
public string Property { get; set; } = "";
public string Label { get; set; } = "";
public string Format { get; set; } = "";
public string Context { get; set; } = "";
public PropertyInfo? Info { get; set; } = null;
public string TypeName { get; set; } = "";
}
Expand Down
4 changes: 2 additions & 2 deletions src/BaseStationReader.Logic/BaseStationReader.Logic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>BaseStationReader.Logic</PackageId>
<PackageVersion>1.26.0.0</PackageVersion>
<PackageVersion>1.27.0.0</PackageVersion>
<Authors>Dave Walker</Authors>
<Copyright>Copyright (c) Dave Walker 2023</Copyright>
<Owners>Dave Walker</Owners>
Expand All @@ -17,7 +17,7 @@
<PackageProjectUrl>https://github.com/davewalker5/ADS-B-BaseStationReader</PackageProjectUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<ReleaseVersion>1.26.0.0</ReleaseVersion>
<ReleaseVersion>1.27.0.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ReleaseVersion>1.26.0.0</ReleaseVersion>
<FileVersion>1.26.0.0</FileVersion>
<ProductVersion>1.26.0</ProductVersion>
<ReleaseVersion>1.27.0.0</ReleaseVersion>
<FileVersion>1.27.0.0</FileVersion>
<ProductVersion>1.27.0</ProductVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ReleaseVersion>1.26.0.0</ReleaseVersion>
<FileVersion>1.26.0.0</FileVersion>
<ProductVersion>1.26.0</ProductVersion>
<ReleaseVersion>1.27.0.0</ReleaseVersion>
<FileVersion>1.27.0.0</FileVersion>
<ProductVersion>1.27.0</ProductVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/BaseStationReader.UI/BaseStationReader.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ReleaseVersion>1.26.0.0</ReleaseVersion>
<FileVersion>1.26.0.0</FileVersion>
<ProductVersion>1.26.0</ProductVersion>
<ReleaseVersion>1.27.0.0</ReleaseVersion>
<FileVersion>1.27.0.0</FileVersion>
<ProductVersion>1.27.0</ProductVersion>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationManifest>app.manifest</ApplicationManifest>
Expand Down
66 changes: 32 additions & 34 deletions src/BaseStationReader.UI/Views/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,23 @@
ItemsSource="{Binding TrackedAircraft}"
AutoGenerateColumns="False"
CanUserSortColumns="False"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
LoadingRow="OnLoadingRow">
LoadingRow="OnLoadingRow"
IsReadOnly="True">
<DataGrid.Columns>
<DataGridTextColumn Header="Address" CanUserSort="False" Binding="{Binding Address}"/>
<DataGridTextColumn Header="Callsign" CanUserSort="False" Binding="{Binding Callsign}" />
<DataGridTextColumn Header="Squawk" CanUserSort="False" Binding="{Binding Squawk}" />
<DataGridTextColumn Header="Altitude" CanUserSort="False" Binding="{Binding Altitude}" />
<DataGridTextColumn Header="GroundSpeed" CanUserSort="False" Binding="{Binding GroundSpeed}" />
<DataGridTextColumn Header="Track" CanUserSort="False" Binding="{Binding Track}" />
<DataGridTextColumn Header="Latitude" CanUserSort="False" Binding="{Binding Latitude}" />
<DataGridTextColumn Header="Longitude" CanUserSort="False" Binding="{Binding Longitude}" />
<DataGridTextColumn Header="VerticalRate" CanUserSort="False" Binding="{Binding VerticalRate}" />
<DataGridTextColumn Header="Distance" CanUserSort="False" Binding="{Binding Distance}" />
<DataGridTextColumn Header="FirstSeen" CanUserSort="False" Binding="{Binding FirstSeen}" />
<DataGridTextColumn Header="LastSeen" CanUserSort="False" Binding="{Binding LastSeen}" />
<DataGridTextColumn Header="Messages" CanUserSort="False" Binding="{Binding Messages}" />
<DataGridTextColumn Header="Status" CanUserSort="False" Binding="{Binding Status}" />
<DataGridTextColumn Header="Address" CanUserSort="False" Width="*" Binding="{Binding Address}"/>
<DataGridTextColumn Header="Callsign" CanUserSort="False" Width="*" Binding="{Binding Callsign}" />
<DataGridTextColumn Header="Squawk" CanUserSort="False" Width="*" Binding="{Binding Squawk}" />
<DataGridTextColumn Header="Altitude" CanUserSort="False" Width="*" Binding="{Binding Altitude}" />
<DataGridTextColumn Header="GroundSpeed" CanUserSort="False" Width="*" Binding="{Binding GroundSpeed}" />
<DataGridTextColumn Header="Track" CanUserSort="False" Width="*" Binding="{Binding Track}" />
<DataGridTextColumn Header="Latitude" CanUserSort="False" Width="*" Binding="{Binding Latitude}" />
<DataGridTextColumn Header="Longitude" CanUserSort="False" Width="*" Binding="{Binding Longitude}" />
<DataGridTextColumn Header="VerticalRate" CanUserSort="False" Width="*" Binding="{Binding VerticalRate}" />
<DataGridTextColumn Header="Distance" CanUserSort="False" Width="*" Binding="{Binding Distance}" />
<DataGridTextColumn Header="FirstSeen" CanUserSort="False" Width="*" Binding="{Binding FirstSeen}" />
<DataGridTextColumn Header="LastSeen" CanUserSort="False" Width="*" Binding="{Binding LastSeen}" />
<DataGridTextColumn Header="Messages" CanUserSort="False" Width="*" Binding="{Binding Messages}" />
<DataGridTextColumn Header="Status" CanUserSort="False" Width="*" Binding="{Binding Status}" />
</DataGrid.Columns>
</DataGrid>
</DockPanel>
Expand All @@ -86,24 +85,23 @@
ItemsSource="{Binding SearchResults}"
AutoGenerateColumns="False"
CanUserSortColumns="False"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
LoadingRow="OnLoadingRow">
LoadingRow="OnLoadingRow"
IsReadOnly="True">
<DataGrid.Columns>
<DataGridTextColumn Header="Address" CanUserSort="False" Binding="{Binding Address}"/>
<DataGridTextColumn Header="Callsign" CanUserSort="False" Binding="{Binding Callsign}" />
<DataGridTextColumn Header="Squawk" CanUserSort="False" Binding="{Binding Squawk}" />
<DataGridTextColumn Header="Altitude" CanUserSort="False" Binding="{Binding Altitude}" />
<DataGridTextColumn Header="GroundSpeed" CanUserSort="False" Binding="{Binding GroundSpeed}" />
<DataGridTextColumn Header="Track" CanUserSort="False" Binding="{Binding Track}" />
<DataGridTextColumn Header="Latitude" CanUserSort="False" Binding="{Binding Latitude}" />
<DataGridTextColumn Header="Longitude" CanUserSort="False" Binding="{Binding Longitude}" />
<DataGridTextColumn Header="VerticalRate" CanUserSort="False" Binding="{Binding VerticalRate}" />
<DataGridTextColumn Header="Distance" CanUserSort="False" Binding="{Binding Distance}" />
<DataGridTextColumn Header="FirstSeen" CanUserSort="False" Binding="{Binding FirstSeen}" />
<DataGridTextColumn Header="LastSeen" CanUserSort="False" Binding="{Binding LastSeen}" />
<DataGridTextColumn Header="Messages" CanUserSort="False" Binding="{Binding Messages}" />
<DataGridTextColumn Header="Status" CanUserSort="False" Binding="{Binding Status}" />
<DataGridTextColumn Header="Address" CanUserSort="False" Width="*" Binding="{Binding Address}"/>
<DataGridTextColumn Header="Callsign" CanUserSort="False" Width="*" Binding="{Binding Callsign}" />
<DataGridTextColumn Header="Squawk" CanUserSort="False" Width="*" Binding="{Binding Squawk}" />
<DataGridTextColumn Header="Altitude" CanUserSort="False" Width="*" Binding="{Binding Altitude}" />
<DataGridTextColumn Header="GroundSpeed" CanUserSort="False" Width="*" Binding="{Binding GroundSpeed}" />
<DataGridTextColumn Header="Track" CanUserSort="False" Width="*" Binding="{Binding Track}" />
<DataGridTextColumn Header="Latitude" CanUserSort="False" Width="*" Binding="{Binding Latitude}" />
<DataGridTextColumn Header="Longitude" CanUserSort="False" Width="*" Binding="{Binding Longitude}" />
<DataGridTextColumn Header="VerticalRate" CanUserSort="False" Width="*" Binding="{Binding VerticalRate}" />
<DataGridTextColumn Header="Distance" CanUserSort="False" Width="*" Binding="{Binding Distance}" />
<DataGridTextColumn Header="FirstSeen" CanUserSort="False" Width="*" Binding="{Binding FirstSeen}" />
<DataGridTextColumn Header="LastSeen" CanUserSort="False" Width="*" Binding="{Binding LastSeen}" />
<DataGridTextColumn Header="Messages" CanUserSort="False" Width="*" Binding="{Binding Messages}" />
<DataGridTextColumn Header="Status" CanUserSort="False" Width="*" Binding="{Binding Status}" />
</DataGrid.Columns>
</DataGrid>
</DockPanel>
Expand Down
26 changes: 24 additions & 2 deletions src/BaseStationReader.UI/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Data;
using Avalonia.Data.Converters;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml.MarkupExtensions;
using Avalonia.Media;
using Avalonia.Platform.Storage;
using Avalonia.ReactiveUI;
Expand All @@ -18,6 +21,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;

Expand Down Expand Up @@ -66,15 +70,33 @@ private void OnLoaded(object? source, RoutedEventArgs e)
/// <param name="grid"></param>
private void ConfigureColumns(DataGrid grid)
{
// Get a list of column definitions that apply either to the grid being configured, based on its name,
// or apply in all contexts
var definitions = ViewModel!.Settings!.Columns.Where(x => string.IsNullOrEmpty(x.Context) || (x.Context == grid.Name)).ToList();

// Iterate over all the columns
foreach (var column in grid.Columns)
{
// Find the corresponding column definition in the settings
var definition = ViewModel!.Settings!.Columns.Find(x => x.Property == column.Header.ToString());
// Find the corresponding column definition
var definition = definitions.Find(x => x.Property == column.Header.ToString());
if (definition != null)
{
// Found it, so apply the label
column.Header = definition.Label;

// See if there's a custom format
if (!string.IsNullOrEmpty(definition.Format))
{
// There is, so get the binding for the column
var bound = column as DataGridBoundColumn;
var binding = bound!.Binding as CompiledBindingExtension;

// Replace the format converter for the binding using the format specified in the
// application settings file
binding!.Mode = BindingMode.OneWay;
binding.StringFormat = definition.Format;
binding.Converter = new StringFormatValueConverter(binding.StringFormat, null);
}
}
else
{
Expand Down
24 changes: 12 additions & 12 deletions src/BaseStationReader.UI/Views/TrackingOptionsWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
WindowStartupLocation="CenterOwner"
SizeToContent="WidthAndHeight">
<DockPanel Margin="10 10 10 10">
<Grid ColumnDefinitions="Auto, Auto" RowDefinitions="Auto, Auto, Auto, Auto, Auto, Auto, Auto, Auto, Auto, Auto, Auto">
<Grid ColumnDefinitions="Auto, Auto, Auto, Auto" RowDefinitions="Auto, Auto, Auto, Auto, Auto, Auto">
<Label Grid.Row="0" Grid.Column="0" Margin="0 0 10 10" >Host:</Label>
<TextBox Grid.Row="0" Grid.Column="1" Name="Host" Margin="0 0 10 10" KeyUp="OnHostKeyUp"/>

Expand All @@ -28,22 +28,22 @@
<Label Grid.Row="4" Grid.Column="0" Margin="0 0 10 10" >Time to stale (ms):</Label>
<TextBox Grid.Row="4" Grid.Column="1" Name="TimeToStale" Margin="0 0 10 10" KeyUp="OnTimeToStaleKeyUp"/>

<Label Grid.Row="5" Grid.Column="0" Margin="0 0 10 10" >Time to removal (ms):</Label>
<TextBox Grid.Row="5" Grid.Column="1" Name="TimeToRemoval" Margin="0 0 10 10" KeyUp="OnTimeToRemovalKeyUp"/>
<Label Grid.Row="0" Grid.Column="2" Margin="0 0 10 10" >Time to removal (ms):</Label>
<TextBox Grid.Row="0" Grid.Column="3" Name="TimeToRemoval" Margin="0 0 10 10" KeyUp="OnTimeToRemovalKeyUp"/>

<Label Grid.Row="6" Grid.Column="0" Margin="0 0 10 10" >Time to locked (ms):</Label>
<TextBox Grid.Row="6" Grid.Column="1" Name="TimeToLocked" Margin="0 0 10 10" KeyUp="OnTimeToLockedKeyUp"/>
<Label Grid.Row="1" Grid.Column="2" Margin="0 0 10 10" >Time to locked (ms):</Label>
<TextBox Grid.Row="1" Grid.Column="3" Name="TimeToLocked" Margin="0 0 10 10" KeyUp="OnTimeToLockedKeyUp"/>

<Label Grid.Row="7" Grid.Column="0" Margin="0 0 10 10" >Refresh interval (ms):</Label>
<TextBox Grid.Row="7" Grid.Column="1" Name="RefreshInterval" Margin="0 0 10 10" KeyUp="OnRefreshIntervalKeyUp"/>
<Label Grid.Row="2" Grid.Column="2" Margin="0 0 10 10" >Refresh interval (ms):</Label>
<TextBox Grid.Row="2" Grid.Column="3" Name="RefreshInterval" Margin="0 0 10 10" KeyUp="OnRefreshIntervalKeyUp"/>

<Label Grid.Row="8" Grid.Column="0" Margin="0 0 10 10" >Receiver Latitude:</Label>
<TextBox Grid.Row="8" Grid.Column="1" Name="ReceiverLatitude" Margin="0 0 10 10" KeyUp="OnReceiverLatitudeKeyUp"/>
<Label Grid.Row="3" Grid.Column="2" Margin="0 0 10 10" >Receiver Latitude:</Label>
<TextBox Grid.Row="3" Grid.Column="3" Name="ReceiverLatitude" Margin="0 0 10 10" KeyUp="OnReceiverLatitudeKeyUp"/>

<Label Grid.Row="9" Grid.Column="0" Margin="0 0 10 10" >Receiver Longitude:</Label>
<TextBox Grid.Row="9" Grid.Column="1" Name="ReceiverLongitude" Margin="0 0 10 10" KeyUp="OnReceiverLongitudeKeyUp"/>
<Label Grid.Row="4" Grid.Column="2" Margin="0 0 10 10" >Receiver Longitude:</Label>
<TextBox Grid.Row="4" Grid.Column="3" Name="ReceiverLongitude" Margin="0 0 10 10" KeyUp="OnReceiverLongitudeKeyUp"/>

<StackPanel Orientation="Horizontal" Grid.Row="10" Grid.Column="1" Margin="0 10 0 0">
<StackPanel Orientation="Horizontal" Grid.Row="5" Grid.Column="3" Margin="0 10 0 0">
<Button Command="{Binding SelectTrackingOptionsCommand}">OK</Button>
<Button Command="{Binding CancelTrackingOptionsCommand}" Margin="10 0 0 0">Cancel</Button>
</StackPanel>
Expand Down
50 changes: 37 additions & 13 deletions src/BaseStationReader.UI/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,67 +21,91 @@
{
"Property": "Address",
"Label": "ID",
"Format": ""
"Format": "",
"Context": ""
},
{
"Property": "Callsign",
"Label": "Callsign",
"Format": ""
"Format": "",
"Context": ""
},
{
"Property": "Squawk",
"Label": "Squawk",
"Format": ""
"Format": "",
"Context": ""
},
{
"Property": "Altitude",
"Label": "Altitude",
"Format": "N0"
"Format": "{0:N0}"
},
{
"Property": "GroundSpeed",
"Label": "Speed",
"Format": "N0"
"Format": "{0:N0}",
"Context": ""
},
{
"Property": "Track",
"Label": "Heading",
"Format": "N0"
"Format": "{0:N0}",
"Context": ""
},
{
"Property": "Latitude",
"Label": "Latitude",
"Format": "N5"
"Format": "{0:N5}",
"Context": ""
},
{
"Property": "Longitude",
"Label": "Longitude",
"Format": "N5"
"Format": "{0:N5}",
"Context": ""
},
{
"Property": "VerticalRate",
"Label": "Vertical Rate",
"Format": "N0"
"Format": "{0:N0}",
"Context": ""
},
{
"Property": "Distance",
"Label": "Distance",
"Format": "N0"
"Format": "{0:N0}",
"Context": ""
},
{
"Property": "FirstSeen",
"Label": "First Seen",
"Format": "HH:mm:ss.fff"
"Format": "{0:HH:mm:ss}",
"Context": "TrackedAircraftGrid"
},
{
"Property": "FirstSeen",
"Label": "First Seen",
"Format": "",
"Context": "DatabaseGrid"
},
{
"Property": "LastSeen",
"Label": "Last Seen",
"Format": "{0:HH:mm:ss}",
"Context": "TrackedAircraftGrid"
},
{
"Property": "LastSeen",
"Label": "Last Seen",
"Format": "HH:mm:ss.fff"
"Format": "",
"Context": "DatabaseGrid"
},
{
"Property": "Messages",
"Label": "Messages",
"Format": ""
"Format": "",
"Context": ""
}
]
},
Expand Down

0 comments on commit c9407cb

Please sign in to comment.