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