Exemplo n.º 1
0
        void StatsTravel(HistoryEntry he, HistoryList hl)
        {
            int[]    intar     = null;
            string[] strarr    = null;
            int      intervals = 0;

            DateTime[] timearr;
            DateTime   endTime;


            if (userControlStatsTimeTravel.TimeMode == UserControlStatsTimeModeEnum.Summary || userControlStatsTimeTravel.TimeMode == UserControlStatsTimeModeEnum.Custom)
            {
                dataGridViewTravel.Rows.Clear();
                dataGridViewTravel.Columns.Clear();
                dataGridViewTravel.Dock    = DockStyle.Fill;
                dataGridViewTravel.Visible = true;


                if (userControlStatsTimeTravel.TimeMode == UserControlStatsTimeModeEnum.Summary)
                {
                    intervals = 5;
                    var Col1 = new DataGridViewTextBoxColumn();
                    Col1.HeaderText = "Last";

                    var Col2 = new DataGridViewTextBoxColumn();
                    ColumnValueAlignment(Col2);
                    Col2.HeaderText = "24 hours";

                    var Col3 = new DataGridViewTextBoxColumn();
                    ColumnValueAlignment(Col3);
                    Col3.HeaderText = "week";

                    var Col4 = new DataGridViewTextBoxColumn();
                    ColumnValueAlignment(Col4);
                    Col4.HeaderText = "month";

                    var Col5 = new DataGridViewTextBoxColumn();
                    Col5.HeaderText = "Last dock";
                    ColumnValueAlignment(Col5);

                    var Col6 = new DataGridViewTextBoxColumn();
                    Col6.HeaderText = "all";
                    ColumnValueAlignment(Col6);

                    dataGridViewTravel.Columns.AddRange(new DataGridViewColumn[] { Col1, Col2, Col3, Col4, Col5, Col6 });


                    intar  = new int[intervals];
                    strarr = new string[intervals];


                    timearr = new DateTime[intervals];


                    HistoryEntry lastdocked   = hl.GetLastHistoryEntry(x => x.IsDocked);
                    DateTime     lastdockTime = DateTime.Now;

                    if (lastdocked != null)
                    {
                        lastdockTime = lastdocked.EventTimeLocal;
                    }


                    timearr[0] = DateTime.Now.AddDays(-1);
                    timearr[1] = DateTime.Now.AddDays(-7);
                    timearr[2] = DateTime.Now.AddMonths(-1);
                    timearr[3] = lastdockTime;
                    timearr[4] = new DateTime(2012, 1, 1);

                    endTime = DateTime.Now;
                }
                else  // Custom
                {
                    intervals = 1;
                    var Col1 = new DataGridViewTextBoxColumn();
                    Col1.HeaderText = "";

                    var Col2 = new DataGridViewTextBoxColumn();
                    ColumnValueAlignment(Col2);
                    Col2.HeaderText = userControlStatsTimeTravel.CustomDateTimePickerFrom.Value.ToShortDateString() + " - " + userControlStatsTimeTravel.CustomDateTimePickerTo.Value.ToShortDateString();

                    dataGridViewTravel.Columns.AddRange(new DataGridViewColumn[] { Col1, Col2 });


                    intar  = new int[intervals];
                    strarr = new string[intervals];


                    timearr = new DateTime[intervals];


                    timearr[0] = userControlStatsTimeTravel.CustomDateTimePickerFrom.Value;
                    endTime    = userControlStatsTimeTravel.CustomDateTimePickerTo.Value.AddDays(1);
                }



                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetFSDJumps(timearr[ii], endTime).ToString("N0", System.Globalization.CultureInfo.CurrentCulture);
                }
                StatToDGV(dataGridViewTravel, "Jumps", strarr);

                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetTraveledLy(timearr[ii], endTime).ToString("N2", System.Globalization.CultureInfo.CurrentCulture);
                }
                StatToDGV(dataGridViewTravel, "Traveled Ly", strarr);

                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetFSDBoostUsed(timearr[ii], endTime).ToString("N0", System.Globalization.CultureInfo.CurrentCulture);
                }
                StatToDGV(dataGridViewTravel, "Boost used", strarr);

                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetJetConeBoost(timearr[ii], endTime).ToString("N0", System.Globalization.CultureInfo.CurrentCulture);
                }
                StatToDGV(dataGridViewTravel, "Jet Cone Boost", strarr);

                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetTouchDown(timearr[ii], endTime).ToString("N0", System.Globalization.CultureInfo.CurrentCulture);
                }
                StatToDGV(dataGridViewTravel, "Landed", strarr);


                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetHeatWarning(timearr[ii], endTime).ToString("N0", System.Globalization.CultureInfo.CurrentCulture);
                }
                StatToDGV(dataGridViewTravel, "Heat Warning", strarr);

                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetHeatDamage(timearr[ii], endTime).ToString("N0", System.Globalization.CultureInfo.CurrentCulture);
                }
                StatToDGV(dataGridViewTravel, "Heat damage", strarr);

                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetFuelScooped(timearr[ii], endTime).ToString("N0", System.Globalization.CultureInfo.CurrentCulture);
                }
                StatToDGV(dataGridViewTravel, "Fuel Scooped", strarr);

                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetFuelScoopedTons(timearr[ii], endTime).ToString("N2", System.Globalization.CultureInfo.CurrentCulture);
                }
                StatToDGV(dataGridViewTravel, "Scooped Tons", strarr);

                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetNrScans(timearr[ii], endTime).ToString("N0", System.Globalization.CultureInfo.CurrentCulture);
                }
                StatToDGV(dataGridViewTravel, "Scans", strarr);

                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetScanValue(timearr[ii], endTime).ToString("N0", System.Globalization.CultureInfo.CurrentCulture);
                }
                StatToDGV(dataGridViewTravel, "Scan value", strarr);
            }
            else
            {
                intervals = 10;
                DateTime[] timeintervals = new DateTime[intervals + 1];
                DateTime   currentday    = DateTime.Today;


                if (userControlStatsTimeTravel.TimeMode == UserControlStatsTimeModeEnum.Day)
                {
                    timeintervals[0] = currentday.AddDays(1);
                    for (int ii = 0; ii < intervals; ii++)
                    {
                        timeintervals[ii + 1] = timeintervals[ii].AddDays(-1);
                    }
                }
                else if (userControlStatsTimeTravel.TimeMode == UserControlStatsTimeModeEnum.Week)
                {
                    DateTime startOfWeek = currentday.AddDays(-1 * (int)(DateTime.Today.DayOfWeek - 1));
                    timeintervals[0] = startOfWeek.AddDays(7);
                    for (int ii = 0; ii < intervals; ii++)
                    {
                        timeintervals[ii + 1] = timeintervals[ii].AddDays(-7);
                    }
                }
                else  // month
                {
                    DateTime startOfMonth = new DateTime(currentday.Year, currentday.Month, 1);
                    timeintervals[0] = startOfMonth.AddMonths(1);
                    for (int ii = 0; ii < intervals; ii++)
                    {
                        timeintervals[ii + 1] = timeintervals[ii].AddMonths(-1);
                    }
                }

                strarr = new string[intervals];

                dataGridViewTravel.Rows.Clear();
                dataGridViewTravel.Columns.Clear();
                dataGridViewTravel.Dock    = DockStyle.Fill;
                dataGridViewTravel.Visible = true;


                var Col1 = new DataGridViewTextBoxColumn();
                Col1.HeaderText = "";

                dataGridViewTravel.Columns.Add(Col1);

                for (int ii = 0; ii < intervals; ii++)
                {
                    var Col2 = new DataGridViewTextBoxColumn();
                    Col2.HeaderText = timeintervals[ii + 1].ToShortDateString();
                    ColumnValueAlignment(Col2);
                    dataGridViewTravel.Columns.Add(Col2);
                }


                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetFSDJumps(timeintervals[ii + 1], timeintervals[ii]).ToString("N0", System.Globalization.CultureInfo.CurrentCulture);
                }
                StatToDGV(dataGridViewTravel, "Jumps", strarr);


                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetTraveledLy(timeintervals[ii + 1], timeintervals[ii]).ToString("N2", System.Globalization.CultureInfo.CurrentCulture);
                }
                StatToDGV(dataGridViewTravel, "Traveled Ly", strarr);


                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetFSDBoostUsed(timeintervals[ii + 1], timeintervals[ii]).ToString("N0", System.Globalization.CultureInfo.CurrentCulture);
                }
                StatToDGV(dataGridViewTravel, "Boost used", strarr);


                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetJetConeBoost(timeintervals[ii + 1], timeintervals[ii]).ToString("N0", System.Globalization.CultureInfo.CurrentCulture);
                }
                StatToDGV(dataGridViewTravel, "Jet Cone Boost", strarr);

                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetDocked(timeintervals[ii + 1], timeintervals[ii]).ToString("N0", System.Globalization.CultureInfo.CurrentCulture);
                }
                StatToDGV(dataGridViewTravel, "Docked", strarr);

                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetTouchDown(timeintervals[ii + 1], timeintervals[ii]).ToString("N0", System.Globalization.CultureInfo.CurrentCulture);
                }
                StatToDGV(dataGridViewTravel, "Landed", strarr);


                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetHeatWarning(timeintervals[ii + 1], timeintervals[ii]).ToString("N0", System.Globalization.CultureInfo.CurrentCulture);
                }
                StatToDGV(dataGridViewTravel, "Heat Warning", strarr);

                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetHeatDamage(timeintervals[ii + 1], timeintervals[ii]).ToString("N0", System.Globalization.CultureInfo.CurrentCulture);
                }
                StatToDGV(dataGridViewTravel, "Heat damage", strarr);

                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetFuelScooped(timeintervals[ii + 1], timeintervals[ii]).ToString("N0", System.Globalization.CultureInfo.CurrentCulture);
                }
                StatToDGV(dataGridViewTravel, "Fuel Scooped", strarr);

                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetFuelScoopedTons(timeintervals[ii + 1], timeintervals[ii]).ToString("N2", System.Globalization.CultureInfo.CurrentCulture);
                }
                StatToDGV(dataGridViewTravel, "Scooped Tons", strarr);

                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetNrScans(timeintervals[ii + 1], timeintervals[ii]).ToString("N0", System.Globalization.CultureInfo.CurrentCulture);
                }
                StatToDGV(dataGridViewTravel, "Scans", strarr);


                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetScanValue(timeintervals[ii + 1], timeintervals[ii]).ToString("N0", System.Globalization.CultureInfo.CurrentCulture);
                }
                StatToDGV(dataGridViewTravel, "Scan value", strarr);
            }
        }
Exemplo n.º 2
0
        void StatsTravel(HistoryEntry he, HistoryList hl)
        {
            int[]    intar  = null;
            string[] strarr = null;

            if (userControlStatsTimeTravel.TimeMode == UserControlStatsTimeModeEnum.Summary)
            {
                dataGridViewTravel.Rows.Clear();
                dataGridViewTravel.Columns.Clear();
                dataGridViewTravel.Dock    = DockStyle.Fill;
                dataGridViewTravel.Visible = true;


                var Col1 = new DataGridViewTextBoxColumn();
                Col1.HeaderText = "Last";

                var Col2 = new DataGridViewTextBoxColumn();
                ColumnValueAlignment(Col2);
                Col2.HeaderText = "24 hours";

                var Col3 = new DataGridViewTextBoxColumn();
                ColumnValueAlignment(Col3);
                Col3.HeaderText = "week";

                var Col4 = new DataGridViewTextBoxColumn();
                ColumnValueAlignment(Col4);
                Col4.HeaderText = "month";

                var Col5 = new DataGridViewTextBoxColumn();
                ColumnValueAlignment(Col5);
                Col5.HeaderText = "all";

                dataGridViewTravel.Columns.AddRange(new DataGridViewColumn[] { Col1, Col2, Col3, Col4, Col5 });


                intar  = new int[4];
                strarr = new string[4];


                intar[0] = hl.GetFSDJumps(DateTime.Now.AddDays(-1), DateTime.Now);
                intar[1] = hl.GetFSDJumps(DateTime.Now.AddDays(-7), DateTime.Now);
                intar[2] = hl.GetFSDJumps(DateTime.Now.AddMonths(-1), DateTime.Now);
                intar[3] = hl.GetFSDJumps(new DateTime(2012, 1, 1), DateTime.Now);
                StatToDGV(dataGridViewTravel, "Jumps", intar);

                strarr[0] = hl.GetTraveledLy(DateTime.Now.AddDays(-1), DateTime.Now).ToString("0.00");
                strarr[1] = hl.GetTraveledLy(DateTime.Now.AddDays(-7), DateTime.Now).ToString("0.00");
                strarr[2] = hl.GetTraveledLy(DateTime.Now.AddDays(-30), DateTime.Now).ToString("0.00");
                strarr[3] = hl.GetTraveledLy(new DateTime(2012, 1, 1), DateTime.Now).ToString("0.00");
                StatToDGV(dataGridViewTravel, "Traveled Ly", strarr);

                intar[0] = hl.GetFSDBoostUsed(DateTime.Now.AddDays(-1), DateTime.Now);
                intar[1] = hl.GetFSDBoostUsed(DateTime.Now.AddDays(-7), DateTime.Now);
                intar[2] = hl.GetFSDBoostUsed(DateTime.Now.AddDays(-30), DateTime.Now);
                intar[3] = hl.GetFSDBoostUsed(new DateTime(2012, 1, 1), DateTime.Now);
                StatToDGV(dataGridViewTravel, "Boost used", intar);



                intar[0] = hl.GetJetConeBoost(DateTime.Now.AddDays(-1), DateTime.Now);
                intar[1] = hl.GetJetConeBoost(DateTime.Now.AddDays(-7), DateTime.Now);
                intar[2] = hl.GetJetConeBoost(DateTime.Now.AddDays(-30), DateTime.Now);
                intar[3] = hl.GetJetConeBoost(new DateTime(2012, 1, 1), DateTime.Now);
                StatToDGV(dataGridViewTravel, "Jet Cone Boost", intar);

                intar[0] = hl.GetTouchDown(DateTime.Now.AddDays(-1), DateTime.Now);
                intar[1] = hl.GetTouchDown(DateTime.Now.AddDays(-7), DateTime.Now);
                intar[2] = hl.GetTouchDown(DateTime.Now.AddDays(-30), DateTime.Now);
                intar[3] = hl.GetTouchDown(new DateTime(2012, 1, 1), DateTime.Now);
                StatToDGV(dataGridViewTravel, "Landed", intar);


                intar[0] = hl.GetHeatWarning(DateTime.Now.AddDays(-1), DateTime.Now);
                intar[1] = hl.GetHeatWarning(DateTime.Now.AddDays(-7), DateTime.Now);
                intar[2] = hl.GetHeatWarning(DateTime.Now.AddDays(-30), DateTime.Now);
                intar[3] = hl.GetHeatWarning(new DateTime(2012, 1, 1), DateTime.Now);
                StatToDGV(dataGridViewTravel, "Heat Warning", intar);

                intar[0] = hl.GetHeatDamage(DateTime.Now.AddDays(-1), DateTime.Now);
                intar[1] = hl.GetHeatDamage(DateTime.Now.AddDays(-7), DateTime.Now);
                intar[2] = hl.GetHeatDamage(DateTime.Now.AddDays(-30), DateTime.Now);
                intar[3] = hl.GetHeatDamage(new DateTime(2012, 1, 1), DateTime.Now);
                StatToDGV(dataGridViewTravel, "Heat damage", intar);

                intar[0] = hl.GetFuelScooped(DateTime.Now.AddDays(-1), DateTime.Now);
                intar[1] = hl.GetFuelScooped(DateTime.Now.AddDays(-7), DateTime.Now);
                intar[2] = hl.GetFuelScooped(DateTime.Now.AddDays(-30), DateTime.Now);
                intar[3] = hl.GetFuelScooped(new DateTime(2012, 1, 1), DateTime.Now);
                StatToDGV(dataGridViewTravel, "Fuel Scooped", intar);

                strarr[0] = hl.GetFuelScoopedTons(DateTime.Now.AddDays(-1), DateTime.Now).ToString("0.00");
                strarr[1] = hl.GetFuelScoopedTons(DateTime.Now.AddDays(-7), DateTime.Now).ToString("0.00");
                strarr[2] = hl.GetFuelScoopedTons(DateTime.Now.AddDays(-30), DateTime.Now).ToString("0.00");
                strarr[3] = hl.GetFuelScoopedTons(new DateTime(2012, 1, 1), DateTime.Now).ToString("0.00");
                StatToDGV(dataGridViewTravel, "Scooped Tons", strarr);

                strarr[0] = hl.GetNrScans(DateTime.Now.AddDays(-1), DateTime.Now).ToString("0");
                strarr[1] = hl.GetNrScans(DateTime.Now.AddDays(-7), DateTime.Now).ToString("0");
                strarr[2] = hl.GetNrScans(DateTime.Now.AddDays(-30), DateTime.Now).ToString("0");
                strarr[3] = hl.GetNrScans(new DateTime(2012, 1, 1), DateTime.Now).ToString("0");
                StatToDGV(dataGridViewTravel, "Scans", strarr);

                strarr[0] = hl.GetScanValue(DateTime.Now.AddDays(-1), DateTime.Now).ToString("0");
                strarr[1] = hl.GetScanValue(DateTime.Now.AddDays(-7), DateTime.Now).ToString("0");
                strarr[2] = hl.GetScanValue(DateTime.Now.AddDays(-30), DateTime.Now).ToString("0");
                strarr[3] = hl.GetScanValue(new DateTime(2012, 1, 1), DateTime.Now).ToString("0");
                StatToDGV(dataGridViewTravel, "Scan value", strarr);
            }
            else
            {
                int        intervals     = 10;
                DateTime[] timeintervals = new DateTime[intervals + 1];
                DateTime   currentday    = DateTime.Today;


                if (userControlStatsTimeTravel.TimeMode == UserControlStatsTimeModeEnum.Day)
                {
                    timeintervals[0] = currentday.AddDays(1);
                    for (int ii = 0; ii < intervals; ii++)
                    {
                        timeintervals[ii + 1] = timeintervals[ii].AddDays(-1);
                    }
                }
                else if (userControlStatsTimeTravel.TimeMode == UserControlStatsTimeModeEnum.Week)
                {
                    DateTime startOfWeek = currentday.AddDays(-1 * (int)(DateTime.Today.DayOfWeek - 1));
                    timeintervals[0] = startOfWeek.AddDays(7);
                    for (int ii = 0; ii < intervals; ii++)
                    {
                        timeintervals[ii + 1] = timeintervals[ii].AddDays(-7);
                    }
                }
                else  // month
                {
                    DateTime startOfMonth = new DateTime(currentday.Year, currentday.Month, 1);
                    timeintervals[0] = startOfMonth.AddMonths(1);
                    for (int ii = 0; ii < intervals; ii++)
                    {
                        timeintervals[ii + 1] = timeintervals[ii].AddMonths(-1);
                    }
                }

                strarr = new string[intervals];

                dataGridViewTravel.Rows.Clear();
                dataGridViewTravel.Columns.Clear();
                dataGridViewTravel.Dock    = DockStyle.Fill;
                dataGridViewTravel.Visible = true;


                var Col1 = new DataGridViewTextBoxColumn();
                Col1.HeaderText = "";

                dataGridViewTravel.Columns.Add(Col1);

                for (int ii = 0; ii < intervals; ii++)
                {
                    var Col2 = new DataGridViewTextBoxColumn();
                    Col2.HeaderText = timeintervals[ii + 1].ToShortDateString();
                    ColumnValueAlignment(Col2);
                    dataGridViewTravel.Columns.Add(Col2);
                }


                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetFSDJumps(timeintervals[ii + 1], timeintervals[ii]).ToString();
                }
                StatToDGV(dataGridViewTravel, "Jumps", strarr);


                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetTraveledLy(timeintervals[ii + 1], timeintervals[ii]).ToString("0.00");
                }
                StatToDGV(dataGridViewTravel, "Traveled Ly", strarr);


                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetFSDBoostUsed(timeintervals[ii + 1], timeintervals[ii]).ToString();
                }
                StatToDGV(dataGridViewTravel, "Boost used", strarr);


                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetJetConeBoost(timeintervals[ii + 1], timeintervals[ii]).ToString();
                }
                StatToDGV(dataGridViewTravel, "Jet Cone Boost", strarr);

                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetDocked(timeintervals[ii + 1], timeintervals[ii]).ToString();
                }
                StatToDGV(dataGridViewTravel, "Docked", strarr);

                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetTouchDown(timeintervals[ii + 1], timeintervals[ii]).ToString();
                }
                StatToDGV(dataGridViewTravel, "Landed", strarr);


                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetHeatWarning(timeintervals[ii + 1], timeintervals[ii]).ToString();
                }
                StatToDGV(dataGridViewTravel, "Heat Warning", strarr);

                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetHeatDamage(timeintervals[ii + 1], timeintervals[ii]).ToString();
                }
                StatToDGV(dataGridViewTravel, "Heat damage", strarr);

                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetFuelScooped(timeintervals[ii + 1], timeintervals[ii]).ToString();
                }
                StatToDGV(dataGridViewTravel, "Fuel Scooped", strarr);

                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetFuelScoopedTons(timeintervals[ii + 1], timeintervals[ii]).ToString("0.00");
                }
                StatToDGV(dataGridViewTravel, "Scooped Tons", strarr);

                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetNrScans(timeintervals[ii + 1], timeintervals[ii]).ToString("0");
                }
                StatToDGV(dataGridViewTravel, "Scans", strarr);


                for (int ii = 0; ii < intervals; ii++)
                {
                    strarr[ii] = hl.GetScanValue(timeintervals[ii + 1], timeintervals[ii]).ToString("0");
                }
                StatToDGV(dataGridViewTravel, "Scan value", strarr);
            }
        }