Exemplo n.º 1
0
        private void pictureBox_ClickElement(object sender, MouseEventArgs e, ExtendedControls.PictureBoxHotspot.ImageElement i, object tag)
        {
            if (i != null)
            {
                string       stag = tag as string;
                HistoryEntry he   = tag as HistoryEntry;

                if (stag != null)      // its SCAN for now
                {
                    HideScanData(null, null);
                }
                else if (he != null)
                {
                    EDDiscovery.EDSM.EDSMClass edsm = new EDDiscovery.EDSM.EDSMClass();

                    string url = edsm.GetUrlToEDSMSystem(he.System.name);

                    if (url.Length > 0)         // may pass back empty string if not known, this solves another exception
                    {
                        System.Diagnostics.Process.Start(url);
                    }
                    else
                    {
                        ExtendedControls.MessageBoxTheme.Show("System " + he.System.name + " unknown to EDSM");
                    }
                }
            }
        }
 private void lblEDSMLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     if (_linkSystem != null)
     {
         var    edsm = new EDDiscovery.EDSM.EDSMClass();
         string url  = edsm.GetUrlToEDSMSystem(_linkSystem.name, _linkSystem.id_edsm);
         System.Diagnostics.Process.Start(url);
     }
 }
Exemplo n.º 3
0
        private void pictureBox_ClickElement(object sender, MouseEventArgs eventargs, ExtendedControls.PictureBoxHotspot.ImageElement i, object tag)
        {
            if (i != null)
            {
                HistoryEntry he = tag as HistoryEntry;

                if (he != null)
                {
                    EDDiscovery.EDSM.EDSMClass edsm = new EDDiscovery.EDSM.EDSMClass();

                    string url = edsm.GetUrlToEDSMSystem(he.System.name);

                    if (url.Length > 0)         // may pass back empty string if not known, this solves another exception
                    {
                        System.Diagnostics.Process.Start(url);
                    }
                    else
                    {
                        ExtendedControls.MessageBoxTheme.Show("System " + he.System.name + " unknown to EDSM");
                    }
                }
                else
                {
                    var list = discoveryform.history.Where(p => p.IsFSDJump).OrderByDescending(p => p.EventTimeUTC).Take(2);
                    if (list.Count() == 0)
                    {
                        return;
                    }
                    he = list.ToArray()[0];
                    if (he.StartMarker)
                    {
                        return;
                    }

                    he.StartMarker = true;
                    EliteDangerous.JournalEntry.UpdateSyncFlagBit(he.Journalid, EliteDangerous.SyncFlags.StartMarker, he.StartMarker);
                    if (list.Count() > 1 && he.isTravelling)
                    {
                        he            = list.ToArray()[1];
                        he.StopMarker = true;
                        EliteDangerous.JournalEntry.UpdateSyncFlagBit(he.Journalid, EliteDangerous.SyncFlags.StopMarker, he.StopMarker);
                    }
                    discoveryform.RefreshHistoryAsync();
                }
            }
        }
Exemplo n.º 4
0
        public override bool ExecuteAction(ActionProgramRun ap)
        {
            string res;

            if (ap.functions.ExpandString(UserData, out res) != ConditionFunctions.ExpandResult.Failed)
            {
                HistoryList  hl     = ap.actioncontroller.HistoryList;
                StringParser sp     = new StringParser(res);
                string       prefix = "EC_";

                string cmdname = sp.NextWord(" ", true);

                // [PREFIX varprefix] [FROM JID] Forward/First/Backward/Last [event or (event list,event)] [WHERE conditions list]
                // FROM JID NEXT gives you the one after the JID
                // FROM JID BACKWARD gives you the JID before the JID
                // FROM JID gives you the JID

                if (cmdname != null && cmdname.Equals("prefix"))
                {
                    prefix = sp.NextWord();

                    if (prefix == null)
                    {
                        ap.ReportError("Missing name after Prefix in Event");
                        return(true);
                    }

                    cmdname = sp.NextWord(" ", true);
                }

                int jidindex = -1;

                if (cmdname != null && (cmdname.Equals("from") || cmdname.Equals("thpos")))
                {
                    long?jid;

                    if (cmdname.Equals("thpos"))
                    {
                        HistoryEntry he = ap.actioncontroller.DiscoveryForm.TravelControl.GetTravelHistoryCurrent;

                        if (he == null)
                        {
                            ReportEntry(ap, null, 0, prefix);
                            return(true);
                        }

                        jid = he.Journalid;
                    }
                    else
                    {
                        jid = sp.NextWord().InvariantParseLongNull();
                        if (!jid.HasValue)
                        {
                            ap.ReportError("Non integer JID after FROM in Event");
                            return(true);
                        }
                    }

                    jidindex = hl.GetIndex(jid.Value);

                    if (jidindex == -1)
                    {
                        ReportEntry(ap, null, 0, prefix);
                        return(true);
                    }

                    cmdname = sp.NextWord(" ", true);
                }

                if (cmdname == null)
                {
                    if (jidindex != -1)
                    {
                        ReportEntry(ap, hl.EntryOrder, jidindex, prefix);
                    }
                    else
                    {
                        ap.ReportError("No commands in Event");
                    }

                    return(true);
                }

                bool fwd  = cmdname.Equals("forward") || cmdname.Equals("first");
                bool back = cmdname.Equals("backward") || cmdname.Equals("last");

                if (fwd || back)
                {
                    List <string> eventnames   = sp.NextOptionallyBracketedList();
                    bool          whereasfirst = eventnames.Count == 1 && eventnames[0].Equals("WHERE", StringComparison.InvariantCultureIgnoreCase);

                    ConditionLists cond = new ConditionLists();
                    string         nextword;

                    if (whereasfirst || ((nextword = sp.NextWord()) != null && nextword.Equals("WHERE", StringComparison.InvariantCultureIgnoreCase)))
                    {
                        if (whereasfirst)       // clear out event names if it was WHERE cond..
                        {
                            eventnames.Clear();
                        }

                        string resc = cond.FromString(sp.LineLeft);       // rest of it is the condition..
                        if (resc != null)
                        {
                            ap.ReportError(resc + " in Where of Event");
                            return(true);
                        }
                    }

                    List <HistoryEntry> hltest;

                    if (jidindex == -1)         // if no JID given..
                    {
                        hltest = hl.EntryOrder; // the whole list
                    }
                    else if (fwd)
                    {
                        hltest = hl.EntryOrder.GetRange(jidindex + 1, hl.Count - (jidindex + 1));       // cut down list, excluding this entry
                    }
                    else
                    {
                        hltest = hl.EntryOrder.GetRange(0, jidindex);
                    }

                    if (eventnames.Count > 0)
                    {
                        hltest = (from h in hltest where eventnames.Contains(h.journalEntry.EventTypeStr, StringComparer.OrdinalIgnoreCase) select h).ToList();
                    }

                    if (cond.Count > 0)                                                  // if we have filters, apply, filter out, true only stays
                    {
                        hltest = cond.CheckFilterTrue(hltest, new ConditionVariables()); // apply filter..
                    }
                    if (fwd)
                    {
                        ReportEntry(ap, hltest, 0, prefix);
                    }
                    else
                    {
                        ReportEntry(ap, hltest, hltest.Count - 1, prefix);
                    }

                    return(true);
                }
                else
                {
                    if (jidindex == -1)
                    {
                        ap.ReportError("Valid JID must be given for command " + cmdname + " in Event");
                    }
                    else if (cmdname.Equals("action"))
                    {
                        int count = ap.actioncontroller.ActionRunOnEntry(hl.EntryOrder[jidindex], "ActionProgram", now: true);
                        ap[prefix + "Count"] = count.ToString(System.Globalization.CultureInfo.InvariantCulture);
                    }
                    else if (cmdname.Equals("edsm"))
                    {
                        HistoryEntry he = hl.EntryOrder[jidindex];
                        ap.actioncontroller.HistoryList.FillEDSM(he, reload: true);

                        long?id_edsm = he.System.id_edsm;
                        if (id_edsm <= 0)
                        {
                            id_edsm = null;
                        }

                        EDDiscovery.EDSM.EDSMClass edsm = new EDDiscovery.EDSM.EDSMClass();
                        string url = edsm.GetUrlToEDSMSystem(he.System.name, id_edsm);

                        ap[prefix + "URL"] = url;

                        if (url.Length > 0)         // may pass back empty string if not known, this solves another exception
                        {
                            System.Diagnostics.Process.Start(url);
                        }
                    }
                    else if (cmdname.Equals("ross"))
                    {
                        HistoryEntry he = hl.EntryOrder[jidindex];
                        ap.actioncontroller.HistoryList.FillEDSM(he, reload: true);

                        string url = "";

                        if (he.System.id_eddb > 0)
                        {
                            url = "http://ross.eddb.io/system/update/" + he.System.id_eddb.ToString();
                            System.Diagnostics.Process.Start(url);
                        }

                        ap[prefix + "URL"] = url;
                    }
                    else if (cmdname.Equals("info"))
                    {
                        HistoryEntry he = hl.EntryOrder[jidindex];
                        ActionVars.HistoryEventFurtherInfo(ap, hl, he, prefix);
                        ActionVars.SystemVarsFurtherInfo(ap, hl, he.System, prefix);
                    }
                    else
                    {
                        ap.ReportError("Unknown command " + cmdname + " in Event");
                    }
                }
            }
            else
            {
                ap.ReportError(res);
            }

            return(true);
        }