private void editBookmarkToolStripMenuItem_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;
            }
            SystemClassDB sc = SystemClassDB.GetSystem((string)obj);

            if (sc == null)
            {
                ExtendedControls.MessageBoxTheme.Show("Unknown system, system is without co-ordinates", "Edit bookmark", MessageBoxButtons.OK);
            }
            else
            {
                TargetHelpers.showBookmarkForm(this, _discoveryForm, sc, null, false);
            }
        }
        private void editBookmarkToolStripMenuItem_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;
            }
            ISystem sc = SystemCache.FindSystem((string)obj);

            if (sc == null)
            {
                ExtendedControls.MessageBoxTheme.Show(FindForm(), "Unknown system, system is without co-ordinates".T(EDTx.UserControlExploration_UnknownS), "Warning".T(EDTx.Warning), MessageBoxButtons.OK);
            }
            else
            {
                TargetHelpers.ShowBookmarkForm(this, discoveryform, sc, null, false);
            }
        }
Exemplo n.º 3
0
 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);
        }
        //    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".T(EDTx.UserControlRouteTracker_NoRoute), "", "");
                return;
            }

            if (currentRoute.Systems.Count == 0)
            {
                DisplayText(currentRoute.Name, "Route contains no waypoints".T(EDTx.UserControlRouteTracker_NoWay), "");
                return;
            }

            string topline = "", bottomline = "", note = "";

            if (!cursys.HasCoordinate)
            {
                topline    = String.Format("Unknown location".T(EDTx.UserControlRouteTracker_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".T(EDTx.UserControlRouteTracker_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".T(EDTx.UserControlRouteTracker_J1) : "jumps".T(EDTx.UserControlRouteTracker_JS));
                        }

                        jumps = (int)Math.Ceiling(closest.disttowaypoint / ji.avgsinglejump);

                        if (jumps > 0)
                        {
                            jumpmsg = ", " + jumps.ToString() + " " + ((jumps == 1) ? "jump".T(EDTx.UserControlRouteTracker_J1) : "jumps".T(EDTx.UserControlRouteTracker_JS));
                        }
                        else
                        {
                            jumpmsg = " No Ship FSD Information".T(EDTx.UserControlRouteTracker_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 ".T(EDTx.UserControlRouteTracker_FL) : "To First WP ".T(EDTx.UserControlRouteTracker_TF);
                        bottomline += wpposmsg + jumpmsg;
                    }
                    else
                    {
                        topline    += String.Format(", Left {0:N1}ly".T(EDTx.UserControlRouteTracker_LF), distleft);
                        bottomline += String.Format("To WP {0} ".T(EDTx.UserControlRouteTracker_ToWP), closest.waypoint + 1);
                        bottomline += wpposmsg + jumpmsg;
                        if (showDeviationFromRouteToolStripMenuItem.Checked)
                        {
                            bottomline += String.Format(", Dev {0:N1}ly".T(EDTx.UserControlRouteTracker_Dev), closest.deviation);
                        }
                    }

                    if (showBookmarkNotesToolStripMenuItem.Checked)
                    {
                        BookmarkClass bookmark = GlobalBookMarkList.Instance.FindBookmarkOnSystem(cursys.Name);
                        if (bookmark != null)
                        {
                            note = String.Format("Note: {0}".T(EDTx.UserControlRouteTracker_Note), bookmark.Note);
                        }
                    }

                    //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, note);
        }
        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);
        }
Exemplo n.º 7
0
        //  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", "");
                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
                {
                    topline = String.Format("{0} {1} WPs, {2:N1}ly", currentRoute.Name,
                                            currentRoute.Systems.Count, currentRoute.CumulativeDistance());

                    double distleft = closest.disttowaypoint + (closest.deviation < 0 ? 0: closest.cumulativewpdist);

                    string jumpmsg = "";

                    if (showJumpsToolStripMenuItem.Checked)
                    {
                        EliteDangerousCalculations.FSDSpec.JumpInfo ji = currentHE.GetJumpInfo();

                        if (ji != null)
                        {
                            int jumps = (int)Math.Ceiling(distleft / ji.avgsinglejump);

                            if (jumps > 0)
                            {
                                jumpmsg = " @ " + jumps.ToString() + ((jumps == 1) ? " jump" : " jumps");
                            }
                        }
                        else
                        {
                            jumpmsg = " No Ship FSD Information";
                        }
                    }

                    string wpposmsg = String.Format("{0} @ {1:N1},{2:N1},{3:N1} {4:N1}ly", closest.system.Name, closest.system.X, closest.system.Y, closest.system.Z, closest.disttowaypoint);

                    if (closest.deviation < 0)        // if not on path
                    {
                        bottomline += closest.cumulativewpdist == 0 ? "From Last WP " : "To First WP ";
                        bottomline += wpposmsg + jumpmsg;
                    }
                    else
                    {
                        topline    += String.Format(", Left {0:N1}ly", distleft);
                        bottomline += String.Format("To WP {0} ", closest.waypoint + 1);
                        bottomline += wpposmsg + jumpmsg;
                        bottomline += String.Format(", Dev {0:N1}ly", 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)
                        {
                            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);
        }
Exemplo n.º 9
0
        // 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);
        }