Exemplo n.º 1
0
        /// <summary>
        /// Returns a dictionary of named range values in the XML spreadsheet to replace with stat values
        /// </summary>
        /// <param name="dodStat"></param>
        /// <returns></returns>
        private static Dictionary <string, string> GetStatValues(GCDConsoleLib.GCD.DoDStats dodStat)
        {
            Dictionary <string, string> StatValues = new Dictionary <string, string>();

            //get settings and options
            UnitsNet.Area            ca      = ProjectManager.Project.CellArea;
            DoDSummaryDisplayOptions options = new DoDSummaryDisplayOptions(ProjectManager.Project.Units);

            UnitsNet.Units.LengthUnit vunit = ProjectManager.Project.Units.VertUnit;

            //using same pattern as ucDoDSummary
            StatValues["ArealLoweringRaw"]         = dodStat.ErosionRaw.GetArea(ca).As(options.AreaUnits).ToString();
            StatValues["ArealLoweringThresholded"] = dodStat.ErosionThr.GetArea(ca).As(options.AreaUnits).ToString();
            StatValues["ArealRaisingRaw"]          = dodStat.DepositionRaw.GetArea(ca).As(options.AreaUnits).ToString();
            StatValues["ArealRaisingThresholded"]  = dodStat.DepositionThr.GetArea(ca).As(options.AreaUnits).ToString();

            StatValues["VolumeLoweringRaw"]         = dodStat.ErosionRaw.GetVolume(ca, vunit).As(options.VolumeUnits).ToString();
            StatValues["VolumeLoweringThresholded"] = dodStat.ErosionThr.GetVolume(ca, vunit).As(options.VolumeUnits).ToString();
            StatValues["VolumeErrorLowering"]       = dodStat.ErosionErr.GetVolume(ca, vunit).As(options.VolumeUnits).ToString();
            StatValues["VolumeRaisingRaw"]          = dodStat.DepositionRaw.GetVolume(ca, vunit).As(options.VolumeUnits).ToString();
            StatValues["VolumeRaisingThresholded"]  = dodStat.DepositionThr.GetVolume(ca, vunit).As(options.VolumeUnits).ToString();
            StatValues["VolumeErrorRaising"]        = dodStat.DepositionErr.GetVolume(ca, vunit).As(options.VolumeUnits).ToString();

            return(StatValues);
        }
Exemplo n.º 2
0
        public void RefreshDisplay(GCDConsoleLib.GCD.DoDStats activeStats, List <GCDConsoleLib.GCD.DoDStats> allStats, UserInterface.BudgetSegregation.frmBudgetSegResults.RawRepresents raw, DoDSummaryDisplayOptions options)
        {
            // Load the base statistics for this class
            RefreshDisplay(activeStats, options);

            // Previous call will hide col 6. Make it visible for bs view
            grdData.Columns[colTot].Visible = true;

            // Build the string formatting based on the precision in the pop-up properties form
            string sFormat = GetFormatString(options);

            UnitsNet.Area             ca = ProjectManager.Project.CellArea;
            UnitsNet.Units.LengthUnit lu = ProjectManager.Project.Units.VertUnit;

            // AREAL

            // Erosion
            double classErosionArea = activeStats.ErosionThr.GetArea(ca).As(options.AreaUnits);
            double totalErosionArea = classErosionArea;

            switch (raw)
            {
            case BudgetSegregation.frmBudgetSegResults.RawRepresents.RawDoDAreaOfInterest:
                totalErosionArea = allStats.Sum(x => x.ErosionRaw.GetArea(ca).As(options.AreaUnits));
                break;

            case BudgetSegregation.frmBudgetSegResults.RawRepresents.ThrDoDAreaDetectableChange:
                totalErosionArea = allStats.Sum(x => x.ErosionThr.GetArea(ca).As(options.AreaUnits));
                break;

            case BudgetSegregation.frmBudgetSegResults.RawRepresents.RawClassAreaOfInterest:
                totalErosionArea = activeStats.ErosionRaw.GetArea(ca).As(options.AreaUnits);
                break;
            }
            grdData.Rows[1].Cells[colTot].Value = SafePercent(classErosionArea, totalErosionArea) / 100f;

            // Deposition
            double classDepositionArea = activeStats.DepositionThr.GetArea(ca).As(options.AreaUnits);
            double totalDepositionArea = classDepositionArea;

            switch (raw)
            {
            case BudgetSegregation.frmBudgetSegResults.RawRepresents.RawDoDAreaOfInterest:
                totalDepositionArea = allStats.Sum(x => x.DepositionRaw.GetArea(ca).As(options.AreaUnits));
                break;

            case BudgetSegregation.frmBudgetSegResults.RawRepresents.ThrDoDAreaDetectableChange:
                totalDepositionArea = allStats.Sum(x => x.DepositionThr.GetArea(ca).As(options.AreaUnits));
                break;

            case BudgetSegregation.frmBudgetSegResults.RawRepresents.RawClassAreaOfInterest:
                totalDepositionArea = activeStats.DepositionRaw.GetArea(ca).As(options.AreaUnits);
                break;
            }
            grdData.Rows[2].Cells[colTot].Value = SafePercent(classDepositionArea, totalDepositionArea) / 100f;

            // VOLUME

            // Erosion
            double classErosionVol = activeStats.ErosionThr.GetVolume(ca, activeStats.StatsUnits).As(options.VolumeUnits);
            double totalErosionVol = classErosionVol;

            switch (raw)
            {
            case BudgetSegregation.frmBudgetSegResults.RawRepresents.RawDoDAreaOfInterest:
                totalErosionVol = allStats.Sum(x => x.ErosionRaw.GetVolume(ca, activeStats.StatsUnits).As(options.VolumeUnits));
                break;

            case BudgetSegregation.frmBudgetSegResults.RawRepresents.ThrDoDAreaDetectableChange:
                totalErosionVol = allStats.Sum(x => x.ErosionThr.GetVolume(ca, activeStats.StatsUnits).As(options.VolumeUnits));
                break;

            case BudgetSegregation.frmBudgetSegResults.RawRepresents.RawClassAreaOfInterest:
                totalErosionVol = activeStats.ErosionRaw.GetVolume(ca, activeStats.StatsUnits).As(options.VolumeUnits);
                break;
            }
            grdData.Rows[7].Cells[colTot].Value = SafePercent(classErosionVol, totalErosionVol) / 100f;

            // Deposition
            double classDepositionVol = activeStats.DepositionThr.GetVolume(ca, activeStats.StatsUnits).As(options.VolumeUnits);
            double totalDepositionVol = classDepositionVol;

            switch (raw)
            {
            case BudgetSegregation.frmBudgetSegResults.RawRepresents.RawDoDAreaOfInterest:
                totalDepositionVol = allStats.Sum(x => x.DepositionRaw.GetVolume(ca, activeStats.StatsUnits).As(options.VolumeUnits));
                break;

            case BudgetSegregation.frmBudgetSegResults.RawRepresents.ThrDoDAreaDetectableChange:
                totalDepositionVol = allStats.Sum(x => x.DepositionThr.GetVolume(ca, activeStats.StatsUnits).As(options.VolumeUnits));
                break;

            case BudgetSegregation.frmBudgetSegResults.RawRepresents.RawClassAreaOfInterest:
                totalDepositionVol = activeStats.DepositionRaw.GetVolume(ca, activeStats.StatsUnits).As(options.VolumeUnits);
                break;
            }
            grdData.Rows[8].Cells[colTot].Value = SafePercent(classDepositionVol, totalDepositionVol) / 100f;

            // Vol of Difference
            double classVolDiff = activeStats.VolumeOfDifference_Thresholded.As(options.VolumeUnits);
            double totalVolDiff = classVolDiff;

            switch (raw)
            {
            case BudgetSegregation.frmBudgetSegResults.RawRepresents.RawDoDAreaOfInterest:
                totalVolDiff = allStats.Sum(x => x.VolumeOfDifference_Raw.As(options.VolumeUnits));
                break;

            case BudgetSegregation.frmBudgetSegResults.RawRepresents.ThrDoDAreaDetectableChange:
                totalVolDiff = allStats.Sum(x => x.VolumeOfDifference_Thresholded.As(options.VolumeUnits));
                break;

            case BudgetSegregation.frmBudgetSegResults.RawRepresents.RawClassAreaOfInterest:
                totalVolDiff = activeStats.VolumeOfDifference_Raw.As(options.VolumeUnits);
                break;
            }
            grdData.Rows[9].Cells[colTot].Value = SafePercent(classVolDiff, totalVolDiff) / 100f;

            // Net Vol of Difference
            double classNetVolDiff = activeStats.NetVolumeOfDifference_Thresholded.As(options.VolumeUnits);
            double totalNetVolDiff = classNetVolDiff;

            switch (raw)
            {
            case BudgetSegregation.frmBudgetSegResults.RawRepresents.RawDoDAreaOfInterest:
                totalNetVolDiff = allStats.Sum(x => x.NetVolumeOfDifference_Raw.As(options.VolumeUnits));
                break;

            case BudgetSegregation.frmBudgetSegResults.RawRepresents.ThrDoDAreaDetectableChange:
                totalNetVolDiff = allStats.Sum(x => x.NetVolumeOfDifference_Thresholded.As(options.VolumeUnits));
                break;

            case BudgetSegregation.frmBudgetSegResults.RawRepresents.RawClassAreaOfInterest:
                totalNetVolDiff = activeStats.NetVolumeOfDifference_Raw.As(options.VolumeUnits);
                break;
            }
            grdData.Rows[10].Cells[colTot].Value = SafePercent(classNetVolDiff, totalNetVolDiff) / 100f;
        }
Exemplo n.º 3
0
        public void RefreshDisplay(GCDConsoleLib.GCD.DoDStats dodStats, DoDSummaryDisplayOptions options)
        {
            // Hide the % total column in single DoD View
            grdData.Columns[colTot].Visible = false;
            grdData.Rows.Clear();
            DataGridViewRow aRow = null;

            // Build the string formatting based on the precision in the pop-up properties form
            string sFormat = GetFormatString(options);

            UnitsNet.Area             ca    = ProjectManager.Project.CellArea;
            UnitsNet.Units.LengthUnit vunit = ProjectManager.Project.Units.VertUnit;

            // Now we know the desired format precision we can assign it to all the numeric columns
            for (int i = 1; i < grdData.Columns.Count; i++)
            {
                grdData.Columns[i].DefaultCellStyle.Format = sFormat;

                if (grdData.Columns[i] == colErrorPC || grdData.Columns[i] == colPCTotal)
                {
                    grdData.Columns[i].DefaultCellStyle.Format += "%";
                }
                else if (grdData.Columns[i] == colError)
                {
                    grdData.Columns[i].DefaultCellStyle.Format = "±" + sFormat;
                }
            }

            ////////////////////////////////////////////////////////////////////////////////////////////////////
            // Show/hide columns based on the properties pop-up
            colRawDoD.Visible      = options.m_bColsRaw;
            colThresholded.Visible = options.m_bColsThresholded;
            colError.Visible       = options.m_bColsPMError;
            colErrorPC.Visible     = options.m_bColsPCError;

            ////////////////////////////////////////////////////////////////////////////////////////////////////
            // Area of erosion header

            if (options.m_eRowGroups == DoDSummaryDisplayOptions.RowGroups.ShowAll || (options.m_eRowGroups == DoDSummaryDisplayOptions.RowGroups.SpecificGroups && options.m_bRowsAreal))
            {
                aRow = grdData.Rows[grdData.Rows.Add()];
                aRow.Cells[colAtt].Value      = "AREAL";
                aRow.Cells[colAtt].Style.Font = new System.Drawing.Font(grdData.Font, System.Drawing.FontStyle.Bold);

                // Area of erosion
                aRow = grdData.Rows[grdData.Rows.Add()];
                aRow.Cells[colAtt].Value           = "Total Area of Surface Lowering (" + UnitsNet.Area.GetAbbreviation(options.AreaUnits) + ")";
                aRow.Cells[colAtt].ToolTipText     = "The amount of area experiencing a lowering of surface elevations";
                aRow.Cells[colRaw].Value           = dodStats.ErosionRaw.GetArea(ca).As(options.AreaUnits);
                aRow.Cells[colThr].Value           = dodStats.ErosionThr.GetArea(ca).As(options.AreaUnits);
                aRow.Cells[colErr].Style.BackColor = System.Drawing.Color.LightGray;
                aRow.Cells[colEPC].Style.BackColor = System.Drawing.Color.LightGray;

                // Area of deposition
                aRow = grdData.Rows[grdData.Rows.Add()];
                aRow.Cells[colAtt].Value           = "Total Area of Surface Raising (" + UnitsNet.Area.GetAbbreviation(options.AreaUnits) + ")";
                aRow.Cells[colAtt].ToolTipText     = "The amount of area experiencing an increase of surface elevations";
                aRow.Cells[colRaw].Value           = dodStats.DepositionRaw.GetArea(ca).As(options.AreaUnits);
                aRow.Cells[colThr].Value           = dodStats.DepositionThr.GetArea(ca).As(options.AreaUnits);
                aRow.Cells[colErr].Style.BackColor = System.Drawing.Color.LightGray;
                aRow.Cells[colEPC].Style.BackColor = System.Drawing.Color.LightGray;

                // Area of detectable change
                aRow = grdData.Rows[grdData.Rows.Add()];
                aRow.Cells[colAtt].Value           = "Total Area of Detectable Change (" + UnitsNet.Area.GetAbbreviation(options.AreaUnits) + ")";
                aRow.Cells[colAtt].ToolTipText     = "The sum of areas experiencing detectable lowering and raising";
                aRow.Cells[colRaw].Value           = "NA";
                aRow.Cells[colThr].Value           = dodStats.AreaDetectableChange_Thresholded.As(options.AreaUnits);
                aRow.Cells[colErr].Style.BackColor = System.Drawing.Color.LightGray;
                aRow.Cells[colEPC].Style.BackColor = System.Drawing.Color.LightGray;

                // Area of interest
                aRow = grdData.Rows[grdData.Rows.Add()];
                aRow.Cells[colAtt].Value           = "Total Area of Interest (" + UnitsNet.Area.GetAbbreviation(options.AreaUnits) + ")";
                aRow.Cells[colAtt].ToolTipText     = "The total amount of area under analysis (including detectable and undetectable)";
                aRow.Cells[colRaw].Value           = dodStats.AreaOfInterest_Raw.As(options.AreaUnits);
                aRow.Cells[colThr].Value           = "NA";
                aRow.Cells[colThr].Style.BackColor = System.Drawing.Color.LightGray;
                aRow.Cells[colErr].Style.BackColor = System.Drawing.Color.LightGray;
                aRow.Cells[colEPC].Style.BackColor = System.Drawing.Color.LightGray;

                // Percent of area of interest with detectable change
                aRow = grdData.Rows[grdData.Rows.Add()];
                aRow.Cells[colAtt].Value           = "Percent of Area of Interest with Detectable Change";
                aRow.Cells[colAtt].ToolTipText     = "The percent of the total area of interest with detectable changes (i.e. either exceeding the minimum level of detection or with a proability greater then the confidence interval chosen by user)";
                aRow.Cells[colRaw].Value           = "NA";
                aRow.Cells[colRaw].Style.BackColor = System.Drawing.Color.LightGray;
                aRow.Cells[colThr].Value           = dodStats.AreaPercentAreaInterestWithDetectableChange.ToString(sFormat) + "%";
                aRow.Cells[colErr].Style.BackColor = System.Drawing.Color.LightGray;
                aRow.Cells[colEPC].Style.BackColor = System.Drawing.Color.LightGray;
            }

            ////////////////////////////////////////////////////////////////////////////////////////////////////
            // VOLUMETRIC

            if (options.m_eRowGroups == DoDSummaryDisplayOptions.RowGroups.ShowAll || options.m_eRowGroups == DoDSummaryDisplayOptions.RowGroups.Normalized || (options.m_eRowGroups == DoDSummaryDisplayOptions.RowGroups.SpecificGroups && options.m_bRowsVolumetric))
            {
                // Volume of erosion header
                aRow = grdData.Rows[grdData.Rows.Add()];
                aRow.Cells[colAtt].Value      = "VOLUMETRIC";
                aRow.Cells[colAtt].Style.Font = new System.Drawing.Font(grdData.Font, System.Drawing.FontStyle.Bold);
            }

            if (options.m_eRowGroups == DoDSummaryDisplayOptions.RowGroups.ShowAll || (options.m_eRowGroups == DoDSummaryDisplayOptions.RowGroups.SpecificGroups && options.m_bRowsVolumetric))
            {
                // Volume of erosion
                aRow = grdData.Rows[grdData.Rows.Add()];
                aRow.Cells[colAtt].Value       = "Total Volume of Surface Lowering (" + UnitsNet.Volume.GetAbbreviation(options.VolumeUnits) + ")";
                aRow.Cells[colAtt].ToolTipText = "On a cell-by-cell basis, the DoD surface lowering depth (e.g. erosion, cut or deflation) multiplied by cell area and summed";
                aRow.Cells[colRaw].Value       = dodStats.ErosionRaw.GetVolume(ca, dodStats.StatsUnits).As(options.VolumeUnits);
                aRow.Cells[colThr].Value       = dodStats.ErosionThr.GetVolume(ca, dodStats.StatsUnits).As(options.VolumeUnits);
                aRow.Cells[colErr].Value       = dodStats.ErosionErr.GetVolume(ca, dodStats.StatsUnits).As(options.VolumeUnits);
                aRow.Cells[colEPC].Value       = dodStats.VolumeOfErosion_Percent / 100m;

                // Volume of deposition
                aRow = grdData.Rows[grdData.Rows.Add()];
                aRow.Cells[colAtt].Value       = "Total Volume of Surface Raising (" + UnitsNet.Volume.GetAbbreviation(options.VolumeUnits) + ")";
                aRow.Cells[colAtt].ToolTipText = "On a cell-by-cell basis, the DoD surface raising (e.g. deposition, fill or inflation) depth multiplied by cell area and summed";
                aRow.Cells[colRaw].Value       = dodStats.DepositionRaw.GetVolume(ca, dodStats.StatsUnits).As(options.VolumeUnits);
                aRow.Cells[colThr].Value       = dodStats.DepositionThr.GetVolume(ca, dodStats.StatsUnits).As(options.VolumeUnits);
                aRow.Cells[colErr].Value       = dodStats.DepositionErr.GetVolume(ca, dodStats.StatsUnits).As(options.VolumeUnits);
                aRow.Cells[colEPC].Value       = dodStats.VolumeOfDeposition_Percent / 100m;

                // Total volume of difference
                aRow = grdData.Rows[grdData.Rows.Add()];
                aRow.Cells[colAtt].Value       = "Total Volume of Difference (" + UnitsNet.Volume.GetAbbreviation(options.VolumeUnits) + ")";
                aRow.Cells[colAtt].ToolTipText = "The sum of lowering and raising volumes (a measure of total turnover)";
                aRow.Cells[colRaw].Value       = dodStats.VolumeOfDifference_Raw.As(options.VolumeUnits);
                aRow.Cells[colThr].Value       = dodStats.VolumeOfDifference_Thresholded.As(options.VolumeUnits);
                aRow.Cells[colErr].Value       = dodStats.VolumeOfDifference_Error.As(options.VolumeUnits);
                aRow.Cells[colEPC].Value       = dodStats.VolumeOfDifference_Percent / 100m;
            }


            if (options.m_eRowGroups == DoDSummaryDisplayOptions.RowGroups.ShowAll || options.m_eRowGroups == DoDSummaryDisplayOptions.RowGroups.Normalized || (options.m_eRowGroups == DoDSummaryDisplayOptions.RowGroups.SpecificGroups && options.m_bRowsVolumetric))
            {
                //Total NET volume difference
                aRow = grdData.Rows[grdData.Rows.Add()];
                aRow.Cells[colAtt].Value       = "Total Net Volume Difference (" + UnitsNet.Volume.GetAbbreviation(options.VolumeUnits) + ")";
                aRow.Cells[colAtt].ToolTipText = "The net difference of erosion and depostion volumes (i.e. deposition minus erosion)";
                aRow.Cells[colRaw].Value       = dodStats.NetVolumeOfDifference_Raw.As(options.VolumeUnits);
                aRow.Cells[colThr].Value       = dodStats.NetVolumeOfDifference_Thresholded.As(options.VolumeUnits);
                aRow.Cells[colErr].Value       = dodStats.NetVolumeOfDifference_Error.As(options.VolumeUnits);
                aRow.Cells[colEPC].Value       = dodStats.NetVolumeOfDifference_Percent / 100m;
            }

            ////////////////////////////////////////////////////////////////////////////////////////////////////
            // VERTICAL AVERAGES

            if (options.m_eRowGroups == DoDSummaryDisplayOptions.RowGroups.ShowAll || options.m_eRowGroups == DoDSummaryDisplayOptions.RowGroups.Normalized || (options.m_eRowGroups == DoDSummaryDisplayOptions.RowGroups.SpecificGroups && options.m_bRowsVerticalAverages))
            {
                // Vertical Averages header
                aRow = grdData.Rows[grdData.Rows.Add()];
                aRow.Cells[colAtt].Value      = "VERTICAL AVERAGES";
                aRow.Cells[colAtt].Style.Font = new System.Drawing.Font(grdData.Font, System.Drawing.FontStyle.Bold);
            }

            if (options.m_eRowGroups == DoDSummaryDisplayOptions.RowGroups.ShowAll || options.m_eRowGroups == DoDSummaryDisplayOptions.RowGroups.SpecificGroups && options.m_bRowsVerticalAverages)
            {
                // Average Depth of Erosion
                aRow = grdData.Rows[grdData.Rows.Add()];
                aRow.Cells[colAtt].Value       = "Average Depth of Surface Lowering (" + UnitsNet.Length.GetAbbreviation(options.LinearUnits) + ")";
                aRow.Cells[colAtt].ToolTipText = "The average depth of lowering (lowering volume divided by lowering area)";
                aRow.Cells[colRaw].Value       = dodStats.AverageDepthErosion_Raw.As(options.LinearUnits);
                aRow.Cells[colThr].Value       = dodStats.AverageDepthErosion_Thresholded.As(options.LinearUnits);
                aRow.Cells[colErr].Value       = dodStats.AverageDepthErosion_Error.As(options.LinearUnits);
                aRow.Cells[colEPC].Value       = dodStats.AverageDepthErosion_Percent / 100m;

                // Average Depth of Deposition
                aRow = grdData.Rows[grdData.Rows.Add()];
                aRow.Cells[colAtt].Value       = "Average Depth of Surface Raising (" + UnitsNet.Length.GetAbbreviation(options.LinearUnits) + ")";
                aRow.Cells[colAtt].ToolTipText = "The average depth of raising (raising volume divided by raising area)";
                aRow.Cells[colRaw].Value       = dodStats.AverageDepthDeposition_Raw.As(options.LinearUnits);
                aRow.Cells[colThr].Value       = dodStats.AverageDepthDeposition_Thresholded.As(options.LinearUnits);
                aRow.Cells[colErr].Value       = dodStats.AverageDepthDeposition_Error.As(options.LinearUnits);
                aRow.Cells[colEPC].Value       = dodStats.AverageDepthDeposition_Percent / 100m;

                // Average Total Thickness of Difference for AOI
                aRow = grdData.Rows[grdData.Rows.Add()];
                aRow.Cells[colAtt].Value       = "Average Total Thickness of Difference (" + UnitsNet.Length.GetAbbreviation(options.LinearUnits) + ") for Area of Interest";
                aRow.Cells[colAtt].ToolTipText = "The total volume of difference divided by the area of interest (a measure of total turnover thickness in the analysis area)";
                aRow.Cells[colRaw].Value       = dodStats.AverageThicknessOfDifferenceAOI_Raw.As(options.LinearUnits);
                aRow.Cells[colThr].Value       = dodStats.AverageThicknessOfDifferenceAOI_Thresholded.As(options.LinearUnits);
                aRow.Cells[colErr].Value       = dodStats.AverageThicknessOfDifferenceAOI_Error.As(options.LinearUnits);
                aRow.Cells[colEPC].Value       = dodStats.AverageThicknessOfDifferenceAOI_Percent / 100m;
            }

            if (options.m_eRowGroups == DoDSummaryDisplayOptions.RowGroups.ShowAll || options.m_eRowGroups == DoDSummaryDisplayOptions.RowGroups.Normalized || (options.m_eRowGroups == DoDSummaryDisplayOptions.RowGroups.SpecificGroups && options.m_bRowsVerticalAverages))
            {
                // Average **NET** Thickness of Difference AOI
                aRow = grdData.Rows[grdData.Rows.Add()];
                aRow.Cells[colAtt].Value       = "Average Net Thickness of Difference (" + UnitsNet.Length.GetAbbreviation(options.LinearUnits) + ") for Area of Interest";
                aRow.Cells[colAtt].ToolTipText = "The total net volume of difference divided by the area of interest (a measure of resulting net change within the analysis area)";
                aRow.Cells[colRaw].Value       = dodStats.AverageNetThicknessofDifferenceAOI_Raw.As(options.LinearUnits);
                aRow.Cells[colThr].Value       = dodStats.AverageNetThicknessOfDifferenceAOI_Thresholded.As(options.LinearUnits);
                aRow.Cells[colErr].Value       = dodStats.AverageNetThicknessOfDifferenceAOI_Error.As(options.LinearUnits);
                aRow.Cells[colEPC].Value       = dodStats.AverageNetThicknessOfDifferenceAOI_Percent / 100m;
            }

            if (options.m_eRowGroups == DoDSummaryDisplayOptions.RowGroups.ShowAll || options.m_eRowGroups == DoDSummaryDisplayOptions.RowGroups.SpecificGroups && options.m_bRowsVerticalAverages)
            {
                // Average Thickness of Difference ADC
                aRow = grdData.Rows[grdData.Rows.Add()];
                aRow.Cells[colAtt].Value           = "Average Total Thickness of Difference (" + UnitsNet.Length.GetAbbreviation(options.LinearUnits) + ") for Area with Detectable Change";
                aRow.Cells[colAtt].ToolTipText     = "The total volume of difference divided by the total area of detectable change (a measure of total turnover thickness where there was detectable change)";
                aRow.Cells[colRaw].Value           = "NA";
                aRow.Cells[colRaw].Style.BackColor = System.Drawing.Color.LightGray;
                aRow.Cells[colThr].Value           = dodStats.AverageThicknessOfDifferenceADC_Thresholded.As(options.LinearUnits);
                aRow.Cells[colErr].Value           = dodStats.AverageThicknessOfDifferenceADC_Error.As(options.LinearUnits);
                aRow.Cells[colEPC].Value           = dodStats.AverageThicknessOfDifferenceADC_Percent / 100m;
            }

            if (options.m_eRowGroups == DoDSummaryDisplayOptions.RowGroups.ShowAll || options.m_eRowGroups == DoDSummaryDisplayOptions.RowGroups.Normalized || (options.m_eRowGroups == DoDSummaryDisplayOptions.RowGroups.SpecificGroups && options.m_bRowsVerticalAverages))
            {
                // Average **NET** Thickness of Difference ADC
                aRow = grdData.Rows[grdData.Rows.Add()];
                aRow.Cells[colAtt].Value           = "Average Net Thickness of Difference (" + UnitsNet.Length.GetAbbreviation(options.LinearUnits) + ") for Area with Detectable Change";
                aRow.Cells[colAtt].ToolTipText     = "The total net volume of difference divided by the total area of detectable change (a measure of resulting net change where the was detectable change)";
                aRow.Cells[colRaw].Value           = "NA";
                aRow.Cells[colRaw].Style.BackColor = System.Drawing.Color.LightGray;
                aRow.Cells[colThr].Value           = dodStats.AverageNetThicknessOfDifferenceADC_Thresholded.As(options.LinearUnits);
                aRow.Cells[colErr].Value           = dodStats.AverageNetThicknessOfDifferenceADC_Error.As(options.LinearUnits);
                aRow.Cells[colEPC].Value           = dodStats.AverageNetThicknessOfDifferenceADC_Percent / 100m;
            }

            if (options.m_eRowGroups == DoDSummaryDisplayOptions.RowGroups.ShowAll || (options.m_eRowGroups == DoDSummaryDisplayOptions.RowGroups.SpecificGroups && options.m_bRowsPercentages))
            {
                ///'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
                // Percentages by Volume
                aRow = grdData.Rows[grdData.Rows.Add()];
                aRow.Cells[colAtt].Value      = "PERCENTAGES (BY VOLUME)";
                aRow.Cells[colAtt].Style.Font = new System.Drawing.Font(grdData.Font, System.Drawing.FontStyle.Bold);

                // Percent Erosion
                aRow = grdData.Rows[grdData.Rows.Add()];
                aRow.Cells[colAtt].Value           = "Percent Elevation Lowering";
                aRow.Cells[colAtt].ToolTipText     = "Percent of Total Volume of Difference that is surface lowering";
                aRow.Cells[colRaw].Value           = dodStats.PercentErosion_Raw;
                aRow.Cells[colThr].Value           = dodStats.PercentErosion_Thresholded;
                aRow.Cells[colErr].Style.BackColor = System.Drawing.Color.LightGray;
                aRow.Cells[colEPC].Style.BackColor = System.Drawing.Color.LightGray;
                aRow.Cells[colTot].Style.BackColor = System.Drawing.Color.LightGray;

                // Percent Deposition
                aRow = grdData.Rows[grdData.Rows.Add()];
                aRow.Cells[colAtt].Value           = "Percent Elevation Raising";
                aRow.Cells[colAtt].ToolTipText     = "Percent of Total Volume of Difference that is surface raising";
                aRow.Cells[colRaw].Value           = dodStats.PercentDeposition_Raw;
                aRow.Cells[colThr].Value           = dodStats.PercentDeposition_Thresholded;
                aRow.Cells[colErr].Style.BackColor = System.Drawing.Color.LightGray;
                aRow.Cells[colEPC].Style.BackColor = System.Drawing.Color.LightGray;
                aRow.Cells[colTot].Style.BackColor = System.Drawing.Color.LightGray;

                // Percent Imbalance
                aRow = grdData.Rows[grdData.Rows.Add()];
                aRow.Cells[colAtt].Value           = "Percent Imbalance (departure from equilibium)";
                aRow.Cells[colAtt].ToolTipText     = "The percent depature from a 50%-50% equilibirum lowering/raising (i.e. erosion/deposition) balance (a normalized indication of the magnitude of the net difference)";
                aRow.Cells[colRaw].Value           = dodStats.PercentImbalance_Raw;
                aRow.Cells[colThr].Value           = dodStats.PercentImbalance_Thresholded;
                aRow.Cells[colErr].Style.BackColor = System.Drawing.Color.LightGray;
                aRow.Cells[colEPC].Style.BackColor = System.Drawing.Color.LightGray;
                aRow.Cells[colTot].Style.BackColor = System.Drawing.Color.LightGray;

                // Net to Total Volume Ratio
                aRow = grdData.Rows[grdData.Rows.Add()];
                aRow.Cells[colAtt].Value           = "Net to Total Volume Ratio";
                aRow.Cells[colAtt].ToolTipText     = "The ratio of net volumetric change divided by total volume of change (a measure of how much the net trend explains of the total turnover)";
                aRow.Cells[colRaw].Value           = dodStats.NetToTotalVolumeRatio_Raw;
                aRow.Cells[colThr].Value           = dodStats.NetToTotalVolumeRatio_Thresholded;
                aRow.Cells[colErr].Style.BackColor = System.Drawing.Color.LightGray;
                aRow.Cells[colEPC].Style.BackColor = System.Drawing.Color.LightGray;
                aRow.Cells[colTot].Style.BackColor = System.Drawing.Color.LightGray;
            }

            for (int rowIndex = 1; rowIndex < grdData.Rows.Count; rowIndex++)
            {
                for (int colIndex = 1; colIndex < grdData.Columns.Count; colIndex++)
                {
                    //if (rowIndex == 0)
                    //{
                    //    grdData.Rows[rowIndex].Cells[colIndex].Style.Font = new System.Drawing.Font(grdData.Font, System.Drawing.FontStyle.Bold);
                    //    grdData.Rows[rowIndex].Cells[colIndex].Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
                    //}
                    //else
                    //{
                    if (grdData.Rows[rowIndex].Cells[colIndex].Value != null)
                    {
                        // Assign the copy to clipboard context menu to non-null cells
                        grdData.Rows[rowIndex].Cells[colIndex].ContextMenuStrip = cmsCopy;
                    }
                    //}
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Generate an inter-comparison summary Excel XML spreadsheet
        /// </summary>
        /// <param name="dodStats">Dictionary of DoD statistics.</param>
        /// <param name="output">File path of the output inter-comparison spreadsheet to be generated</param>
        /// <remarks>
        /// This method is used from two places for subtly different purposes:
        ///
        /// 1. Every budget segregation will generate a single inter-comparison spreadsheet summarizing the DoD statistics for all classes
        /// 2. The user can manually generate an inter-comparison by selecting two or more DoDs in the user interface.
        ///
        /// In both cases the code that calls this method is responsible for building a dictionary of DoD statistics. In the first
        /// case the dictionary key will be the budget segregation class ("pool", "riffle" etc). In the second case the key will be
        /// the DoD name ("2006 - 2006 Min LoD 0.2m" etc).
        ///
        /// The processing in this class is identical for both cases.</remarks>
        public static void Generate(Dictionary <string, GCDConsoleLib.GCD.DoDStats> dodStats, FileInfo output)
        {
            int DoDCount = 0;

            //get template and throw error if it doesnt exists
            FileInfo template = new FileInfo(Path.Combine(Project.ProjectManager.ExcelTemplatesFolder.FullName, "InterComparison.xml"));

            if (!template.Exists)
            {
                throw new Exception("The GCD intercomparison spreadsheet template cannot be found at " + template.FullName);
            }

            //setup ExcelXMLDocument which does the heavy lifting of updating the XML
            ExcelXMLDocument xmlExcelDoc = new ExcelXMLDocument(template.FullName);

            foreach (KeyValuePair <string, GCDConsoleLib.GCD.DoDStats> kvp in dodStats)
            {
                //get name and stats from input
                string DoDName = kvp.Key;
                GCDConsoleLib.GCD.DoDStats dodStat = kvp.Value;

                //turn these into a dictionary of named values to replace in XML
                Dictionary <string, string> dicStatValues = GetStatValues(dodStat);
                dicStatValues.Add("TemplateRowName", DoDName); //Add name so the Named Range for the name (e.g. ArealDoDName) is updated

                DoDCount += 1;

                //update or clone all template rows. All references are maintained by the ExcelXMLDocument
                //e.g. relative references, sum formulas and named ranges
                if (DoDCount > 1)
                {
                    xmlExcelDoc.CloneRow("ArealDoDName", DoDCount - 1, dicStatValues);
                    xmlExcelDoc.CloneRow("VolumeDoDName", DoDCount - 1, dicStatValues);
                    xmlExcelDoc.CloneRow("VerticalDoDName", DoDCount - 1, dicStatValues);
                    xmlExcelDoc.CloneRow("PercentagesDoDName", DoDCount - 1, dicStatValues);
                }
                else
                {
                    xmlExcelDoc.UpdateRow("ArealDoDName", dicStatValues);
                    xmlExcelDoc.UpdateRow("VolumeDoDName", dicStatValues);
                    xmlExcelDoc.UpdateRow("VerticalDoDName", dicStatValues);
                    xmlExcelDoc.UpdateRow("PercentagesDoDName", dicStatValues);
                }
            }

            //cells should be formatted with grey, single weight top and bottom border
            CellStyle oCellStyle = new CellStyle();

            oCellStyle.TopBorder.Weight    = 1;
            oCellStyle.TopBorder.Color     = "#E7E6E6";
            oCellStyle.BottomBorder.Weight = 1;
            oCellStyle.BottomBorder.Color  = "#E7E6E6";

            //loop through all cells and format
            for (int i = 0; i < dodStats.Count; i++)
            {
                xmlExcelDoc.FormatRow("ArealDoDName", i, oCellStyle);
                xmlExcelDoc.FormatRow("VolumeDoDName", i, oCellStyle);
                xmlExcelDoc.FormatRow("VerticalDoDName", i, oCellStyle);
                xmlExcelDoc.FormatRow("PercentagesDoDName", i, oCellStyle);
            }

            //save output
            xmlExcelDoc.Save(output.FullName);
        }