private void textBoxTarget_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { TargetHelpers.setTargetSystem(this, discoveryform, textBoxTarget.Text); } }
private void setTargetToolStripMenuItem_Click(object sender, EventArgs e) { int[] selectedRows = dataGridViewExplore.SelectedCells.OfType <DataGridViewCell>().Where(c => c.RowIndex != dataGridViewExplore.NewRowIndex).Select(c => c.RowIndex).OrderBy(v => v).Distinct().ToArray(); if (selectedRows.Length == 0) { return; } var obj = dataGridViewExplore[0, selectedRows[0]].Value; if (obj == null) { return; } TargetHelpers.setTargetSystem(this, discoveryform, (string)obj); }
private void updateScreen() { if (currentSystem == null) { return; } if (_currentRoute == null) { DisplayText("Please set a route, by right clicking", ""); return; } if (_currentRoute.Systems.Count == 0) { DisplayText(_currentRoute.Name, "Route contains no waypoints"); return; } string topline = ""; string bottomLine = ""; string firstSystemName = _currentRoute.Systems[0]; SystemClassDB firstSystem = SystemClassDB.GetSystem(firstSystemName); SystemClassDB finalSystem = SystemClassDB.GetSystem(_currentRoute.Systems[_currentRoute.Systems.Count - 1]); if (finalSystem != null) { string mesg = "remain"; double distX = SystemClassDB.Distance(currentSystem.System, finalSystem); //Small hack to pull the jump range from TripPanel1 var jumpRange = SQLiteDBClass.GetSettingDouble("TripPanel1" + "JumpRange", -1.0); //TBD Not a good idea. if (jumpRange > 0) { int jumps = (int)Math.Ceiling(distX / jumpRange); if (jumps > 0) { mesg = "@ " + jumps.ToString() + ((jumps == 1) ? " jump" : " jumps"); } } topline = String.Format("{0} {1} WPs {2:N2}ly {3}", _currentRoute.Name, _currentRoute.Systems.Count, distX, mesg); } else { topline = String.Format("{0} {1} WPs remain", _currentRoute.Name, _currentRoute.Systems.Count); } SystemClassDB nearestSystem = null; double minDist = double.MaxValue; int nearestidx = -1; for (int i = 0; i < _currentRoute.Systems.Count; i++) { String sys = _currentRoute.Systems[i]; SystemClassDB sc = SystemClassDB.GetSystem(sys); if (sc == null) { continue; } double dist = SystemClassDB.Distance(currentSystem.System, sc); if (dist <= minDist) { if (nearestSystem == null || !nearestSystem.name.Equals(sc.name)) { minDist = dist; nearestidx = i; nearestSystem = sc; } } } string name = null; if (nearestSystem != null && firstSystem != null) { double first2Neasest = SystemClassDB.Distance(firstSystem, nearestSystem); double first2Me = SystemClassDB.Distance(firstSystem, currentSystem.System); string nextName = null; int wp = nearestidx + 1; if (nearestidx < _currentRoute.Systems.Count - 1) { nextName = _currentRoute.Systems[nearestidx + 1]; } if (first2Me >= first2Neasest && !String.IsNullOrWhiteSpace(nextName)) { name = nextName; wp++; } else { name = nearestSystem.name; } SystemClassDB nextSystem = SystemClassDB.GetSystem(name); if (nextSystem == null) { bottomLine = String.Format("WP{0}: {1} {2}", wp, nextName, autoCopyWPToolStripMenuItem.Checked ? " (AUTO)" : ""); } else { double distance = SystemClassDB.Distance(currentSystem.System, nextSystem); bottomLine = String.Format("{0:N2}ly to WP{1}: {2} {3}", distance, wp, name, autoCopyWPToolStripMenuItem.Checked ? " (AUTO)" : ""); } } else { bottomLine = String.Format("WP{0}: {1} {2}", 1, firstSystemName, autoCopyWPToolStripMenuItem.Checked ? " (AUTO)" : ""); name = firstSystemName; } if (name != null && name.CompareTo(lastsystem) != 0) { if (autoCopyWPToolStripMenuItem.Checked) { Clipboard.SetText(name); } if (autoSetTargetToolStripMenuItem.Checked) { string targetName; double x, y, z; TargetClass.GetTargetPosition(out targetName, out x, out y, out z); if (name.CompareTo(targetName) != 0) { TargetHelpers.setTargetSystem(this, discoveryform, name, false); } } } lastsystem = name; DisplayText(topline, bottomLine); }
// double percent = 39; Timer t = new Timer();// play thru harness private void Display(ISystem cursys) { if (currentRoute == null) { DisplayText("Please set a route, by right clicking", ""); return; } if (currentRoute.Systems.Count == 0) { DisplayText(currentRoute.Name, "Route contains no waypoints"); return; } string topline = "", bottomline = ""; if (!cursys.HasCoordinate) { topline = String.Format("Unknown location"); bottomline = ""; } else { SavedRouteClass.ClosestInfo closest = currentRoute.ClosestTo(cursys); if (closest == null) // if null, no systems found.. uh oh { topline = String.Format("No systems in route have known co-ords"); bottomline = ""; } else if (closest.system == null) // this is returned if past last system { topline = String.Format("Past Last WP{0} {1}", currentRoute.Systems.Count(), currentRoute.LastSystem); bottomline = ""; } else { double distleft = closest.waypointdistleft + closest.disttowaypoint; string mesg = ""; var jumpRange = SQLiteDBClass.GetSettingDouble("TripPanel1" + "JumpRange", -1.0); //TBD Not a good idea. if (jumpRange > 0) { int jumps = (int)Math.Ceiling(distleft / jumpRange); if (jumps > 0) { mesg = "@ " + jumps.ToString() + ((jumps == 1) ? " jump" : " jumps"); } } topline = String.Format("{0} {1} WPs, {2:N1}ly, left {3:N1}ly {4}", currentRoute.Name, currentRoute.Systems.Count, currentRoute.CumulativeDistance(), distleft, mesg); bottomline = String.Format("{0:N2}ly to WP{1} {2} @ {3},{4},{5}", closest.disttowaypoint, closest.waypoint + 1, closest.system.Name, closest.system.X.ToString("0.#"), closest.system.Y.ToString("0.#"), closest.system.Z.ToString("0.#")); //System.Diagnostics.Debug.WriteLine("T:" + topline + Environment.NewLine + "B:" + bottomline); string name = closest.system.Name; if (lastsystem == null || name.CompareTo(lastsystem) != 0) { if (autoCopyWPToolStripMenuItem.Checked) { Clipboard.SetText(name); } if (autoSetTargetToolStripMenuItem.Checked) { string targetName; double x, y, z; TargetClass.GetTargetPosition(out targetName, out x, out y, out z); if (name.CompareTo(targetName) != 0) { TargetHelpers.setTargetSystem(this, discoveryform, name, false); } } lastsystem = name; } } } DisplayText(topline, bottomline); }
// double percent = -10; Timer t = new Timer();// play thru harness private void Display(ISystem cursys) { if (currentRoute == null) { DisplayText("Please set a route, by right clicking".Tx(this, "NoRoute"), ""); return; } if (currentRoute.Systems.Count == 0) { DisplayText(currentRoute.Name, "Route contains no waypoints".Tx(this, "NoWay")); return; } string topline = "", bottomline = ""; if (!cursys.HasCoordinate) { topline = String.Format("Unknown location".Tx(this, "Unk")); bottomline = ""; } else { SavedRouteClass.ClosestInfo closest = currentRoute.ClosestTo(cursys); if (closest == null) // if null, no systems found.. uh oh { topline = String.Format("No systems in route have known co-ords".Tx(this, "NoCo")); bottomline = ""; } else { double routedistance = currentRoute.CumulativeDistance(); double distleft = closest.disttowaypoint + (closest.deviation < 0 ? 0 : closest.cumulativewpdist); topline = String.Format("{0} {1} WPs, {2:N1}ly", currentRoute.Name, currentRoute.Systems.Count, routedistance); EliteDangerousCalculations.FSDSpec.JumpInfo ji = currentHE.GetJumpInfo(); string jumpmsg = ""; if (showJumpsToolStripMenuItem.Checked && ji != null) { int jumps = (int)Math.Ceiling(routedistance / ji.avgsinglejump); if (jumps > 0) { topline += ", " + jumps.ToString() + " " + ((jumps == 1) ? "jump".Tx(this, "J1") : "jumps".Tx(this, "JS")); } jumps = (int)Math.Ceiling(closest.disttowaypoint / ji.avgsinglejump); if (jumps > 0) { jumpmsg = ", " + jumps.ToString() + " " + ((jumps == 1) ? "jump".Tx(this, "J1") : "jumps".Tx(this, "JS")); } else { jumpmsg = " No Ship FSD Information".Tx(this, "NoFSD"); } } string wpposmsg = closest.system.Name; if (showWaypointCoordinatesToolStripMenuItem.Checked) { wpposmsg += String.Format(" @{0:N1},{1:N1},{2:N1}", closest.system.X, closest.system.Y, closest.system.Z); } wpposmsg += String.Format(" {0:N1}ly", closest.disttowaypoint); if (closest.deviation < 0) // if not on path { bottomline += closest.cumulativewpdist == 0 ? "From Last WP ".Tx(this, "FL") : "To First WP ".Tx(this, "TF"); bottomline += wpposmsg + jumpmsg; } else { topline += String.Format(", Left {0:N1}ly".Tx(this, "LF"), distleft); bottomline += String.Format("To WP {0} ".Tx(this, "ToWP"), closest.waypoint + 1); bottomline += wpposmsg + jumpmsg; if (showDeviationFromRouteToolStripMenuItem.Checked) { bottomline += String.Format(", Dev {0:N1}ly".Tx(this, "Dev"), closest.deviation); } } //System.Diagnostics.Debug.WriteLine("T:" + topline + Environment.NewLine + "B:" + bottomline); string name = closest.system.Name; if (lastsystem == null || name.CompareTo(lastsystem) != 0) { if (autoCopyWPToolStripMenuItem.Checked) { SetClipboardText(name); } if (autoSetTargetToolStripMenuItem.Checked) { string targetName; double x, y, z; TargetClass.GetTargetPosition(out targetName, out x, out y, out z); if (name.CompareTo(targetName) != 0) { TargetHelpers.setTargetSystem(this, discoveryform, name, false); } } lastsystem = name; } } } DisplayText(topline, bottomline); }
// double percent = 0; Timer t = new Timer();// play thru harness private void Display(ISystem cursys) { if (currentRoute == null) { DisplayText("Please set a route, by right clicking", ""); return; } if (currentRoute.Systems.Count == 0) { DisplayText(currentRoute.Name, "Route contains no waypoints"); return; } string topline = ""; ISystem finalSystem = SystemClassDB.GetSystem(currentRoute.Systems[currentRoute.Systems.Count - 1]); if (finalSystem != null && cursys.HasCoordinate) { string mesg = "remain"; double distX = cursys.Distance(finalSystem); //Small hack to pull the jump range from TripPanel1 var jumpRange = SQLiteDBClass.GetSettingDouble("TripPanel1" + "JumpRange", -1.0); //TBD Not a good idea. if (jumpRange > 0) { int jumps = (int)Math.Ceiling(distX / jumpRange); if (jumps > 0) { mesg = "@ " + jumps.ToString() + ((jumps == 1) ? " jump" : " jumps"); } } topline = String.Format("{0} {1} WPs, {2:N2}ly {3}", currentRoute.Name, currentRoute.Systems.Count, distX, mesg); } else { topline = String.Format("{0} {1} WPs remain", currentRoute.Name, currentRoute.Systems.Count); } string bottomline = ""; Tuple <ISystem, int> closest = cursys.HasCoordinate ? currentRoute.ClosestTo(cursys) : null; if (closest != null) { if (closest.Item2 >= currentRoute.Systems.Count) // if past end.. { bottomline = String.Format("Past Last WP{0} {1}", closest.Item2, currentRoute.LastSystem); } else { string name = null; if (closest.Item1 != null) // if have a closest system { double distance = cursys.Distance(closest.Item1); bottomline = String.Format("{0:N2}ly to WP{1} {2} @ {3},{4},{5}", distance, closest.Item2 + 1, closest.Item1.Name, closest.Item1.X.ToString("0.#"), closest.Item1.Y.ToString("0.#"), closest.Item1.Z.ToString("0.#")); name = closest.Item1.Name; } else { // just know waypoint.. bottomline = String.Format("To WP{0} {1}", closest.Item2 + 1, currentRoute.Systems[closest.Item2]); name = currentRoute.Systems[closest.Item2]; } if (lastsystem == null || name.CompareTo(lastsystem) != 0) { if (autoCopyWPToolStripMenuItem.Checked) { Clipboard.SetText(name); } if (autoSetTargetToolStripMenuItem.Checked) { string targetName; double x, y, z; TargetClass.GetTargetPosition(out targetName, out x, out y, out z); if (name.CompareTo(targetName) != 0) { TargetHelpers.setTargetSystem(this, discoveryform, name, false); } } lastsystem = name; } } } else { bottomline = "No current position/no systems found in database"; } DisplayText(topline, bottomline); }