From f227b8fbdde39f4fd6399e663c8e7cd0fcb68af1 Mon Sep 17 00:00:00 2001 From: Philippe St-Arnaud <17132057+pstarn@users.noreply.github.com> Date: Fri, 29 Mar 2024 15:48:24 -0400 Subject: [PATCH 1/2] Anomalies panel improvements Visual changes to how the anomalies are presented as well as functionality changes inspired by https://wormholes.new-eden.io/. - Fix crash when double-clicking cells in the list of anomalies - Implement visual enhancements for presenting anomalies in the panel - Colorize anomalies based on their type - Add a "Since" column displaying how long ago the anomaly was added - Add a button to delete the selected anomalies - Anomalies missing from an update are selected to make their removal easier - Support CTRL+V to paste anomalies into the datagrid - Support CTRL+C to copy anomalies from the datagrid to the clipboard - Support pressing Delete to delete selected anomalies --- EVEData/Anom.cs | 2 +- EVEData/AnomData.cs | 109 +++++++++++--------------- SMT/MainWindow.xaml | 62 ++++++++++----- SMT/MainWindow.xaml.cs | 170 +++++++++++++++++++++++++++++++++++++++-- 4 files changed, 253 insertions(+), 90 deletions(-) diff --git a/EVEData/Anom.cs b/EVEData/Anom.cs index 3b4ff693..46fb637f 100644 --- a/EVEData/Anom.cs +++ b/EVEData/Anom.cs @@ -83,6 +83,6 @@ public enum SignatureType /// /// To String /// - public override string ToString() => Signature + " " + Type + " " + Name; + public override string ToString() => Signature + "\t" + "Cosmic Signature" + "\t" + Type + "\t" + Name + "\t\t"; } } \ No newline at end of file diff --git a/EVEData/AnomData.cs b/EVEData/AnomData.cs index c6a86193..516cae98 100644 --- a/EVEData/AnomData.cs +++ b/EVEData/AnomData.cs @@ -40,82 +40,63 @@ public AnomData() /// Update the AnomData from the string (usually the clipboard) /// /// raw Anom strings - public void UpdateFromPaste(string pastedText) + public HashSet UpdateFromPaste(string pastedText) { - bool validPaste = false; - List itemsToKeep = new List(); + HashSet signaturesPresent = new HashSet(); + string[] pastelines = pastedText.Split('\n'); foreach (string line in pastelines) { // split on tabs string[] words = line.Split('\t'); - if (words.Length == 6) - { - // only care about "Cosmic Signature" - if (CosmicSignatureTags.Contains(words[1])) - { - validPaste = true; - - string sigID = words[0]; - string sigType = words[2]; - string sigName = words[3]; - - if (string.IsNullOrEmpty(sigType)) - { - sigType = "Unknown"; - } - - itemsToKeep.Add(sigID); - - // valid sig - if (Anoms.ContainsKey(sigID)) - { - // updating an existing one - Anom an = Anoms[sigID]; - if (an.Type == "Unknown") - { - an.Type = sigType; - } - - if (!string.IsNullOrEmpty(sigName)) - { - an.Name = sigName; - } - } - else - { - Anom an = new Anom(); - an.Signature = sigID; - an.Type = sigType; - - if (!string.IsNullOrEmpty(sigName)) - { - an.Name = sigName; - } - - Anoms.Add(sigID, an); - } - } - } - } - // if we had a valid paste dump any items we didnt reference, brute force scan and remove.. come back to this later.. - if (validPaste) - { - List toRemove = new List(); - foreach (string an in Anoms.Keys.ToList()) + if (words.Length != 6) + continue; + + // only care about "Cosmic Signature" + if (!CosmicSignatureTags.Contains(words[1])) + continue; + + string sigID = words[0]; + string sigType = words[2]; + string sigName = words[3]; + + if (string.IsNullOrEmpty(sigType)) + sigType = "Unknown"; + + signaturesPresent.Add(sigID); + + if (Anoms.ContainsKey(sigID)) { - if (!itemsToKeep.Contains(an)) - { - toRemove.Add(an); - } - } + // update an existing signature + Anom an = Anoms[sigID]; - foreach (string s in toRemove) + if (an.Type == "Unknown") + an.Type = sigType; + + if (!string.IsNullOrEmpty(sigName)) + an.Name = sigName; + } + else { - Anoms.Remove(s); + // add a new signature + Anom an = new Anom(); + an.Signature = sigID; + an.Type = sigType; + + if (!string.IsNullOrEmpty(sigName)) + an.Name = sigName; + + Anoms.Add(sigID, an); } } + + // find existing signatures that are missing from the paste + var signaturesMissing = Anoms.Where(kvp => !signaturesPresent.Contains(kvp.Value.Signature)) + .Select(kvp => kvp.Key) + .ToHashSet(); + + return signaturesMissing; } } } \ No newline at end of file diff --git a/SMT/MainWindow.xaml b/SMT/MainWindow.xaml index fa140a8e..162209b7 100644 --- a/SMT/MainWindow.xaml +++ b/SMT/MainWindow.xaml @@ -20,6 +20,7 @@ + @@ -114,43 +115,68 @@ - + - + - + + -