Example #1
0
        public void Initialize(Project project, bool enableMergeDeps)
        {
            this.DataGridViewStrata.BackgroundColor  = System.Drawing.Color.White;
            this.DataGridViewStrata.PaintGridBorders = false;
            this.DataGridViewStrata.MultiSelect      = true;
            this.DataGridViewStrata.StandardTab      = true;
            this.PanelGrid.ShowBorder      = true;
            this.CheckBoxMergeDeps.Enabled = enableMergeDeps;

            DataSheet ds             = project.GetDataSheet(Strings.DATASHEET_STRATA_NAME);
            DataView  dv             = new DataView(ds.GetData(), null, ds.DisplayMember, DataViewRowState.CurrentRows);
            bool      AtLeastOneDesc = false;

            foreach (DataRowView v in dv)
            {
                string n = Convert.ToString(v[ds.DisplayMember], CultureInfo.InvariantCulture);
                string d = DataTableUtilities.GetDataStr(v[Strings.DATASHEET_DESCRIPTION_COLUMN_NAME]);

                if (!string.IsNullOrEmpty(d))
                {
                    AtLeastOneDesc = true;
                }

                this.DataGridViewStrata.Rows.Add(n, d);
            }

            this.ButtonOK.Enabled           = (this.DataGridViewStrata.Rows.Count > 0);
            this.DataGridViewStrata.Enabled = (this.DataGridViewStrata.Rows.Count > 0);

            if (!AtLeastOneDesc)
            {
                this.ColumnDescription.Visible = false;
            }
        }
Example #2
0
        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;

            if (!CheckBoxCellSizeOverride.Checked)
            {
                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);
        }
Example #3
0
        public void Initialize(Project project, string selectedStratum)
        {
            this.DataGridViewStrata.BackgroundColor          = System.Drawing.Color.White;
            this.DataGridViewStrata.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Single;
            this.DataGridViewStrata.PaintGridBorders         = false;
            this.PanelGrid.ShowBorder = true;

            DataSheet ds             = project.GetDataSheet(Strings.DATASHEET_STRATA_NAME);
            DataView  dv             = new DataView(ds.GetData(), null, ds.DisplayMember, DataViewRowState.CurrentRows);
            bool      AtLeastOneDesc = false;

            this.DataGridViewStrata.Rows.Add(Strings.DIAGRAM_ALL_STRATA_DISPLAY_NAME, null);

            foreach (DataRowView v in dv)
            {
                string n = Convert.ToString(v[ds.DisplayMember], CultureInfo.InvariantCulture);
                string d = DataTableUtilities.GetDataStr(v[Strings.DATASHEET_DESCRIPTION_COLUMN_NAME]);

                if (!string.IsNullOrEmpty(d))
                {
                    AtLeastOneDesc = true;
                }

                this.DataGridViewStrata.Rows.Add(n, d);
            }

            this.ButtonOK.Enabled           = (this.DataGridViewStrata.Rows.Count > 0);
            this.DataGridViewStrata.Enabled = (this.DataGridViewStrata.Rows.Count > 0);
            this.m_SelectedStratum          = selectedStratum;

            if (!AtLeastOneDesc)
            {
                this.ColumnDescription.Visible = false;
            }

            this.RefreshTitleBar(project);
        }
Example #4
0
        private static void AddChartGroupedAttributes(
            Dictionary <string, SyncroSimLayoutItem> groupsDict,
            DataSheet groupsDataSheet,
            DataView attrsView,
            DataSheet attrsDataSheet,
            string outputDataSheetName,
            string outputColumnName, bool skipTimestepZero)
        {
            //The density groups have already been created and added to the groups.  Howver, we want the
            //attributes themselves to appear before this group so we must insert them in reverse order.

            for (int i = attrsView.Count - 1; i >= 0; i--)
            {
                DataRowView drv = attrsView[i];

                if (drv.Row[Strings.DATASHEET_ATTRIBUTE_GROUP_ID_COLUMN_NAME] != DBNull.Value)
                {
                    int    GroupId   = Convert.ToInt32(drv.Row[Strings.DATASHEET_ATTRIBUTE_GROUP_ID_COLUMN_NAME], CultureInfo.InvariantCulture);
                    string GroupName = groupsDataSheet.ValidationTable.GetDisplayName(GroupId);
                    int    AttrId    = Convert.ToInt32(drv.Row[attrsDataSheet.ValueMember], CultureInfo.InvariantCulture);
                    SyncroSimLayoutItem MainGroup    = groupsDict[GroupName];
                    SyncroSimLayoutItem DensityGroup = groupsDict[DENSITY_GROUP_NAME + GroupName];
                    string Units = DataTableUtilities.GetDataStr(drv.Row, Strings.DATASHEET_STATE_ATTRIBUTE_TYPE_UNITS_COLUMN_NAME);

                    //Normal Attribute
                    //----------------

                    string AttrNameNormal    = string.Format(CultureInfo.InvariantCulture, "stsim_AttrNormal-{0}", AttrId);
                    string DisplayNameNormal = Convert.ToString(drv.Row[attrsDataSheet.ValidationTable.DisplayMember], CultureInfo.InvariantCulture);

                    if (Units != null)
                    {
                        DisplayNameNormal = string.Format(CultureInfo.InvariantCulture, "{0} ({1})", DisplayNameNormal, Units);
                    }

                    SyncroSimLayoutItem ItemNormal = new SyncroSimLayoutItem(AttrNameNormal, DisplayNameNormal, false);

                    ItemNormal.Properties.Add(new MetaDataProperty("dataSheet", outputDataSheetName));
                    ItemNormal.Properties.Add(new MetaDataProperty("column", outputColumnName));
                    ItemNormal.Properties.Add(new MetaDataProperty("prefixFolderName", "False"));
                    ItemNormal.Properties.Add(new MetaDataProperty("customTitle", GroupName + ": " + DisplayNameNormal));
                    ItemNormal.Properties.Add(new MetaDataProperty("defaultValue", "0.0"));

                    if (skipTimestepZero)
                    {
                        ItemNormal.Properties.Add(new MetaDataProperty("skipTimestepZero", "True"));
                    }

                    MainGroup.Items.Insert(0, ItemNormal);

                    //Density Attribute
                    //-----------------

                    string AttrNameDensity    = string.Format(CultureInfo.InvariantCulture, "stsim_AttrDensity-{0}", AttrId);
                    string DisplayNameDensity = Convert.ToString(drv.Row[attrsDataSheet.ValidationTable.DisplayMember], CultureInfo.InvariantCulture);

                    if (Units != null)
                    {
                        DisplayNameDensity = string.Format(CultureInfo.InvariantCulture, "{0} ({1})", DisplayNameDensity, Units);
                    }

                    SyncroSimLayoutItem ItemDensity = new SyncroSimLayoutItem(AttrNameDensity, DisplayNameDensity, false);

                    ItemDensity.Properties.Add(new MetaDataProperty("dataSheet", outputDataSheetName));
                    ItemDensity.Properties.Add(new MetaDataProperty("column", outputColumnName));
                    ItemDensity.Properties.Add(new MetaDataProperty("prefixFolderName", "False"));
                    ItemDensity.Properties.Add(new MetaDataProperty("customTitle", GroupName + " (Density): " + DisplayNameNormal));
                    ItemDensity.Properties.Add(new MetaDataProperty("defaultValue", "0.0"));

                    if (skipTimestepZero)
                    {
                        ItemDensity.Properties.Add(new MetaDataProperty("skipTimestepZero", "True"));
                    }

                    DensityGroup.Items.Insert(0, ItemDensity);
                }
            }
        }
Example #5
0
        private static void AddChartNonGroupedAttributes(
            SyncroSimLayoutItemCollection items,
            DataView attrsView,
            DataSheet attrsDataSheet,
            string outputDataSheetName,
            string outputColumnName,
            bool skipTimestepZero,
            SyncroSimLayoutItem densityGroup)
        {
            foreach (DataRowView drv in attrsView)
            {
                if (drv.Row[Strings.DATASHEET_ATTRIBUTE_GROUP_ID_COLUMN_NAME] == DBNull.Value)
                {
                    int    AttrId = Convert.ToInt32(drv.Row[attrsDataSheet.ValueMember], CultureInfo.InvariantCulture);
                    string Units  = DataTableUtilities.GetDataStr(drv.Row, Strings.DATASHEET_STATE_ATTRIBUTE_TYPE_UNITS_COLUMN_NAME);

                    //Normal Attribute
                    //----------------

                    string AttrNameNormal    = string.Format(CultureInfo.InvariantCulture, "stsim_AttrNormal-{0}", AttrId);
                    string DisplayNameNormal = Convert.ToString(drv.Row[attrsDataSheet.ValidationTable.DisplayMember], CultureInfo.InvariantCulture);

                    if (Units != null)
                    {
                        DisplayNameNormal = string.Format(CultureInfo.InvariantCulture, "{0} ({1})", DisplayNameNormal, Units);
                    }

                    SyncroSimLayoutItem ItemNormal = new SyncroSimLayoutItem(AttrNameNormal, DisplayNameNormal, false);

                    ItemNormal.Properties.Add(new MetaDataProperty("dataSheet", outputDataSheetName));
                    ItemNormal.Properties.Add(new MetaDataProperty("column", outputColumnName));
                    ItemNormal.Properties.Add(new MetaDataProperty("prefixFolderName", "False"));
                    ItemNormal.Properties.Add(new MetaDataProperty("customTitle", DisplayNameNormal));
                    ItemNormal.Properties.Add(new MetaDataProperty("defaultValue", "0.0"));

                    if (skipTimestepZero)
                    {
                        ItemNormal.Properties.Add(new MetaDataProperty("skipTimestepZero", "True"));
                    }

                    items.Add(ItemNormal);

                    //Density Attribute
                    //-----------------

                    string AttrNameDensity    = string.Format(CultureInfo.InvariantCulture, "stsim_AttrDensity-{0}", AttrId);
                    string DisplayNameDensity = Convert.ToString(drv.Row[attrsDataSheet.ValidationTable.DisplayMember], CultureInfo.InvariantCulture);

                    if (Units != null)
                    {
                        DisplayNameDensity = string.Format(CultureInfo.InvariantCulture, "{0} ({1})", DisplayNameDensity, Units);
                    }

                    SyncroSimLayoutItem ItemDensity = new SyncroSimLayoutItem(AttrNameDensity, DisplayNameDensity, false);

                    ItemDensity.Properties.Add(new MetaDataProperty("dataSheet", outputDataSheetName));
                    ItemDensity.Properties.Add(new MetaDataProperty("column", outputColumnName));
                    ItemDensity.Properties.Add(new MetaDataProperty("prefixFolderName", "False"));
                    ItemDensity.Properties.Add(new MetaDataProperty("customTitle", "(Density): " + DisplayNameNormal));
                    ItemDensity.Properties.Add(new MetaDataProperty("defaultValue", "0.0"));

                    if (skipTimestepZero)
                    {
                        ItemDensity.Properties.Add(new MetaDataProperty("skipTimestepZero", "True"));
                    }

                    densityGroup.Items.Add(ItemDensity);
                }
            }
        }