Exemple #1
0
        private void saveDataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TabPage tab = new TabPage();

            foreach (Control ctrl in tabControl1.SelectedTab.Controls)
            {
                if ((ctrl as TabControl) != null)
                {
                    tab = (ctrl as TabControl).SelectedTab;
                }
            }

            int q = ed_tboxes.GetLength(0);

            double[,] matrix = new double[q, q];
            for (int j = 0; j < q; j++)
            {
                matrix[j, j] = 1;
            }
            int tIndex = 0;

            for (int i = 0; i < q - 1; i++)
            {
                for (int j = i + 1; j < q; j++)
                {
                    double value = ParseValue(ed_tboxes[i, j].Text);

                    /*if (ed_tboxes[i, j].Text.Length == 1)
                     *  value = Convert.ToDouble(ed_tboxes[i, j].Text);
                     * else
                     *  value = 1.0 / Convert.ToDouble(ed_tboxes[i, j].Text[2].ToString());*/
                    matrix[i, j] = value;
                    matrix[j, i] = 1.0 / value;
                    tIndex++;
                }
            }
            for (int i = 0; i < matrixes.Count; i++)
            {
                if (tab.Name == matrixes[i].mainCriteria)
                {
                    matrixes[i] = PairedMatrix.EditPairedMatrix(matrixes[i], matrix);
                }
            }

            for (int i = 0; i < AHP.criteriasComparison.Count; i++)
            {
                for (int j = 0; j < AHP.criteriasComparison[i].Count; j++)
                {
                    if (tab.Name == AHP.criteriasComparison[i][j].mainCriteria)
                    {
                        AHP.criteriasComparison[i][j] = PairedMatrix.EditPairedMatrix(AHP.criteriasComparison[i][j], matrix);
                    }
                }
            }

            if (AHP.results != null)
            {
                AHP.Calculate();
                TabResultsShow();
                t      = null;
                tboxes = null;
            }
            TabHandle.MakeReadOnly(tabControl1.SelectedTab);
            editing = false;
            editDataToolStripMenuItem.Enabled = true;
            saveDataToolStripMenuItem.Enabled = false;
            ed_tboxes = null;
        }
Exemple #2
0
 public static PairedMatrix EditPairedMatrix(PairedMatrix pm, double[,] m)
 {
     return(new PairedMatrix(pm.mainCriteria, pm.comparableCriterias, m));
 }