add GUI elements for ignoring market buy

This commit is contained in:
Florian Stinglmayr 2023-04-19 09:17:06 +02:00
parent d6acbda55c
commit f4bbd3df2b
3 changed files with 17 additions and 4 deletions

View File

@ -207,12 +207,15 @@
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<mah:ToggleSwitch x:Name="NoInfluenceSupport" Grid.Row="1" Grid.ColumnSpan="2" Content="Ignore secondary influence support given out by certain missions" Toggled="NoInfluenceSupport_Toggled"/> <mah:ToggleSwitch x:Name="NoInfluenceSupport" Grid.Row="1" Grid.ColumnSpan="2" Content="Ignore secondary influence support given out by certain missions" Toggled="NoInfluenceSupport_Toggled"/>
<mah:ToggleSwitch x:Name="NoMarketBuy" Grid.Row="2" Grid.ColumnSpan="2" Content="Ignore commodities bought at stations" Toggled="NoMarketBuy_Toggled"/>
</Grid> </Grid>
</GroupBox> </GroupBox>
</Grid> </Grid>

View File

@ -171,6 +171,7 @@ public partial class MainWindow : MetroWindow {
TransactionParserOptions options = new(); TransactionParserOptions options = new();
options.IgnoreInfluenceSupport = Config.Global.IgnoreInfluenceSupport; options.IgnoreInfluenceSupport = Config.Global.IgnoreInfluenceSupport;
options.IgnoreMarketBuy = Config.Global.IgnoreMarketBuy;
List<Transaction> transactions = parser.Parse(entries, options); List<Transaction> transactions = parser.Parse(entries, options);
@ -277,7 +278,7 @@ public partial class MainWindow : MetroWindow {
} }
} }
private void entries_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) { private void entries_KeyUp(object sender, KeyEventArgs e) {
if (e.Key == Key.Delete) { if (e.Key == Key.Delete) {
RemoveCurrentObjective(); RemoveCurrentObjective();
} }
@ -296,7 +297,7 @@ public partial class MainWindow : MetroWindow {
} }
private Objective GetObjectiveFromControl(object sender) { private Objective GetObjectiveFromControl(object sender) {
System.Windows.Controls.Control control = sender as System.Windows.Controls.Control; Control control = sender as Control;
if (control == null || control.DataContext == null) { if (control == null || control.DataContext == null) {
return null; return null;
} }
@ -361,7 +362,7 @@ public partial class MainWindow : MetroWindow {
try { try {
Config.SaveGlobal(); Config.SaveGlobal();
} catch (Exception error) { } catch (Exception error) {
System.Windows.MessageBox.Show("There was an error saving your settings: " + error.Message); MessageBox.Show("There was an error saving your settings: " + error.Message);
} }
} }
@ -369,7 +370,7 @@ public partial class MainWindow : MetroWindow {
} }
private TransactionType GetTransaction<TransactionType>(object sender) where TransactionType : Transaction { private TransactionType GetTransaction<TransactionType>(object sender) where TransactionType : Transaction {
System.Windows.Controls.Control button = sender as System.Windows.Controls.Control; Control button = sender as Control;
if (button == null || button.DataContext == null) { if (button == null || button.DataContext == null) {
return null; return null;
} }
@ -530,4 +531,8 @@ public partial class MainWindow : MetroWindow {
private void NoInfluenceSupport_Toggled(object sender, RoutedEventArgs e) { private void NoInfluenceSupport_Toggled(object sender, RoutedEventArgs e) {
Config.Global.IgnoreInfluenceSupport = this.NoInfluenceSupport.IsOn; Config.Global.IgnoreInfluenceSupport = this.NoInfluenceSupport.IsOn;
} }
private void NoMarketBuy_Toggled(object sender, RoutedEventArgs e) {
Config.Global.IgnoreMarketBuy = this.NoMarketBuy.IsOn;
}
} }

View File

@ -53,6 +53,11 @@ namespace EliteBGS.Util {
/// </summary> /// </summary>
public bool IgnoreInfluenceSupport { get; set; } = false; public bool IgnoreInfluenceSupport { get; set; } = false;
/// <summary>
/// Whether we ignore market buy entries during parsing.
/// </summary>
public bool IgnoreMarketBuy { get; set; } = false;
[JsonIgnore] [JsonIgnore]
public string FullTheme { public string FullTheme {
get { return Theme + "." + Colour; } get { return Theme + "." + Colour; }