示例#1
0
        public void SetRecruitmentControls(MarkovMatrixRecruitment currentRecruit, Panel panelRecruitModelParameter)
        {
            //defaults
            int defaultRecruitLvl = 1;
            int defaultSSBLvl     = 1;

            //Assign Recruit/SSB levels to Default if they are (less than or) equal to zero
            if (currentRecruit.numRecruitLevels <= 0)
            {
                currentRecruit.numRecruitLevels = defaultRecruitLvl;
            }
            if (currentRecruit.numSSBLevels <= 0)
            {
                currentRecruit.numSSBLevels = defaultSSBLvl;
            }

            if (!(currentRecruit.markovRecruitment != null))
            {
                currentRecruit.markovRecruitment = new DataSet("markovRecruitmentTables");

                DataTable markovRecruit     = currentRecruit.NewRecruitLevelTable(defaultRecruitLvl);
                DataTable markovSSBLevel    = currentRecruit.NewSSBLevelTable(defaultSSBLvl);
                DataTable markovProbability = currentRecruit.NewProbabilityTable(defaultSSBLvl, defaultRecruitLvl);

                currentRecruit.markovRecruitment.Tables.Add(markovRecruit);
                currentRecruit.markovRecruitment.Tables.Add(markovSSBLevel);
                currentRecruit.markovRecruitment.Tables.Add(markovProbability);
            }
            else
            {
                //Create Data Table if null
                if (!(currentRecruit.markovRecruitment.Tables["Recruitment"] != null))
                {
                    currentRecruit.markovRecruitment.Tables.Add(
                        currentRecruit.NewRecruitLevelTable(currentRecruit.numRecruitLevels));
                }

                if (!(currentRecruit.markovRecruitment.Tables["SSB"] != null))
                {
                    currentRecruit.markovRecruitment.Tables.Add(currentRecruit.NewSSBLevelTable(currentRecruit.numSSBLevels));
                }

                if (!(currentRecruit.markovRecruitment.Tables["Probability"] != null))
                {
                    currentRecruit.markovRecruitment.Tables.Add(
                        currentRecruit.NewProbabilityTable(currentRecruit.numSSBLevels, currentRecruit.numRecruitLevels));
                }
            }
            //Set data bindings
            this.spinBoxNumRecruitLevels.DataBindings.Add("Value", currentRecruit, "numRecruitLevels",
                                                          true, DataSourceUpdateMode.OnPropertyChanged);
            this.spinBoxNumSSBLevels.DataBindings.Add("Value", currentRecruit, "numSSBlevels", true,
                                                      DataSourceUpdateMode.OnPropertyChanged);

            this.recruitLevelTable = currentRecruit.markovRecruitment.Tables["Recruitment"];
            this.SSBLevelTable     = currentRecruit.markovRecruitment.Tables["SSB"];
            this.probabilityTable  = currentRecruit.markovRecruitment.Tables["Probability"];

            panelRecruitModelParameter.Controls.Clear();
            this.Dock = DockStyle.Fill;
            panelRecruitModelParameter.Controls.Add(this);
        }
        //TODO:REFACTOR
        private void LoadRecruitModelParameterControls(RecruitmentModel currentRecruitSelection)
        {
            if (currentRecruitSelection is EmpiricalRecruitment)
            {
                if (((EmpiricalRecruitment)currentRecruitSelection).subType == EmpiricalType.Empirical)
                {
                    EmpiricalRecruitment currentEmpiricalRecruitSelection = (EmpiricalRecruitment)currentRecruitSelection;

                    ControlRecruitmentEmpirical empiricalParameterControls = new ControlRecruitmentEmpirical();

                    empiricalParameterControls.SetEmpiricalRecruitmentControls(currentEmpiricalRecruitSelection, panelRecruitModelParameter);
                    empiricalParameterControls.collectionAgeproRecruitmentModels = this.collectionAgeproRecruitmentModels;
                    empiricalParameterControls.collectionSelectedIndex           = this.comboBoxRecruitSelection.SelectedIndex;
                }
                else if (((EmpiricalRecruitment)currentRecruitSelection).subType == EmpiricalType.TwoStage)
                {
                    TwoStageEmpiricalRecruitment currentTwoStageEmpiricalRecruitSelection =
                        (TwoStageEmpiricalRecruitment)currentRecruitSelection;

                    //Load TwoStage Controls
                    ControlRecruitmentEmpiricalTwoStage twoStageControls = new ControlRecruitmentEmpiricalTwoStage();
                    twoStageControls.SetTwoStageEmpiricalRecruitmentControls(currentTwoStageEmpiricalRecruitSelection,
                                                                             panelRecruitModelParameter);
                    twoStageControls.collectionAgeproRecruitmentModels = this.collectionAgeproRecruitmentModels;
                    twoStageControls.collectionSelectedIndex           = this.comboBoxRecruitSelection.SelectedIndex;
                }
                else if (((EmpiricalRecruitment)currentRecruitSelection).subType == EmpiricalType.CDFZero)
                {
                    EmpiricalCDFZero currentEmpiricalCDFZeroRecruitmentSelection = (EmpiricalCDFZero)currentRecruitSelection;

                    ControlRecruitmentEmpirical empiricalCDFZeroControls = new ControlRecruitmentEmpirical();

                    empiricalCDFZeroControls.SetEmpiricalCDFZeroRecruitmentControls(
                        currentEmpiricalCDFZeroRecruitmentSelection, panelRecruitModelParameter);
                    empiricalCDFZeroControls.collectionAgeproRecruitmentModels = this.collectionAgeproRecruitmentModels;
                    empiricalCDFZeroControls.collectionSelectedIndex           = this.comboBoxRecruitSelection.SelectedIndex;
                }
                else if (((EmpiricalRecruitment)currentRecruitSelection).subType == EmpiricalType.Fixed)
                {
                    FixedEmpiricalRecruitment currentFixedRecruitmentSelection = (FixedEmpiricalRecruitment)currentRecruitSelection;

                    ControlRecruitmentFixed fixedRecruitmentControls = new ControlRecruitmentFixed();
                    fixedRecruitmentControls.seqYears = this.seqRecruitYears;
                    fixedRecruitmentControls.SetFixedRecruitmentControls(currentFixedRecruitmentSelection, panelRecruitModelParameter);
                    fixedRecruitmentControls.collectionAgeproRecruitmentModels = this.collectionAgeproRecruitmentModels;
                    fixedRecruitmentControls.collectionSelectedIndex           = this.comboBoxRecruitSelection.SelectedIndex;
                }
            }
            else if (currentRecruitSelection is ParametricRecruitment)
            {
                if (((ParametricRecruitment)currentRecruitSelection).subtype == ParametricType.Curve)
                {
                    ParametricCurve currentParametricCurveRecruit = (ParametricCurve)currentRecruitSelection;

                    ControlRecruitmentParametricCurve parametricCurveControls = new ControlRecruitmentParametricCurve();

                    parametricCurveControls.collectionAgeproRecruitmentModels = this.collectionAgeproRecruitmentModels;
                    parametricCurveControls.collectionSelectedIndex           = this.comboBoxRecruitSelection.SelectedIndex;
                    parametricCurveControls.SetParametricRecruitmentControls(currentParametricCurveRecruit, panelRecruitModelParameter);
                }
                else if (((ParametricRecruitment)currentRecruitSelection).subtype == ParametricType.Lognormal)
                {
                    ParametricLognormal currentParametricLognormalRecruit = (ParametricLognormal)currentRecruitSelection;

                    ControlRecruitmentParametricLognormal lognormalControls = new ControlRecruitmentParametricLognormal();

                    lognormalControls.SetParametricRecruitmentControls(currentParametricLognormalRecruit, panelRecruitModelParameter);
                    lognormalControls.collectionAgeproRecruitmentModels = this.collectionAgeproRecruitmentModels;
                    lognormalControls.collectionSelectedIndex           = this.comboBoxRecruitSelection.SelectedIndex;
                }
            }
            else if (currentRecruitSelection is PredictorRecruitment)
            {
                PredictorRecruitment currentPredictorRecruitSelection = (PredictorRecruitment)currentRecruitSelection;

                ControlRecruitmentPredictor predictorParameterControls = new ControlRecruitmentPredictor();

                predictorParameterControls.seqYears = this.seqRecruitYears;
                predictorParameterControls.collectionSelectedIndex           = this.comboBoxRecruitSelection.SelectedIndex;
                predictorParameterControls.collectionAgeproRecruitmentModels = this.collectionAgeproRecruitmentModels;
                predictorParameterControls.SetPredictorRecruitmentcontrols(currentPredictorRecruitSelection, panelRecruitModelParameter);
            }
            else if (currentRecruitSelection is MarkovMatrixRecruitment)
            {
                MarkovMatrixRecruitment currentRecruit = (MarkovMatrixRecruitment)currentRecruitSelection;

                ControlRecruitmentMarkovMatrix markovControls = new ControlRecruitmentMarkovMatrix();

                markovControls.SetRecruitmentControls(currentRecruit, panelRecruitModelParameter);
                markovControls.collectionAgeproRecruitModels = this.collectionAgeproRecruitmentModels;
                markovControls.collectionSelectedIndex       = this.comboBoxRecruitSelection.SelectedIndex;
            }
            else
            {
                panelRecruitModelParameter.Controls.Clear();
            }
        }