Esempio n. 1
0
        private void Display()
        {
            MissionList ml = last_he?.MissionList;

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

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

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

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

                missionListCurrent.Finish();

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

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

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

                missionListPrevious.Finish();
            }
        }
Esempio n. 2
0
        private void Display()
        {
            MissionList ml = last_he?.MissionList;

            dataGridViewCurrent.Rows.Clear();
            dataGridViewPrevious.Rows.Clear();

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

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

                var totalReward = 0;
                foreach (MissionState ms in mcurrent)
                {
                    object[] rowobj = { JournalFieldNaming.ShortenMissionName(ms.Mission.Name),
                                        EDDiscoveryForm.EDDConfig.DisplayUTC ? ms.Mission.EventTimeUTC : ms.Mission.EventTimeLocal,
                                        EDDiscoveryForm.EDDConfig.DisplayUTC ? ms.Mission.Expiry : ms.Mission.Expiry.ToLocalTime(),
                                        ms.OriginatingSystem + ":" + ms.OriginatingStation,
                                        ms.Mission.Faction,
                                        ms.DestinationSystemStation(),
                                        ms.Mission.TargetFaction,
                                        ms.Mission.Reward.GetValueOrDefault().ToString("N0"),
                                        ms.Info() };

                    if (ms.Mission.Reward.HasValue)
                    {
                        totalReward += ms.Mission.Reward.Value;
                    }

                    int rowno = dataGridViewCurrent.Rows.Add(rowobj);
                    dataGridViewCurrent.Rows[rowno].Tag = ms;
                }

                int count = mcurrent.Count();

                cColName.HeaderText  = (count > 0) ? (count.ToStringInvariant() + (count > 1 ? " Missions".Tx(this, "MPlural") : " Mission".Tx(this, "MSingular"))) : "Name".Tx(this, "Name");
                cColValue.HeaderText = (totalReward != 0) ? string.Format("Value (cr):\n{0:N0}".Tx(this, "Value"), totalReward) : "Value (cr)".Tx(this, "ValueN");

                //                cColValue.HeaderText = (count>0) ? (count.ToStringInvariant() + (count > 1 ? " Missions" : " Mission") + (totalReward>0 ? $", {totalReward:N0}" : "")) : "Value";

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

                DateTime startdate = customDateTimePickerStart.Checked ? customDateTimePickerStart.Value : new DateTime(1980, 1, 1);
                DateTime enddate   = customDateTimePickerEnd.Checked ? customDateTimePickerEnd.Value : new DateTime(2999, 1, 1);

                long value = 0;
                int  completed = 0, abandonded = 0, failed = 0;

                foreach (MissionState ms in mprev)
                {
                    int cmps = EDDiscoveryForm.EDDConfig.DisplayUTC ? DateTime.Compare(ms.Mission.EventTimeUTC, startdate) : DateTime.Compare(ms.Mission.EventTimeLocal, startdate);

                    //System.Diagnostics.Debug.WriteLine(ms.Mission.EventTimeUTC.ToString() + " " + startdate.ToString() + " " + cmps);
                    if (cmps >= 0)
                    {
                        int cmpe = EDDiscoveryForm.EDDConfig.DisplayUTC ? DateTime.Compare(ms.Mission.EventTimeUTC, enddate) : DateTime.Compare(ms.Mission.EventTimeLocal, enddate);

                        if (cmpe <= 0)
                        {
                            if (ms.State == MissionState.StateTypes.Abandoned)
                            {
                                abandonded++;
                            }
                            else if (ms.State == MissionState.StateTypes.Completed)
                            {
                                completed++;
                            }
                            else if (ms.State == MissionState.StateTypes.Failed)
                            {
                                failed++;
                            }

                            object[] rowobj = { JournalFieldNaming.ShortenMissionName(ms.Mission.Name),
                                                EDDiscoveryForm.EDDConfig.DisplayUTC ? ms.Mission.EventTimeUTC : ms.Mission.EventTimeLocal,
                                                EDDiscoveryForm.EDDConfig.DisplayUTC ? ms.MissionEndTime : ms.MissionEndTime.ToLocalTime(),
                                                ms.OriginatingSystem + ":" + ms.OriginatingStation,
                                                ms.Mission.Faction,
                                                ms.DestinationSystemStation(),
                                                ms.Mission.TargetFaction,
                                                ms.StateText,
                                                ms.Info() };

                            int rowno = dataGridViewPrevious.Rows.Add(rowobj);
                            dataGridViewPrevious.Rows[rowno].Tag = ms;

                            value += ms.Value;
                        }
                    }
                }

                labelValue.Visible = (value != 0);
                labelValue.Text    = "Value: ".Tx(this, "ValueC") + value.ToStringInvariant() + " C:" + completed.ToStringInvariant() + " A:" + abandonded.ToStringInvariant() + " F:" + failed.ToStringInvariant();
            }
        }
        private void Display()
        {
            MissionList ml = last_he?.MissionList;

            DataGridViewColumn sortcolprev   = dataGridViewPrevious.SortedColumn != null ? dataGridViewPrevious.SortedColumn : dataGridViewPrevious.Columns[1];
            SortOrder          sortorderprev = dataGridViewPrevious.SortedColumn != null ? dataGridViewPrevious.SortOrder : SortOrder.Descending;

            DataGridViewColumn sortcolcur   = dataGridViewCurrent.SortedColumn != null ? dataGridViewCurrent.SortedColumn : dataGridViewCurrent.Columns[1];
            SortOrder          sortordercur = dataGridViewCurrent.SortedColumn != null ? dataGridViewCurrent.SortOrder : SortOrder.Descending;

            dataGridViewCurrent.Rows.Clear();
            dataGridViewPrevious.Rows.Clear();

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

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

                var totalReward = 0;
                foreach (MissionState ms in mcurrent)
                {
                    object[] rowobj = { JournalFieldNaming.ShortenMissionName(ms.Mission.LocalisedName),
                                        EDDiscoveryForm.EDDConfig.ConvertTimeToSelectedFromUTC(ms.Mission.EventTimeUTC),
                                        EDDiscoveryForm.EDDConfig.ConvertTimeToSelectedFromUTC(ms.Mission.Expiry),
                                        ms.OriginatingSystem + ":" + ms.OriginatingStation,
                                        ms.Mission.Faction,
                                        ms.DestinationSystemStation(),
                                        ms.Mission.TargetFaction,
                                        ms.Mission.Reward.GetValueOrDefault().ToString("N0"),
                                        ms.Info() };

                    if (ms.Mission.Reward.HasValue)
                    {
                        totalReward += ms.Mission.Reward.Value;
                    }

                    int rowno = dataGridViewCurrent.Rows.Add(rowobj);
                    dataGridViewCurrent.Rows[rowno].Tag = ms;
                }

                int count = mcurrent.Count();

                cColName.HeaderText  = (count > 0) ? (count.ToString() + (count > 1 ? " Missions".T(EDTx.UserControlMissions_MPlural) : " Mission".T(EDTx.UserControlMissions_MSingular))) : "Name".T(EDTx.UserControlMissions_Name);
                cColValue.HeaderText = (totalReward != 0) ? string.Format("Value (cr):\n{0:N0}".T(EDTx.UserControlMissions_Value), totalReward) : "Value (cr)".T(EDTx.UserControlMissions_ValueN);

                //                cColValue.HeaderText = (count>0) ? (count.ToStringInvariant() + (count > 1 ? " Missions" : " Mission") + (totalReward>0 ? $", {totalReward:N0}" : "")) : "Value";

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

                DateTime startdateutc = customDateTimePickerStart.Checked ? EDDConfig.Instance.ConvertTimeToUTCFromSelected(customDateTimePickerStart.Value) : new DateTime(1980, 1, 1);
                DateTime enddateutc   = customDateTimePickerEnd.Checked ? EDDConfig.Instance.ConvertTimeToUTCFromSelected(customDateTimePickerEnd.Value) : new DateTime(8999, 1, 1);

                long value = 0;
                int  completed = 0, abandonded = 0, failed = 0;

                foreach (MissionState ms in mprev)
                {
                    int cmps = DateTime.Compare(ms.Mission.EventTimeUTC, startdateutc);

                    //System.Diagnostics.Debug.WriteLine(ms.Mission.EventTimeUTC.ToString() + " " + startdate.ToString() + " " + cmps);
                    if (cmps >= 0)
                    {
                        int cmpe = DateTime.Compare(ms.Mission.EventTimeUTC, enddateutc);

                        if (cmpe <= 0)
                        {
                            if (ms.State == MissionState.StateTypes.Abandoned)
                            {
                                abandonded++;
                            }
                            else if (ms.State == MissionState.StateTypes.Completed)
                            {
                                completed++;
                            }
                            else if (ms.State == MissionState.StateTypes.Failed)
                            {
                                failed++;
                            }

                            object[] rowobj = { JournalFieldNaming.ShortenMissionName(ms.Mission.LocalisedName),
                                                EDDiscoveryForm.EDDConfig.ConvertTimeToSelectedFromUTC(ms.Mission.EventTimeUTC),
                                                EDDiscoveryForm.EDDConfig.ConvertTimeToSelectedFromUTC(ms.MissionEndTime),
                                                ms.OriginatingSystem + ":" + ms.OriginatingStation,
                                                ms.Mission.Faction,
                                                ms.DestinationSystemStation(),
                                                ms.Mission.TargetFaction,
                                                ms.StateText,
                                                ms.Info() };

                            int rowno = dataGridViewPrevious.Rows.Add(rowobj);
                            dataGridViewPrevious.Rows[rowno].Tag = ms;

                            value += ms.Value;
                        }
                    }
                }

                labelValue.Visible = (value != 0);
                labelValue.Text    = "Value: ".T(EDTx.UserControlMissions_ValueC) + value.ToString("N0") + " C:" + completed.ToString("N0") + " A:" + abandonded.ToString("N0") + " F:" + failed.ToString("N0");

                //System.Diagnostics.Debug.WriteLine("Prev " + sortorderprev + " " + sortcolprev.Index);
                dataGridViewPrevious.Sort(sortcolprev, (sortorderprev == SortOrder.Descending) ? ListSortDirection.Descending : ListSortDirection.Ascending);
                dataGridViewPrevious.Columns[sortcolprev.Index].HeaderCell.SortGlyphDirection = sortorderprev;

                dataGridViewCurrent.Sort(sortcolcur, (sortordercur == SortOrder.Descending) ? ListSortDirection.Descending : ListSortDirection.Ascending);
                dataGridViewCurrent.Columns[sortcolcur.Index].HeaderCell.SortGlyphDirection = sortordercur;
            }
        }