public JObject CreateEDDNMessage(JournalScan journal) { JObject msg = new JObject(); return null; /* msg["header"] = Header(); msg["$schemaRef"] = "http://schemas.elite-markets.net/eddn/journal/1/test"; JObject message = new JObject(); message["StarSystem"] = journal.StarSystem; message["Faction"] = journal.Faction; message["Government"] = journal.Government; message["timestamp"] = journal.EventTimeUTC.ToString("yyyy-MM-ddTHH:mm:ssZ"); message["Allegiance"] = journal.Allegiance; message["Security"] = journal.Security; message["event"] = journal.EventTypeStr; message["Economy"] = journal.Economy; msg["message"] = message; return msg; */ }
Point CreateMaterialNodes(List<PictureBoxHotspot.ImageElement> pc, JournalScan sn, Point matpos, Size matsize) { Point startpos = matpos; Point maximum = matpos; int noperline = 0; bool noncommon = checkBoxMaterialsRare.Checked; string matclicktext = sn.DisplayMaterials(2); foreach (KeyValuePair<string, double> sd in sn.Materials) { string abv = sd.Key.Substring(0, 1); string tooltip = sd.Key; Color fillc = Color.Yellow; EDDiscovery2.DB.MaterialCommodities mc = EDDiscovery2.DB.MaterialCommodities.GetCachedMaterial(sd.Key); if (mc != null) { abv = mc.shortname; fillc = mc.colour; tooltip = mc.name + " (" + mc.shortname + ") " + mc.type + " " + sd.Value.ToString("0.0") + "%"; if (noncommon && mc.type.IndexOf("common", StringComparison.InvariantCultureIgnoreCase) >= 0) continue; } CreateMaterialImage(pc, matpos, matsize, abv, tooltip + "\n\n" + "All " + matclicktext, tooltip, fillc, Color.Black); maximum = new Point(Math.Max(maximum.X, matpos.X + matsize.Width), Math.Max(maximum.Y, matpos.Y + matsize.Height)); if (++noperline == 4) { matpos = new Point(startpos.X, matpos.Y + matsize.Height + materialspacer); noperline = 0; } else matpos.X += matsize.Width + materialspacer; } return maximum; }
public static List<JournalScan> GetBodiesList(int edsmid) { List<JournalScan> bodies = new List<JournalScan>(); EDSMClass edsm = new EDSMClass(); JObject jo = edsm.GetBodies(edsmid); // Colonia if (jo != null) { foreach (JObject bodie in jo["bodies"]) { EDSMClass.ConvertFromEDSMBodies(bodie); JournalScan js = new JournalScan(bodie); js.EdsmID = edsmid; bodies.Add(js); } return bodies; } return null; }
public void NewBodyScan(JournalScan js) { if (IsSummaryPopOutReady) summaryPopOut.ShowScanData(js); }
public JObject CreateEDDNMessage(JournalScan journal, string starSystem, double x, double y, double z) { JObject msg = new JObject(); msg["header"] = Header(); msg["$schemaRef"] = GetEDDNSchemaRef(); JObject message = (JObject)JObject.Parse(journal.EventDataString); message["StarSystem"] = starSystem; message["StarPos"] = new JArray(new float[] { (float)x, (float)y, (float)z }); if (!journal.BodyName.StartsWith(starSystem)) // For now test if its a different name ( a few exception for like sol system with named planets) To catch a rare out of sync bug in historylist. { return null; } message = RemoveCommonKeys(message); msg["message"] = message; return msg; }
public bool Process(JournalScan sc, EDDiscovery2.DB.ISystem sys) // FALSE if you can't process it { Tuple <string, long> withedsm = new Tuple <string, long>(sys.name, sys.id_edsm); Tuple <string, long> withoutedsm = new Tuple <string, long>(sys.name, 0); SystemNode sn; if (scandata.ContainsKey(withedsm)) // if with edsm (if id_edsm=0, then thats okay) { sn = scandata[withedsm]; } else if (scandata.ContainsKey(withoutedsm)) // if we now have an edsm id, see if we have one without it { sn = scandata[withoutedsm]; if (sys.id_edsm != 0) // yep, replace { scandata.Remove(new Tuple <string, long>(sys.name, 0)); scandata.Add(new Tuple <string, long>(sys.name, sys.id_edsm), sn); } } else { sn = new SystemNode() { system = sys, starnodes = new SortedList <string, ScanNode>(new DuplicateKeyComparer <string>()) }; scandata.Add(new Tuple <string, long>(sys.name, sys.id_edsm), sn); } // handle Earth, starname = Sol // handle Eol Prou LW-L c8-306 A 4 a and Eol Prou LW-L c8-306 // handle Colonia 4 , starname = Colonia, planet 4 // handle Aurioum B A BELT // Kyloasly OY-Q d5-906 13 1 List <string> elements; ScanNodeType starscannodetype = ScanNodeType.star; // presuming.. string rest = sc.IsStarNameRelatedReturnRest(sys.name); if (rest != null) // if we have a relationship.. { if (rest.Length > 0) { elements = rest.Split(' ').ToList(); if (char.IsDigit(elements[0][0])) // if digits, planet number, no star designator { elements.Insert(0, "Main Star"); // no star designator, main star, add MAIN } else if (elements[0].Length > 1) // designator, is it multiple chars.. { starscannodetype = ScanNodeType.barycentre; } } else { elements = new List <string>(); // only 1 item, the star, which is the same as the system name.. elements.Add("Main Star"); // Sol / SN:Sol should come thru here } } else { // so not part of starname elements = sc.BodyName.Split(' ').ToList(); // not related in any way (earth) so assume all bodyparts, and elements.Insert(0, "Main Star"); // insert the MAIN designator as the star designator } if (elements.Count >= 1) // okay, we have an element.. first is the star.. { ScanNode sublv0; if (!sn.starnodes.TryGetValue(elements[0], out sublv0)) // not found this node, add.. { sublv0 = new ScanNode() { ownname = elements[0], fullname = sys.name + (elements[0].Contains("Main") ? "" : (" " + elements[0])), scandata = null, children = null, type = starscannodetype }; sn.starnodes.Add(elements[0], sublv0); //System.Diagnostics.Debug.WriteLine("Added star " + star.fullname + " '" + star.ownname + "'" + " under '" + designator + "' type " + ty); } if (elements.Count >= 2) // we have a sub designator.. { ScanNode sublv1; if (sublv0.children == null || !sublv0.children.TryGetValue(elements[1], out sublv1)) { if (sublv0.children == null) { sublv0.children = new SortedList <string, ScanNode>(new DuplicateKeyComparer <string>()); } sublv1 = new ScanNode() { ownname = elements[1], fullname = sublv0.fullname + " " + elements[1], scandata = null, children = null, type = ScanNodeType.planet }; sublv0.children.Add(elements[1], sublv1); } if (elements.Count >= 3) { ScanNode sublv2; if (sublv1.children == null || !sublv1.children.TryGetValue(elements[2], out sublv2)) { if (sublv1.children == null) { sublv1.children = new SortedList <string, ScanNode>(new DuplicateKeyComparer <string>()); } sublv2 = new ScanNode() { ownname = elements[2], fullname = sublv0.fullname + " " + elements[1] + " " + elements[2], scandata = null, children = null, type = ScanNodeType.moon }; sublv1.children.Add(elements[2], sublv2); } if (elements.Count >= 4) { ScanNode sublv3; if (sublv2.children == null || !sublv2.children.TryGetValue(elements[3], out sublv3)) { if (sublv2.children == null) { sublv2.children = new SortedList <string, ScanNode>(new DuplicateKeyComparer <string>()); } sublv3 = new ScanNode() { ownname = elements[3], fullname = sublv0.fullname + " " + elements[1] + " " + elements[2] + " " + elements[3], scandata = null, children = null, type = ScanNodeType.submoon }; sublv2.children.Add(elements[3], sublv3); } if (elements.Count == 4) // okay, need only 4 elements now.. if not, we have not coped.. { sublv3.scandata = sc; } else { System.Diagnostics.Debug.WriteLine("Failed to add system " + sc.BodyName + " too long"); return(false); } } else { sublv2.scandata = sc; } } else { sublv1.scandata = sc; } } else { sublv0.scandata = sc; } return(true); } else { System.Diagnostics.Debug.WriteLine("Failed to add system " + sc.BodyName + " not enough elements"); return(false); } }