Exemplo n.º 1
0
 public static void GetCheckedItems(FolderStructureModel node)
 {
     if (node.IsChecked == true && node.folderExists == GV._brush_set_folder_dontexists)
     {
         GV.folderList.Add(node);
     }
     foreach (var item in node.Children)
     {
         if (item.IsChecked == true && item.folderExists == GV._brush_set_folder_dontexists)
         {
             GV.folderList.Add(item);
             //MessageBox.Show(item.folderPath, "1");
             //lView.Items.Add(item.Name + item.folderPath);
         }
         foreach (var item2 in item.Children)
         {
             if (item2.IsChecked == true && item2.folderExists == GV._brush_set_folder_dontexists)
             {
                 //MessageBox.Show(item2.folderPath, "2");
                 GV.folderList.Add(item2);
                 //lView.Items.Add(item2.Name + "|| " + item2.folderPath);
             }
             foreach (var item3 in item2.Children)
             {
                 if (item3.IsChecked == true && item3.folderExists == GV._brush_set_folder_dontexists)
                 {
                     //MessageBox.Show(item3.folderPath, "3");
                     GV.folderList.Add(item3);
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
        public static List <FolderStructureModel> SetTree(string topLevelName, string _folderPath, System.Windows.Media.Brush _folderExists, bool _folderCreationEnabled)
        {
            List <FolderStructureModel> treeView = new List <FolderStructureModel>();
            FolderStructureModel        tv       = new FolderStructureModel(topLevelName, _folderPath, _folderExists, _folderCreationEnabled);

            treeView.Add(tv);

            //add sub fodlers
            if (GV.selectedFodlerEntity.NumberOfChildren > 0)
            {
                foreach (VDF.Vault.Currency.Entities.Folder subFolder in GV.subFolders)
                {
                    string trimPath = subFolder.FolderPath.ToString().Remove(0, 2);
                    string path     = GV.m_connection.WorkingFoldersManager.GetWorkingFolder("$") + trimPath + @"\" + subFolder.EntityName;
                    FolderStructureModel subFolder_Item;
                    string pathsubsubFinal = path.Replace(@"/", @"\");
                    if (Directory.Exists(pathsubsubFinal))
                    {
                        subFolder_Item = new FolderStructureModel(subFolder.EntityName, pathsubsubFinal, GV._brush_set_folder_exists, false);
                    }
                    else
                    {
                        subFolder_Item = new FolderStructureModel(subFolder.EntityName, pathsubsubFinal, GV._brush_set_folder_dontexists, true);
                    }

                    tv.Children.Add(subFolder_Item);

                    if (subFolder.FolderPath.ToString().Length > 3)
                    {
                        if (subFolder.NumberOfChildren > 0)
                        {
                            //get all the sub-sub folders.
                            //now add all sub-subs
                            IEnumerable <VDF.Vault.Currency.Entities.Folder> subFolders = GV.m_connection.FolderManager.GetChildFolders(subFolder, false, false);
                            foreach (VDF.Vault.Currency.Entities.Folder sub_subFolder in subFolders)
                            {
                                string trimPathsubsub   = sub_subFolder.FolderPath.ToString().Remove(0, 2);
                                string pathsubsub       = GV.m_connection.WorkingFoldersManager.GetWorkingFolder("$") + trimPathsubsub + @"\" + sub_subFolder.EntityName;
                                string pathsubsub_final = pathsubsub.Replace(@"/", @"\");
                                if (Directory.Exists(pathsubsub_final))
                                {
                                    subFolder_Item.Children.Add(new FolderStructureModel(sub_subFolder.EntityName.ToString(), pathsubsub_final, GV._brush_set_folder_exists, false));
                                }
                                else
                                {
                                    subFolder_Item.Children.Add(new FolderStructureModel(sub_subFolder.EntityName.ToString(), pathsubsub_final, GV._brush_set_folder_dontexists, true));
                                }
                            }
                        }
                        else
                        {
                        }
                    }
                }
            }
            //Perform recursive method to build treeview

            #region Test Data
            //Doing this below for this example, you should do it dynamically

            /***************************************************
             * FolderStructureModel tvChild4 = new FolderStructureModel("Child4");
             *
             * tv.Children.Add(new FolderStructureModel("Child1"));
             * tv.Children.Add(new FolderStructureModel("Child2"));
             * tv.Children.Add(new FolderStructureModel("Child3"));
             * tv.Children.Add(tvChild4);
             * tv.Children.Add(new FolderStructureModel("Child5"));
             *
             * FolderStructureModel grtGrdChild2 = (new FolderStructureModel("GrandChild4-2"));
             *
             * tvChild4.Children.Add(new FolderStructureModel("GrandChild4-1"));
             * tvChild4.Children.Add(grtGrdChild2);
             * tvChild4.Children.Add(new FolderStructureModel("GrandChild4-3"));
             *
             * grtGrdChild2.Children.Add(new FolderStructureModel("GreatGrandChild4-2-1"));
             */
            #endregion

            tv.Initialize();

            return(treeView);
        }