Esempio n. 1
0
        protected override void buttonSetParameters_Click(object sender, EventArgs e)
        {
            try
            {
                int newNumLv1Obs = Convert.ToInt32(this.spinBoxLv1NumObservations.Value);
                int newNumLv2Obs = Convert.ToInt32(this.spinBoxLv2NumObservations.Value);

                if (newNumLv1Obs > maxNumObservations)
                {
                    throw new Nmfs.Agepro.CoreLib.InvalidAgeproParameterException(
                              "Number of Level 1 Observations exceed maximum limit of " + maxNumObservations + ".");
                }
                if (newNumLv2Obs > maxNumObservations)
                {
                    throw new Nmfs.Agepro.CoreLib.InvalidAgeproParameterException(
                              "Number of Level 2 Observations exceed maximum limit of " + maxNumObservations + ".");
                }

                lv1Observations = ControlRecruitment.ResizeDataGridTable(lv1Observations, newNumLv1Obs);
                lv2Observations = ControlRecruitment.ResizeDataGridTable(lv2Observations, newNumLv2Obs);

                ((Nmfs.Agepro.CoreLib.TwoStageEmpiricalRecruitment)
                 this.collectionAgeproRecruitmentModels[this.collectionSelectedIndex]).lv1NumObs = newNumLv1Obs;
                ((Nmfs.Agepro.CoreLib.TwoStageEmpiricalRecruitment)
                 this.collectionAgeproRecruitmentModels[this.collectionSelectedIndex]).lv2NumObs = newNumLv2Obs;
                ((Nmfs.Agepro.CoreLib.TwoStageEmpiricalRecruitment)
                 this.collectionAgeproRecruitmentModels[this.collectionSelectedIndex]).SSBBreakVal
                    = Convert.ToInt32(this.textBoxSSBBreakValue.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Can not resize number of Observation(s)." + Environment.NewLine + ex.Message,
                                "AGEPRO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Esempio n. 2
0
        private void buttonSetParameters_Click(object sender, EventArgs e)
        {
            try
            {
                int  newNumRecruitLevelsValue = Convert.ToInt32(spinBoxNumRecruitLevels.Value);
                int  newNumSSBLevelsValue     = Convert.ToInt32(spinBoxNumSSBLevels.Value);
                bool renameProbTableCols      = newNumRecruitLevelsValue > probabilityTable.Columns.Count;

                recruitLevelTable = ControlRecruitment.ResizeDataGridTable(recruitLevelTable, newNumRecruitLevelsValue);
                SSBLevelTable     = ControlRecruitment.ResizeDataGridTable(SSBLevelTable, newNumSSBLevelsValue);

                probabilityTable = ControlRecruitment.ResizeDataGridTable(probabilityTable, newNumSSBLevelsValue,
                                                                          newNumRecruitLevelsValue);

                if (renameProbTableCols)
                {
                    int ncol = 1;
                    foreach (DataColumn dcol in probabilityTable.Columns)
                    {
                        dcol.ColumnName = "PR(" + ncol + ")";
                        ncol++;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Can not readjust markov matrix level(s)." + Environment.NewLine + ex.Message,
                                "AGEPRO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Changes the number of rows in the observations table, based on the value the
        /// Number of Observations spin box was set to.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected virtual void buttonSetParameters_Click(object sender, EventArgs e)
        {
            try
            {
                int newNumObservationsValue = Convert.ToInt32(this.spinBoxNumObservations.Value);

                //Catch if the number of Observations exceed maxNumObservations limit
                //(in case control couldn't prevent it)
                if (newNumObservationsValue > maxNumObservations)
                {
                    throw new Nmfs.Agepro.CoreLib.InvalidAgeproParameterException(
                              "Number of Observations exceed maximum limit of " + maxNumObservations + ".");
                }
                observationTable = ControlRecruitment.ResizeDataGridTable(observationTable, newNumObservationsValue);
                numObservations  = newNumObservationsValue;
                ((EmpiricalRecruitment)this.collectionAgeproRecruitmentModels[this.collectionSelectedIndex]).numObs
                    = newNumObservationsValue;
                if (this.empiricalSubtype == EmpiricalType.CDFZero)
                {
                    ((EmpiricalCDFZero)this.collectionAgeproRecruitmentModels[this.collectionSelectedIndex]).SSBHinge =
                        Convert.ToDouble(this.textBoxSSBHinge.Text);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Can not resize number of Observation(s)." + Environment.NewLine + ex.Message,
                                "AGEPRO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
        public void SetFixedRecruitmentControls(EmpiricalRecruitment currentRecruit, Panel panelRecruitModelParameter)
        {
            //create empty obsTable if null
            if (!(currentRecruit.obsTable != null))
            {
                if (!(seqYears != null))
                {
                    currentRecruit.obsTable = currentRecruit.SetNewObsTable(0);
                }
                else
                {
                    currentRecruit.obsTable = currentRecruit.SetNewObsTable(seqYears.Count() - 1);
                }
            }
            else
            {
                //If recruitModel has more rows then resize
                if (currentRecruit.numObs > (this.seqYears.Count() - 1))
                {
                    currentRecruit.obsTable =
                        ControlRecruitment.ResizeDataGridTable(currentRecruit.obsTable, this.seqYears.Count() - 1);
                }
            }

            this.fixedRecruitTable = currentRecruit.obsTable;

            panelRecruitModelParameter.Controls.Clear();
            this.Dock = DockStyle.Fill;
            panelRecruitModelParameter.Controls.Add(this);
        }
Esempio n. 5
0
        /// <summary>
        /// Resizes the PStar Levels Data Grid View Table when the spinBoxNumPStarLevels value has been
        /// changed by the user.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void spinBoxNumPStarLevels_ValueChanged(object sender, EventArgs e)
        {
            if (setControlValues == false)
            {
                NumericUpDown newPStarLevel = sender as NumericUpDown;
                ControlRecruitment.ResizeDataGridTable(
                    (DataTable)this.dataGridPStarLevelValues.DataSource, 1, Convert.ToInt32(newPStarLevel.Value));

                //Rename Columns
                for (int colNum = 0; colNum < this.dataGridPStarLevelValues.Columns.Count; colNum++)
                {
                    this.dataGridPStarLevelValues.Columns[colNum].HeaderText = "Level " + (colNum + 1);

                    //Set blank cells to 0
                    if (string.IsNullOrEmpty(this.dataGridPStarLevelValues.Rows[0].Cells[colNum].Value.ToString()))
                    {
                        this.dataGridPStarLevelValues.Rows[0].Cells[colNum].Value = 0;
                    }
                }
            }
        }//end spinBoxNumPStarLevels_ValueChanged