예제 #1
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (currentedit != null)      // if we have a current cell..
            {
                BookmarkClass bk = (BookmarkClass)currentedit.Tag;

                SaveBackAnyChanges();

                BookmarkForm frm = new BookmarkForm();
                frm.Update(bk);
                DialogResult dr = frm.ShowDialog(this);

                updating = true;

                if (dr == DialogResult.OK)
                {
                    //System.Diagnostics.Debug.WriteLine("Updating bookmark " + bk.Name);
                    GlobalBookMarkList.Instance.AddOrUpdateBookmark(bk, !bk.isRegion, frm.StarHeading, double.Parse(frm.x), double.Parse(frm.y), double.Parse(frm.z),
                                                                    bk.Time, frm.Notes, frm.SurfaceLocations);
                }
                else if (dr == DialogResult.Abort)
                {
                    GlobalBookMarkList.Instance.Delete(bk);
                }

                updating = false;
                Display();
            }
        }
예제 #2
0
        public void UpdateBookmarks(ref List <IData3DCollection> _datasets, float widthly, float heightly, Vector3 rotation)
        {
            if (_datasets == null)
            {
                return;
            }

            foreach (IData3DCollection dataset in _datasets)
            {
                TexturedQuadDataCollection tqdc = dataset as TexturedQuadDataCollection;

                foreach (TexturedQuadData tqd in tqdc.Primatives)
                {
                    PointData pd;
                    if ((int)tqd.Tag2 == 1)
                    {
                        HistoryEntry vs = (HistoryEntry)tqd.Tag;
                        pd = new PointData(vs.System.X, vs.System.Y, vs.System.Z);
                    }
                    else
                    {
                        BookmarkClass bc = (BookmarkClass)tqd.Tag;
                        pd = new PointData(bc.x, bc.y, bc.z);
                    }

                    tqd.UpdateVertices(pd, rotation, widthly, heightly, 0, heightly / 2);
                }
            }
        }
예제 #3
0
        public void Bookmark(BookmarkClass bk)        // from multiple places, update this bookmark, region or system..
        {
            string note = "";
            string name;
            long?  edsmid = null;

            if (!bk.isRegion)
            {
                ISystem s = SystemCache.FindSystem(bk.StarName);
                if (s != null)    // paranoia
                {
                    InitialisePos(s);
                    edsmid = s.EDSMID;
                }
                else
                {
                    InitialisePos(bk.x, bk.y, bk.z);
                }

                SystemNoteClass sn = SystemNoteClass.GetNoteOnSystem(bk.StarName);
                note = (sn != null) ? sn.Note : "";

                name = bk.StarName;
            }
            else
            {       // region, set position, set name
                InitialisePos(bk.x, bk.y, bk.z);
                name = bk.Heading;
            }

            this.Text                  = "Update Bookmark".T(EDTx.BookmarkForm_UB);
            buttonOK.Text              = "Update".T(EDTx.BookmarkForm_Update);
            textBoxName.Text           = name;
            textBoxName.ReadOnly       = !bk.isRegion;
            textBoxName.ReturnPressed += (ctrl) => { return(true); };
            textBoxBookmarkNotes.Text  = bk.Note;
            textBoxBookmarkNotes.CursorToEnd();
            textBoxBookmarkNotes.ScrollToCaret();
            textBoxTravelNote.Text = note;
            textBoxTime.Text       = EDDConfig.Instance.ConvertTimeToSelectedFromUTC(bk.TimeUTC).ToString();
            checkBoxTarget.Checked = bk.id == TargetClass.GetTargetBookmark();      // who is the target of a bookmark (0=none)

            //foreach (Control c in panelOuter.Controls) System.Diagnostics.Debug.WriteLine("All Control {0} at {1}", c.Name, c.Top);

            if (bk.isRegion)
            {
                HideEDSM();
                HideTravelNote();   // in order note
                HideSurfaceBookmarks();
            }
            else
            {
                var edsm = new EDSMClass();
                edsmurl = edsm.GetUrlToEDSMSystem(name, edsmid);
                SurfaceBookmarks.Init(bk.StarName, bk.PlanetaryMarks);
            }


            buttonOK.Enabled = true;
        }
예제 #4
0
        private void SaveBackAnyChanges()
        {
            if (currentedit != null)
            {
                BookmarkClass bk      = (BookmarkClass)currentedit.Tag;
                string        newNote = "";
                if (null != currentedit.Cells[2].Value)
                {
                    newNote = currentedit.Cells[2].Value.ToString();
                }
                //System.Diagnostics.Debug.WriteLine("Checking for save " + currentedit.Index);

                if (!newNote.Equals(bk.Note) || userControlSurfaceBookmarks.Edited)     // notes or planet marks changed
                {
                    updating = true;
                    //System.Diagnostics.Debug.WriteLine("Save back " + bk.Name + " " + newNote);
                    currentedit.Tag = GlobalBookMarkList.Instance.AddOrUpdateBookmark(bk, !bk.isRegion,
                                                                                      bk.isRegion ? bk.Heading : bk.StarName,
                                                                                      bk.x, bk.y, bk.z, bk.Time,
                                                                                      newNote,
                                                                                      userControlSurfaceBookmarks.PlanetMarks);
                    updating = false;
                    userControlSurfaceBookmarks.Edited = false;
                }

                currentedit = null;
            }
        }
예제 #5
0
 private void Discoveryform_OnHistoryChange(HistoryList obj) // need to handle this in case commander changed..
 {
     last_he         = discoveryform.history.GetLast;
     currentBookmark = null;
     PopulateBookmarkCombo();
     OnNewEntry(last_he, discoveryform.history);
 }
예제 #6
0
        public void UpdateBookmarks(ref List <IData3DSet> _datasets, float widthly, float heightly, Vector3 rotation)
        {
            if (_datasets == null)
            {
                return;
            }

            foreach (IData3DSet dataset in _datasets)
            {
                TexturedQuadDataCollection tqdc = dataset as TexturedQuadDataCollection;

                foreach (TexturedQuadData tqd in tqdc.BaseTextures)
                {
                    PointData pd;
                    if ((int)tqd.Tag2 == 1)
                    {
                        VisitedSystemsClass vs = (VisitedSystemsClass)tqd.Tag;
                        pd = new PointData((vs.HasTravelCoordinates) ? vs.X : vs.curSystem.x, (vs.HasTravelCoordinates) ? vs.Y : vs.curSystem.y, (vs.HasTravelCoordinates) ? vs.Z : vs.curSystem.z);
                    }
                    else
                    {
                        BookmarkClass bc = (BookmarkClass)tqd.Tag;
                        pd = new PointData(bc.x, bc.y, bc.z);
                    }

                    tqd.UpdateVertices(pd, rotation, widthly, heightly, 0, heightly / 2);
                }
            }
        }
예제 #7
0
        private void PopulateBookmarkCombo()
        {
            if (last_he == null)
            {
                buttonNewBookmark.Enabled = false;
                return;
            }
            buttonNewBookmark.Enabled = true;
            if (currentBookmark != null && currentBookmark.StarName == last_he.System.Name)
            {
                return;
            }
            string selection = externallyForcedBookmark ? externalLocationName : comboBoxBookmarks.Text;

            comboBoxBookmarks.Items.Clear();
            currentBookmark = GlobalBookMarkList.Instance.FindBookmarkOnSystem(last_he.System.Name);
            if (currentBookmark != null)
            {
                List <PlanetMarks.Planet> planetMarks = currentBookmark.PlanetaryMarks?.Planets;

                if (heading.HasValue)
                {
                    // orbital flight or landed, just do this body
                    labelBookmark.Text = "Planet Bookmarks";
                    planetMarks        = planetMarks?.Where(p => p.Name == last_he.WhereAmI)?.ToList();
                }
                else
                {
                    // add whole system
                    labelBookmark.Text = "System Bookmarks";
                }

                if (planetMarks != null)
                {
                    foreach (PlanetMarks.Planet pl in planetMarks)
                    {
                        if (pl.Locations != null && pl.Locations.Any())
                        {
                            foreach (PlanetMarks.Location loc in pl.Locations.OrderBy(l => l.Name))
                            {
                                comboBoxBookmarks.Items.Add($"{loc.Name} ({pl.Name})");
                            }
                        }
                    }
                }
            }
            if (externallyForcedBookmark && !comboBoxBookmarks.Items.Contains(externalLocationName))
            {
                comboBoxBookmarks.Items.Add(externalLocationName);
            }
            if (!String.IsNullOrEmpty(selection) && comboBoxBookmarks.Items.Contains(selection))
            {
                comboBoxBookmarks.Text = selection;
            }
            else
            {
                comboBoxBookmarks.Text = "";
            }
        }
예제 #8
0
 private void GlobalBookMarkList_OnBookmarkChange(BookmarkClass bk, bool deleted)
 {
     if (bookMark != null && bookMark.id == bk.id)
     {
         bookMark = null;
     }
     Display();
 }
예제 #9
0
        private void BackgroundInit()
        {
            StarScan.LoadBodyDesignationMap();
            MaterialCommodityDB.SetUpInitialTable();

            if (!EDDOptions.Instance.NoSystemsLoad)
            {
                downloadMapsTask = FGEImage.DownloadMaps(this, () => PendingClose, LogLine, LogLineHighlight);
                CheckSystems(() => PendingClose, (p, s) => ReportProgress(p, s));
            }

            SystemNoteClass.GetAllSystemNotes();                                // fill up memory with notes, bookmarks, galactic mapping
            BookmarkClass.GetAllBookmarks();

            ReportProgress(-1, "");
            InvokeAsyncOnUiThread(() => OnInitialSyncComplete?.Invoke());

            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!");
                }
            }

            if (PendingClose)
            {
                return;
            }
            LogLine("Reading travel history");

            if (!EDDOptions.Instance.NoLoad)
            {
                DoRefreshHistory(new RefreshWorkerArgs {
                    CurrentCommander = EDCommander.CurrentCmdrID
                });
            }

            if (PendingClose)
            {
                return;
            }

            if (syncstate.performeddbsync || syncstate.performedsmsync)
            {
                string databases = (syncstate.performedsmsync && syncstate.performeddbsync) ? "EDSM and EDDB" : ((syncstate.performedsmsync) ? "EDSM" : "EDDB");

                LogLine("ED Discovery will now synchronise to the " + databases + " databases to obtain star information." + Environment.NewLine +
                        "This will take a while, up to 15 minutes, please be patient." + Environment.NewLine +
                        "Please continue running ED Discovery until refresh is complete.");
            }
            InvokeAsyncOnUiThread(() => OnInitialisationComplete?.Invoke());
        }
예제 #10
0
        public void Update(BookmarkClass bk)        // from multiple places, update this bookmark, region or system..
        {
            string note = "";
            string name;
            long?  edsmid = null;

            if (!bk.isRegion)
            {
                ISystem s = SystemCache.FindSystem(bk.StarName);
                if (s != null)    // paranoia
                {
                    InitialisePos(s);
                    edsmid = s.EDSMID;
                }
                else
                {
                    InitialisePos(bk.x, bk.y, bk.z);
                }

                SystemNoteClass sn = SystemNoteClass.GetNoteOnSystem(bk.StarName);
                note = (sn != null) ? sn.Note : "";

                name = bk.StarName;
            }
            else
            {       // region, set position, set name
                InitialisePos(bk.x, bk.y, bk.z);
                name = bk.Heading;
            }

            this.Text                  = "Update Bookmark".Tx(this, "UB");
            buttonOK.Text              = "Update".Tx(this);
            textBoxName.Text           = name;
            textBoxName.ReadOnly       = !bk.isRegion;
            textBoxName.ReturnPressed += (ctrl) => { return(true); };
            textBoxBookmarkNotes.Text  = bk.Note;
            textBoxBookmarkNotes.CursorToEnd();
            textBoxBookmarkNotes.ScrollToCaret();
            textBoxTravelNote.Text = note;
            textBoxTime.Text       = bk.Time.ToString();
            checkBoxTarget.Checked = bk.id == TargetClass.GetTargetBookmark();      // who is the target of a bookmark (0=none)

            if (bk.isRegion)
            {
                HideEDSM();
                HideTravelNote();
                HideSurfaceBookmarks();
            }
            else
            {
                var edsm = new EDSMClass();
                edsmurl = edsm.GetUrlToEDSMSystem(name, edsmid);
                SurfaceBookmarks.Init(bk.StarName, bk.PlanetaryMarks);
            }

            buttonOK.Enabled = true;
        }
예제 #11
0
        private void GlobalBookMarkList_OnBookmarkChange(BookmarkClass bk, bool deleted)
        {
            if (currentBookmark != null && currentBookmark.id == bk.id)
            {
                currentBookmark = null;
            }

            PopulateBookmarkCombo();
            DisplayCompass();
        }
예제 #12
0
        private void CompassSelected(string planet, string locname)
        {
            if (currentedit != null)      // if we have a current cell..
            {
                BookmarkClass bk = (BookmarkClass)currentedit.Tag;

                UserControlCompass comp = (UserControlCompass)EDDApplicationContext.EDDMainForm.PopOuts.PopOut(PanelInformation.PanelIDs.Compass);
                comp.SetSurfaceBookmark(bk, planet, locname);
            }
        }
예제 #13
0
        public void DisplayPlanetMarks(BookmarkClass bk)
        {
            Edited = false;
            dataGridViewMarks.Rows.Clear();

            if (bk == null)
            {
                dataGridViewMarks.AllowUserToAddRows = false;
                buttonSave.Hide();
                return;
            }

            if (bk.isRegion)
            {
                dataGridViewMarks.AllowUserToAddRows = false;
                buttonSave.Hide();
                return;
            }

            dataGridViewMarks.SuspendLayout();

            dataGridViewMarks.AllowUserToAddRows = true;
            SetSystem(bk.StarName);
            thisBookmark = bk;
            PlanetMarks  = bk.PlanetaryMarks == null ? new PlanetMarks() : bk.PlanetaryMarks;

            if (PlanetMarks.Planets != null)
            {
                foreach (Planet pl in PlanetMarks.Planets)
                {
                    foreach (Location loc in pl.Locations)
                    {
                        if (((DataGridViewComboBoxCell)dataGridViewMarks.Rows[0].Cells[0]).Items.Contains(pl.Name))
                        {
                            using (DataGridViewRow dr = dataGridViewMarks.Rows[dataGridViewMarks.Rows.Add()])
                            {
                                dr.Cells[0].Value    = pl.Name;
                                dr.Cells[0].ReadOnly = true;
                                dr.Cells[1].Value    = loc.Name;
                                dr.Cells[1].ReadOnly = true;
                                dr.Cells[2].Value    = loc.Comment;
                                dr.Cells[3].Value    = loc.Latitude.ToString("F4");
                                dr.Cells[4].Value    = loc.Longitude.ToString("F4");
                                ((DataGridViewCheckBoxCell)dr.Cells[5]).Value = true;
                                dr.Tag = loc;
                            }
                        }
                    }
                }
            }

            sendToCompassToolStripMenuItem.Enabled = true;

            dataGridViewMarks.ResumeLayout();
        }
예제 #14
0
        private void BookmarksChanged(BookmarkClass bk, bool deleted)
        {
            //System.Diagnostics.Debug.WriteLine("Changed called " + updating);
            if (updating)
            {
                return;
            }

            SaveBackAnyChanges();
            Display();
        }
예제 #15
0
        private void BookmarksChanged(BookmarkClass bk, bool deleted)
        {
            //System.Diagnostics.Debug.WriteLine("Changed called " + updating);
            if (updating)
            {
                return;
            }

            // removed this - this can overwrite commanded changes SaveBackAnyChanges();
            Display();
        }
예제 #16
0
 public void SetSurfaceBookmark(BookmarkClass bk, string planetName, string locName)
 {
     externallyForcedBookmark = true;
     externalLocation         = bk.PlanetaryMarks.Planets.Where(pl => pl.Name == planetName).FirstOrDefault()?.Locations.Where(l => l.Name == locName).FirstOrDefault();
     if (externalLocation != null)
     {
         externalLocationName           = $"{locName} ({planetName})";
         numberBoxTargetLatitude.Value  = externalLocation.Latitude;
         numberBoxTargetLongitude.Value = externalLocation.Longitude;
     }
     Display();
 }
예제 #17
0
        private void CheckSystems(Func <bool> cancelRequested, Action <int, string> reportProgress)  // ASYNC process, done via start up, must not be too slow.
        {
            reportProgress(-1, "");

            string   rwsystime = SQLiteConnectionSystem.GetSettingString("EDSMLastSystems", "2000-01-01 00:00:00"); // Latest time from RW file.
            DateTime edsmdate;

            if (!DateTime.TryParse(rwsystime, CultureInfo.InvariantCulture, DateTimeStyles.None, out edsmdate))
            {
                edsmdate = new DateTime(2000, 1, 1);
            }

            if (DateTime.Now.Subtract(edsmdate).TotalDays > 7)  // Over 7 days do a sync from EDSM
            {
                // Also update galactic mapping from EDSM
                LogLine("Get galactic mapping from EDSM.");
                galacticMapping.DownloadFromEDSM();

                // Skip EDSM full update if update has been performed in last 4 days
                bool     outoforder = SQLiteConnectionSystem.GetSettingBool("EDSMSystemsOutOfOrder", true);
                DateTime lastmod    = outoforder ? SystemClass.GetLastSystemModifiedTime() : SystemClass.GetLastSystemModifiedTimeFast();

                if (DateTime.UtcNow.Subtract(lastmod).TotalDays > 4 ||
                    DateTime.UtcNow.Subtract(edsmdate).TotalDays > 28)
                {
                    syncstate.performedsmsync = true;
                }
                else
                {
                    SQLiteConnectionSystem.PutSettingString("EDSMLastSystems", DateTime.Now.ToString(CultureInfo.InvariantCulture));
                }
            }

            if (!cancelRequested())
            {
                SQLiteConnectionUser.TranferVisitedSystemstoJournalTableIfRequired();
                SQLiteConnectionSystem.CreateSystemsTableIndexes();
                SystemNoteClass.GetAllSystemNotes();                    // fill up memory with notes, bookmarks, galactic mapping
                BookmarkClass.GetAllBookmarks();
                galacticMapping.ParseData();                            // at this point, EDSM data is loaded..
                SystemClass.AddToAutoComplete(galacticMapping.GetGMONames());
                EDDiscovery.EliteDangerous.MaterialCommodityDB.SetUpInitialTable();

                LogLine("Loaded Notes, Bookmarks and Galactic mapping.");

                string   timestr = SQLiteConnectionSystem.GetSettingString("EDDBSystemsTime", "0");
                DateTime time    = new DateTime(Convert.ToInt64(timestr), DateTimeKind.Utc);
                if (DateTime.UtcNow.Subtract(time).TotalDays > 6.5)     // Get EDDB data once every week.
                {
                    syncstate.performeddbsync = true;
                }
            }
        }
예제 #18
0
        private void Discoveryform_OnHistoryChange(HistoryList obj) // need to handle this in case commander changed..
        {
            HistoryEntry curhe           = discoveryform.history.GetLast;
            bool         differentsystem = last_he != null && curhe != null && last_he.System.Name != curhe.System.Name;

            last_he = curhe;
            if (differentsystem)
            {
                bookMark = null;
                PopulateBookmarkCombo();
            }

            OnNewEntry(last_he, discoveryform.history);
        }
예제 #19
0
        private void buttonNewBookmark_Click(object sender, EventArgs e)
        {
            if (last_he == null)
            {
                return;
            }

            BookmarkForm frm     = new BookmarkForm();
            DateTime     timeutc = DateTime.UtcNow;

            if (currentBookmark == null)
            {
                if (latitude.HasValue)
                {
                    frm.NewSystemBookmark(last_he.System, "", timeutc, last_he.WhereAmI, latitude.Value, longitude.Value);
                }
                else
                {
                    frm.NewSystemBookmark(last_he.System, "", timeutc);
                }
            }
            else
            {
                if (latitude.HasValue)
                {
                    frm.Bookmark(currentBookmark, last_he.WhereAmI, latitude.Value, longitude.Value);
                }
                else
                {
                    frm.Bookmark(currentBookmark);
                }
            }

            frm.StartPosition = FormStartPosition.CenterScreen;
            DialogResult dr = frm.ShowDialog();

            if (dr == DialogResult.OK)
            {
                currentBookmark = GlobalBookMarkList.Instance.AddOrUpdateBookmark(currentBookmark, true, frm.StarHeading, double.Parse(frm.x), double.Parse(frm.y), double.Parse(frm.z), timeutc, frm.Notes, frm.SurfaceLocations);
            }
            if (dr == DialogResult.Abort)
            {
                GlobalBookMarkList.Instance.Delete(currentBookmark);
                currentBookmark = null;
            }

            PopulateBookmarkCombo();
            DisplayCompass();
        }
예제 #20
0
 private void RefreshCurrentEdit()
 {
     if (dataGridViewBookMarks.CurrentCell != null)
     {
         currentedit = dataGridViewBookMarks.Rows[dataGridViewBookMarks.CurrentCell.RowIndex];
         BookmarkClass bk = (BookmarkClass)(currentedit.Tag);
         //System.Diagnostics.Debug.WriteLine("Move to row " + currentedit.Index + " Notes " + bk.Name);
         userControlSurfaceBookmarks.DisplayPlanetMarks(bk);
     }
     else
     {
         currentedit = null;
         userControlSurfaceBookmarks.DisplayPlanetMarks(null);
     }
 }
예제 #21
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            if (currentedit != null)      // if we have a current cell..
            {
                BookmarkClass bk = (BookmarkClass)currentedit.Tag;

                if (ExtendedControls.MessageBoxTheme.Show(FindForm(), "Do you really want to delete the bookmark for " + bk.Name + Environment.NewLine + "Confirm or Cancel", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                {
                    updating = true;
                    GlobalBookMarkList.Instance.Delete(bk);
                    updating = false;
                    Display();
                }
            }
        }
예제 #22
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (currentedit != null)      // if we have a current cell..
            {
                BookmarkClass bk = (BookmarkClass)currentedit.Tag;

                SaveBackAnyChanges();
                EliteDangerousCore.ISystem sys = bk.isStar ? EliteDangerousCore.SystemCache.FindSystem(bk.Name) : null;

                updating = true;
                UserControls.TargetHelpers.showBookmarkForm(this.FindForm(), discoveryform, sys, bk, false);
                updating = false;
                Display();
            }
        }
예제 #23
0
        private void buttonNewBookmark_Click(object sender, EventArgs e)
        {
            BookmarkForm frm = new BookmarkForm();
            DateTime     tme = DateTime.Now;

            if (bookMark == null)
            {
                if (latitude.HasValue)
                {
                    frm.NewSystemBookmark(last_he.System, "", tme.ToString(), last_he.WhereAmI, latitude.Value, longitude.Value);
                }
                else
                {
                    frm.NewSystemBookmark(last_he.System, "", tme.ToString());
                }
            }
            else
            {
                if (latitude.HasValue)
                {
                    frm.Update(bookMark, last_he.WhereAmI, latitude.Value, longitude.Value);
                }
                else
                {
                    frm.Update(bookMark);
                }
            }

            frm.StartPosition = FormStartPosition.CenterScreen;
            DialogResult dr = frm.ShowDialog();

            if (dr == DialogResult.OK)
            {
                bookMark = GlobalBookMarkList.Instance.AddOrUpdateBookmark(bookMark, true, frm.StarHeading, double.Parse(frm.x), double.Parse(frm.y), double.Parse(frm.z), tme, frm.Notes, frm.SurfaceLocations);
            }
            if (dr == DialogResult.Abort)
            {
                GlobalBookMarkList.Instance.Delete(bookMark);
                bookMark = null;
            }
            Display();
        }
예제 #24
0
 private void RefreshCurrentEdit()
 {
     if (dataGridViewBookMarks.CurrentCell != null)
     {
         currentedit = dataGridViewBookMarks.Rows[dataGridViewBookMarks.CurrentCell.RowIndex];
         BookmarkClass bk = (BookmarkClass)(currentedit.Tag);
         //System.Diagnostics.Debug.WriteLine("Move to row " + currentedit.Index + " Notes " + bk.Name);
         if (bk.isRegion)
         {
             userControlSurfaceBookmarks.Disable();
         }
         else
         {
             userControlSurfaceBookmarks.Init(bk.StarName, bk.PlanetaryMarks);
         }
     }
     else
     {
         currentedit = null;
         userControlSurfaceBookmarks.Disable();
     }
 }
예제 #25
0
        private void dataGridViewBookMarks_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)         // right click on travel map, get in before the context menu
            {
                rightclickbookmark = null;
            }

            if (dataGridViewBookMarks.SelectedCells.Count < 2 || dataGridViewBookMarks.SelectedRows.Count == 1)      // if single row completely selected, or 1 cell or less..
            {
                DataGridView.HitTestInfo hti = dataGridViewBookMarks.HitTest(e.X, e.Y);
                if (hti.Type == DataGridViewHitTestType.Cell)
                {
                    dataGridViewBookMarks.ClearSelection();                // select row under cursor.
                    dataGridViewBookMarks.Rows[hti.RowIndex].Selected = true;

                    if (e.Button == MouseButtons.Right)         // right click on travel map, get in before the context menu
                    {
                        rightclickbookmark = (BookmarkClass)dataGridViewBookMarks.Rows[hti.RowIndex].Tag;
                    }
                }
            }
        }
예제 #26
0
        public void Update(BookmarkClass bk)
        {
            string note = "";
            string name;

            if (!bk.isRegion)
            {
                SystemNoteClass sn = SystemNoteClass.GetNoteOnSystem(bk.StarName);
                ISystem         s  = SystemClassDB.GetSystem(bk.StarName);
                InitialisePos(s);
                note = (sn != null) ? sn.Note : "";
                name = bk.StarName;
            }
            else
            {
                name = bk.Heading;
            }

            Update(name, note, bk.Note, bk.Time.ToString(), bk.isRegion, false, bk.PlanetaryMarks);
            userControlSurfaceBookmarks1.DisplayPlanetMarks(bk);
            buttonOK.Enabled = true;
        }
예제 #27
0
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            int[] rows = null;

            if (dataGridViewBookMarks.SelectedCells.Count > 0)      // being paranoid
            {
                rows = (from DataGridViewCell x in dataGridViewBookMarks.SelectedCells select x.RowIndex).Distinct().ToArray();
            }

            //System.Diagnostics.Debug.WriteLine("cells {0} rows {1} selrows {2}", dataGridViewBookMarks.SelectedCells.Count, dataGridViewBookMarks.SelectedRows.Count , rows.Length);

            if (rows != null && rows.Length > 1)
            {
                if (ExtendedControls.MessageBoxTheme.Show(FindForm(), string.Format(("Do you really want to delete {0} bookmarks?" + Environment.NewLine + "Confirm or Cancel").Tx(this, "CFN"), rows.Length), "Warning".Tx(), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                {
                    updating = true;
                    foreach (int r in rows)
                    {
                        BookmarkClass bk = (BookmarkClass)dataGridViewBookMarks.Rows[r].Tag;
                        //System.Diagnostics.Debug.WriteLine("Delete " + bk.Name);
                        GlobalBookMarkList.Instance.Delete(bk);
                    }
                    updating = false;
                    Display();
                }
            }
            else if (currentedit != null)      // if we have a current cell..
            {
                BookmarkClass bk = (BookmarkClass)currentedit.Tag;

                if (ExtendedControls.MessageBoxTheme.Show(FindForm(), string.Format(("Do you really want to delete the bookmark for {0}" + Environment.NewLine + "Confirm or Cancel").Tx(this, "CF"), bk.Name), "Warning".Tx(), MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
                {
                    updating = true;
                    GlobalBookMarkList.Instance.Delete(bk);
                    updating = false;
                    Display();
                }
            }
        }
예제 #28
0
        private void buttonExtImport_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.InitialDirectory = SQLiteConnectionUser.GetSettingString("BookmarkFormImportExcelFolder", "c:\\");

            if (!System.IO.Directory.Exists(dlg.InitialDirectory))
            {
                System.IO.Directory.CreateDirectory(dlg.InitialDirectory);
            }

            dlg.DefaultExt   = "csv";
            dlg.AddExtension = true;
            dlg.Filter       = "CVS Files (*.csv)|*.csv|All files (*.*)|*.*";

            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                string path = dlg.FileName;

                BaseUtils.CSVFile csv = new BaseUtils.CSVFile();

                if (csv.Read(path, System.IO.FileShare.ReadWrite))
                {
                    List <BaseUtils.CSVFile.Row> rows = csv.RowsExcludingHeaderRow;

                    BookmarkClass currentbk = null;

                    var Regexyyyyddmm = new System.Text.RegularExpressions.Regex(@"\d\d\d\d-\d\d-\d\d", System.Text.RegularExpressions.RegexOptions.Compiled | System.Text.RegularExpressions.RegexOptions.Singleline);

                    foreach (var r in rows)
                    {
                        string type = r[0];
                        string date = r[1];

                        if (type.HasChars() && date.HasChars())
                        {
                            bool region = type?.Equals("Region", StringComparison.InvariantCultureIgnoreCase) ?? false;

                            DateTime time = DateTime.MinValue;

                            bool isyyyy = Regexyyyyddmm.IsMatch(date);      // excel, after getting our output in, converts the damn thing to local dates.. this distinguishes it.

                            bool success = isyyyy ? DateTime.TryParse(date, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AssumeLocal, out time) :
                                           DateTime.TryParse(date, System.Globalization.CultureInfo.CurrentCulture, System.Globalization.DateTimeStyles.AssumeLocal, out time);

                            if (success)
                            {
                                string name = r[2];
                                string note = r[3];
                                double?x    = r[4].InvariantParseDoubleNull();
                                double?y    = r[5].InvariantParseDoubleNull();
                                double?z    = r[6].InvariantParseDoubleNull();

                                if (x != null && y != null && z != null)
                                {
                                    System.Diagnostics.Debug.WriteLine("Bookmark {0} {1} {2} {3} ({4},{5},{6}", type, time.ToStringZulu(), name, note, x, y, z);

                                    currentbk = GlobalBookMarkList.Instance.FindBookmark(name, region);

                                    if (currentbk != null)
                                    {
                                        GlobalBookMarkList.Instance.AddOrUpdateBookmark(currentbk, !region, name, x.Value, y.Value, z.Value, time, note, currentbk.PlanetaryMarks);
                                    }
                                    else
                                    {
                                        currentbk = GlobalBookMarkList.Instance.AddOrUpdateBookmark(null, !region, name, x.Value, y.Value, z.Value, time, note, null);
                                    }
                                }
                                else
                                {
                                    System.Diagnostics.Debug.WriteLine("Not a system with valid coords {0} {1}", r[0], r[1]);
                                }
                            }
                            else
                            {
                                System.Diagnostics.Debug.WriteLine("Rejected due to date {0} {1}", r[0], r[1]);
                            }
                        }

                        string planet = r[7];

                        if (planet.HasChars() && currentbk != null)
                        {
                            string locname   = r[8];
                            string comment   = r[9];
                            double?latitude  = r[10].InvariantParseDoubleNull();
                            double?longitude = r[11].InvariantParseDoubleNull();

                            if (!locname.HasChars() && latitude == null && longitude == null) // whole planet bookmark
                            {
                                currentbk.AddOrUpdatePlanetBookmark(planet, comment);
                            }
                            else if (locname.HasChars() && latitude.HasValue && longitude.HasValue)
                            {
                                currentbk.AddOrUpdateLocation(planet, locname, comment, latitude.Value, longitude.Value);
                            }
                        }
                    }

                    SQLiteConnectionUser.PutSettingString("BookmarkFormImportExcelFolder", System.IO.Path.GetDirectoryName(path));
                }
                else
                {
                    ExtendedControls.MessageBoxTheme.Show(FindForm(), "Failed to read " + path, "Import Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
예제 #29
0
        private void buttonExtExcel_Click(object sender, EventArgs e)
        {
            if (dataGridViewBookMarks.Rows.Count == 0)
            {
                ExtendedControls.MessageBoxTheme.Show(FindForm(), "No data to export", "Export EDSM", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            Forms.ExportForm frm = new Forms.ExportForm();
            frm.Init(new string[] { "Export Current View" }, disablestartendtime: true);

            if (frm.ShowDialog(FindForm()) == DialogResult.OK)
            {
                if (frm.SelectedIndex == 0)
                {
                    string path = frm.Path;               //string path = "C:\\code\\f.csv"; // debug

                    BaseUtils.CSVWriteGrid grd = new BaseUtils.CSVWriteGrid();
                    grd.SetCSVDelimiter(frm.Comma);

                    List <string> colh = new List <string>();
                    colh.AddRange(new string[] { "Type", "Time", "System/Region", "Note", "X", "Y", "Z", "Planet", "Name", "Comment", "Lat", "Long" });

                    grd.GetHeader += delegate(int c)
                    {
                        return((c < colh.Count && frm.IncludeHeader) ? colh[c] : null);
                    };

                    int bkrowno = 0;
                    IEnumerator <Tuple <PlanetMarks.Planet, PlanetMarks.Location> > planetloc = null;

                    System.Diagnostics.Debug.WriteLine("Rows " + dataGridViewBookMarks.Rows.Count);

                    grd.GetLineStatus += delegate(int r)
                    {
                        return(bkrowno < dataGridViewBookMarks.Rows.Count ? BaseUtils.CSVWriteGrid.LineStatus.OK : BaseUtils.CSVWriteGrid.LineStatus.EOF);
                    };

                    grd.GetLine += delegate(int r)
                    {
                        DataGridViewRow rw             = dataGridViewBookMarks.Rows[bkrowno];
                        BookmarkClass   bk             = rw.Tag as BookmarkClass;
                        bool            firstplanetrow = false;

                        if (planetloc == null && bk.hasPlanetaryMarks)          // if not iterating planets, but it has one, iterate
                        {
                            planetloc = bk.PlanetaryMarks.GetEnumerator();
                            planetloc.MoveNext();       // move to first
                            firstplanetrow = true;
                        }

                        List <Object> retrow = new List <Object>
                        {
                            bk.isRegion ? "Region" : "System",
                                      bk.Time.ToStringYearFirst(),
                                      bk.isRegion ? bk.Heading : bk.StarName,
                                      bk.Note,
                                      bk.x.ToString("0.##"),
                            bk.y.ToString("0.##"),
                            bk.z.ToString("0.##"),
                        };

                        System.Diagnostics.Debug.WriteLine("Export system " + bkrowno + " " + bk.StarName);

                        if (planetloc != null)
                        {
                            var           plloc     = planetloc.Current;
                            List <Object> planetrow = new List <Object>
                            {
                                plloc.Item1.Name,
                                plloc.Item2.Name,
                                plloc.Item2.Comment,
                                plloc.Item2.IsWholePlanetBookmark ? "" : plloc.Item2.Latitude.ToString("0.##"),
                                plloc.Item2.IsWholePlanetBookmark ? "" : plloc.Item2.Longitude.ToString("0.##"),
                            };

                            if (!firstplanetrow)
                            {
                                retrow = new List <object>()
                                {
                                    "", "", "", "", "", "", ""
                                };
                            }

                            retrow.AddRange(planetrow);
                        }

                        if (planetloc == null || planetloc.MoveNext() == false)
                        {
                            planetloc = null;
                            bkrowno++;
                        }

                        return(retrow.ToArray());
                    };

                    if (grd.WriteCSV(path))
                    {
                        if (frm.AutoOpen)
                        {
                            System.Diagnostics.Process.Start(path);
                        }
                    }
                    else
                    {
                        ExtendedControls.MessageBoxTheme.Show(FindForm(), "Failed to write to " + path, "Export Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
            }
        }
예제 #30
0
        private void UpdateSystemRow(int rowindex)
        {
            const int idxVisits = 5;
            const int idxScans  = 6;
            const int idxBodies = 7;
            const int idxstars  = 8;
            const int idxInfo   = 9;
            const int idxNote   = 10;

            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 = discoveryform.history.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();

                    StarScan.SystemNode sysnode = discoveryform.history.starscan.FindSystemSynchronous(sys, false);

                    if (sysnode != null)
                    {
                        dataGridViewExplore[idxScans, rowindex].Value = sysnode.StarPlanetsScanned().ToString();
                        if (sysnode.FSSTotalBodies.HasValue)
                        {
                            dataGridViewExplore[idxBodies, rowindex].Value = sysnode.FSSTotalBodies.Value.ToString();
                        }

                        dataGridViewExplore[idxstars, rowindex].Value = sysnode.StarTypesFound(false);

                        string info = "";
                        foreach (var scan in sysnode.Bodies)
                        {
                            JournalScan sd = scan.ScanData;
                            if (sd != null)
                            {
                                if (sd.IsStar)
                                {
                                    if (sd.StarTypeID == EDStar.AeBe)
                                    {
                                        info = info + " " + "AeBe";
                                    }
                                    if (sd.StarTypeID == EDStar.N)
                                    {
                                        info = info + " " + "NS";
                                    }
                                    if (sd.StarTypeID == EDStar.H)
                                    {
                                        info = info + " " + "BH";
                                    }
                                }
                                else
                                {
                                    if (sd.PlanetTypeID == EDPlanet.Earthlike_body)
                                    {
                                        info = info + " " + (sd.Terraformable ? "T-ELW" : "ELW");
                                    }
                                    else if (sd.PlanetTypeID == EDPlanet.Water_world)
                                    {
                                        info = info + " " + (sd.Terraformable ? "T-WW" : "WW");
                                    }
                                    else if (sd.PlanetTypeID == EDPlanet.High_metal_content_body && sd.Terraformable)
                                    {
                                        info = info + " " + "T-HMC";
                                    }
                                }
                            }
                        }

                        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".T(EDTx.Systemnotknown);
                }
                else
                {
                    dataGridViewExplore.Rows[rowindex].ErrorText = "";
                }
            }
        }