public void InitSettingsTab() { checkBoxEDSMLog.Checked = EDDiscoveryForm.EDDConfig.EDSMLog; checkBoxOrderRowsInverted.Checked = EDDiscoveryForm.EDDConfig.OrderRowsInverted; checkBoxMinimizeToNotifyIcon.Checked = EDDiscoveryForm.EDDConfig.MinimizeToNotifyIcon; checkBoxFocusNewSystem.Checked = EDDiscoveryForm.EDDConfig.FocusOnNewSystem; checkBoxKeepOnTop.Checked = EDDiscoveryForm.EDDConfig.KeepOnTop; checkBoxUseNotifyIcon.Checked = EDDiscoveryForm.EDDConfig.UseNotifyIcon; checkBoxUTC.Checked = EDDiscoveryForm.EDDConfig.DisplayUTC; checkBoxAutoLoad.Checked = EDDiscoveryForm.EDDConfig.AutoLoadPopOuts; checkBoxAutoSave.Checked = EDDiscoveryForm.EDDConfig.AutoSavePopOuts; checkBoxMinimizeToNotifyIcon.Enabled = EDDiscoveryForm.EDDConfig.UseNotifyIcon; HomeSystem = SystemClass.GetSystem(SQLiteDBClass.GetSettingString("DefaultMapCenter", "Sol")); textBoxDefaultZoom.Text = SQLiteDBClass.GetSettingDouble("DefaultMapZoom", 1.0).ToString(); bool selectionCentre = SQLiteDBClass.GetSettingBool("CentreMapOnSelection", true); radioButtonHistorySelection.Checked = selectionCentre; radioButtonCentreHome.Checked = !selectionCentre; dataGridViewCommanders.AutoGenerateColumns = false; // BEFORE assigned to list.. dataGridViewCommanders.DataSource = EDCommander.GetList(); panel_defaultmapcolor.BackColor = Color.FromArgb(EDDConfig.Instance.DefaultMapColour); this.comboBoxTheme.SelectedIndexChanged += this.comboBoxTheme_SelectedIndexChanged; // now turn on the handler.. }
private void editBookmarkToolStripMenuItem_Click(object sender, EventArgs e) { int[] selectedRows = dataGridViewRouteSystems.SelectedCells.OfType <DataGridViewCell>().Where(c => c.RowIndex != dataGridViewRouteSystems.NewRowIndex).Select(c => c.RowIndex).OrderBy(v => v).Distinct().ToArray(); if (selectedRows.Length == 0) { return; } var obj = dataGridViewRouteSystems[0, selectedRows[0]].Value; if (obj == null) { return; } SystemClass sc = SystemClass.GetSystem((string)obj); if (sc == null) { EDDiscovery.Forms.MessageBoxTheme.Show("Unknown system, system is without co-ordinates", "Edit bookmark", MessageBoxButtons.OK); } else { RoutingUtils.showBookmarkForm(_discoveryForm, sc, null, false); } }
private void textBoxHomeSystem_Validated(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(textBoxHomeSystem.Text)) { HomeSystem = SystemClass.GetSystem(textBoxHomeSystem.Text); } }
public static ISystem FindSystem(List <VisitedSystemsClass> visitedSystems, GalacticMapping glist, string name) // in system or name { EDDiscovery2.DB.ISystem ds1 = SystemClass.GetSystem(name); if (ds1 == null) { VisitedSystemsClass vs = VisitedSystemsClass.FindByName(visitedSystems, name); if (vs != null && vs.HasTravelCoordinates) { ds1 = vs.curSystem; } else { GalacticMapObject gmo = glist.Find(name, true, true); if (gmo != null && gmo.points.Count > 0) { return(new SystemClass(gmo.name, gmo.points[0].X, gmo.points[0].Y, gmo.points[0].Z)); // fudge it into a system } } } return(ds1); }
// Runs as a thread. private void ViewPushedSystems() { try { pushed = edsm.GetPushedSystems(); foreach (String system in pushed) { SystemClass star = SystemClass.GetSystem(system); if (star == null) { star = new SystemClass(system); } this.BeginInvoke(new MethodInvoker(() => { var index = dataGridViewClosestSystems.Rows.Add("EDSM"); dataGridViewClosestSystems[1, index].Value = system; dataGridViewClosestSystems[1, index].Tag = star; })); } } catch (Exception ex) { this.BeginInvoke(new MethodInvoker(() => { LogTextHighlight("ViewPushedSystems Exception:" + ex.Message); LogText(ex.StackTrace); })); } }
public void AddWantedSystem(string sysName) { if (wanted == null) { PopulateLocalWantedSystems(); } WantedSystemClass entry = wanted.Where(x => x.system == sysName).FirstOrDefault(); //duplicate? if (entry == null) { WantedSystemClass toAdd = new WantedSystemClass(sysName); // make one.. toAdd.Add(); // add to db. wanted.Add(toAdd); SystemClass star = SystemClass.GetSystem(sysName); if (star == null) { star = new SystemClass(sysName); } var index = dataGridViewClosestSystems.Rows.Add("Local"); dataGridViewClosestSystems[1, index].Value = sysName; dataGridViewClosestSystems[1, index].Tag = star; } }
public ISystem FindSystem(string name, EDSM.GalacticMapping glist = null) // in system or name { ISystem ds1 = SystemClass.GetSystem(name); if (ds1 == null) { HistoryEntry vs = FindByName(name); if (vs != null) { ds1 = vs.System; } else if (glist != null) { EDSM.GalacticMapObject gmo = glist.Find(name, true, true); if (gmo != null && gmo.points.Count > 0) { return(new SystemClass(gmo.name, gmo.points[0].X, gmo.points[0].Y, gmo.points[0].Z)); // fudge it into a system } } } return(ds1); }
public int GetLogs(DateTime starttimeutc, out List <HistoryEntry> log) { log = new List <HistoryEntry>(); if (!IsApiKeySet) { return(0); } string query = "get-logs?showId=1&startdatetime=" + HttpUtility.UrlEncode(starttimeutc.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)) + "&apiKey=" + apiKey + "&commanderName=" + HttpUtility.UrlEncode(commanderName); //string query = "get-logs?apiKey=" + apiKey + "&commanderName=" + HttpUtility.UrlEncode(commanderName); var response = RequestGet("api-logs-v1/" + query); if ((int)response.StatusCode >= 400) { return(0); } var json = response.Body; if (json == null) { return(0); } JObject msg = JObject.Parse(json); int msgnr = msg["msgnum"].Value <int>(); JArray logs = (JArray)msg["logs"]; if (logs != null) { using (SQLiteConnectionSystem cn = new SQLiteConnectionSystem()) { foreach (JObject jo in logs) { string name = jo["system"].Value <string>(); string ts = jo["date"].Value <string>(); long id = jo["systemId"].Value <long>(); DateTime etutc = DateTime.ParseExact(ts, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal); // UTC time SystemClass sc = SystemClass.GetSystem(id, cn, SystemClass.SystemIDType.EdsmId); if (sc == null) { sc = new SystemClass(name) { id_edsm = id } } ; HistoryEntry he = new HistoryEntry(); he.MakeVSEntry(sc, etutc, EDDConfig.Instance.DefaultMapColour, "", ""); // FSD jump entry log.Add(he); } } } return(msgnr); }
private void dataGridViewDistances_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { 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 = SystemClass.GetSystem(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 = 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); })); } }
private void UpdateTo(bool updatename) { changesilence = true; if (textBox_To.ReadOnly == false) // if entering system name.. { EDDiscovery2.DB.ISystem ds1 = SystemClass.GetSystem(SystemNameOnly(textBox_To.Text)); if (ds1 != null) { if (updatename) // can't fix it as you type.. so leave alone { textBox_To.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 = SystemClass.FindNearestSystem(curpos.X, curpos.Y, curpos.Z); 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; } UpdateDistance(); changesilence = false; button_Route.Enabled = IsValid(); }
public static void UpdateVisitedSystemsEntries(VisitedSystemsClass item, VisitedSystemsClass item2, bool usedistancedb) // this is a split in two version with the same code of AddHistoryRow.. { SystemClass sys1 = SystemClass.GetSystem(item.Name); if (sys1 == null) { sys1 = new SystemClass(item.Name); if (item.HasTravelCoordinates) { sys1.x = item.X; sys1.y = item.Y; sys1.z = item.Z; } } SystemClass sys2 = null; if (item2 != null) { sys2 = SystemClass.GetSystem(item2.Name); if (sys2 == null) { sys2 = new SystemClass(item2.Name); if (item2.HasTravelCoordinates) { sys2.x = item2.X; sys2.y = item2.Y; sys2.z = item2.Z; } } } else { sys2 = null; } item.curSystem = sys1; item.prevSystem = sys2; string diststr = ""; if (sys2 != null) { double dist = usedistancedb ? SystemClass.DistanceIncludeDB(sys1, sys2) : SystemClass.Distance(sys1, sys2); if (dist > 0) { diststr = dist.ToString("0.00"); } } item.strDistance = diststr; }
private SystemClass GetSystem(string sysname) { SystemClass sys = SystemClass.GetSystem(sysname); if (sys == null) { //if (edsm.IsKnownSystem(sysname)) //{ // sys = new SystemClass(sysname); //} } return(sys); }
/* Tries to load the system data for the given name. If no system data is available, but the system is known, * it creates a new System entity, otherwise logs it and returns null. */ private SystemClass getSystemForTrilateration(string systemName) { var system = SystemClass.GetSystem(systemName); if (system == null) { if (!edsm.IsKnownSystem(systemName)) { LogTextHighlight("Only systems with coordinates or already known to EDSM can be added" + Environment.NewLine); } else { system = new SystemClass(systemName); } } return(system); }
private void checkForUnknownSystemsNowKnown() { for (int i = 0, count = dataGridViewDistances.Rows.Count - 1; i < count; i++) { var systemCell = dataGridViewDistances[0, i]; var oldSystem = (SystemClass)systemCell.Tag; if (!oldSystem.HasCoordinate) { var value = systemCell.Value as string; var newSystem = SystemClass.GetSystem(value); if (newSystem != null && newSystem.HasCoordinate) { systemCell.Tag = newSystem; dataGridViewDistances[3, i].Style.ForeColor = _discoveryForm.theme.VisitedSystemColor; dataGridViewDistances[3, i].Value = "Position found"; } } } }
private void dataGridViewRouteSystems_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { if (e.ColumnIndex == 0) { string sysname = e.FormattedValue.ToString(); var row = dataGridViewRouteSystems.Rows[e.RowIndex]; var cell = dataGridViewRouteSystems[e.ColumnIndex, e.RowIndex]; SystemClass sys = SystemClass.GetSystem(sysname); if (sysname != "" && sys == null && !edsm.IsKnownSystem(sysname)) { row.ErrorText = "System not known to EDSM"; } else { row.ErrorText = ""; } } }
private bool IsValid() // have we star names or co-ords ready to go { bool readytocalc = true; Point3D pos; if (textBox_From.ReadOnly == false) // if enabled, we are doing star names { if (SystemClass.GetSystem(SystemNameOnly(textBox_From.Text)) == null) { readytocalc = false; } } else // check co-ords { if (!GetCoordsFrom(out pos)) { readytocalc = false; } } if (textBox_To.ReadOnly == false) // if enabled, we are doing star names { if (SystemClass.GetSystem(SystemNameOnly(textBox_To.Text)) == null) { readytocalc = false; } } else // check co-ords { if (!GetCoordsTo(out pos)) { readytocalc = false; } } if (comboBoxRoutingMetric.SelectedIndex < 0) { readytocalc = false; } return(readytocalc); }
private void buttonShow_Click(object sender, EventArgs e) { // Class not used broken for now due to systemdata removal. would need work, maybe a helper func in systemclass.cs #if false SystemClass sys = SystemClass.GetSystem(textBox_From.Text); if (sys == null) { return; } var syslist = (from c in SystemData.SystemList orderby(c.x - sys.x) * (c.x - sys.x) + (c.y - sys.y) * (c.y - sys.y) + (c.z - sys.z) * (c.z - sys.z) select c).ToList <SystemClass>(); dataGridView1.Rows.Clear(); dataGridView1.Columns.Clear(); dataGridView1.Columns.Add("Name", "Name"); dataGridView1.Columns.Add("Dist", "Dist"); dataGridView1.Columns.Add("Government", "Government"); dataGridView1.Columns.Add("Government", "Allegiance"); dataGridView1.Columns.Add("Government", "Population"); foreach (SystemClass sys2 in syslist) { double dist = SystemClass.Distance(sys, sys2); object[] rowobj = { sys2.name, dist.ToString("0.00"), sys2.government.ToString(), sys2.allegiance.ToString(), sys2.population }; int rownr; dataGridView1.Rows.Add(rowobj); rownr = dataGridView1.Rows.Count - 1; var cell = dataGridView1.Rows[rownr].Cells[1]; cell.Tag = sys2; } #endif }
private void PopulateLocalWantedSystems() { wanted = WantedSystemClass.GetAllWantedSystems(); if (wanted != null && wanted.Any()) { foreach (WantedSystemClass sys in wanted) { SystemClass star = SystemClass.GetSystem(sys.system); if (star == null) { star = new SystemClass(sys.system); } var index = dataGridViewClosestSystems.Rows.Add("Local"); dataGridViewClosestSystems[1, index].Value = sys.system; dataGridViewClosestSystems[1, index].Tag = star; } } else { wanted = new List <WantedSystemClass>(); } }
public int GetLogs(DateTime?starttimeutc, DateTime?endtimeutc, out List <HistoryEntry> log, out DateTime logstarttime, out DateTime logendtime) { log = new List <HistoryEntry>(); logstarttime = DateTime.MaxValue; logendtime = DateTime.MinValue; if (!IsApiKeySet) { return(0); } string query = "get-logs?showId=1&apiKey=" + apiKey + "&commanderName=" + HttpUtility.UrlEncode(commanderName); if (starttimeutc != null) { query += "&startDateTime=" + HttpUtility.UrlEncode(starttimeutc.Value.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)); } if (endtimeutc != null) { query += "&endDateTime=" + HttpUtility.UrlEncode(endtimeutc.Value.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)); } var response = RequestGet("api-logs-v1/" + query, handleException: true); if (response.Error) { return(0); } var json = response.Body; if (json == null) { return(0); } JObject msg = JObject.Parse(json); int msgnr = msg["msgnum"].Value <int>(); JArray logs = (JArray)msg["logs"]; if (logs != null) { string startdatestr = msg["startDateTime"].Value <string>(); string enddatestr = msg["endDateTime"].Value <string>(); if (startdatestr == null || !DateTime.TryParseExact(startdatestr, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out logstarttime)) { logstarttime = DateTime.MaxValue; } if (enddatestr == null || !DateTime.TryParseExact(enddatestr, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal, out logendtime)) { logendtime = DateTime.MinValue; } using (SQLiteConnectionSystem cn = new SQLiteConnectionSystem()) { foreach (JObject jo in logs) { string name = jo["system"].Value <string>(); string ts = jo["date"].Value <string>(); long id = jo["systemId"].Value <long>(); bool firstdiscover = jo["firstDiscover"].Value <bool>(); DateTime etutc = DateTime.ParseExact(ts, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeUniversal); // UTC time SystemClass sc = SystemClass.GetSystem(id, cn, SystemClass.SystemIDType.EdsmId); if (sc == null) { sc = new SystemClass(name) { id_edsm = id } } ; HistoryEntry he = HistoryEntry.MakeVSEntry(sc, etutc, EDDConfig.Instance.DefaultMapColour, "", "", firstdiscover: firstdiscover); // FSD jump entry log.Add(he); } } } return(msgnr); }
private void RouteIterative(string fromsys, bool usingcoordsfrom, Point3D coordsfrom, string tosys, bool usingcoordsto, Point3D coordsto, float maxrange, int routemethod) { double traveldistance = Point3D.DistanceBetween(coordsfrom, coordsto); // its based on a percentage of the traveldistance routeSystems = new List <SystemClass>(); routeSystems.Add(SystemClass.GetSystem(textBox_From.Text)); AppendText("Searching route from " + fromsys + " to " + tosys + " using " + metric_options[routemethod] + " metric" + Environment.NewLine); AppendText("Total distance: " + traveldistance.ToString("0.00") + " in " + maxrange.ToString("0.00") + "ly jumps" + Environment.NewLine); AppendText(Environment.NewLine); AppendText(string.Format("{0,-40} Depart @ {1,9:0.00},{2,8:0.00},{3,9:0.00}" + Environment.NewLine, fromsys, coordsfrom.X, coordsfrom.Y, coordsfrom.Z)); Point3D curpos = coordsfrom; int jump = 1; double actualdistance = 0; #if DEBUG //Console.WriteLine("-------------------------- BEGIN"); #endif do { double distancetogo = Point3D.DistanceBetween(coordsto, curpos); // to go if (distancetogo <= maxrange) // within distance, we can go directly { break; } Point3D travelvector = new Point3D(coordsto.X - curpos.X, coordsto.Y - curpos.Y, coordsto.Z - curpos.Z); // vector to destination Point3D travelvectorperly = new Point3D(travelvector.X / distancetogo, travelvector.Y / distancetogo, travelvector.Z / distancetogo); // per ly travel vector Point3D nextpos = new Point3D(curpos.X + maxrange * travelvectorperly.X, curpos.Y + maxrange * travelvectorperly.Y, curpos.Z + maxrange * travelvectorperly.Z); // where we would like to be.. #if DEBUG //Console.WriteLine("Curpos " + curpos.X + "," + curpos.Y + "," + curpos.Z); //Console.WriteLine(" next" + nextpos.X + "," + nextpos.Y + "," + nextpos.Z); #endif SystemClass bestsystem = SystemClass.GetSystemNearestTo(curpos, nextpos, maxrange, maxrange - 0.5, routemethod); string sysname = "WAYPOINT"; double deltafromwaypoint = 0; double deviation = 0; if (bestsystem != null) { Point3D bestposition = new Point3D(bestsystem.x, bestsystem.y, bestsystem.z); deltafromwaypoint = Point3D.DistanceBetween(bestposition, nextpos); // how much in error deviation = Point3D.DistanceBetween(curpos.InterceptPoint(nextpos, bestposition), bestposition); nextpos = bestposition; sysname = bestsystem.name; routeSystems.Add(bestsystem); } AppendText(string.Format("{0,-40}{1,3} Dist:{2,8:0.00}ly @ {3,9:0.00},{4,8:0.00},{5,9:0.00} WPd:{6,8:0.00}ly Dev:{7,8:0.00}ly" + Environment.NewLine, sysname, jump, Point3D.DistanceBetween(curpos, nextpos), nextpos.X, nextpos.Y, nextpos.Z, deltafromwaypoint, deviation)); actualdistance += Point3D.DistanceBetween(curpos, nextpos); curpos = nextpos; jump++; } while (true); routeSystems.Add(SystemClass.GetSystem(textBox_To.Text)); actualdistance += Point3D.DistanceBetween(curpos, coordsto); AppendText(string.Format("{0,-40}{1,3} Dist:{2,8:0.00}ly @ {3,9:0.00},{4,8:0.00},{5,9:0.00}" + Environment.NewLine, tosys, jump, Point3D.DistanceBetween(curpos, coordsto), coordsto.X, coordsto.Y, coordsto.Z)); AppendText(Environment.NewLine); AppendText(string.Format("Straight Line Distance {0,8:0.00}ly vs Travelled Distance {1,8:0.00}ly" + Environment.NewLine, traveldistance, actualdistance)); }
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]; SystemClass firstSystem = SystemClass.GetSystem(firstSystemName); SystemClass finalSystem = SystemClass.GetSystem(_currentRoute.Systems[_currentRoute.Systems.Count - 1]); if (finalSystem != null) { string mesg = "remain"; double distX = SystemClass.Distance(currentSystem.System, finalSystem); //Small hack to pull the jump range from TripPanel1 var jumpRange = SQLiteDBClass.GetSettingDouble("TripPanel1" + "JumpRange", -1.0); 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); } SystemClass nearestSystem = null; double minDist = double.MaxValue; int nearestidx = -1; for (int i = 0; i < _currentRoute.Systems.Count; i++) { String sys = _currentRoute.Systems[i]; SystemClass sc = SystemClass.GetSystem(sys); if (sc == null) { continue; } double dist = SystemClass.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 = SystemClass.Distance(firstSystem, nearestSystem); double first2Me = SystemClass.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; } SystemClass nextSystem = SystemClass.GetSystem(name); if (nextSystem == null) { bottomLine = String.Format("WP{0}: {1} {2}", wp, nextName, autoCopyWPToolStripMenuItem.Checked ? " (AUTO)" : ""); } else { double distance = SystemClass.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) { RoutingUtils.setTargetSystem(discoveryform, name, false); } } } lastsystem = name; DisplayText(topline, bottomLine); }
public ReferenceSystem GetCandidate() { double maxdistance = 0; ReferencesSector sectorcandidate = null; // Get Sector with maximum distance for all others... for (int i = 0; i < sections; i++) { for (int j = 0; j < sections / 2; j++) { if (sectors[i, j].ReferencesCount == 0 && sectors[i, j].CandidatesCount > 0) // An unused sector with candidates left? { double dist; double mindist = 10; for (int ii = 0; ii < sections; ii++) { for (int jj = 0; jj < sections / 2; jj++) { if (sectors[ii, jj].CandidatesCount > 0) { dist = CalculateAngularDistance(sectors[i, j].AzimuthCenterRad, sectors[i, j].LatitudeCenterRad, sectors[ii, jj].AzimuthCenterRad, sectors[ii, jj].LatitudeCenterRad); if (dist > 0.001) { if (dist < mindist) { mindist = dist; } } } } } if (mindist > maxdistance) // New candidate { maxdistance = mindist; sectorcandidate = sectors[i, j]; } } } } if (sectorcandidate == null) { if (NrOfRefenreceSystems == 0) { SystemClass sys = SystemClass.GetSystem("Sol"); if (EstimatedPosition.x == 0 && EstimatedPosition.y == 0 && EstimatedPosition.z == 0) { sys = SystemClass.GetSystem("Sirius"); } if (sys == null) { return(null); // Should not happend } ReferenceSystem refSys = new ReferenceSystem(sys, EstimatedPosition); return(refSys); } return(null); } return(sectorcandidate.GetBestCandidate()); }