Exemplo n.º 1
0
        public void NotedSystem(string name, string note, bool target)
        {
            this.Text = "System Information";
            buttonCancel.Hide();
            buttonDelete.Hide();
            textBoxNotes.Hide();
            textBoxTime.Hide();
            labelTimeMade.Hide();
            labelBookmarkNotes.Hide();
            textBoxName.Text       = name;
            textBoxTravelNote.Text = (note != null) ? note : "";

            int delta = textBoxTravelNote.Location.Y - checkBoxTarget.Location.Y;       // before we move it

            checkBoxTarget.Location = new Point(checkBoxTarget.Location.X, labelTimeMade.Location.Y);
            buttonEDSM.Location     = new Point(buttonEDSM.Location.X, labelTimeMade.Location.Y);

            ShiftLocationY(buttonOK, delta);
            ShiftLocationY(labelTravelNote, delta);
            ShiftLocationY(labelTravelNoteEdit, delta);
            ShiftLocationY(textBoxTravelNote, delta);
            this.Height           -= delta;
            checkBoxTarget.Checked = target;

            var edsm = new EDSM.EDSMClass();

            edsmurl = edsm.GetUrlToEDSMSystem(name);
        }
Exemplo n.º 2
0
        public void Update(string name, string note, string bookmarknote, string tme, bool regionmark, bool istarget)
        {
            this.Text              = "Update Bookmark";
            buttonOK.Text          = "Update";
            textBoxName.Text       = name;
            textBoxName.ReadOnly   = !regionmark;
            textBoxNotes.Text      = bookmarknote;
            textBoxTravelNote.Text = note;
            textBoxTime.Text       = tme;
            checkBoxTarget.Checked = istarget;

            if (regionmark)
            {
                buttonEDSM.Hide();
                labelTravelNote.Hide();
                labelTravelNoteEdit.Hide();
                textBoxTravelNote.Hide();
                int delta = buttonOK.Location.Y - labelTravelNote.Location.Y;
                ShiftLocationY(buttonOK, delta);
                ShiftLocationY(buttonCancel, delta);
                ShiftLocationY(buttonDelete, delta);
                this.Height -= delta;
            }
            else
            {
                var edsm = new EDSM.EDSMClass();
                edsmurl = edsm.GetUrlToEDSMSystem(name);
            }
        }
Exemplo n.º 3
0
        public void NewSystemBookmark(string name, string note, string tme)
        {
            this.Text              = "New System Bookmark";
            textBoxName.Text       = name;
            textBoxTravelNote.Text = note;
            textBoxTime.Text       = tme;
            buttonDelete.Hide();
            var edsm = new EDSM.EDSMClass();

            edsmurl = edsm.GetUrlToEDSMSystem(name);
        }
Exemplo n.º 4
0
        // given a list of systems, check to see if in DB, if not, ask EDSM for them as long as they are not on the not found list
        // checked feb 21

        public static void UpdateDBWithSystems(List <string> sysnames)
        {
            if (SystemsDatabase.Instance.RebuildRunning)               // if we are not rebuilding, store it. if we are, it won't be saved and will be checked again, which is fine
            {
                return;
            }

            List <string> tolookup = new List <string>();

            SystemsDatabase.Instance.ExecuteWithDatabase(conn =>
            {
                foreach (var s in sysnames)
                {
                    if (FindSystem(new SystemClass(s), conn) == null)     // if not found..
                    {
                        lock (edsmnotfoundlist)
                        {
                            if (!edsmnotfoundlist.Contains(s))          // if not present in previous edsm not found list, add it for lookup
                            {
                                tolookup.Add(s);
                            }
                        }
                    }
                }
            });

            if (tolookup.Count > 0)                                 // something to do
            {
                EDSM.EDSMClass edsm  = new EDSM.EDSMClass();
                var            slist = edsm.GetSystems(tolookup);           // find them!
                if (slist != null)
                {
                    if (slist.Count > 0)                                     // any found, write back to db
                    {
                        SystemsDatabase.Instance.StoreSystems(slist);        // won't do anything if rebuilding
                    }
                    var except = tolookup.Except(slist.Select(x => x.Name)); // give me ones which i tried to lookup but failed on,

                    lock (edsmnotfoundlist)
                    {
                        foreach (var e in except)                               // add to except list
                        {
                            edsmnotfoundlist.Add(e);
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        public static ISystem FindSystem(ISystem find, bool checkedsm = false)
        {
            ISystem found;

            if (SystemsDatabase.Instance.RebuildRunning) // Find the system in the cache if a rebuild is running
            {
                found = FindSystem(find, null);
            }
            else
            {
                found = SystemsDatabase.Instance.ExecuteWithDatabase(conn => FindSystem(find, conn));

                // we need to do this after the normal connection above, as if we find something, we need to go into read write mode (took a moment to realise this)

                // if not found, checking edsm, and its a good name

                if (found == null && checkedsm && find.Name.HasChars() && find.Name != "UnKnown")
                {
                    lock (edsmnotfoundlist)                               // lock it against threads
                    {
                        if (!edsmnotfoundlist.Contains(find.Name))        // if not in not found list
                        {
                            EDSM.EDSMClass edsm = new EDSM.EDSMClass();
                            found = edsm.GetSystem(find.Name)?.FirstOrDefault();     // this may return an empty list, so first or default, or it may return null

                            // if found one, and EDSM ID/coords (paranoia), and not rebuilding, add back to our db so next time we have it

                            if (found != null && found.EDSMID > 0 && found.HasCoordinate)       // if its a good system
                            {
                                SystemsDatabase.Instance.StoreSystems(new List <ISystem> {
                                    found
                                });                                                                     // won't do anything if rebuilding
                            }
                            else
                            {
                                edsmnotfoundlist.Add(find.Name);            // else exclude from futher checks. Checked 22/2/21
                            }
                        }
                    }
                }
            }

            return(found);
        }