Пример #1
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();
        }
Пример #2
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();
        }
Пример #3
0
        private void buttonNew_Click(object sender, EventArgs e)
        {
            BookmarkForm frm = new BookmarkForm();
            DateTime     tme = DateTime.Now;

            frm.NewSystemBookmark(tme.ToString());
            if (frm.ShowDialog(this) == DialogResult.OK)
            {
                updating = true;
                GlobalBookMarkList.Instance.AddOrUpdateBookmark(null, true, frm.StarHeading, double.Parse(frm.x), double.Parse(frm.y), double.Parse(frm.z),
                                                                tme, frm.Notes, frm.SurfaceLocations);
                updating = false;
                Display();
            }
        }
Пример #4
0
        // cursystem = null, curbookmark = null, new system free entry bookmark
        // cursystem != null, curbookmark = null, system bookmark found, update
        // cursystem != null, curbookmark = null, no system bookmark found, new bookmark on system
        // curbookmark != null, edit current bookmark

        public static void showBookmarkForm(Object sender,
                                            EDDiscoveryForm discoveryForm, ISystem cursystem, BookmarkClass curbookmark, bool notedsystem)
        {
            Form senderForm = ((Control)sender)?.FindForm() ?? discoveryForm;

            // try and find the associated bookmark..
            BookmarkClass bkmark = (curbookmark != null) ? curbookmark : (cursystem != null ? GlobalBookMarkList.Instance.FindBookmarkOnSystem(cursystem.Name) : null);

            SystemNoteClass sn   = (cursystem != null) ? SystemNoteClass.GetNoteOnSystem(cursystem.Name, cursystem.EDSMID) : null;
            string          note = (sn != null) ? sn.Note : "";

            BookmarkForm frm = new BookmarkForm();

            if (notedsystem && bkmark == null)                      // note on a system
            {
                long targetid = TargetClass.GetTargetNotedSystem(); // who is the target of a noted system (0=none)
                long noteid   = sn.id;

                frm.InitialisePos(cursystem);
                frm.NotedSystem(cursystem.Name, note, noteid == targetid);       // note may be passed in null
                frm.ShowDialog(senderForm);

                if ((frm.IsTarget && targetid != noteid) || (!frm.IsTarget && targetid == noteid)) // changed..
                {
                    if (frm.IsTarget)
                    {
                        TargetClass.SetTargetNotedSystem(cursystem.Name, noteid, cursystem.X, cursystem.Y, cursystem.Z);
                    }
                    else
                    {
                        TargetClass.ClearTarget();
                    }
                }
            }
            else
            {
                bool     regionmarker = false;
                DateTime tme;

                if (bkmark == null)                         // new bookmark
                {
                    tme = DateTime.Now;
                    if (cursystem == null)
                    {
                        frm.NewFreeEntrySystemBookmark(tme);
                    }
                    else
                    {
                        frm.NewSystemBookmark(cursystem, note, tme);
                    }
                }
                else                                        // update bookmark
                {
                    regionmarker = bkmark.isRegion;
                    tme          = bkmark.Time;
                    frm.Update(bkmark);
                }

                DialogResult res = frm.ShowDialog(senderForm);

                long curtargetid = TargetClass.GetTargetBookmark();      // who is the target of a bookmark (0=none)

                if (res == DialogResult.OK)
                {
                    BookmarkClass newcls = GlobalBookMarkList.Instance.AddOrUpdateBookmark(bkmark, !regionmarker, frm.StarHeading, double.Parse(frm.x), double.Parse(frm.y), double.Parse(frm.z),
                                                                                           tme, frm.Notes, frm.SurfaceLocations);


                    if ((frm.IsTarget && curtargetid != newcls.id) || (!frm.IsTarget && curtargetid == newcls.id)) // changed..
                    {
                        if (frm.IsTarget)
                        {
                            TargetClass.SetTargetBookmark(regionmarker ? ("RM:" + newcls.Heading) : newcls.StarName, newcls.id, newcls.x, newcls.y, newcls.z);
                        }
                        else
                        {
                            TargetClass.ClearTarget();
                        }
                    }
                }
                else if (res == DialogResult.Abort && bkmark != null)
                {
                    if (curtargetid == bkmark.id)
                    {
                        TargetClass.ClearTarget();
                    }

                    GlobalBookMarkList.Instance.Delete(bkmark);
                }
            }

            discoveryForm.NewTargetSet(sender);
        }
Пример #5
0
        public static void showBookmarkForm(Object sender,
                                            EDDiscoveryForm discoveryForm, ISystem cursystem, BookmarkClass curbookmark, bool notedsystem)
        {
            Form senderForm = ((Control)sender)?.FindForm() ?? discoveryForm;

            // try and find the associated bookmark..
            BookmarkClass bkmark = (curbookmark != null) ? curbookmark : BookmarkClass.bookmarks.Find(x => x.StarName != null && x.StarName.Equals(cursystem.Name));

            SystemNoteClass sn   = (cursystem != null) ? SystemNoteClass.GetNoteOnSystem(cursystem.Name, cursystem.EDSMID) : null;
            string          note = (sn != null) ? sn.Note : "";

            BookmarkForm frm = new BookmarkForm();

            if (notedsystem && bkmark == null)                      // note on a system
            {
                long targetid = TargetClass.GetTargetNotedSystem(); // who is the target of a noted system (0=none)
                long noteid   = sn.id;

                frm.InitialisePos(cursystem.X, cursystem.Y, cursystem.Z);
                frm.NotedSystem(cursystem.Name, note, noteid == targetid);       // note may be passed in null
                frm.ShowDialog(senderForm);

                if ((frm.IsTarget && targetid != noteid) || (!frm.IsTarget && targetid == noteid)) // changed..
                {
                    if (frm.IsTarget)
                    {
                        TargetClass.SetTargetNotedSystem(cursystem.Name, noteid, cursystem.X, cursystem.Y, cursystem.Z);
                    }
                    else
                    {
                        TargetClass.ClearTarget();
                    }
                }
            }
            else
            {
                bool     regionmarker = false;
                DateTime tme;

                long targetid = TargetClass.GetTargetBookmark(); // who is the target of a bookmark (0=none)

                if (bkmark == null)                              // new bookmark
                {
                    frm.InitialisePos(cursystem.X, cursystem.Y, cursystem.Z);
                    tme = DateTime.Now;
                    frm.NewSystemBookmark(cursystem.Name, note, tme.ToString());
                }
                else                                        // update bookmark
                {
                    frm.InitialisePos(bkmark.x, bkmark.y, bkmark.z);
                    regionmarker = bkmark.isRegion;
                    tme          = bkmark.Time;
                    frm.Update(regionmarker ? bkmark.Heading : bkmark.StarName, note, bkmark.Note, tme.ToString(), regionmarker, targetid == bkmark.id);
                }

                DialogResult res = frm.ShowDialog(senderForm);

                if (res == DialogResult.OK)
                {
                    BookmarkClass newcls = new BookmarkClass();

                    if (regionmarker)
                    {
                        newcls.Heading = frm.StarHeading;
                    }
                    else
                    {
                        newcls.StarName = frm.StarHeading;
                    }

                    newcls.x    = double.Parse(frm.x);
                    newcls.y    = double.Parse(frm.y);
                    newcls.z    = double.Parse(frm.z);
                    newcls.Time = tme;
                    newcls.Note = frm.Notes;

                    if (bkmark != null)
                    {
                        newcls.id = bkmark.id;
                        newcls.Update();
                    }
                    else
                    {
                        newcls.Add();
                    }

                    if ((frm.IsTarget && targetid != newcls.id) || (!frm.IsTarget && targetid == newcls.id)) // changed..
                    {
                        if (frm.IsTarget)
                        {
                            TargetClass.SetTargetBookmark(regionmarker ? ("RM:" + newcls.Heading) : newcls.StarName, newcls.id, newcls.x, newcls.y, newcls.z);
                        }
                        else
                        {
                            TargetClass.ClearTarget();
                        }
                    }
                }
                else if (res == DialogResult.Abort && bkmark != null)
                {
                    if (targetid == bkmark.id)
                    {
                        TargetClass.ClearTarget();
                    }

                    bkmark.Delete();
                }
            }

            discoveryForm.NewTargetSet(sender);
        }