コード例 #1
0
        public void TrendAnalysis()
        {
            SelectAnalyzedVariable dlg = new SelectAnalyzedVariable(this.data.SeriesVariables);
            dlg.ShowDialog();
            if (dlg.DialogResult == DialogResult.OK)
            {
                TrendAnalysisForm trendForm = new TrendAnalysisForm();
                trendForm.SetVariable(dlg.SelectedVariable);
                trendForm.ShowDialog();
                if (trendForm.DialogResult == DialogResult.OK)
                {

                    if (trendForm.IsStorePredicted)
                    {
                        SeriesVariable var = new SeriesVariable(trendForm.PredictedName, "Predicted Value of trend analysis of variable '"
                            + dlg.SelectedVariable.VariableName + "'");
                        int lag = dlg.SelectedVariable.SeriesValues.Count - trendForm.Predicted.Length;
                        var.InitializeItem(dlg.SelectedVariable.SeriesValues.Count);
                        for (int i = 0; i < lag; i++) var[i] = double.NaN;
                        for (int i = 0; i < trendForm.Predicted.Length; i++) var[i + lag] = trendForm.Predicted[i];
                        try
                        {
                            this.data.SeriesVariables.Add(var);
                        }
                        catch (DuplicateVariableException)
                        {
                            MessageBox.Show("Variable '" + var.VariableName + "' already exist", "Duplicate Variable Name", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        this.seriesDataList.Refresh();
                    }

                    if (trendForm.IsStoreResidual)
                    {
                        SeriesVariable var = new SeriesVariable(trendForm.ResidualName, "Residual Value of trend analysis of variable '"
                            + dlg.SelectedVariable.VariableName + "'");
                        int lag = dlg.SelectedVariable.SeriesValues.Count - trendForm.Residual.Length;
                        var.InitializeItem(dlg.SelectedVariable.SeriesValues.Count);
                        for (int i = 0; i < lag; i++) var[i] = double.NaN;
                        for (int i = 0; i < trendForm.Residual.Length; i++) var[i + lag] = trendForm.Residual[i];
                        try
                        {
                            this.data.SeriesVariables.Add(var);
                        }
                        catch (DuplicateVariableException)
                        {
                            MessageBox.Show("Variable '" + var.VariableName + "' already exist", "Duplicate Variable Name", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        this.seriesDataList.Refresh();
                    }

                    TrendAnalysisResultTabPage trendTabPage = new TrendAnalysisResultTabPage();

                    trendTabPage.Title = "Trend Analysis : '" + dlg.SelectedVariable.VariableName + "'";

                    if (trendForm.IsForecastedDataGridChecked)
                    {
                        trendTabPage.SetData(this.data, dlg.SelectedVariable, trendForm.TrendProperties, trendForm.Predicted,
                            trendForm.Forecast(trendForm.ForecastingStep), trendForm.Residual);
                    }
                    else
                    {
                        trendTabPage.SetData(this.data, dlg.SelectedVariable, trendForm.TrendProperties,
                            trendForm.Predicted, null, trendForm.Residual);
                    }

                    trendTabPage.IsTrendAnalysisModelSummaryVisible = trendForm.IsTrendAnalysisModelSummaryChecked;
                    trendTabPage.IsActualPredictedResidualDataGridVisible = trendForm.IsActualPredictedResidualDataGridChecked;
                    trendTabPage.IsForecastedDataGridVisible = trendForm.IsForecastedDataGridChecked;
                    trendTabPage.IsActualAndPredictedGraphVisible = trendForm.IsActualAndPredictedGraphChecked;
                    trendTabPage.IsActualAndForecastedGraphVisible = trendForm.IsActualAndForecastedGraphChecked;
                    trendTabPage.IsActualVsPredictedGraphVisible = trendForm.IsActualVsPredictedGraphChecked;
                    trendTabPage.IsResidualGraphVisible = trendForm.IsResidualGraphChecked;
                    trendTabPage.IsResidualVsActualGraphVisible = trendForm.IsResidualVsActualGraphChecked;
                    trendTabPage.IsResidualVsPredictedGraphVisible = trendForm.IsResidualVsPredictedGraphChecked;

                    trendTabPage.DrawControl();

                    trendTabPage.IsDrawn = true;
                    this.tabControlResult.AddTab(trendTabPage);
                    this.tabControlResult.SelectedItem = trendTabPage;

                    this.tabControlData.SelectedTab = this.tabPageResult;

                }
            }
        }