2022-11-24 19:38:19 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
using Ookii.Dialogs.Wpf;
|
|
|
|
|
using EDPlayerJournal;
|
|
|
|
|
using EDPlayerJournal.BGS;
|
|
|
|
|
using EDPlayerJournal.Entries;
|
|
|
|
|
using EliteBGS.BGS;
|
|
|
|
|
using EliteBGS.Util;
|
2022-12-14 18:44:39 +01:00
|
|
|
|
using System.Globalization;
|
2022-12-14 19:28:23 +01:00
|
|
|
|
using System.Windows.Controls.Primitives;
|
2023-02-22 20:39:40 +01:00
|
|
|
|
using MahApps.Metro.Controls;
|
2023-02-23 20:55:17 +01:00
|
|
|
|
using ControlzEx.Theming;
|
|
|
|
|
using System.Windows.Media;
|
2023-02-25 18:12:33 +01:00
|
|
|
|
using System.Diagnostics;
|
2022-11-24 19:38:19 +01:00
|
|
|
|
|
|
|
|
|
namespace EliteBGS;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interaction logic for MainWindow.xaml
|
|
|
|
|
/// </summary>
|
2023-02-26 10:09:50 +01:00
|
|
|
|
public partial class MainWindow : MetroWindow {
|
2022-11-24 19:38:19 +01:00
|
|
|
|
private PlayerJournal journal;
|
|
|
|
|
private Report report;
|
|
|
|
|
|
|
|
|
|
public Config Config { get; set; } = new Config();
|
|
|
|
|
|
|
|
|
|
private LoadEntriesWindow loadentries = null;
|
|
|
|
|
|
|
|
|
|
private static readonly List<DiscordLogGenerator> logtypes = new List<DiscordLogGenerator>() {
|
|
|
|
|
new NonaDiscordLog(),
|
|
|
|
|
new GenericDiscordLog(),
|
2022-12-07 23:00:38 +01:00
|
|
|
|
new OneLineDiscordLog(),
|
2022-11-24 19:38:19 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public MainWindow() {
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
Config.LoadGlobal();
|
|
|
|
|
} catch (Exception) {
|
|
|
|
|
/* ignored */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (DiscordLogGenerator type in logtypes) {
|
|
|
|
|
LogType.Items.Add(type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string lastused = Config.Global.LastUsedDiscordTemplate;
|
|
|
|
|
int lastindex = logtypes.FindIndex(x => x.ToString() == lastused);
|
|
|
|
|
if (lastindex > -1) {
|
|
|
|
|
LogType.SelectedIndex = lastindex;
|
|
|
|
|
} else {
|
|
|
|
|
LogType.SelectedIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-29 18:40:36 +02:00
|
|
|
|
this.NoInfluenceSupport.IsOn = Config.Global.IgnoreInfluenceSupport;
|
2023-04-19 09:25:36 +02:00
|
|
|
|
this.NoMarketBuy.IsOn = Config.Global.IgnoreMarketBuy;
|
2023-05-15 18:38:03 +02:00
|
|
|
|
this.NoFleetCarrier.IsOn = Config.Global.IgnoreFleetCarrier;
|
2023-03-29 18:40:36 +02:00
|
|
|
|
|
2023-02-22 20:39:40 +01:00
|
|
|
|
// Apply theme
|
|
|
|
|
try {
|
2023-02-23 20:55:17 +01:00
|
|
|
|
AddCustomThemes();
|
|
|
|
|
|
2023-02-22 20:39:40 +01:00
|
|
|
|
string[] colours = ThemeManager.Current.Themes
|
|
|
|
|
.Select(x => x.ColorScheme)
|
|
|
|
|
.DistinctBy(x => x)
|
|
|
|
|
.OrderBy(x => x)
|
|
|
|
|
.ToArray()
|
|
|
|
|
;
|
2023-02-23 20:55:17 +01:00
|
|
|
|
|
2023-02-22 20:39:40 +01:00
|
|
|
|
foreach (var colour in colours) {
|
|
|
|
|
Colour.Items.Add(colour);
|
2023-02-23 20:55:17 +01:00
|
|
|
|
if (!string.IsNullOrEmpty(Config.Global.Colour) &&
|
|
|
|
|
string.Compare(colour, Config.Global.Colour, true) == 0) {
|
2023-02-22 20:39:40 +01:00
|
|
|
|
Colour.SelectedIndex = Colour.Items.Count - 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Colour.SelectedIndex < 0) {
|
|
|
|
|
Colour.SelectedIndex = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SwitchTheme.IsOn = (string.Compare(Config.Global.Theme, "dark", true) == 0);
|
|
|
|
|
|
|
|
|
|
ThemeManager.Current.ChangeTheme(this, Config.Global.FullTheme);
|
|
|
|
|
} catch (Exception) {
|
2023-02-23 20:55:17 +01:00
|
|
|
|
// Theme is invalid, revert back to our standard dark theme
|
2023-02-26 10:09:50 +01:00
|
|
|
|
Config.Global.Colour = "Amber";
|
2023-02-23 20:55:17 +01:00
|
|
|
|
Config.Global.Theme = "Dark";
|
2023-02-22 20:39:40 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 19:38:19 +01:00
|
|
|
|
journal = new PlayerJournal(Config.Global.JournalLocation);
|
|
|
|
|
|
|
|
|
|
// Set both to now
|
2022-12-14 19:07:05 +01:00
|
|
|
|
InitialiseTime();
|
2022-12-14 18:44:39 +01:00
|
|
|
|
|
2022-11-24 19:38:19 +01:00
|
|
|
|
journallocation.Text = Config.Global.JournalLocation;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-23 20:55:17 +01:00
|
|
|
|
private void AddCustomThemes() {
|
|
|
|
|
Dictionary<string, Color> colorThemes = new() {
|
2023-02-23 20:57:43 +01:00
|
|
|
|
//{ "HouseSalus", Color.FromRgb(0xBC, 0x94, 0x39) },
|
|
|
|
|
{ "HouseSalus", Color.FromRgb(0xED, 0xDA, 0x70) },
|
2023-02-23 20:55:17 +01:00
|
|
|
|
{ "NovaNavy", Color.FromRgb(0xA1, 0xA4, 0xDB) },
|
2024-04-13 12:18:33 +02:00
|
|
|
|
// Official Red of the Polish Flag
|
|
|
|
|
{ "PolskaGurom", Color.FromRgb(0xD4, 0x21, 0x3D) },
|
2024-04-28 12:46:01 +02:00
|
|
|
|
// Official Blue in the Armenian Flag
|
|
|
|
|
{ "ArmeniaBlue", Color.FromRgb(0x00, 0x33, 0xA0) },
|
2023-02-23 20:55:17 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
foreach (var colourtheme in colorThemes) {
|
|
|
|
|
var brush = new SolidColorBrush(colourtheme.Value);
|
|
|
|
|
|
|
|
|
|
// Add light theme
|
|
|
|
|
ThemeManager.Current.AddTheme(new Theme(
|
|
|
|
|
"Light." + colourtheme.Key,
|
|
|
|
|
"Light." + colourtheme.Key,
|
|
|
|
|
"Light",
|
|
|
|
|
colourtheme.Key,
|
|
|
|
|
colourtheme.Value,
|
|
|
|
|
brush,
|
|
|
|
|
true,
|
|
|
|
|
false)
|
|
|
|
|
);
|
|
|
|
|
// Add dark theme
|
|
|
|
|
ThemeManager.Current.AddTheme(new Theme(
|
|
|
|
|
"Dark." + colourtheme.Key,
|
|
|
|
|
"Dark." + colourtheme.Key,
|
|
|
|
|
"Dark",
|
|
|
|
|
colourtheme.Key,
|
|
|
|
|
colourtheme.Value,
|
|
|
|
|
brush,
|
|
|
|
|
true,
|
|
|
|
|
false)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-14 19:07:05 +01:00
|
|
|
|
private void InitialiseTime() {
|
2022-12-14 18:44:39 +01:00
|
|
|
|
DateTime today = DateTime.Today;
|
|
|
|
|
DateTime tomorrow = today.AddDays(1);
|
|
|
|
|
|
2023-02-22 20:39:40 +01:00
|
|
|
|
// HOCHKULTUR
|
|
|
|
|
startdate.Culture = enddate.Culture = CultureInfo.GetCultureInfo("de-AT");
|
2022-12-14 19:07:05 +01:00
|
|
|
|
|
2023-02-22 20:39:40 +01:00
|
|
|
|
startdate.SelectedDateTime = today;
|
|
|
|
|
enddate.SelectedDateTime = tomorrow;
|
2022-12-14 18:44:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-11-24 19:38:19 +01:00
|
|
|
|
private void TreeView_CheckBox_Updated(object sender, RoutedEventArgs args) {
|
|
|
|
|
GenerateLog();
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-09 17:52:03 +01:00
|
|
|
|
private void Report_OnLog(string message) {
|
|
|
|
|
StringBuilder builder = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
builder.Append(DateTime.Now.ToString());
|
|
|
|
|
builder.Append(": ");
|
|
|
|
|
builder.Append(message);
|
|
|
|
|
builder.Append("\n");
|
|
|
|
|
|
|
|
|
|
log.AppendText(builder.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Log(string message) {
|
|
|
|
|
Report_OnLog(message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void HandleEntries(List<Entry> entries, DateTime start, DateTime end) {
|
2022-11-24 19:38:19 +01:00
|
|
|
|
try {
|
2023-03-29 18:40:36 +02:00
|
|
|
|
TransactionParser parser = new();
|
|
|
|
|
TransactionParserOptions options = new();
|
|
|
|
|
|
|
|
|
|
options.IgnoreInfluenceSupport = Config.Global.IgnoreInfluenceSupport;
|
2023-04-19 09:17:06 +02:00
|
|
|
|
options.IgnoreMarketBuy = Config.Global.IgnoreMarketBuy;
|
2023-05-15 18:38:03 +02:00
|
|
|
|
options.IgnoreFleetCarrierFaction = Config.Global.IgnoreFleetCarrier;
|
2023-03-29 18:40:36 +02:00
|
|
|
|
|
|
|
|
|
List<Transaction> transactions = parser.Parse(entries, options);
|
2022-11-25 15:58:06 +01:00
|
|
|
|
|
2022-12-09 17:52:03 +01:00
|
|
|
|
// Filter the transactions down to the given time frame
|
|
|
|
|
transactions = transactions
|
2022-12-14 18:44:39 +01:00
|
|
|
|
.Where(t => t.CompletedAtDateTime >= start && t.CompletedAtDateTime <= end)
|
2022-12-09 17:52:03 +01:00
|
|
|
|
.ToList()
|
|
|
|
|
;
|
|
|
|
|
|
2022-11-25 17:28:10 +01:00
|
|
|
|
List<IncompleteTransaction> incompletes = transactions.OfType<IncompleteTransaction>().ToList();
|
2022-11-25 15:58:06 +01:00
|
|
|
|
// Log incomplete and remove them from the results.
|
2022-11-25 17:28:10 +01:00
|
|
|
|
foreach (var incomplete in incompletes) {
|
2022-11-25 15:58:06 +01:00
|
|
|
|
Log(incomplete.Reason);
|
|
|
|
|
}
|
2022-11-25 17:28:10 +01:00
|
|
|
|
transactions.RemoveAll(x => incompletes.Contains(x));
|
2022-11-24 19:38:19 +01:00
|
|
|
|
|
|
|
|
|
report = new Report(transactions);
|
2024-04-11 16:25:20 +02:00
|
|
|
|
this.entries.ItemsSource = report.SystemObjectives;
|
2022-11-24 19:38:19 +01:00
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
Log("Something went terribly wrong while parsing the E:D player journal.");
|
|
|
|
|
Log("Please send this to CMDR Hekateh:");
|
|
|
|
|
Log(exception.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-09 17:52:03 +01:00
|
|
|
|
private void HandleEntries(List<Entry> entries) {
|
2023-02-22 20:39:40 +01:00
|
|
|
|
HandleEntries(entries, startdate.SelectedDateTime ?? DateTime.Now, enddate.SelectedDateTime ?? DateTime.Now);
|
2022-11-24 19:38:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-12-09 17:52:03 +01:00
|
|
|
|
private void Loadentries_EntriesLoaded(List<Entry> lines) {
|
|
|
|
|
HandleEntries(lines);
|
2022-11-24 19:38:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ParseJournal_Click(object sender, RoutedEventArgs e) {
|
|
|
|
|
try {
|
|
|
|
|
TransactionParser parser = new TransactionParser();
|
|
|
|
|
|
2023-02-22 20:39:40 +01:00
|
|
|
|
DateTime start = startdate.SelectedDateTime ?? DateTime.Now;
|
|
|
|
|
DateTime end = enddate.SelectedDateTime ?? DateTime.Now;
|
2022-11-24 19:38:19 +01:00
|
|
|
|
|
|
|
|
|
journal.Open(); // Load all files
|
|
|
|
|
// Log files only get rotated if you restart the game client. This means that there might
|
|
|
|
|
// be - say - entries from the 4th of May in the file with a timestamp of 3rd of May. This
|
|
|
|
|
// happens if you happen to play a session late into the night.
|
|
|
|
|
// At first I tried extracting the first and last line of a file to see the date range, but
|
|
|
|
|
// if you have a lot of files this becomes quite slow, and quite the memory hog (as journal
|
|
|
|
|
// files have to be read in their entirety to check this). So we assume that you can't play
|
|
|
|
|
// three days straight, and keep the code fast.
|
|
|
|
|
DateTime actualstart = start.AddDays(-3);
|
2022-12-09 17:52:03 +01:00
|
|
|
|
DateTime actualend = end.AddDays(1);
|
2022-11-24 19:38:19 +01:00
|
|
|
|
List<Entry> entries = journal.Files
|
2022-12-09 17:52:03 +01:00
|
|
|
|
.Where(f => f.NormalisedDateTime >= actualstart && f.NormalisedDateTime <= actualend)
|
2022-11-24 19:38:19 +01:00
|
|
|
|
.SelectMany(e => e.Entries)
|
|
|
|
|
.ToList()
|
|
|
|
|
;
|
|
|
|
|
|
2022-12-09 17:52:03 +01:00
|
|
|
|
HandleEntries(entries, start, end);
|
2022-11-24 19:38:19 +01:00
|
|
|
|
GenerateLog();
|
2023-10-25 11:30:44 +02:00
|
|
|
|
|
|
|
|
|
var errors = journal.AllErrors;
|
|
|
|
|
foreach (var error in errors) {
|
|
|
|
|
Log("An error has occured in the Journal file, please send this to CMDR Hekateh:");
|
|
|
|
|
Log(error.ToString());
|
|
|
|
|
}
|
2022-11-24 19:38:19 +01:00
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
Log("Something went terribly wrong while parsing the E:D player journal.");
|
|
|
|
|
Log("Please send this to CMDR Hekateh:");
|
|
|
|
|
Log(exception.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GenerateLog() {
|
|
|
|
|
try {
|
|
|
|
|
DiscordLogGenerator discord = LogType.SelectedItem as DiscordLogGenerator;
|
|
|
|
|
string report = discord.GenerateDiscordLog(this.report);
|
|
|
|
|
|
|
|
|
|
DiscordLog.Text = report;
|
|
|
|
|
} catch (Exception exception) {
|
|
|
|
|
Log("Something went terribly wrong while generating the Discord log.");
|
|
|
|
|
Log("Please send this to CMDR Hekateh:");
|
|
|
|
|
Log(exception.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GenerateDiscord_Click(object sender, RoutedEventArgs e) {
|
|
|
|
|
GenerateLog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RemoveCurrentObjective() {
|
|
|
|
|
if (entries.SelectedItem == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object obj = entries.SelectedItem;
|
|
|
|
|
bool removed = false;
|
|
|
|
|
|
2024-04-13 12:07:38 +02:00
|
|
|
|
if (obj.GetType() == typeof(SystemObjectives)) {
|
|
|
|
|
removed = report.SystemObjectives.Remove(obj as SystemObjectives);
|
|
|
|
|
} else if (obj.GetType() == typeof(Objective)) {
|
|
|
|
|
report
|
|
|
|
|
.SystemObjectives
|
|
|
|
|
.ForEach(x => {
|
|
|
|
|
if (x.Objectives.Remove(obj as Objective)) {
|
|
|
|
|
removed = true;
|
|
|
|
|
}
|
|
|
|
|
});
|
2022-11-24 19:38:19 +01:00
|
|
|
|
} else if (obj.GetType() == typeof(UITransaction) ||
|
2024-04-13 12:07:38 +02:00
|
|
|
|
obj.GetType().IsSubclassOf(typeof(UITransaction))) {
|
|
|
|
|
report
|
|
|
|
|
.SystemObjectives
|
|
|
|
|
.SelectMany(x =>
|
|
|
|
|
x.Objectives
|
|
|
|
|
.Where(x => x.UITransactions.Contains(obj as UITransaction))
|
|
|
|
|
)
|
|
|
|
|
.ToList()
|
|
|
|
|
.ForEach(x => removed = x.UITransactions.Remove(obj as UITransaction))
|
|
|
|
|
;
|
2022-11-24 19:38:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (removed) {
|
2022-11-25 16:03:32 +01:00
|
|
|
|
RefreshView();
|
2022-11-24 19:38:19 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-19 09:17:06 +02:00
|
|
|
|
private void entries_KeyUp(object sender, KeyEventArgs e) {
|
2022-11-24 19:38:19 +01:00
|
|
|
|
if (e.Key == Key.Delete) {
|
|
|
|
|
RemoveCurrentObjective();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void browsejournallocation_Click(object sender, RoutedEventArgs e) {
|
|
|
|
|
var dialog = new VistaFolderBrowserDialog();
|
|
|
|
|
|
|
|
|
|
if ((bool)!dialog.ShowDialog()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Config.Global.JournalLocation = dialog.SelectedPath;
|
|
|
|
|
journallocation.Text = Config.Global.JournalLocation;
|
|
|
|
|
journal = new PlayerJournal(Config.Global.JournalLocation);
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-14 19:28:23 +01:00
|
|
|
|
private Objective GetObjectiveFromControl(object sender) {
|
2023-04-19 09:17:06 +02:00
|
|
|
|
Control control = sender as Control;
|
2022-11-29 17:42:20 +01:00
|
|
|
|
if (control == null || control.DataContext == null) {
|
2022-12-14 19:28:23 +01:00
|
|
|
|
return null;
|
2022-11-24 19:38:19 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-12-14 19:28:23 +01:00
|
|
|
|
return control.DataContext as Objective;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AddCombatZone_Click(object sender, RoutedEventArgs e) {
|
|
|
|
|
Objective objective = GetObjectiveFromControl(sender);
|
2022-11-29 17:42:20 +01:00
|
|
|
|
if (objective == null) {
|
2022-11-24 19:38:19 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CombatZone zone = new CombatZone {
|
|
|
|
|
Faction = objective.Faction,
|
|
|
|
|
System = objective.System,
|
2022-11-29 17:42:20 +01:00
|
|
|
|
Grade = "Low",
|
|
|
|
|
Type = "Ship",
|
2022-11-24 19:38:19 +01:00
|
|
|
|
};
|
|
|
|
|
|
2022-11-26 17:15:23 +01:00
|
|
|
|
UITransaction uitransaction = new UITransaction(zone);
|
|
|
|
|
objective.UITransactions.Add(uitransaction);
|
|
|
|
|
|
2022-11-25 16:03:32 +01:00
|
|
|
|
RefreshView();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RefreshView() {
|
|
|
|
|
entries.Items.Refresh();
|
2022-11-24 19:38:19 +01:00
|
|
|
|
GenerateLog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LogType_SelectionChanged(object sender, SelectionChangedEventArgs e) {
|
|
|
|
|
if (LogType.SelectedItem == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string template = LogType.SelectedItem.ToString();
|
|
|
|
|
Config.Global.LastUsedDiscordTemplate = template;
|
|
|
|
|
GenerateLog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ManuallyParse_Click(object sender, RoutedEventArgs e) {
|
|
|
|
|
if (loadentries != null) {
|
|
|
|
|
loadentries.Show();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loadentries = new LoadEntriesWindow();
|
|
|
|
|
loadentries.Closed += Loadentries_Closed;
|
|
|
|
|
loadentries.EntriesLoaded += Loadentries_EntriesLoaded;
|
|
|
|
|
loadentries.Show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Loadentries_Closed(object sender, EventArgs e) {
|
|
|
|
|
loadentries = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void window_Closing(object sender, System.ComponentModel.CancelEventArgs e) {
|
|
|
|
|
loadentries?.Close();
|
|
|
|
|
loadentries = null;
|
2023-02-22 20:39:40 +01:00
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
Config.SaveGlobal();
|
|
|
|
|
} catch (Exception error) {
|
2023-04-19 09:17:06 +02:00
|
|
|
|
MessageBox.Show("There was an error saving your settings: " + error.Message);
|
2023-02-22 20:39:40 +01:00
|
|
|
|
}
|
2022-11-24 19:38:19 +01:00
|
|
|
|
}
|
2022-11-26 16:19:55 +01:00
|
|
|
|
|
|
|
|
|
private void Transaction_Initialized(object sender, EventArgs e) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private TransactionType GetTransaction<TransactionType>(object sender) where TransactionType : Transaction {
|
2023-04-19 09:17:06 +02:00
|
|
|
|
Control button = sender as Control;
|
2022-11-26 16:19:55 +01:00
|
|
|
|
if (button == null || button.DataContext == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UITransaction transaction = button.DataContext as UITransaction;
|
|
|
|
|
if (transaction == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return transaction.Transaction as TransactionType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Low_Click(object sender, RoutedEventArgs e) {
|
|
|
|
|
CombatZone transaction = GetTransaction<CombatZone>(sender);
|
|
|
|
|
if (transaction == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-03 14:33:09 +01:00
|
|
|
|
transaction.Grade = CombatZones.DifficultyLow;
|
2022-11-26 16:19:55 +01:00
|
|
|
|
RefreshView();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Med_Click(object sender, RoutedEventArgs e) {
|
|
|
|
|
CombatZone transaction = GetTransaction<CombatZone>(sender);
|
|
|
|
|
if (transaction == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-03 14:33:09 +01:00
|
|
|
|
transaction.Grade = CombatZones.DifficultyMedium;
|
2022-11-26 16:19:55 +01:00
|
|
|
|
RefreshView();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void High_Click(object sender, RoutedEventArgs e) {
|
|
|
|
|
CombatZone transaction = GetTransaction<CombatZone>(sender);
|
|
|
|
|
if (transaction == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-03 14:33:09 +01:00
|
|
|
|
transaction.Grade = CombatZones.DifficultyHigh;
|
2022-11-26 16:19:55 +01:00
|
|
|
|
RefreshView();
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-03 20:42:38 +01:00
|
|
|
|
private void VeryHigh_Click(object sender, RoutedEventArgs e) {
|
|
|
|
|
CombatZone transaction = GetTransaction<CombatZone>(sender);
|
|
|
|
|
if (transaction == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
transaction.Grade = CombatZones.DifficultyVeryHigh;
|
|
|
|
|
RefreshView();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-29 17:52:27 +01:00
|
|
|
|
private void Ground_Click(object sender, RoutedEventArgs e) {
|
2022-11-26 16:19:55 +01:00
|
|
|
|
CombatZone transaction = GetTransaction<CombatZone>(sender);
|
|
|
|
|
if (transaction == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-03 14:33:09 +01:00
|
|
|
|
transaction.Type = CombatZones.GroundCombatZone;
|
2022-11-26 16:19:55 +01:00
|
|
|
|
RefreshView();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Ship_Click(object sender, RoutedEventArgs e) {
|
|
|
|
|
CombatZone transaction = GetTransaction<CombatZone>(sender);
|
|
|
|
|
if (transaction == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-03 14:33:09 +01:00
|
|
|
|
transaction.Type = CombatZones.ShipCombatZone;
|
2022-11-26 16:19:55 +01:00
|
|
|
|
RefreshView();
|
|
|
|
|
}
|
2022-11-26 17:09:01 +01:00
|
|
|
|
|
2022-12-03 14:47:31 +01:00
|
|
|
|
private void Thargoid_Click(object sender, RoutedEventArgs e) {
|
|
|
|
|
CombatZone transaction = GetTransaction<CombatZone>(sender);
|
|
|
|
|
if (transaction == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-03 20:42:38 +01:00
|
|
|
|
transaction.Type = CombatZones.AXCombatZone;
|
2022-12-03 14:47:31 +01:00
|
|
|
|
RefreshView();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-29 18:05:08 +01:00
|
|
|
|
private void Profit_LostFocus(object sender, RoutedEventArgs e) {
|
2022-11-26 17:09:01 +01:00
|
|
|
|
RefreshView();
|
|
|
|
|
}
|
2022-11-29 18:05:08 +01:00
|
|
|
|
|
|
|
|
|
private void Profit_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) {
|
|
|
|
|
if (e.Key == Key.Enter) {
|
|
|
|
|
RefreshView();
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-14 19:07:05 +01:00
|
|
|
|
|
|
|
|
|
private DateTime ResetTimeToZero(DateTime d) {
|
|
|
|
|
DateTime obj = d;
|
|
|
|
|
|
|
|
|
|
obj = obj.AddHours(d.Hour * -1);
|
|
|
|
|
obj = obj.AddMinutes(d.Minute * -1);
|
|
|
|
|
obj = obj.AddSeconds(d.Second * -1);
|
|
|
|
|
|
|
|
|
|
return obj;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ResetTime_Click(object sender, RoutedEventArgs e) {
|
2023-02-22 20:39:40 +01:00
|
|
|
|
DateTime? d = startdate.SelectedDateTime;
|
2022-12-14 19:07:05 +01:00
|
|
|
|
if (d != null) {
|
2023-02-22 20:39:40 +01:00
|
|
|
|
startdate.SelectedDateTime = ResetTimeToZero(d.Value);
|
2022-12-14 19:07:05 +01:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-22 20:39:40 +01:00
|
|
|
|
d = enddate.SelectedDateTime;
|
2022-12-14 19:07:05 +01:00
|
|
|
|
if (d != null) {
|
2023-02-22 20:39:40 +01:00
|
|
|
|
enddate.SelectedDateTime = ResetTimeToZero(d.Value);
|
2022-12-14 19:07:05 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-14 19:28:23 +01:00
|
|
|
|
|
|
|
|
|
private void ToggleAll_Click(object sender, RoutedEventArgs e) {
|
|
|
|
|
ToggleButton button = sender as ToggleButton;
|
|
|
|
|
Objective objective = GetObjectiveFromControl(sender);
|
|
|
|
|
if (objective == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
objective.UITransactions
|
|
|
|
|
.ForEach(x => x.IsEnabled = (button.IsChecked ?? true))
|
|
|
|
|
;
|
|
|
|
|
}
|
2023-02-22 20:39:40 +01:00
|
|
|
|
|
|
|
|
|
private void UpdateTheme() {
|
|
|
|
|
ThemeManager.Current.ChangeTheme(this, Config.Global.FullTheme);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void SwitchTheme_Toggled(object sender, RoutedEventArgs e) {
|
|
|
|
|
ToggleSwitch toggle = sender as ToggleSwitch;
|
|
|
|
|
if (toggle.IsOn) {
|
|
|
|
|
Config.Global.Theme = "Dark";
|
|
|
|
|
} else {
|
|
|
|
|
Config.Global.Theme = "Light";
|
|
|
|
|
}
|
|
|
|
|
UpdateTheme();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Colour_SelectionChanged(object sender, SelectionChangedEventArgs e) {
|
|
|
|
|
if (Colour.SelectedItem == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Config.Global.Colour = Colour.SelectedItem.ToString();
|
|
|
|
|
UpdateTheme();
|
|
|
|
|
}
|
2023-02-25 18:12:33 +01:00
|
|
|
|
|
|
|
|
|
private void URL_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e) {
|
|
|
|
|
ProcessStartInfo info = new ProcessStartInfo();
|
|
|
|
|
info.UseShellExecute = true;
|
|
|
|
|
info.FileName = e.Uri.AbsoluteUri;
|
|
|
|
|
Process.Start(info);
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
}
|
2023-03-29 18:40:36 +02:00
|
|
|
|
|
|
|
|
|
private void NoInfluenceSupport_Toggled(object sender, RoutedEventArgs e) {
|
|
|
|
|
Config.Global.IgnoreInfluenceSupport = this.NoInfluenceSupport.IsOn;
|
|
|
|
|
}
|
2023-04-19 09:17:06 +02:00
|
|
|
|
|
|
|
|
|
private void NoMarketBuy_Toggled(object sender, RoutedEventArgs e) {
|
|
|
|
|
Config.Global.IgnoreMarketBuy = this.NoMarketBuy.IsOn;
|
|
|
|
|
}
|
2023-05-15 18:38:03 +02:00
|
|
|
|
|
|
|
|
|
private void NoFleetCarrier_Toggled(object sender, RoutedEventArgs e) {
|
|
|
|
|
Config.Global.IgnoreFleetCarrier = this.NoFleetCarrier.IsOn;
|
|
|
|
|
}
|
2023-05-15 18:44:11 +02:00
|
|
|
|
|
|
|
|
|
private void OpenInExplorer_Click(object sender, RoutedEventArgs e) {
|
|
|
|
|
try {
|
|
|
|
|
Process.Start(new ProcessStartInfo(Config.Global.JournalLocation) {
|
|
|
|
|
UseShellExecute = true,
|
|
|
|
|
});
|
|
|
|
|
} catch (Exception) {
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-04-12 13:48:55 +02:00
|
|
|
|
|
|
|
|
|
private void SelectAll_Click(object sender, RoutedEventArgs e) {
|
|
|
|
|
if (report == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
report.SystemObjectives.ForEach(t => { t.IsEnabled = (bool)SelectAll.IsChecked; });
|
|
|
|
|
}
|
2022-11-24 19:38:19 +01:00
|
|
|
|
}
|