Exemplo n.º 1
0
        private void SolutionViewer_AfterSelect(object sender, TreeViewEventArgs e)
        {
            //node.Level==0 soluzione
            //node.level==1 cluster

            TreeNode node = e.Node;
            String   str;

            String[] nodeText = node.Text.Split(' ');
            String[] str2;
            uint     index, index2;
            bool     wrap = false; //false perchè se è vera la prima cond, non fa la seconda e se è vera la prima la seconda è per forza falsa.

            if ((uint.TryParse(nodeText[1], out index)) ||
                (wrap = (nodeText[1] == "Wrapper")))
            {
                str = node.Text + " = ";
                switch (nodeText[0])
                {
                case solutio_str:
                    if (wrap)
                    {
                        str += pm.WrapperSolution.ToString();
                    }
                    else
                    {
                        str += pm.Solutions[index].ToString();
                    }
                    break;

                case cluster_str:
                    str2 = node.Parent.Text.Split(' ');
                    wrap = (str2[1] == "Wrapper");
                    if (wrap)
                    {
                        str += pm.ComputeWrapperClusterCost(index).ToString() +
                               " --- Length = " + pm.WrapperSolutionClusters[index].Count +
                               //"\r\nRefined Solution Gap : " + pm.GapClusters[index2][index] +
                               "\r\nNodes:\r\n";
                        foreach (uint l in pm.WrapperSolutionClusters[index])
                        {
                            str += l.ToString() + " ";
                        }
                    }
                    else if (uint.TryParse(str2[1], out index2))
                    {
                        str += pm.ComputeClusterCost(index2, index).ToString() +
                               " --- Length = " + pm.SolutionsClusters[index2][index].Count +
                               "\r\nRefined Solution Gap : " + pm.GapClusters[index2][index] +
                               "\r\nNodes:\r\n";

                        foreach (uint l in pm.SolutionsClusters[index2][index])
                        {
                            str += l.ToString() + " ";
                        }
                    }
                    else
                    {
                        str += str2[1] + "error on parsing!";
                    }

                    break;

                default: str += "Which node is it?";
                    break;
                }
            }
            else
            {
                str = "Error on parsing text = " + nodeText[1] + " entire nodeText = " + node.Text;
            }

            ClusterTextBox.Text = str;
        }