private void buttonExtExcel_Click(object sender, EventArgs e) { Forms.ExportForm frm = new Forms.ExportForm(); frm.Init(new string[] { "All", "Stars only", "Planets only", //2 "Exploration List Stars", //3 "Exploration List Planets", //4 "Sold Exploration Data", // 5 }); if (frm.ShowDialog(FindForm()) == DialogResult.OK) { BaseUtils.CSVWrite csv = new BaseUtils.CSVWrite(); csv.SetCSVDelimiter(frm.Comma); try { using (System.IO.StreamWriter writer = new System.IO.StreamWriter(frm.Path)) { if (frm.SelectedIndex == 5) { int count; List <HistoryEntry> data = HistoryList.FilterByJournalEvent(discoveryform.history.ToList(), "Sell Exploration Data", out count); data = (from he in data where he.EventTimeLocal >= frm.StartTime && he.EventTimeLocal <= frm.EndTime orderby he.EventTimeUTC descending select he).ToList(); List <HistoryEntry> scans = HistoryList.FilterByJournalEvent(discoveryform.history.ToList(), "Scan", out count); if (frm.IncludeHeader) { writer.Write(csv.Format("Time")); writer.Write(csv.Format("System")); writer.Write(csv.Format("Star type")); writer.Write(csv.Format("Planet type", false)); writer.WriteLine(); } foreach (HistoryEntry he in data) { JournalSellExplorationData jsed = he.journalEntry as JournalSellExplorationData; if (jsed == null || jsed.Discovered == null) { continue; } foreach (String system in jsed.Discovered) { writer.Write(csv.Format(jsed.EventTimeLocal)); writer.Write(csv.Format(system)); EDStar star = EDStar.Unknown; EDPlanet planet = EDPlanet.Unknown; foreach (HistoryEntry scanhe in scans) { JournalScan scan = scanhe.journalEntry as JournalScan; if (scan.BodyName.Equals(system, StringComparison.OrdinalIgnoreCase)) { star = scan.StarTypeID; planet = scan.PlanetTypeID; break; } } writer.Write(csv.Format((star != EDStar.Unknown) ? Enum.GetName(typeof(EDStar), star) : "")); writer.Write(csv.Format((planet != EDPlanet.Unknown) ? Enum.GetName(typeof(EDPlanet), planet) : "", false)); writer.WriteLine(); } } } else { List <JournalScan> scans = null; if (frm.SelectedIndex < 3) { var entries = JournalEntry.GetByEventType(JournalTypeEnum.Scan, EDCommander.CurrentCmdrID, frm.StartTime, frm.EndTime); scans = entries.ConvertAll(x => (JournalScan)x); } else { ExplorationSetClass currentExplorationSet = new ExplorationSetClass(); string file = currentExplorationSet.DialogLoad(FindForm()); if (file != null) { scans = new List <JournalScan>(); foreach (string system in currentExplorationSet.Systems) { ISystem sys = SystemCache.FindSystem(system); if (sys != null) { List <JournalScan> sysscans = EDSMClass.GetBodiesList(sys.EDSMID); if (sysscans != null) { scans.AddRange(sysscans); } } } } else { return; } } bool ShowStars = frm.SelectedIndex < 2 || frm.SelectedIndex == 3; bool ShowPlanets = frm.SelectedIndex == 0 || frm.SelectedIndex == 2 || frm.SelectedIndex == 4; List <JournalSAAScanComplete> mappings = ShowPlanets ? JournalEntry.GetByEventType(JournalTypeEnum.SAAScanComplete, EDCommander.CurrentCmdrID, frm.StartTime, frm.EndTime) .ConvertAll(x => (JournalSAAScanComplete)x) : null; if (frm.IncludeHeader) { // Write header writer.Write(csv.Format("Time")); writer.Write(csv.Format("BodyName")); writer.Write(csv.Format("Estimated Value")); writer.Write(csv.Format("DistanceFromArrivalLS")); writer.Write(csv.Format("WasMapped")); writer.Write(csv.Format("WasDiscovered")); if (ShowStars) { writer.Write(csv.Format("StarType")); writer.Write(csv.Format("StellarMass")); writer.Write(csv.Format("AbsoluteMagnitude")); writer.Write(csv.Format("Age MY")); writer.Write(csv.Format("Luminosity")); } writer.Write(csv.Format("Radius")); writer.Write(csv.Format("RotationPeriod")); writer.Write(csv.Format("SurfaceTemperature")); if (ShowPlanets) { writer.Write(csv.Format("TidalLock")); writer.Write(csv.Format("TerraformState")); writer.Write(csv.Format("PlanetClass")); writer.Write(csv.Format("Atmosphere")); writer.Write(csv.Format("Iron")); writer.Write(csv.Format("Silicates")); writer.Write(csv.Format("SulphurDioxide")); writer.Write(csv.Format("CarbonDioxide")); writer.Write(csv.Format("Nitrogen")); writer.Write(csv.Format("Oxygen")); writer.Write(csv.Format("Water")); writer.Write(csv.Format("Argon")); writer.Write(csv.Format("Ammonia")); writer.Write(csv.Format("Methane")); writer.Write(csv.Format("Hydrogen")); writer.Write(csv.Format("Helium")); writer.Write(csv.Format("Volcanism")); writer.Write(csv.Format("SurfaceGravity")); writer.Write(csv.Format("SurfacePressure")); writer.Write(csv.Format("Landable")); writer.Write(csv.Format("EarthMasses")); writer.Write(csv.Format("IcePercent")); writer.Write(csv.Format("RockPercent")); writer.Write(csv.Format("MetalPercent")); } // Common orbital param writer.Write(csv.Format("SemiMajorAxis")); writer.Write(csv.Format("Eccentricity")); writer.Write(csv.Format("OrbitalInclination")); writer.Write(csv.Format("Periapsis")); writer.Write(csv.Format("OrbitalPeriod")); writer.Write(csv.Format("AxialTilt")); if (ShowPlanets) { writer.Write(csv.Format("Carbon")); writer.Write(csv.Format("Iron")); writer.Write(csv.Format("Nickel")); writer.Write(csv.Format("Phosphorus")); writer.Write(csv.Format("Sulphur")); writer.Write(csv.Format("Arsenic")); writer.Write(csv.Format("Chromium")); writer.Write(csv.Format("Germanium")); writer.Write(csv.Format("Manganese")); writer.Write(csv.Format("Selenium")); writer.Write(csv.Format("Vanadium")); writer.Write(csv.Format("Zinc")); writer.Write(csv.Format("Zirconium")); writer.Write(csv.Format("Cadmium")); writer.Write(csv.Format("Mercury")); writer.Write(csv.Format("Molybdenum")); writer.Write(csv.Format("Niobium")); writer.Write(csv.Format("Tin")); writer.Write(csv.Format("Tungsten")); writer.Write(csv.Format("Antimony")); writer.Write(csv.Format("Polonium")); writer.Write(csv.Format("Ruthenium")); writer.Write(csv.Format("Technetium")); writer.Write(csv.Format("Tellurium")); writer.Write(csv.Format("Yttrium")); } writer.WriteLine(); } foreach (JournalScan je in scans) { JournalScan scan = je as JournalScan; if (ShowPlanets == false) // Then only show stars. { if (String.IsNullOrEmpty(scan.StarType)) { continue; } } if (ShowStars == false) // Then only show planets { if (String.IsNullOrEmpty(scan.PlanetClass)) { continue; } } writer.Write(csv.Format(scan.EventTimeUTC)); writer.Write(csv.Format(scan.BodyName)); writer.Write(csv.Format(scan.EstimatedValue)); writer.Write(csv.Format(scan.DistanceFromArrivalLS)); writer.Write(csv.Format(scan.WasMapped)); writer.Write(csv.Format(scan.WasDiscovered)); if (ShowStars) { writer.Write(csv.Format(scan.StarType)); writer.Write(csv.Format((scan.nStellarMass.HasValue) ? scan.nStellarMass.Value : 0)); writer.Write(csv.Format((scan.nAbsoluteMagnitude.HasValue) ? scan.nAbsoluteMagnitude.Value : 0)); writer.Write(csv.Format((scan.nAge.HasValue) ? scan.nAge.Value : 0)); writer.Write(csv.Format(scan.Luminosity)); } writer.Write(csv.Format(scan.nRadius.HasValue ? scan.nRadius.Value : 0)); writer.Write(csv.Format(scan.nRotationPeriod.HasValue ? scan.nRotationPeriod.Value : 0)); writer.Write(csv.Format(scan.nSurfaceTemperature.HasValue ? scan.nSurfaceTemperature.Value : 0)); if (ShowPlanets) { writer.Write(csv.Format(scan.nTidalLock.HasValue ? scan.nTidalLock.Value : false)); writer.Write(csv.Format((scan.TerraformState != null) ? scan.TerraformState : "")); writer.Write(csv.Format((scan.PlanetClass != null) ? scan.PlanetClass : "")); writer.Write(csv.Format((scan.Atmosphere != null) ? scan.Atmosphere : "")); writer.Write(csv.Format(scan.GetAtmosphereComponent("Iron"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Silicates"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("SulphurDioxide"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("CarbonDioxide"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Nitrogen"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Oxygen"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Water"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Argon"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Ammonia"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Methane"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Hydrogen"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Helium"))); writer.Write(csv.Format((scan.Volcanism != null) ? scan.Volcanism : "")); writer.Write(csv.Format(scan.nSurfaceGravity.HasValue ? scan.nSurfaceGravity.Value : 0)); writer.Write(csv.Format(scan.nSurfacePressure.HasValue ? scan.nSurfacePressure.Value : 0)); writer.Write(csv.Format(scan.nLandable.HasValue ? scan.nLandable.Value : false)); writer.Write(csv.Format((scan.nMassEM.HasValue) ? scan.nMassEM.Value : 0)); writer.Write(csv.Format(scan.GetCompositionPercent("Ice"))); writer.Write(csv.Format(scan.GetCompositionPercent("Rock"))); writer.Write(csv.Format(scan.GetCompositionPercent("Metal"))); } // Common orbital param writer.Write(csv.Format(scan.nSemiMajorAxis.HasValue ? scan.nSemiMajorAxis.Value : 0)); writer.Write(csv.Format(scan.nEccentricity.HasValue ? scan.nEccentricity.Value : 0)); writer.Write(csv.Format(scan.nOrbitalInclination.HasValue ? scan.nOrbitalInclination.Value : 0)); writer.Write(csv.Format(scan.nPeriapsis.HasValue ? scan.nPeriapsis.Value : 0)); writer.Write(csv.Format(scan.nOrbitalPeriod.HasValue ? scan.nOrbitalPeriod.Value : 0)); writer.Write(csv.Format(scan.nAxialTilt.HasValue ? scan.nAxialTilt : null)); if (ShowPlanets) { writer.Write(csv.Format(scan.GetMaterial("Carbon"))); writer.Write(csv.Format(scan.GetMaterial("Iron"))); writer.Write(csv.Format(scan.GetMaterial("Nickel"))); writer.Write(csv.Format(scan.GetMaterial("Phosphorus"))); writer.Write(csv.Format(scan.GetMaterial("Sulphur"))); writer.Write(csv.Format(scan.GetMaterial("Arsenic"))); writer.Write(csv.Format(scan.GetMaterial("Chromium"))); writer.Write(csv.Format(scan.GetMaterial("Germanium"))); writer.Write(csv.Format(scan.GetMaterial("Manganese"))); writer.Write(csv.Format(scan.GetMaterial("Selenium"))); writer.Write(csv.Format(scan.GetMaterial("Vanadium"))); writer.Write(csv.Format(scan.GetMaterial("Zinc"))); writer.Write(csv.Format(scan.GetMaterial("Zirconium"))); writer.Write(csv.Format(scan.GetMaterial("Cadmium"))); writer.Write(csv.Format(scan.GetMaterial("Mercury"))); writer.Write(csv.Format(scan.GetMaterial("Molybdenum"))); writer.Write(csv.Format(scan.GetMaterial("Niobium"))); writer.Write(csv.Format(scan.GetMaterial("Tin"))); writer.Write(csv.Format(scan.GetMaterial("Tungsten"))); writer.Write(csv.Format(scan.GetMaterial("Antimony"))); writer.Write(csv.Format(scan.GetMaterial("Polonium"))); writer.Write(csv.Format(scan.GetMaterial("Ruthenium"))); writer.Write(csv.Format(scan.GetMaterial("Technetium"))); writer.Write(csv.Format(scan.GetMaterial("Tellurium"))); writer.Write(csv.Format(scan.GetMaterial("Yttrium"))); } writer.WriteLine(); } } writer.Close(); if (frm.AutoOpen) { System.Diagnostics.Process.Start(frm.Path); } } } catch { ExtendedControls.MessageBoxTheme.Show(FindForm(), "Failed to write to " + frm.Path, "Export Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
private void buttonExtExcel_Click(object sender, EventArgs e) { Forms.ExportForm frm = new Forms.ExportForm(); frm.Init(new string[] { "All", "Stars only", "Planets only", //2 "Exploration List Stars", //3 "Exploration List Planets", //4 "Ring Scans", //5 }); if (frm.ShowDialog(FindForm()) == DialogResult.OK) { BaseUtils.CSVWrite csv = new BaseUtils.CSVWrite(); csv.SetCSVDelimiter(frm.Comma); try { if (frm.SelectedIndex == 5) { var saaentries = JournalEntry.GetByEventType(JournalTypeEnum.SAASignalsFound, EDCommander.CurrentCmdrID, frm.StartTimeUTC, frm.EndTimeUTC).ConvertAll(x => (JournalSAASignalsFound)x); var scanentries = JournalEntry.GetByEventType(JournalTypeEnum.Scan, EDCommander.CurrentCmdrID, frm.StartTimeUTC, frm.EndTimeUTC).ConvertAll(x => (JournalScan)x); BaseUtils.CSVWriteGrid grd = new BaseUtils.CSVWriteGrid(); grd.SetCSVDelimiter(frm.Comma); string[] headers1 = { "", "", "", "", "", "", "Icy Ring", "", "", "", "", "","", "", "", "", "Rocky", "", "", "", "", "","", "", "Metal Rich", "", "", "", "", "Metalic", "", "", "", "", "Other" }; string[] headers2 = { "Time", "BodyName", "Ring Types", "Mass MT", "Inner Rad (ls)", "Outer Rad (ls)", // icy ring "Water", "Liquid Oxygen", "Methanol Mono", "Methane", "Bromellite", "Grandidierite", "Low Temp Diamonds","Void Opals", "Alexandrite", "Tritium", // rocky "Bauxite", "Indite", "Alexandrite", "Monazite", "Musgravite", "Benitoite", "Serendibite", "Rhodplumsite", // metal rich "Rhodplumsite", "Serendibite", "Platinum", "Monazite", "Painite", // metalic "Rhodplumsite", "Serendibite", "Platinum", "Monazite", "Painite", // others "Geological", "Biological", "Thargoid", "Human", "Guardian", }; string[] fdname = { "Water", "LiquidOxygen", "methanolmonohydratecrystals", "MethaneClathrate", // icy "Bromellite", "Grandidierite", "lowtemperaturediamond", "Opal", "Alexandrite", "Tritium", "Bauxite", "Indite", "Alexandrite", "Monazite", "Musgravite","Benitoite", "Serendibite", "Rhodplumsite", // rocky "Rhodplumsite", "Serendibite", "Platinum", "Monazite", "Painite", // metal rich "Rhodplumsite", "Serendibite", "Platinum", "Monazite", "Painite", // metalic "$SAA_SignalType_Geological;", "$SAA_SignalType_Biological;", "$SAA_SignalType_Thargoid;", "$SAA_SignalType_Human;","$SAA_SignalType_Guardian;" }; grd.GetLineHeader = (row) => { return(row == 1 ? headers2 : row == 0 ? headers1 : null); }; grd.GetLineStatus = (row) => { if (row < saaentries.Count) { for (int rp = row + 1; rp < saaentries.Count; rp++) { if (saaentries[rp].BodyName == saaentries[row].BodyName && (saaentries[rp].EventTimeUTC - saaentries[row].EventTimeUTC) < new TimeSpan(30, 0, 0, 0)) { return(CSVWriteGrid.LineStatus.Skip); // if matches one in front, and its less than 30 days from it, ignore } } return(CSVWriteGrid.LineStatus.OK); } else { return(CSVWriteGrid.LineStatus.EOF); } }; grd.GetLine = (r) => { var entry = saaentries[r]; string signals = string.Join(",", entry.Signals.Select(x => x.Type_Localised)); JournalScan scanof = scanentries.Find(x => x.FindRing(entry.BodyName) != null); bool showrocky = true, showmr = true, showmetalic = true, showicy = true; // only used if item appears more than once below string ringtype = "", mass = "", innerrad = "", outerrad = ""; if (scanof != null) { var ri = scanof.FindRing(entry.BodyName); ringtype = ri.RingClassNormalised(); if (ringtype.Contains("metalic", StringComparison.InvariantCultureIgnoreCase)) { showicy = showrocky = showmr = false; } else if (ringtype.Contains("Metal", StringComparison.InvariantCultureIgnoreCase)) { showicy = showrocky = showmetalic = false; } else if (ringtype.Contains("rocky", StringComparison.InvariantCultureIgnoreCase)) { showicy = showmetalic = showmr = false; } else if (ringtype.Contains("icy", StringComparison.InvariantCultureIgnoreCase)) { showrocky = showmetalic = showmr = false; } mass = ri.MassMT.ToStringInvariant(); innerrad = (ri.InnerRad / JournalScan.oneLS_m).ToStringInvariant("N3"); outerrad = (ri.OuterRad / JournalScan.oneLS_m).ToStringInvariant("N3"); } //string sig = string.Join(",", entry.Signals.Select(x=>x.Type)); // debug return(new object[] { EDDConfig.Instance.ConvertTimeToSelectedFromUTC(entry.EventTimeUTC), entry.BodyName, ringtype, mass, innerrad, outerrad, entry.ContainsStr(fdname[0]), entry.ContainsStr(fdname[1]), entry.ContainsStr(fdname[2]), entry.ContainsStr(fdname[3]), entry.ContainsStr(fdname[4]), entry.ContainsStr(fdname[5]), entry.ContainsStr(fdname[6]), entry.ContainsStr(fdname[7]), entry.ContainsStr(fdname[8], showicy), entry.ContainsStr(fdname[9]), // "Bauxite","Indite","Alexandrite","Monazite", // rocky entry.ContainsStr(fdname[10]), entry.ContainsStr(fdname[11]), entry.ContainsStr(fdname[12], showrocky), entry.ContainsStr(fdname[13], showrocky), // "Musgravite","Benitoite","Serendibite","Rhodplumsite", // rocky entry.ContainsStr(fdname[14]), entry.ContainsStr(fdname[15]), entry.ContainsStr(fdname[16], showrocky), entry.ContainsStr(fdname[17], showrocky), // "Rhodplumsite","Serendibite","Platinum","Monazite","Painite", // metal rich entry.ContainsStr(fdname[18], showmr), entry.ContainsStr(fdname[19], showmr), entry.ContainsStr(fdname[20], showmr), entry.ContainsStr(fdname[21], showmr), entry.ContainsStr(fdname[22], showmr), // "Rhodplumsite","Serendibite","Platinum","Monazite","Painite", // metalic entry.ContainsStr(fdname[23], showmetalic), entry.ContainsStr(fdname[24], showmetalic), entry.ContainsStr(fdname[25], showmetalic), entry.ContainsStr(fdname[26], showmetalic), entry.ContainsStr(fdname[27], showmetalic), entry.ContainsStr(fdname[28]), entry.ContainsStr(fdname[29]), entry.ContainsStr(fdname[30]), entry.ContainsStr(fdname[31]), entry.ContainsStr(fdname[32]), }); }; grd.WriteGrid(frm.Path, frm.AutoOpen, FindForm()); } else { using (System.IO.StreamWriter writer = new System.IO.StreamWriter(frm.Path)) { List <JournalScan> scans = null; if (frm.SelectedIndex < 3) { var entries = JournalEntry.GetByEventType(JournalTypeEnum.Scan, EDCommander.CurrentCmdrID, frm.StartTimeUTC, frm.EndTimeUTC); scans = entries.ConvertAll(x => (JournalScan)x); } else { ExplorationSetClass currentExplorationSet = new ExplorationSetClass(); string file = currentExplorationSet.DialogLoad(FindForm()); if (file != null) { scans = new List <JournalScan>(); foreach (string system in currentExplorationSet.Systems) { ISystem sys = SystemCache.FindSystem(system); if (sys != null) { var jl = EDSMClass.GetBodiesList(sys); List <JournalScan> sysscans = jl.Item1; if (sysscans != null) { scans.AddRange(sysscans); } } } } else { return; } } bool ShowStars = frm.SelectedIndex < 2 || frm.SelectedIndex == 3; bool ShowPlanets = frm.SelectedIndex == 0 || frm.SelectedIndex == 2 || frm.SelectedIndex == 4; bool ShowBeltClusters = frm.SelectedIndex == 0; List <JournalSAAScanComplete> mappings = ShowPlanets ? JournalEntry.GetByEventType(JournalTypeEnum.SAAScanComplete, EDCommander.CurrentCmdrID, frm.StartTimeUTC, frm.EndTimeUTC).ConvertAll(x => (JournalSAAScanComplete)x) : null; if (frm.IncludeHeader) { // Write header writer.Write(csv.Format("Time")); writer.Write(csv.Format("BodyName")); writer.Write(csv.Format("Estimated Value")); writer.Write(csv.Format("DistanceFromArrivalLS")); writer.Write(csv.Format("WasMapped")); writer.Write(csv.Format("WasDiscovered")); if (ShowStars) { writer.Write(csv.Format("StarType")); writer.Write(csv.Format("StellarMass")); writer.Write(csv.Format("AbsoluteMagnitude")); writer.Write(csv.Format("Age MY")); writer.Write(csv.Format("Luminosity")); } writer.Write(csv.Format("Radius")); writer.Write(csv.Format("RotationPeriod")); writer.Write(csv.Format("SurfaceTemperature")); if (ShowPlanets) { writer.Write(csv.Format("TidalLock")); writer.Write(csv.Format("TerraformState")); writer.Write(csv.Format("PlanetClass")); writer.Write(csv.Format("Atmosphere")); writer.Write(csv.Format("Iron")); writer.Write(csv.Format("Silicates")); writer.Write(csv.Format("SulphurDioxide")); writer.Write(csv.Format("CarbonDioxide")); writer.Write(csv.Format("Nitrogen")); writer.Write(csv.Format("Oxygen")); writer.Write(csv.Format("Water")); writer.Write(csv.Format("Argon")); writer.Write(csv.Format("Ammonia")); writer.Write(csv.Format("Methane")); writer.Write(csv.Format("Hydrogen")); writer.Write(csv.Format("Helium")); writer.Write(csv.Format("Volcanism")); writer.Write(csv.Format("SurfaceGravity")); writer.Write(csv.Format("SurfacePressure")); writer.Write(csv.Format("Landable")); writer.Write(csv.Format("EarthMasses")); writer.Write(csv.Format("IcePercent")); writer.Write(csv.Format("RockPercent")); writer.Write(csv.Format("MetalPercent")); } // Common orbital param writer.Write(csv.Format("SemiMajorAxis")); writer.Write(csv.Format("Eccentricity")); writer.Write(csv.Format("OrbitalInclination")); writer.Write(csv.Format("Periapsis")); writer.Write(csv.Format("OrbitalPeriod")); writer.Write(csv.Format("AxialTilt")); if (ShowPlanets) { writer.Write(csv.Format("Carbon")); writer.Write(csv.Format("Iron")); writer.Write(csv.Format("Nickel")); writer.Write(csv.Format("Phosphorus")); writer.Write(csv.Format("Sulphur")); writer.Write(csv.Format("Arsenic")); writer.Write(csv.Format("Chromium")); writer.Write(csv.Format("Germanium")); writer.Write(csv.Format("Manganese")); writer.Write(csv.Format("Selenium")); writer.Write(csv.Format("Vanadium")); writer.Write(csv.Format("Zinc")); writer.Write(csv.Format("Zirconium")); writer.Write(csv.Format("Cadmium")); writer.Write(csv.Format("Mercury")); writer.Write(csv.Format("Molybdenum")); writer.Write(csv.Format("Niobium")); writer.Write(csv.Format("Tin")); writer.Write(csv.Format("Tungsten")); writer.Write(csv.Format("Antimony")); writer.Write(csv.Format("Polonium")); writer.Write(csv.Format("Ruthenium")); writer.Write(csv.Format("Technetium")); writer.Write(csv.Format("Tellurium")); writer.Write(csv.Format("Yttrium")); } writer.WriteLine(); } foreach (JournalScan je in scans) { JournalScan scan = je as JournalScan; if ((je.IsPlanet && ShowPlanets) || (je.IsStar && ShowStars) || (je.IsBeltCluster && ShowBeltClusters)) { if (je.IsPlanet) { var mapping = mappings?.FirstOrDefault(m => m.BodyID == scan.BodyID && m.BodyName == scan.BodyName); if (mapping != null) { scan.SetMapped(true, mapping.ProbesUsed <= mapping.EfficiencyTarget); } } writer.Write(csv.Format(EDDConfig.Instance.ConvertTimeToSelectedFromUTC(scan.EventTimeUTC))); writer.Write(csv.Format(scan.BodyName)); writer.Write(csv.Format(scan.EstimatedValue)); writer.Write(csv.Format(scan.DistanceFromArrivalLS)); writer.Write(csv.Format(scan.WasMapped)); writer.Write(csv.Format(scan.WasDiscovered)); if (ShowStars) { writer.Write(csv.Format(scan.StarType)); writer.Write(csv.Format((scan.nStellarMass.HasValue) ? scan.nStellarMass.Value : 0)); writer.Write(csv.Format((scan.nAbsoluteMagnitude.HasValue) ? scan.nAbsoluteMagnitude.Value : 0)); writer.Write(csv.Format((scan.nAge.HasValue) ? scan.nAge.Value : 0)); writer.Write(csv.Format(scan.Luminosity)); } writer.Write(csv.Format(scan.nRadius.HasValue ? scan.nRadius.Value : 0)); writer.Write(csv.Format(scan.nRotationPeriod.HasValue ? scan.nRotationPeriod.Value : 0)); writer.Write(csv.Format(scan.nSurfaceTemperature.HasValue ? scan.nSurfaceTemperature.Value : 0)); if (ShowPlanets) { writer.Write(csv.Format(scan.nTidalLock.HasValue ? scan.nTidalLock.Value : false)); writer.Write(csv.Format((scan.TerraformState != null) ? scan.TerraformState : "")); writer.Write(csv.Format((scan.PlanetClass != null) ? scan.PlanetClass : "")); writer.Write(csv.Format((scan.Atmosphere != null) ? scan.Atmosphere : "")); writer.Write(csv.Format(scan.GetAtmosphereComponent("Iron"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Silicates"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("SulphurDioxide"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("CarbonDioxide"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Nitrogen"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Oxygen"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Water"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Argon"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Ammonia"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Methane"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Hydrogen"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Helium"))); writer.Write(csv.Format((scan.Volcanism != null) ? scan.Volcanism : "")); writer.Write(csv.Format(scan.nSurfaceGravity.HasValue ? scan.nSurfaceGravity.Value : 0)); writer.Write(csv.Format(scan.nSurfacePressure.HasValue ? scan.nSurfacePressure.Value : 0)); writer.Write(csv.Format(scan.nLandable.HasValue ? scan.nLandable.Value : false)); writer.Write(csv.Format((scan.nMassEM.HasValue) ? scan.nMassEM.Value : 0)); writer.Write(csv.Format(scan.GetCompositionPercent("Ice"))); writer.Write(csv.Format(scan.GetCompositionPercent("Rock"))); writer.Write(csv.Format(scan.GetCompositionPercent("Metal"))); } // Common orbital param writer.Write(csv.Format(scan.nSemiMajorAxis.HasValue ? scan.nSemiMajorAxis.Value : 0)); writer.Write(csv.Format(scan.nEccentricity.HasValue ? scan.nEccentricity.Value : 0)); writer.Write(csv.Format(scan.nOrbitalInclination.HasValue ? scan.nOrbitalInclination.Value : 0)); writer.Write(csv.Format(scan.nPeriapsis.HasValue ? scan.nPeriapsis.Value : 0)); writer.Write(csv.Format(scan.nOrbitalPeriod.HasValue ? scan.nOrbitalPeriod.Value : 0)); writer.Write(csv.Format(scan.nAxialTilt.HasValue ? scan.nAxialTilt : null)); if (ShowPlanets) { writer.Write(csv.Format(scan.GetMaterial("Carbon"))); writer.Write(csv.Format(scan.GetMaterial("Iron"))); writer.Write(csv.Format(scan.GetMaterial("Nickel"))); writer.Write(csv.Format(scan.GetMaterial("Phosphorus"))); writer.Write(csv.Format(scan.GetMaterial("Sulphur"))); writer.Write(csv.Format(scan.GetMaterial("Arsenic"))); writer.Write(csv.Format(scan.GetMaterial("Chromium"))); writer.Write(csv.Format(scan.GetMaterial("Germanium"))); writer.Write(csv.Format(scan.GetMaterial("Manganese"))); writer.Write(csv.Format(scan.GetMaterial("Selenium"))); writer.Write(csv.Format(scan.GetMaterial("Vanadium"))); writer.Write(csv.Format(scan.GetMaterial("Zinc"))); writer.Write(csv.Format(scan.GetMaterial("Zirconium"))); writer.Write(csv.Format(scan.GetMaterial("Cadmium"))); writer.Write(csv.Format(scan.GetMaterial("Mercury"))); writer.Write(csv.Format(scan.GetMaterial("Molybdenum"))); writer.Write(csv.Format(scan.GetMaterial("Niobium"))); writer.Write(csv.Format(scan.GetMaterial("Tin"))); writer.Write(csv.Format(scan.GetMaterial("Tungsten"))); writer.Write(csv.Format(scan.GetMaterial("Antimony"))); writer.Write(csv.Format(scan.GetMaterial("Polonium"))); writer.Write(csv.Format(scan.GetMaterial("Ruthenium"))); writer.Write(csv.Format(scan.GetMaterial("Technetium"))); writer.Write(csv.Format(scan.GetMaterial("Tellurium"))); writer.Write(csv.Format(scan.GetMaterial("Yttrium"))); } writer.WriteLine(); } } writer.Close(); } if (frm.AutoOpen) { System.Diagnostics.Process.Start(frm.Path); } } } catch { ExtendedControls.MessageBoxTheme.Show(FindForm(), "Failed to write to " + frm.Path, "Export Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
private void dataGridViewDistances_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { if (e.RowIndex < 0 || e.RowIndex >= dataGridViewDistances.Rows.Count) { return; } try { if (e.ColumnIndex == 0) { var value = e.FormattedValue.ToString(); var cell = dataGridViewDistances[e.ColumnIndex, e.RowIndex]; if (value == "" && (cell.Value == null || cell.Value.ToString() == "")) { return; } var system = SystemCache.FindSystem(value); var enteredSystems = GetEnteredSystems(); if (cell.Value != null) { enteredSystems.RemoveAll(s => s.Name == cell.Value.ToString()); } if (system == null || (enteredSystems.Contains(system))) { return; } } if (e.ColumnIndex == 1) { var value = e.FormattedValue.ToString().Trim(); if (value == "") { dataGridViewDistances.Rows[e.RowIndex].ErrorText = null; return; } var parsed = BaseUtils.DistanceParser.ParseInterstellarDistance(value); if (parsed.HasValue) { dataGridViewDistances.Rows[e.RowIndex].ErrorText = null; } else { e.Cancel = true; dataGridViewDistances.Rows[e.RowIndex].ErrorText = "Invalid number"; } } } catch (Exception ex) { this.BeginInvoke(new MethodInvoker(() => { LogTextHighlight("Exception:" + ex.Message); LogText(ex.StackTrace); })); } }
// I think we rework so we have a SyncBackgroundworker, and a refresh background worker. // loading of history is done on refresh one.. private void BackgroundWorkerThread() { readyForInitialLoad.WaitOne(); // wait for shown in form // check first and download items StarScan.LoadBodyDesignationMap(); Debug.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Check systems"); ReportSyncProgress(""); bool checkGithub = EDDOptions.Instance.CheckGithubFiles; if (checkGithub) // not normall in debug, due to git hub chokeing { // Async load of maps in another thread DownloadMaps(() => PendingClose); // and Expedition data DownloadExpeditions(() => PendingClose); // and Exploration data DownloadExploration(() => PendingClose); } if (!EDDOptions.Instance.NoSystemsLoad) { // New Galmap load - it was not doing a refresh if EDSM sync kept on happening. Now has its own timer DateTime galmaptime = SQLiteConnectionSystem.GetSettingDate("EDSMGalMapLast", DateTime.MinValue); // Latest time from RW file. if (DateTime.Now.Subtract(galmaptime).TotalDays > 14 || !galacticMapping.GalMapFilePresent()) // Over 14 days do a sync from EDSM for galmap { LogLine("Get galactic mapping from EDSM.".Tx(this, "EDSM")); if (galacticMapping.DownloadFromEDSM()) { SQLiteConnectionSystem.PutSettingDate("EDSMGalMapLast", DateTime.UtcNow); } } Debug.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Check systems complete"); } galacticMapping.ParseData(); // at this point, gal map data has been uploaded - get it into memory SystemCache.AddToAutoCompleteList(galacticMapping.GetGMONames()); SystemNoteClass.GetAllSystemNotes(); LogLine("Loaded Notes, Bookmarks and Galactic mapping.".Tx(this, "LN")); if (PendingClose) { return; } if (EliteDangerousCore.EDDN.EDDNClass.CheckforEDMC()) // EDMC is running { if (EDCommander.Current.SyncToEddn) // Both EDD and EDMC should not sync to EDDN. { LogLineHighlight("EDDiscovery and EDMarketConnector should not both sync to EDDN. Stop EDMC or uncheck 'send to EDDN' in settings tab!".Tx(this, "EDMC")); } } if (!EDDOptions.Instance.NoLoad) // here in this thread, we do a refresh of history. { LogLine("Reading travel history".Tx(this, "RTH")); if (EDDOptions.Instance.Commander != null) { EDCommander switchto = EDCommander.GetCommander(EDDOptions.Instance.Commander); if (switchto != null) { EDCommander.CurrentCmdrID = switchto.Nr; } } DoRefreshHistory(new RefreshWorkerArgs { CurrentCommander = EDCommander.CurrentCmdrID }); // kick the background refresh worker thread into action } if (PendingClose) { return; } CheckForSync(); // see if any EDSM/EDDB sync is needed if (PendingClose) { return; } // Now stay in loop services stuff backgroundRefreshWorker = new Thread(BackgroundHistoryRefreshWorkerThread) { Name = "Background Refresh Worker", IsBackground = true }; backgroundRefreshWorker.Start(); // start the refresh worker, another thread which does subsequenct (not the primary one) refresh work in the background.. try { if (!EDDOptions.Instance.NoSystemsLoad && EDDConfig.Instance.EDSMEDDBDownload) // if no system off, and EDSM download on { DoPerformSync(); // this is done after the initial history load.. } while (!PendingClose) { int wh = WaitHandle.WaitAny(new WaitHandle[] { closeRequested, resyncRequestedEvent }); if (PendingClose) { break; } switch (wh) { case 0: // Close Requested break; case 1: // Resync Requested if (!EDDOptions.Instance.NoSystemsLoad && EDDConfig.Instance.EDSMEDDBDownload) // if no system off, and EDSM download on { DoPerformSync(); } break; } } } catch (OperationCanceledException) { } backgroundRefreshWorker.Join(); // Now we have been ordered to close down, so go thru the process closeRequested.WaitOne(); OnBgSafeClose?.Invoke(); ReadyForFinalClose = true; InvokeAsyncOnUiThread(() => { OnFinalClose?.Invoke(); }); }
private void BackgroundWorkerThread() { // check first and download items StarScan.LoadBodyDesignationMap(); Debug.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Check systems"); ReportSyncProgress(""); bool checkGithub = EDDOptions.Instance.CheckGithubFiles; if (checkGithub) // not normall in debug, due to git hub chokeing { // and Expedition data DownloadExpeditions(() => PendingClose); // and Exploration data DownloadExploration(() => PendingClose); } if (!EDDOptions.Instance.NoSystemsLoad) { // New Galmap load - it was not doing a refresh if EDSM sync kept on happening. Now has its own timer DateTime galmaptime = SystemsDatabase.Instance.GetEDSMGalMapLast(); // Latest time from RW file. if (DateTime.Now.Subtract(galmaptime).TotalDays > 14 || !galacticMapping.GalMapFilePresent()) // Over 14 days do a sync from EDSM for galmap { LogLine("Get galactic mapping from EDSM.".T(EDTx.EDDiscoveryController_EDSM)); if (galacticMapping.DownloadFromEDSM()) { SystemsDatabase.Instance.SetEDSMGalMapLast(DateTime.UtcNow); } } Debug.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Check systems complete"); } galacticMapping.ParseData(); // at this point, gal map data has been uploaded - get it into memory SystemCache.AddToAutoCompleteList(galacticMapping.GetGMONames()); SystemNoteClass.GetAllSystemNotes(); LogLine("Loaded Notes, Bookmarks and Galactic mapping.".T(EDTx.EDDiscoveryController_LN)); if (!EDDOptions.Instance.NoLoad) // here in this thread, we do a refresh of history. { LogLine("Reading travel history".T(EDTx.EDDiscoveryController_RTH)); if (EDDOptions.Instance.Commander != null) { EDCommander switchto = EDCommander.GetCommander(EDDOptions.Instance.Commander); if (switchto != null) { EDCommander.CurrentCmdrID = switchto.Nr; } } DoRefreshHistory(new RefreshWorkerArgs { CurrentCommander = EDCommander.CurrentCmdrID }); // kick the background refresh worker thread into action } CheckForSync(); // see if any EDSM/EDDB sync is needed - this just sets some variables up System.Diagnostics.Debug.WriteLine("Background worker setting up refresh worker"); backgroundRefreshWorker = new Thread(BackgroundHistoryRefreshWorkerThread) { Name = "Background Refresh Worker", IsBackground = true }; backgroundRefreshWorker.Start(); // start the refresh worker, another thread which does subsequenct (not the primary one) refresh work in the background.. try { if (!EDDOptions.Instance.NoSystemsLoad) { SystemsDatabase.Instance.WithReadWrite(() => DoPerformSync()); // this is done after the initial history load.. } SystemsDatabase.Instance.SetReadOnly(); while (!PendingClose) { int wh = WaitHandle.WaitAny(new WaitHandle[] { closeRequested, resyncRequestedEvent }); System.Diagnostics.Debug.WriteLine("Background worker kicked by " + wh); if (PendingClose) { break; } if (wh == 1) { if (!EDDOptions.Instance.NoSystemsLoad && EDDConfig.Instance.EDSMEDDBDownload) // if no system off, and EDSM download on { SystemsDatabase.Instance.WithReadWrite(() => DoPerformSync()); } } } } catch (OperationCanceledException) { } backgroundRefreshWorker.Join(); // this should terminate due to closeRequested.. System.Diagnostics.Debug.WriteLine("BW Refresh joined"); // Now we have been ordered to close down, so go thru the process closeRequested.WaitOne(); InvokeAsyncOnUiThread(() => { System.Diagnostics.Debug.WriteLine("Final close"); OnFinalClose?.Invoke(); }); }
private void UpdateTo(bool updatename) { changesilence = true; if (textBox_To.ReadOnly == false) // if entering system name.. { ISystem ds1 = discoveryform.history.FindSystem(SystemNameOnly(textBox_To.Text), discoveryform.galacticMapping); if (ds1 != null) { if (updatename) // can't fix it as you type.. so leave alone { if (ds1 is GalacticMapSystem) { GalacticMapSystem gms = (GalacticMapSystem)ds1; textBox_To.Text = gms.GalMapObject.name; } else { textBox_To.Text = ds1.Name; } } textBox_ToName.Text = ds1.Name; textBox_ToX.Text = ds1.X.ToString("0.00"); textBox_ToY.Text = ds1.Y.ToString("0.00"); textBox_ToZ.Text = ds1.Z.ToString("0.00"); } else { textBox_ToX.Text = textBox_ToY.Text = textBox_ToZ.Text = ""; } } else // Co-ords.. { string res = ""; Point3D curpos; if (GetCoordsTo(out curpos)) { ISystem nearest = SystemCache.FindNearestSystemTo(curpos.X, curpos.Y, curpos.Z, 100); if (nearest != null) { double distance = Point3D.DistanceBetween(curpos, new Point3D(nearest.X, nearest.Y, nearest.Z)); if (distance < 0.1) { res = nearest.Name; } else { res = nearest.Name + " @ " + distance.ToString("0.00") + "ly"; } } } textBox_To.Text = res; textBox_ToName.Text = res; } UpdateDistance(); changesilence = false; button_Route.Enabled = IsValid(); }
private void UpdateSystemRow(int rowindex) { const int idxVisits = 5; const int idxScans = 6; const int idxPriStar = 7; const int idxInfo = 8; const int idxNote = 9; ISystem currentSystem = discoveryform.history.CurrentSystem; // may be null if (rowindex < dataGridViewExplore.Rows.Count && dataGridViewExplore[0, rowindex].Value != null) { string sysname = dataGridViewExplore[0, rowindex].Value.ToString(); ISystem sys = (ISystem)dataGridViewExplore[0, rowindex].Tag; if (sys == null) { sys = SystemCache.FindSystem(sysname); } if (sys != null && currentSystem != null) { double dist = sys.Distance(currentSystem); string strdist = dist >= 0 ? ((double)dist).ToString("0.00") : ""; dataGridViewExplore[1, rowindex].Value = strdist; } dataGridViewExplore[0, rowindex].Tag = sys; dataGridViewExplore.Rows[rowindex].DefaultCellStyle.ForeColor = (sys != null && sys.HasCoordinate) ? discoveryform.theme.VisitedSystemColor : discoveryform.theme.NonVisitedSystemColor; if (sys != null) { if (sys.HasCoordinate) { dataGridViewExplore[2, rowindex].Value = sys.X.ToString("0.00"); dataGridViewExplore[3, rowindex].Value = sys.Y.ToString("0.00"); dataGridViewExplore[4, rowindex].Value = sys.Z.ToString("0.00"); } dataGridViewExplore[idxVisits, rowindex].Value = discoveryform.history.GetVisitsCount(sysname).ToString(); List <JournalScan> scans = discoveryform.history.GetScans(sysname); dataGridViewExplore[idxScans, rowindex].Value = scans.Count.ToString(); string pristar = ""; // Search for primary star foreach (var scan in scans) { if (scan.IsStar && scan.DistanceFromArrivalLS == 0.0) { pristar = scan.StarType; break; } } dataGridViewExplore[idxPriStar, rowindex].Value = pristar; string info = ""; foreach (var scan in scans) { if (scan.IsStar) { if (scan.StarTypeID == EDStar.AeBe) { info = info + " " + "AeBe"; } if (scan.StarTypeID == EDStar.N) { info = info + " " + "NS"; } if (scan.StarTypeID == EDStar.H) { info = info + " " + "BH"; } } else { if (scan.PlanetTypeID == EDPlanet.Earthlike_body) { info = info + " " + "ELW"; } if (scan.PlanetTypeID == EDPlanet.Water_world) { info = info + " " + "WW"; } } } dataGridViewExplore[idxInfo, rowindex].Value = info.Trim(); string note = ""; SystemNoteClass sn = SystemNoteClass.GetNoteOnSystem(sys.Name, sys.EDSMID); if (sn != null && !string.IsNullOrWhiteSpace(sn.Note)) { note = sn.Note; } else { BookmarkClass bkmark = GlobalBookMarkList.Instance.FindBookmarkOnSystem(sys.Name); if (bkmark != null && !string.IsNullOrWhiteSpace(bkmark.Note)) { note = bkmark.Note; } else { var gmo = discoveryform.galacticMapping.Find(sys.Name); if (gmo != null && !string.IsNullOrWhiteSpace(gmo.description)) { note = gmo.description; } } } dataGridViewExplore[idxNote, rowindex].Value = note.WordWrap(60); } if (sys == null && sysname != "") { dataGridViewExplore.Rows[rowindex].ErrorText = "System not known".Tx(); } else { dataGridViewExplore.Rows[rowindex].ErrorText = ""; } } }
/// <summary> /// 查询火车信息列表 /// </summary> /// <param name="startStation">出发站</param> /// <param name="endStation">到达站</param> /// <param name="takeDate">出发日期</param> /// <param name="ticketType">席座类型(软卧,硬座等)</param> /// <param name="seat">票种(成人,学生,儿童)</param> /// <returns></returns> public List <Train> GetTrainTableList(string startStation, string endStation, DateTime takeDate, string ticketType, Int32 seat) { List <Train> trainList = null; //DataTable dt = new DataTable("Datas"); //dt.Columns.Add("序号", Type.GetType("System.Int32")); //dt.Columns[0].AutoIncrement = true; //dt.Columns[0].AutoIncrementSeed = 1; //dt.Columns[0].AutoIncrementStep = 1; //dt.Columns.Add("车次", Type.GetType("System.String")); //dt.Columns.Add("出发站(s)", Type.GetType("System.String")); //dt.Columns.Add("目的站(s)", Type.GetType("System.String")); //dt.Columns.Add("历时", Type.GetType("System.String")); //dt.Columns.Add("商务座", Type.GetType("System.String")); //dt.Columns.Add("一等座", Type.GetType("System.String")); //dt.Columns.Add("二等座", Type.GetType("System.String")); //dt.Columns.Add("高级软卧", Type.GetType("System.String")); //dt.Columns.Add("软卧", Type.GetType("System.String")); //dt.Columns.Add("动卧", Type.GetType("System.String")); //dt.Columns.Add("硬卧", Type.GetType("System.String")); //dt.Columns.Add("软座", Type.GetType("System.String")); //dt.Columns.Add("硬座", Type.GetType("System.String")); //dt.Columns.Add("无座", Type.GetType("System.String")); //dt.Columns.Add("其他", Type.GetType("System.String")); //dt.Columns.Add("备注", Type.GetType("System.String")); //dt.Rows.Add(new object[] { null, train[3], "郑州 " + train[8], "上海 " + train[9]); string url = StringHelper.GetConfigValByKey("QUERYURL", false); //席座类型 //ticketType //票种 string seatType = seat == 0 ? "ADULT" : (seat == 1 ? "0X00" : " "); Dictionary <String, String> parames = new Dictionary <string, string> { { "leftTicketDTO.train_date", takeDate.ToString("yyyy-MM-dd") }, { "leftTicketDTO.from_station", startStation }, { "leftTicketDTO.to_station", endStation }, { "purpose_codes", seatType.ToString() }, }; HttpItem item = new HttpItem() { URL = url, Referer = "https://kyfw.12306.cn/otn/leftTicket/init", PostData = parames, Cookie = HttpRequest.JSessionCookie + "tk=" + Login.AppTk }; string originJSON = TrainCommon.HttpRequest.HttpGet(item).ToString(); //string originJSON = "{\"data\":{\"flag\":\"1\",\"map\":{\"SHH\":\"上海\",\"SNH\":\"上海南\",\"XUN\":\"信阳\"},\"result\":[\"ANNFYzQXMTSV6Z5AQ32qZwMm2YztAH1wV7p%2FeNEQ1W%2BYjRZ8kpo%2Bhds9JlnsROxfl%2BqluEGylrf8%0ANxQ5aDwJadAJL6u5i1ypTtT9GunzhMFX1Q7ZKA8rVnCph44fYuOFkUY4smS1jhoiSqIo3kV%2FpbOf%0A4jVlb1kwjpHUI3pVlS0CDktXXm38xNcXGeXoCNt08akMCNoHqBGhp%2Bl5L1ilpaAnIP8IsPUYkNkE%0A%2B0%2Fi65aH4qAs70%2FaeWKYDs26lX9kZbpM8MLNYjA%3D|预订|390000K7520G|K752|XUN|SNH|XUN|SNH|13:30|05:42|16:12|Y|IowYIPoZ%2B6ym2KcqJHtu3Gwhvqs47ejPulCrl2HJgIY%2FfuoNfW6we9VDgbs%3D|20180121|3|N2|01|21|0|0||||无|||有||2|有|||||10401030|1413|1\",\"dw5KsNj4bymOaI2zlkbZiLTBD78rRGi4S542V4sUCibDn0h6fJJb16mZ%2F30yi0J3FCMUO8Iufmh3%0AmLomu0QY70xhJu2RSxMo4z7a879uEqzE3rUCFLoDVBYcKmJG0%2BIqLS4XGkx2xpXNmgh4uMB9A76S%0Aod%2FpwlmDb4o6HKDVAW2j%2ByD9cbDg8a5WubmQMTwmJYrObcWQNstt%2FRHaV4gxiAzYzRY%2BgOBF9hI3%0A35uKONBSylE96WTtnAAVFSsXupg1oEGSLg%3D%3D|预订|390000K4620C|K462|PEN|SHH|XUN|SHH|22:00|10:20|12:20|Y|MKMqQGpPXOIE56zzBLrLJBPtCYVvR9%2B%2FheycY60d%2BfEFFWrVcEoBga7%2FcJg%3D|20180121|3|N2|05|16|0|0||||1|||有||无|有|||||10401030|1413|0\"]},\"httpstatus\":200,\"messages\":\"\",\"status\":true}"; if (!originJSON.Contains("\"flag\":\"1\"")) { LogHelper.Log(new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name, "出错了请检查网络"); return(null); } JObject json = JObject.Parse(originJSON); JArray result = JObject.Parse(json["data"].ToString())["result"] as JArray; string[] train = null; Train trainItem = null; if (result != null) { trainList = new List <Train>(); foreach (var arry in result) { train = arry.ToString().Split('|'); trainItem = new Train(); trainItem.TrainSecretStr = System.Web.HttpUtility.UrlDecode(train[0]); //车次加密信息解码 trainItem.TrainID = GetFormatTicket(train[3]); //车次 trainItem.TrainNo = GetFormatTicket(train[2]); //车次码 trainItem.FromStation = GetFormatTicket(SystemCache._station[train[6]].ToString()); //出发站 trainItem.ToStation = GetFormatTicket(SystemCache._station[train[5]].ToString()); //到达站 trainItem.StartTime = GetFormatTicket(train[8]); //出发时间 trainItem.EndTime = GetFormatTicket(train[9]); //到达时间 trainItem.Duration = GetFormatTicket(train[10]); //历时 trainItem.BusinessSeat = GetFormatTicket(train[32]); //商务座特等座 trainItem.FirstLevelSeat = GetFormatTicket(train[31]); //一等座 trainItem.SecondLevelSeat = GetFormatTicket(train[32]); //二等座 trainItem.HighSoftBerth = GetFormatTicket(train[25]); //高级软卧(un) trainItem.SoftBerth = GetFormatTicket(train[23]); //软卧 trainItem.PneumaticBerth = GetFormatTicket(train[27]); //动卧 trainItem.HardBerth = GetFormatTicket(train[28]); //硬卧 trainItem.SoftSeate = GetFormatTicket(train[24]); //软座 trainItem.HardSeate = GetFormatTicket(train[29]); //硬座 trainItem.NoSeat = GetFormatTicket(train[26]); //无座 trainItem.Other = GetFormatTicket(train[22]); //其他 trainItem.TrainLocation = GetFormatTicket(train[15]); //列车坐标 trainItem.IsOpen = GetFormatTicket(train[11]); //是否开票(Y 如14:30起售)或者系统维护时间(IS_TIME_NOT_BUY) trainItem.Remark = GetFormatTicket(train[1]); //备注 //train[13]出发日期 trainList.Add(trainItem); } } SystemCache.SetSysObj(Constant.TrainList, trainList); return(trainList); }
private void buttonExtExcel_Click(object sender, EventArgs e) { Forms.ExportForm frm = new Forms.ExportForm(); frm.Init(new string[] { "All", "Stars only", "Planets only", //2 "Exploration List Stars", //3 "Exploration List Planets", //4 }); if (frm.ShowDialog(FindForm()) == DialogResult.OK) { BaseUtils.CSVWrite csv = new BaseUtils.CSVWrite(); csv.SetCSVDelimiter(frm.Comma); try { using (System.IO.StreamWriter writer = new System.IO.StreamWriter(frm.Path)) { { List <JournalScan> scans = null; if (frm.SelectedIndex < 3) { var entries = JournalEntry.GetByEventType(JournalTypeEnum.Scan, EDCommander.CurrentCmdrID, frm.StartTimeUTC, frm.EndTimeUTC); scans = entries.ConvertAll(x => (JournalScan)x); } else { ExplorationSetClass currentExplorationSet = new ExplorationSetClass(); string file = currentExplorationSet.DialogLoad(FindForm()); if (file != null) { scans = new List <JournalScan>(); foreach (string system in currentExplorationSet.Systems) { ISystem sys = SystemCache.FindSystem(system); if (sys != null) { List <JournalScan> sysscans = EDSMClass.GetBodiesList(sys.EDSMID); if (sysscans != null) { scans.AddRange(sysscans); } } } } else { return; } } bool ShowStars = frm.SelectedIndex < 2 || frm.SelectedIndex == 3; bool ShowPlanets = frm.SelectedIndex == 0 || frm.SelectedIndex == 2 || frm.SelectedIndex == 4; List <JournalSAAScanComplete> mappings = ShowPlanets ? JournalEntry.GetByEventType(JournalTypeEnum.SAAScanComplete, EDCommander.CurrentCmdrID, frm.StartTimeUTC, frm.EndTimeUTC) .ConvertAll(x => (JournalSAAScanComplete)x) : null; if (frm.IncludeHeader) { // Write header writer.Write(csv.Format("Time")); writer.Write(csv.Format("BodyName")); writer.Write(csv.Format("Estimated Value")); writer.Write(csv.Format("DistanceFromArrivalLS")); writer.Write(csv.Format("WasMapped")); writer.Write(csv.Format("WasDiscovered")); if (ShowStars) { writer.Write(csv.Format("StarType")); writer.Write(csv.Format("StellarMass")); writer.Write(csv.Format("AbsoluteMagnitude")); writer.Write(csv.Format("Age MY")); writer.Write(csv.Format("Luminosity")); } writer.Write(csv.Format("Radius")); writer.Write(csv.Format("RotationPeriod")); writer.Write(csv.Format("SurfaceTemperature")); if (ShowPlanets) { writer.Write(csv.Format("TidalLock")); writer.Write(csv.Format("TerraformState")); writer.Write(csv.Format("PlanetClass")); writer.Write(csv.Format("Atmosphere")); writer.Write(csv.Format("Iron")); writer.Write(csv.Format("Silicates")); writer.Write(csv.Format("SulphurDioxide")); writer.Write(csv.Format("CarbonDioxide")); writer.Write(csv.Format("Nitrogen")); writer.Write(csv.Format("Oxygen")); writer.Write(csv.Format("Water")); writer.Write(csv.Format("Argon")); writer.Write(csv.Format("Ammonia")); writer.Write(csv.Format("Methane")); writer.Write(csv.Format("Hydrogen")); writer.Write(csv.Format("Helium")); writer.Write(csv.Format("Volcanism")); writer.Write(csv.Format("SurfaceGravity")); writer.Write(csv.Format("SurfacePressure")); writer.Write(csv.Format("Landable")); writer.Write(csv.Format("EarthMasses")); writer.Write(csv.Format("IcePercent")); writer.Write(csv.Format("RockPercent")); writer.Write(csv.Format("MetalPercent")); } // Common orbital param writer.Write(csv.Format("SemiMajorAxis")); writer.Write(csv.Format("Eccentricity")); writer.Write(csv.Format("OrbitalInclination")); writer.Write(csv.Format("Periapsis")); writer.Write(csv.Format("OrbitalPeriod")); writer.Write(csv.Format("AxialTilt")); if (ShowPlanets) { writer.Write(csv.Format("Carbon")); writer.Write(csv.Format("Iron")); writer.Write(csv.Format("Nickel")); writer.Write(csv.Format("Phosphorus")); writer.Write(csv.Format("Sulphur")); writer.Write(csv.Format("Arsenic")); writer.Write(csv.Format("Chromium")); writer.Write(csv.Format("Germanium")); writer.Write(csv.Format("Manganese")); writer.Write(csv.Format("Selenium")); writer.Write(csv.Format("Vanadium")); writer.Write(csv.Format("Zinc")); writer.Write(csv.Format("Zirconium")); writer.Write(csv.Format("Cadmium")); writer.Write(csv.Format("Mercury")); writer.Write(csv.Format("Molybdenum")); writer.Write(csv.Format("Niobium")); writer.Write(csv.Format("Tin")); writer.Write(csv.Format("Tungsten")); writer.Write(csv.Format("Antimony")); writer.Write(csv.Format("Polonium")); writer.Write(csv.Format("Ruthenium")); writer.Write(csv.Format("Technetium")); writer.Write(csv.Format("Tellurium")); writer.Write(csv.Format("Yttrium")); } writer.WriteLine(); } foreach (JournalScan je in scans) { JournalScan scan = je as JournalScan; if (ShowPlanets == true && !string.IsNullOrEmpty(scan.PlanetClass)) { var mapping = mappings?.FirstOrDefault(m => m.BodyID == scan.BodyID); if (mapping != null) { scan.SetMapped(true, mapping.ProbesUsed <= mapping.EfficiencyTarget); } } if (ShowPlanets == false) // Then only show stars. { if (String.IsNullOrEmpty(scan.StarType)) { continue; } } if (ShowStars == false) // Then only show planets { if (String.IsNullOrEmpty(scan.PlanetClass)) { continue; } } writer.Write(csv.Format(EDDConfig.Instance.ConvertTimeToSelectedFromUTC(scan.EventTimeUTC))); writer.Write(csv.Format(scan.BodyName)); writer.Write(csv.Format(scan.EstimatedValue)); writer.Write(csv.Format(scan.DistanceFromArrivalLS)); writer.Write(csv.Format(scan.WasMapped)); writer.Write(csv.Format(scan.WasDiscovered)); if (ShowStars) { writer.Write(csv.Format(scan.StarType)); writer.Write(csv.Format((scan.nStellarMass.HasValue) ? scan.nStellarMass.Value : 0)); writer.Write(csv.Format((scan.nAbsoluteMagnitude.HasValue) ? scan.nAbsoluteMagnitude.Value : 0)); writer.Write(csv.Format((scan.nAge.HasValue) ? scan.nAge.Value : 0)); writer.Write(csv.Format(scan.Luminosity)); } writer.Write(csv.Format(scan.nRadius.HasValue ? scan.nRadius.Value : 0)); writer.Write(csv.Format(scan.nRotationPeriod.HasValue ? scan.nRotationPeriod.Value : 0)); writer.Write(csv.Format(scan.nSurfaceTemperature.HasValue ? scan.nSurfaceTemperature.Value : 0)); if (ShowPlanets) { writer.Write(csv.Format(scan.nTidalLock.HasValue ? scan.nTidalLock.Value : false)); writer.Write(csv.Format((scan.TerraformState != null) ? scan.TerraformState : "")); writer.Write(csv.Format((scan.PlanetClass != null) ? scan.PlanetClass : "")); writer.Write(csv.Format((scan.Atmosphere != null) ? scan.Atmosphere : "")); writer.Write(csv.Format(scan.GetAtmosphereComponent("Iron"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Silicates"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("SulphurDioxide"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("CarbonDioxide"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Nitrogen"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Oxygen"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Water"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Argon"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Ammonia"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Methane"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Hydrogen"))); writer.Write(csv.Format(scan.GetAtmosphereComponent("Helium"))); writer.Write(csv.Format((scan.Volcanism != null) ? scan.Volcanism : "")); writer.Write(csv.Format(scan.nSurfaceGravity.HasValue ? scan.nSurfaceGravity.Value : 0)); writer.Write(csv.Format(scan.nSurfacePressure.HasValue ? scan.nSurfacePressure.Value : 0)); writer.Write(csv.Format(scan.nLandable.HasValue ? scan.nLandable.Value : false)); writer.Write(csv.Format((scan.nMassEM.HasValue) ? scan.nMassEM.Value : 0)); writer.Write(csv.Format(scan.GetCompositionPercent("Ice"))); writer.Write(csv.Format(scan.GetCompositionPercent("Rock"))); writer.Write(csv.Format(scan.GetCompositionPercent("Metal"))); } // Common orbital param writer.Write(csv.Format(scan.nSemiMajorAxis.HasValue ? scan.nSemiMajorAxis.Value : 0)); writer.Write(csv.Format(scan.nEccentricity.HasValue ? scan.nEccentricity.Value : 0)); writer.Write(csv.Format(scan.nOrbitalInclination.HasValue ? scan.nOrbitalInclination.Value : 0)); writer.Write(csv.Format(scan.nPeriapsis.HasValue ? scan.nPeriapsis.Value : 0)); writer.Write(csv.Format(scan.nOrbitalPeriod.HasValue ? scan.nOrbitalPeriod.Value : 0)); writer.Write(csv.Format(scan.nAxialTilt.HasValue ? scan.nAxialTilt : null)); if (ShowPlanets) { writer.Write(csv.Format(scan.GetMaterial("Carbon"))); writer.Write(csv.Format(scan.GetMaterial("Iron"))); writer.Write(csv.Format(scan.GetMaterial("Nickel"))); writer.Write(csv.Format(scan.GetMaterial("Phosphorus"))); writer.Write(csv.Format(scan.GetMaterial("Sulphur"))); writer.Write(csv.Format(scan.GetMaterial("Arsenic"))); writer.Write(csv.Format(scan.GetMaterial("Chromium"))); writer.Write(csv.Format(scan.GetMaterial("Germanium"))); writer.Write(csv.Format(scan.GetMaterial("Manganese"))); writer.Write(csv.Format(scan.GetMaterial("Selenium"))); writer.Write(csv.Format(scan.GetMaterial("Vanadium"))); writer.Write(csv.Format(scan.GetMaterial("Zinc"))); writer.Write(csv.Format(scan.GetMaterial("Zirconium"))); writer.Write(csv.Format(scan.GetMaterial("Cadmium"))); writer.Write(csv.Format(scan.GetMaterial("Mercury"))); writer.Write(csv.Format(scan.GetMaterial("Molybdenum"))); writer.Write(csv.Format(scan.GetMaterial("Niobium"))); writer.Write(csv.Format(scan.GetMaterial("Tin"))); writer.Write(csv.Format(scan.GetMaterial("Tungsten"))); writer.Write(csv.Format(scan.GetMaterial("Antimony"))); writer.Write(csv.Format(scan.GetMaterial("Polonium"))); writer.Write(csv.Format(scan.GetMaterial("Ruthenium"))); writer.Write(csv.Format(scan.GetMaterial("Technetium"))); writer.Write(csv.Format(scan.GetMaterial("Tellurium"))); writer.Write(csv.Format(scan.GetMaterial("Yttrium"))); } writer.WriteLine(); } } writer.Close(); if (frm.AutoOpen) { System.Diagnostics.Process.Start(frm.Path); } } } catch { ExtendedControls.MessageBoxTheme.Show(FindForm(), "Failed to write to " + frm.Path, "Export Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
private void InitializeStation() { string urlStation = StringHelper.GetConfigValByKey(Constant.StationNameUrl, false); string urlInitial = StringHelper.GetConfigValByKey(Constant.InitialUrl, false); string urlAuth = StringHelper.GetConfigValByKey(Constant.Auth, false); //LogHelper.WriteTextLog("Loaded", url); LogHelper.Info(urlStation); Station station = null; String[] stations = null; try { //stations = client.HttpGet(url, String.Empty).ToString().Split('@'); HttpItem item = new HttpItem() { URL = urlStation }; stations = HttpRequest.HttpGet(item).ToString().Split('@'); //初始化生成客户端环境Cookie HttpItem itemInit = new HttpItem() { URL = urlInitial, Referer = @"http://www.12306.cn/mormhweb/", IsInitialLoaded = true }; HttpRequest.HttpGet(itemInit); HttpItem item2 = new HttpItem() { URL = urlAuth, Referer = @"https://kyfw.12306.cn/otn/login/init", PostData = new Dictionary <string, string>() { { "appid", "otn" } }, IsInitialLoaded = true }; HttpRequest.HttpPost(item2); } catch (Exception ex) { MessageBoxResult dialog = MessageBox.Show("请排查以下可能故障:\r\n1.请检查网络故障 \r\n2.请确认12306官网是否可以登录\r\n3." + ex.Message + "4.关闭程序重新打开", "出错了", MessageBoxButton.OKCancel, MessageBoxImage.Error); if (dialog == MessageBoxResult.OK) { Task.Factory.StartNew(InitializeStation); LogHelper.Error(ex.Message); return; } else { Environment.Exit(0); } } UpdateProgressBarDelegate updatePbDelegate = this.InitialProgressBar(stations.Length); var i = 0; //item = "sha|上海|SHH|shanghai|sh|10" foreach (var item in stations) { if (item.Contains("station_names")) { continue; } if (!String.IsNullOrEmpty(item)) { var items = item.Split('|'); station = new Station(items[0], items[1], items[2], items[3], items[4], items[5]); SystemCache.SetTrainStation(item.Split('|')[1], station); } i++; this.UpdateUIInfo(updatePbDelegate, i, station); } Dispatcher.Invoke(() => { this.Hide(); new Login().Show(); string msg = String.Format("加载完毕,共{0}个车站。", stations.Length); LogHelper.Auth(msg); LogHelper.Info(msg); LogHelper.Log(new System.Diagnostics.StackTrace().GetFrame(0).GetMethod().Name, msg); }); }
private void tsbAddSystems_Click(object sender, EventArgs e) { ExtendedControls.ConfigurableForm f = new ExtendedControls.ConfigurableForm(); FindSystemsUserControl usc = new FindSystemsUserControl(); usc.ReturnSystems = (List <Tuple <ISystem, double> > syslist) => { List <String> systems = new List <String>(); int countunknown = 0; foreach (Tuple <ISystem, double> ret in syslist) { string name = ret.Item1.Name; ISystem sc = SystemCache.FindSystem(name.Trim()); if (sc == null) { sc = new SystemClass(name.Trim()); countunknown++; } systems.Add(sc.Name); } if (systems.Count == 0) { ExtendedControls.MessageBoxTheme.Show(FindForm(), "The imported file contains no known system names", "Unsaved", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { foreach (var sysname in systems) { dataGridViewExplore.Rows.Add(sysname, "", ""); } UpdateSystemRows(); } f.DialogResult = DialogResult.OK; f.Close(); }; f.Add(new ExtendedControls.ConfigurableForm.Entry("UC", null, "", new Point(5, 30), new Size(740, 150), null) { control = usc }); f.Add(new ExtendedControls.ConfigurableForm.Entry("Cancel", typeof(ExtendedControls.ButtonExt), "Cancel", new Point(650, 190), new Size(80, 24), "Press to Cancel")); f.Trigger += (dialogname, controlname, tag) => { if (controlname == "Cancel") { f.DialogResult = DialogResult.Cancel; f.Close(); } }; f.ShowDialog(this.FindForm(), this.FindForm().Icon, new Size(750, 240), new Point(-999, -999), "Add Systems", callback: () => { usc.Font = EDDTheme.Instance.GetFontStandardFontSize(); usc.Init(0, false, discoveryform); }); usc.Closing(); }
private void toolStripButtonImportFile_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Text Files|*.txt"; ofd.Title = "Select a exploration set file"; if (ofd.ShowDialog(FindForm()) != System.Windows.Forms.DialogResult.OK) { return; } string[] sysnames; try { sysnames = System.IO.File.ReadAllLines(ofd.FileName); } catch (IOException) { ExtendedControls.MessageBoxTheme.Show(FindForm(), $"There was a problem opening file {ofd.FileName}", "Import file", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } List <String> systems = new List <String>(); int countunknown = 0; foreach (String name in sysnames) { String sysname = name; if (sysname.Contains(",")) { String[] values = sysname.Split(','); sysname = values[0]; } if (String.IsNullOrWhiteSpace(sysname)) { continue; } ISystem sc = SystemCache.FindSystem(sysname.Trim()); if (sc == null) { sc = new SystemClass(sysname.Trim()); countunknown++; } systems.Add(sc.Name); } if (systems.Count == 0) { ExtendedControls.MessageBoxTheme.Show(FindForm(), "The imported file contains no known system names", "Unsaved", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } ClearExplorationSet(); foreach (var sysname in systems) { dataGridViewExplore.Rows.Add(sysname, "", ""); } UpdateSystemRows(); }
private void toolStripButtonImportFile_Click(object sender, EventArgs e) { if (!PromptAndSaveIfNeeded()) { return; } OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Text Files|*.txt|CSV Files|*.csv|All Files|*.*"; ofd.Title = "Select a route file".T(EDTx.UserControlExpedition_SelRoute); if (ofd.ShowDialog(FindForm()) != System.Windows.Forms.DialogResult.OK) { return; } string[] sysnames; try { sysnames = System.IO.File.ReadAllLines(ofd.FileName); } catch (IOException) { ExtendedControls.MessageBoxTheme.Show(FindForm(), "There was an error reading file".T(EDTx.UserControlExpedition_FileE), "Warning".T(EDTx.Warning), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } List <String> systems = new List <String>(); foreach (String name in sysnames) { String sysname = name; if (sysname.Contains(",")) { String[] values = sysname.Split(','); sysname = values[0]; } if (!String.IsNullOrWhiteSpace(sysname)) { sysname = sysname.Trim(); sysname = sysname.Trim('"'); systems.Add(sysname); } } if (systems.Count == 0) { ExtendedControls.MessageBoxTheme.Show(FindForm(), "The imported file contains no known system names".T(EDTx.UserControlExpedition_Nonames), "Warning".T(EDTx.Warning), MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } SystemCache.UpdateDBWithSystems(systems); // try and fill them in ClearRoute(); toolStripComboBoxRouteSelection.SelectedItem = null; foreach (var sysname in systems) { dataGridView.Rows.Add(sysname); } UpdateSystemRows(); }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.functions.ExpandString(UserData, out res) != BaseUtils.Functions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string prefix = "ST_"; string cmdname = sp.NextQuotedWord(); if (cmdname != null && cmdname.Equals("PREFIX", StringComparison.InvariantCultureIgnoreCase)) { prefix = sp.NextWord(); if (prefix == null) { ap.ReportError("Missing name after Prefix in Star"); return(true); } cmdname = sp.NextQuotedWord(); } if (cmdname != null) { ISystem sc = SystemCache.FindSystem(cmdname); ap[prefix + "Found"] = sc != null ? "1" : "0"; if (sc != null) { BaseUtils.Variables vars = new BaseUtils.Variables(); ActionVars.SystemVars(vars, sc, prefix); ap.Add(vars); ActionVars.SystemVarsFurtherInfo(ap, (ap.actioncontroller as ActionController).HistoryList, sc, prefix); string options = sp.NextWord(); if (options != null) { if (options.Equals("NEAREST", StringComparison.InvariantCultureIgnoreCase)) { double mindist = sp.NextDouble(0.01); double maxdist = sp.NextDouble(20.0); int number = sp.NextInt(50); bool cube = (sp.NextWord() ?? "Spherical").Equals("Cube", StringComparison.InvariantCultureIgnoreCase); // spherical default for all but cube StarDistanceComputer computer = new StarDistanceComputer(); apr = ap; ret_prefix = prefix; computer.CalculateClosestSystems(sc, (sys, list) => (apr.actioncontroller as ActionController).DiscoveryForm.BeginInvoke(new Action(() => NewStarListComputed(sys, list))), (mindist > 0) ? (number - 1) : number, // adds an implicit 1 on for centre star mindist, maxdist, !cube); return(false); // go to sleep until value computed } } } } else { ap.ReportError("Missing starname in Star"); } } else { ap.ReportError(res); } return(true); }
private void UpdateTo(object sender, string optupdateto = null) { changesilence = true; if (optupdateto != null) { textBox_To.Text = optupdateto; } if (sender == textBox_To) { ISystem ds1 = discoveryform.history.FindSystem(SystemNameOnly(textBox_To.Text), discoveryform.galacticMapping, true); if (ds1 != null) { textBox_ToName.Text = ds1.Name; textBox_ToX.Text = ds1.X.ToString("0.00"); textBox_ToY.Text = ds1.Y.ToString("0.00"); textBox_ToZ.Text = ds1.Z.ToString("0.00"); } else { textBox_ToX.Text = textBox_ToY.Text = textBox_ToZ.Text = ""; } } else { string res = "", resname = ""; if (GetCoordsTo(out Point3D curpos)) { ISystem nearest = SystemCache.FindNearestSystemTo(curpos.X, curpos.Y, curpos.Z, 100); GalacticMapObject nearestgmo = discoveryform.galacticMapping.FindNearest(curpos.X, curpos.Y, curpos.Z); if (nearest != null) { if (nearestgmo != null && nearest.Distance(curpos.X, curpos.Y, curpos.Z) > nearestgmo.GetSystem().Distance(curpos.X, curpos.Y, curpos.Z)) { nearest = nearestgmo.GetSystem(); } } else { nearest = nearestgmo?.GetSystem(); } if (nearest != null) { res = resname = nearest.Name; double distance = Point3D.DistanceBetween(curpos, new Point3D(nearest.X, nearest.Y, nearest.Z)); if (distance > 0.1) { resname = nearest.Name + " @ " + distance.ToString("0.00") + "ly"; } } } textBox_To.Text = res; textBox_ToName.Text = resname; } UpdateDistance(); button_Route.Enabled = IsValid(); changesilence = false; }
public override bool ExecuteAction(ActionProgramRun ap) { string res; if (ap.functions.ExpandString(UserData, out res) != BaseUtils.Functions.ExpandResult.Failed) { StringParser sp = new StringParser(res); string prefix = "S_"; string cmdname = sp.NextQuotedWord(); if (cmdname != null && cmdname.Equals("PREFIX", StringComparison.InvariantCultureIgnoreCase)) { prefix = sp.NextWord(); if (prefix == null) { ap.ReportError("Missing name after Prefix in Scan"); return(true); } cmdname = sp.NextQuotedWord(); } bool edsm = false; if (cmdname != null && cmdname.Equals("EDSM", StringComparison.InvariantCultureIgnoreCase)) { edsm = true; cmdname = sp.NextQuotedWord(); } if (cmdname != null) { StarScan scan = (ap.actioncontroller as ActionController).HistoryList.starscan; ISystem sc = SystemCache.FindSystem(cmdname); if (sc == null) { sc = new SystemClass(cmdname); sc.EDSMID = 0; } StarScan.SystemNode sn = scan.FindSystem(sc, edsm); System.Globalization.CultureInfo ct = System.Globalization.CultureInfo.InvariantCulture; if (sn != null) { int starno = 1; ap[prefix + "Stars"] = sn.starnodes.Count.ToString(ct); foreach (KeyValuePair <string, StarScan.ScanNode> scannode in sn.starnodes) { DumpInfo(ap, scannode, prefix + "Star_" + starno.ToString(ct), "_Planets"); int pcount = 1; if (scannode.Value.children != null) { foreach (KeyValuePair <string, StarScan.ScanNode> planetnodes in scannode.Value.children) { DumpInfo(ap, planetnodes, prefix + "Planet_" + starno.ToString(ct) + "_" + pcount.ToString(ct), "_Moons"); if (planetnodes.Value.children != null) { int mcount = 1; foreach (KeyValuePair <string, StarScan.ScanNode> moonnodes in planetnodes.Value.children) { DumpInfo(ap, moonnodes, prefix + "Moon_" + starno.ToString(ct) + "_" + pcount.ToString(ct) + "_" + mcount.ToString(ct), "_Submoons"); if (moonnodes.Value.children != null) { int smcount = 1; foreach (KeyValuePair <string, StarScan.ScanNode> submoonnodes in moonnodes.Value.children) { DumpInfo(ap, submoonnodes, prefix + "SubMoon_" + starno.ToString(ct) + "_" + pcount.ToString(ct) + "_" + mcount.ToString(ct) + "_" + smcount.ToString(ct), null); smcount++; } } mcount++; } } pcount++; } } starno++; } } else { ap[prefix + "Stars"] = "0"; } } else { ap.ReportError("Missing starname in Scan"); } } else { ap.ReportError(res); } return(true); }
private void toolStripMenuItemGotoStar3dmap_Click(object sender, EventArgs e) { EliteDangerousCore.ISystem s = SystemCache.FindSystem(rightclickentry.SystemName, discoveryform.galacticMapping, true); discoveryform.Open3DMap(s); }