private void Display()
        {
            List <MissionState> ml = last_he != null?discoveryform.history.MissionListAccumulator.GetMissionList(last_he.MissionList) : null;

            missionListCurrent.Clear();
            missionListPrevious.Clear();

            if (ml != null)
            {
                DateTime hetime = last_he.EventTimeUTC;

                List <MissionState> mcurrent = MissionListAccumulator.GetAllCurrentMissions(ml, hetime);

                foreach (MissionState ms in mcurrent)
                {
                    missionListCurrent.Add(ms, false);
                }

                missionListCurrent.Finish();

                List <MissionState> mprev = MissionListAccumulator.GetAllExpiredMissions(ml, hetime);

                var previousRows = new List <DataGridViewRow>(mprev.Count);

                foreach (MissionState ms in mprev)
                {
                    missionListPrevious.Add(ms, true);
                }

                missionListPrevious.Finish();
            }
        }
        //EliteDangerousCore.UIEvents.UIOverallStatus status,
        public JToken MakeResponse(int entry, string type)       // entry = -1 means latest
        {
            if (discoveryform.InvokeRequired)
            {
                return((JToken)discoveryform.Invoke(new Func <JToken>(() => MakeResponse(entry, type))));
            }
            else
            {
                JObject response = new JObject();
                response["responsetype"] = type;

                var hl = discoveryform.history;
                if (hl.Count == 0)
                {
                    response["entry"] = -1;
                }
                else
                {
                    if (entry < 0 || entry >= hl.Count)
                    {
                        entry = hl.Count - 1;
                    }

                    response["entry"] = entry;

                    HistoryEntry he = hl[entry];

                    List <MissionState> ml = discoveryform.history.MissionListAccumulator.GetMissionList(he.MissionList);

                    DateTime hetime = he.EventTimeUTC;

                    List <MissionState> mcurrent = MissionListAccumulator.GetAllCurrentMissions(ml, hetime);

                    JArray cur = new JArray();

                    foreach (MissionState ms in mcurrent)
                    {
                        cur.Add(MissionInfo(ms, false));
                    }

                    response["current"] = cur;

                    List <MissionState> mprev = MissionListAccumulator.GetAllExpiredMissions(ml, hetime);

                    JArray prev = new JArray();

                    foreach (MissionState ms in mprev)
                    {
                        prev.Add(MissionInfo(ms, true));
                    }

                    response["previous"] = prev;
                }

                return(response);
            }
        }
Example #3
0
        private void Display(HistoryEntry he)
        {
            currentHE = he;

            pictureBox.ClearImageList();

            if (currentHE != null)
            {
                Color textcolour = IsTransparent ? discoveryform.theme.SPanelColor : discoveryform.theme.LabelColor;
                Color backcolour = IsTransparent ? Color.Transparent : this.BackColor;

                DateTime hetime = currentHE.EventTimeUTC;

                List <MissionState> ml       = discoveryform.history.MissionListAccumulator.GetMissionList(currentHE.MissionList);
                List <MissionState> mcurrent = MissionListAccumulator.GetAllCurrentMissions(ml, hetime);

                int  vpos        = 4;
                Font displayfont = discoveryform.theme.GetFont;

                foreach (MissionState ms in mcurrent)
                {
                    string text = "";

                    if (missionNameToolStripMenuItem.Checked)
                    {
                        text += JournalFieldNaming.ShortenMissionName(ms.Mission.Name);
                    }

                    if (missionDescriptionToolStripMenuItem.Checked && ms.Mission.LocalisedName.HasChars())
                    {
                        text = text.AppendPrePad(ms.Mission.LocalisedName, ", ");
                    }

                    if (startDateToolStripMenuItem.Checked)
                    {
                        text = text.AppendPrePad(EDDiscoveryForm.EDDConfig.ConvertTimeToSelectedFromUTC(ms.Mission.EventTimeUTC).ToString(), ", ");
                    }

                    if (endDateToolStripMenuItem.Checked)
                    {
                        text = text.AppendPrePad(EDDiscoveryForm.EDDConfig.ConvertTimeToSelectedFromUTC(ms.Mission.Expiry).ToString(), startDateToolStripMenuItem.Checked ? "-" : ", ");
                    }

                    string mainpart = BaseUtils.FieldBuilder.Build(
                        "< ", ms.DestinationSystemStation(),
                        " ", factionInformationToolStripMenuItem.Checked ? ms.Mission.TargetFaction : null,
                        "< ", ms.Mission.TargetLocalised,
                        "< ", ms.Mission.KillCount?.ToString("N") ?? null,
                        " ", ms.Mission.CommodityLocalised,
                        "< ", ms.Mission.Count,
                        " Left ".T(EDTx.UserControlMissionOverlay_IL), ms.CargoDepot?.ItemsToGo
                        );

                    text = text.AppendPrePad(mainpart, ", ");

                    if (rewardToolStripMenuItem.Checked && ms.Mission.Reward.HasValue && ms.Mission.Reward > 0)
                    {
                        text = text.AppendPrePad(BaseUtils.FieldBuilder.Build(" ;cr", ms.Mission.Reward.GetValueOrDefault().ToString("N0")), ", ");
                    }

                    using (StringFormat frmt = new StringFormat())
                    {
                        var ie = pictureBox.AddTextAutoSize(new Point(10, vpos), new Size(this.Width - 20, this.Height), text, displayfont, textcolour, backcolour, 1.0F, frmt: frmt);
                        vpos = ie.Location.Bottom + displayfont.ScalePixels(4);
                    }
                }
            }

            pictureBox.Render();
        }