Beispiel #1
0
        public pastaspref(string json)
        {
            InitializeComponent();
            initial = true;
            working = false;
            paths   = new List <string>();
            treeView1.CheckBoxes  = true;
            treeView1.AfterCheck += TreeView1_AfterCheck;;

            try
            {
                DisplayTreeView(JToken.Parse(json), @"Pastas :\");
            }
            catch
            {
            }
            try
            {
                treeView1.Nodes[0].Checked = true;
                initial = false;
                if (f1.prefpastas == null)
                {
                    f1.prefpastas = new List <Pastapref>();
                    foreach (string s in paths)
                    {
                        f1.prefpastas.Add(new Pastapref(s, true));
                    }
                }
                else
                {
                    working = true;
                    Console.WriteLine("no add");
                    f1.prefpastas.Print();
                    foreach (string s in paths)
                    {
                        Pastapref.addifNew(f1.prefpastas, s);
                    }

                    Console.WriteLine("AfterAdd");
                    f1.prefpastas.Print();
                    Console.WriteLine("-------");
                    List <TreeNode> nodes = treeView1.GetAllNodes();
                    Console.WriteLine("kkkk");
                    for (int i = 0; i < nodes.Count; i++)
                    {
                        string    a  = nodes[i].FullPath.Replace(@"Pastas :\", "");
                        Pastapref pf = Pastapref.getboolvalue(f1.prefpastas, a);
                        if (pf != null && pf.check != nodes[i].Checked)
                        {
                            nodes[i].Checked = pf.check;
                        }
                    }
                    working = false;
                }
            }
            catch (Exception xp)
            {
                MessageBox.Show("Erro ao gerar pastas, os arquivos ainda não foram carregados \r\n " + xp.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            try
            {/*
              *   List<TreeNode> tr = treeView1.GetAllNodes();
              *    List<TreeNode> checados = new List<TreeNode>();
              *
              *    foreach (TreeNode te in tr)
              *    {
              *        int a = -1;
              *        Console.WriteLine("procurei node2 " + te.Name);
              *
              *        if (!checados.Contains(te))
              *            for (int i = 0; i < te.Nodes.Count; i++)
              *            {
              *                a++;
              *                Console.WriteLine("procurei node " + te.Name);
              *                if (te.Nodes[i].Checked) a++;
              *            }
              *        if (a !=0&& te.Nodes.Count>0) te.Checked = false;
              *        checados.Add(te);
              *    }*/
            }
            catch
            {
            }
        }