private void toolStripButtonImportTextFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Text Files|*.txt";
            ofd.Title  = "Select a exploration set file".T(EDTx.UserControlExploration_SelectSet);

            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(), string.Format("There was a problem opening file {0}".T(EDTx.UserControlExploration_OpenE), ofd.FileName), "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 (sysname.HasChars())
                {
                    systems.Add(sysname.Trim());
                }
            }

            if (systems.Count == 0)
            {
                ExtendedControls.MessageBoxTheme.Show(FindForm(),
                                                      "The imported file contains no known system names".T(EDTx.UserControlExploration_NoSys), "Warning".T(EDTx.Warning), MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            SystemCache.UpdateDBWithSystems(systems);           // try and fill them in

            ClearExplorationSet();

            AddSystems(systems);        // makes it dirty
        }
Beispiel #2
0
        private void toolStripButtonImportNavRoute_Click(object sender, EventArgs e)
        {
            var route = discoveryform.history.GetLastHistoryEntry(x => x.EntryType == JournalTypeEnum.NavRoute)?.journalEntry as EliteDangerousCore.JournalEvents.JournalNavRoute;

            if (route != null)
            {
                List <string> systems = new List <string>();
                foreach (var s in route.Route)
                {
                    if (s.StarSystem.HasChars())
                    {
                        dataGridView.Rows.Add(s.StarSystem);
                        systems.Add(s.StarSystem);
                    }
                }

                SystemCache.UpdateDBWithSystems(systems);           // try and fill them in

                UpdateSystemRows();
            }
        }
Beispiel #3
0
        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();
        }