add button that removes unneeded events from test data

This commit is contained in:
Florian Stinglmayr 2022-02-14 18:11:22 +01:00
parent 9d81a9ad7d
commit f499d7763b
2 changed files with 36 additions and 1 deletions

View File

@ -28,11 +28,13 @@
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Button x:Name="Load" Content="Load Entries" Grid.Row="0" Margin="5,5,5,5" Height="Auto" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Click="Load_Click" />
<Button x:Name="LoadFile" Content="Load File" Grid.Row="0" Margin="5,5,5,5" Height="Auto" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" Click="LoadFile_Click" />
<Button x:Name="Clear" Content="Clear" Grid.Row="0" Height="Auto" Margin="5,5,5,5" Grid.Column="3" Click="Clear_Click" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<Button x:Name="DeleteUnimportant" Content="Remove Unimportant" Grid.Row="0" Margin="5,5,5,5" Height="Auto" Grid.Column="3" HorizontalAlignment="Center" VerticalAlignment="Center" Click="DeleteUnimportant_Click" />
<Button x:Name="Clear" Content="Clear" Grid.Row="0" Height="Auto" Margin="5,5,5,5" Grid.Column="4" Click="Clear_Click" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Grid>
</Grid>
</Window>

View File

@ -1,9 +1,11 @@
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Windows;
using Microsoft.Win32;
using EDJournal;
using EliteBGS.BGS;
using EliteBGS.Util;
namespace EliteBGS {
@ -73,5 +75,36 @@ namespace EliteBGS {
} catch (Exception) {
}
}
private void DeleteUnimportant_Click(object sender, RoutedEventArgs e) {
string lines = Lines.Text.Trim();
if (lines.Length <= 0) {
return;
}
try {
List<Entry> entries = new List<Entry>();
foreach (string line in lines.Split('\n')) {
Entry entry = Entry.Parse(line);
if (Report.IsRelevant(entry)) {
entries.Add(entry);
}
}
if (entries.Count <= 0) {
return;
}
string[] text = entries
.ConvertAll(x => x.JSON.ToString(Newtonsoft.Json.Formatting.None))
.ToArray()
;
Lines.Text = string.Join("\n", text).Trim();
} catch (Exception exception) {
MessageBox.Show(string.Format("There was an error while parsing the JSON: {0}",
exception.ToString()));
}
}
}
}