Esempio n. 1
0
        private static void AddChartStateClassVariables(SyncroSimLayoutItemCollection items, Project project)
        {
            string          AmountLabel = null;
            string          UnitsLabel  = null;
            TerminologyUnit TermUnit    = 0;
            DataSheet       dsterm      = project.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME);

            TerminologyUtilities.GetAmountLabelTerminology(dsterm, ref AmountLabel, ref TermUnit);
            UnitsLabel = TerminologyUtilities.TerminologyUnitToString(TermUnit);

            string disp = string.Format(CultureInfo.InvariantCulture, "{0} ({1})", AmountLabel, UnitsLabel);
            SyncroSimLayoutItem Normal     = new SyncroSimLayoutItem(Strings.STATE_CLASS_AMOUNT_VARIABLE_NAME, disp, false);
            SyncroSimLayoutItem Proportion = new SyncroSimLayoutItem(Strings.STATE_CLASS_PROPORTION_VARIABLE_NAME, "Proportion", false);

            Normal.Properties.Add(new MetaDataProperty("dataSheet", "stsim_OutputStratumState"));
            Proportion.Properties.Add(new MetaDataProperty("dataSheet", "stsim_OutputStratumState"));

            Normal.Properties.Add(new MetaDataProperty("column", "Amount"));
            Proportion.Properties.Add(new MetaDataProperty("column", "Amount"));

            Normal.Properties.Add(new MetaDataProperty("defaultValue", "0.0"));
            Proportion.Properties.Add(new MetaDataProperty("defaultValue", "0.0"));

            items.Add(Normal);
            items.Add(Proportion);
        }
        protected override void OnDataSheetChanged(DataSheetMonitorEventArgs e)
        {
            base.OnDataSheetChanged(e);

            string          AmountLabel = null;
            TerminologyUnit AmountUnits = TerminologyUnit.None;

            TerminologyUtilities.GetAmountLabelTerminology(e.DataSheet, ref AmountLabel, ref AmountUnits);

            this.Columns[Strings.DATASHEET_TRANSITION_SIZE_DISTRIBUTION_MAXIMUM_AREA_COLUMN_NAME].DisplayName =
                (string.Format(CultureInfo.InvariantCulture, "Maximum {0} ({1})",
                               AmountLabel, TerminologyUtilities.TerminologyUnitToString(AmountUnits)));
        }
        protected override void OnDataSheetChanged(DataSheetMonitorEventArgs e)
        {
            base.OnDataSheetChanged(e);

            string          amountlabel = null;
            TerminologyUnit units       = 0;
            string          unitsLbl    = null;

            TerminologyUtilities.GetAmountLabelTerminology(e.DataSheet, ref amountlabel, ref units);
            unitsLbl = TerminologyUtilities.TerminologyUnitToString(units).ToLower(CultureInfo.InvariantCulture);

            this.LabelTotalAmount.Text   = string.Format(CultureInfo.InvariantCulture, "Total ({0}):", unitsLbl);
            this.LabelCellSize.Text      = string.Format(CultureInfo.InvariantCulture, "Cell size ({0}):", unitsLbl);
            this.TextBoxNumCells.Enabled = (this.ShouldEnableView() && (!this.CheckBoxCalcFromDist.Checked));
        }
Esempio n. 4
0
        private ExportColumnCollection CreateColumnCollection()
        {
            ExportColumnCollection c = new ExportColumnCollection();

            string          AmountLabel           = null;
            string          UnitsLabel            = null;
            TerminologyUnit TermUnit              = 0;
            string          PrimaryStratumLabel   = null;
            string          SecondaryStratumLabel = null;
            string          TertiaryStratumLabel  = null;
            DataSheet       dsterm        = this.Project.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME);
            string          TimestepLabel = TerminologyUtilities.GetTimestepUnits(this.Project);

            TerminologyUtilities.GetAmountLabelTerminology(dsterm, ref AmountLabel, ref TermUnit);
            TerminologyUtilities.GetStratumLabelTerminology(dsterm, ref PrimaryStratumLabel, ref SecondaryStratumLabel, ref TertiaryStratumLabel);
            UnitsLabel = TerminologyUtilities.TerminologyUnitToString(TermUnit);

            string AmountTitle = string.Format(CultureInfo.InvariantCulture, "{0} ({1})", AmountLabel, UnitsLabel);

            c.Add(new ExportColumn("ScenarioID", "Scenario ID"));
            c.Add(new ExportColumn("ScenarioName", "Scenario"));
            c.Add(new ExportColumn("Iteration", "Iteration"));
            c.Add(new ExportColumn("Timestep", TimestepLabel));
            c.Add(new ExportColumn("Stratum", PrimaryStratumLabel));
            c.Add(new ExportColumn("SecondaryStratum", SecondaryStratumLabel));
            c.Add(new ExportColumn("TertiaryStratum", TertiaryStratumLabel));
            c.Add(new ExportColumn("TransitionType", "Transition Type"));
            c.Add(new ExportColumn("StateClass", "State Class"));
            c.Add(new ExportColumn("EndStateClass", "End State Class"));
            c.Add(new ExportColumn("Amount", AmountTitle));

            c["Amount"].DecimalPlaces = 2;
            c["Amount"].Alignment     = ColumnAlignment.Right;

            return(c);
        }
Esempio n. 5
0
        protected override void OnDataSheetChanged(DataSheetMonitorEventArgs e)
        {
            base.OnDataSheetChanged(e);

            string          AmountLabel = null;
            TerminologyUnit AmountUnits = TerminologyUnit.None;

            TerminologyUtilities.GetAmountLabelTerminology(e.DataSheet, ref AmountLabel, ref AmountUnits);

            this.Columns[Strings.DATASHEET_AMOUNT_COLUMN_NAME].DisplayName                 = (string.Format(CultureInfo.InvariantCulture, "Target {0} ({1})", AmountLabel, TerminologyUtilities.TerminologyUnitToString(AmountUnits)));
            this.Columns[Strings.DATASHEET_DISTRIBUTIONTYPE_COLUMN_NAME].DisplayName       = string.Format(CultureInfo.InvariantCulture, "Target {0} Distribution", AmountLabel);
            this.Columns[Strings.DATASHEET_DISTRIBUTION_FREQUENCY_COLUMN_NAME].DisplayName = string.Format(CultureInfo.InvariantCulture, "Target {0} Sampling Frequency", AmountLabel);
            this.Columns[Strings.DATASHEET_DISTRIBUTIONSD_COLUMN_NAME].DisplayName         = string.Format(CultureInfo.InvariantCulture, "Target {0} SD", AmountLabel);
            this.Columns[Strings.DATASHEET_DISTRIBUTIONMIN_COLUMN_NAME].DisplayName        = string.Format(CultureInfo.InvariantCulture, "Target {0} Min", AmountLabel);
            this.Columns[Strings.DATASHEET_DISTRIBUTIONMAX_COLUMN_NAME].DisplayName        = string.Format(CultureInfo.InvariantCulture, "Target {0} Max", AmountLabel);
        }
        private void RefreshCalculatedValues()
        {
            DataRow drProp = this.DataFeed.GetDataSheet(Strings.DATASHEET_SPPIC_NAME).GetDataRow();

            if (drProp == null)
            {
                return;
            }

            //Num Cells
            int NumCells = DataTableUtilities.GetDataInt(drProp[Strings.DATASHEET_SPPIC_NUM_CELLS_COLUMN_NAME]);

            this.TextBoxNumCells.Text = NumCells.ToString(CultureInfo.InvariantCulture);

            //Get the units and refresh the units labels - the default Raster Cell Units is Metres^2
            string          srcSizeUnits = DataTableUtilities.GetDataStr(drProp[Strings.DATASHEET_SPPIC_CELL_SIZE_UNITS_COLUMN_NAME]);
            string          srcAreaUnits = srcSizeUnits + "^2";
            string          amountlabel  = null;
            TerminologyUnit destUnitsVal = 0;

            TerminologyUtilities.GetAmountLabelTerminology(
                this.Project.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME), ref amountlabel, ref destUnitsVal);

            string destAreaLbl = TerminologyUtilities.TerminologyUnitToString(destUnitsVal);

            srcAreaUnits = srcAreaUnits.ToLower(CultureInfo.InvariantCulture);
            amountlabel  = amountlabel.ToLower(CultureInfo.InvariantCulture);
            destAreaLbl  = destAreaLbl.ToLower(CultureInfo.InvariantCulture);

            this.LabelRasterCellArea.Text = string.Format(CultureInfo.InvariantCulture, "Cell size ({0}):", srcAreaUnits);
            this.LabelCalcCellArea.Text   = string.Format(CultureInfo.InvariantCulture, "Cell size ({0}):", destAreaLbl);
            this.LabelCalcTtlAmount.Text  = string.Format(CultureInfo.InvariantCulture, "Total {0} ({1}):", amountlabel, destAreaLbl);

            // Calculate Cell Area in raster's native units
            float  cellSize = DataTableUtilities.GetDataSingle(drProp[Strings.DATASHEET_SPPIC_CELL_SIZE_COLUMN_NAME]);
            double cellArea = Math.Pow(cellSize, 2);

            this.TextBoxCellArea.Text = cellArea.ToString("N4", CultureInfo.InvariantCulture);

            // Calc Cell Area in terminology units
            double cellAreaTU   = 0;
            bool   SizeOverride = DataTableUtilities.GetDataBool(drProp[Strings.DATASHEET_SPPIC_CELL_AREA_OVERRIDE_COLUMN_NAME]);

            if (!SizeOverride)
            {
                cellAreaTU = InitialConditionsSpatialDataSheet.CalcCellArea(cellArea, srcSizeUnits, destUnitsVal);
                this.TextBoxCellAreaCalc.Text = cellAreaTU.ToString("N4", CultureInfo.InvariantCulture);
                drProp[Strings.DATASHEET_SPPIC_CELL_AREA_COLUMN_NAME] = cellAreaTU;
                TextBoxCellAreaCalc.ReadOnly = true;
            }
            else
            {
                cellAreaTU = DataTableUtilities.GetDataDbl(drProp[Strings.DATASHEET_SPPIC_CELL_AREA_COLUMN_NAME]);
                TextBoxCellAreaCalc.ReadOnly = false;
            }

            // Now calculate total area in the specified terminology units
            var ttlArea = cellAreaTU * NumCells;

            this.TextBoxTotalArea.Text = ttlArea.ToString("N4", CultureInfo.InvariantCulture);
        }