Ejemplo n.º 1
0
        /// <summary>
        /// Refreshes the node.
        /// </summary>
        /// <param name="node">The node.</param>
        private void RefreshNode(TreeViewItem item)
        {
            Folder folder = null;
            item.Dispatcher.Invoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                folder = (Folder)item.Tag;
            }));

            {

                SiteSetting siteSetting = ApplicationContext.Current.Configuration.SiteSettings[folder.SiteSettingID];
                List<Folder> subFolders = ApplicationContext.Current.GetSubFolders(siteSetting, folder, this.IncludedFolderTypes);
                folder.Folders = subFolders;
                item.Dispatcher.Invoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    FoldersTreeView.BeginInit();
                    item.Items.Clear();
                    foreach (Folder subFolder in subFolders)
                    {
                        subFolder.PublicFolder = this.AdministrativeView;
                        subFolder.Selected = false;
                        AddNode(item.Items, subFolder, siteSetting.ID);
                    }
                    FoldersTreeView.EndInit();
                }));
            }
        }
Ejemplo n.º 2
0
 public void Initialize(SiteSettings siteSettings, List <Folder> dataSource, int[] includedFolderTypes)
 {
     this.IncludedFolderTypes = includedFolderTypes;
     this.SiteSettings        = siteSettings;
     this.DataSource          = dataSource;
     FoldersTreeView.AddHandler(TreeViewItem.ExpandedEvent, new RoutedEventHandler(rootNode_Expanded));
 }
        public ICollection <string> ShowDialog(IEnumerable <string> monitoredPaths, IEnumerable <Folder> folders)
        {
            var paths = new HashSet <string>(monitoredPaths);

            void PopulateFolders(IEnumerable <Folder> fds, TreeNodeCollection parentCollection)
            {
                try
                {
                    foreach (var f in fds)
                    {
                        var node = new TreeNode(f.Name)
                        {
                            Checked = paths.Contains(f.FolderPath),
                            Tag     = f.FolderPath,
                        };
                        parentCollection.Add(node);
                        if (f.Folders.Count > 0)
                        {
                            PopulateFolders(f.Folders.OfType <Folder>(), node.Nodes);
                        }
                    }
                }
                catch (COMException ex) when(ex.HResult == unchecked ((int)0xA304010F))
                {
                    // This situation can happen if you have SharePoint accounts
                    // AND currently there is no network available.
                }
            }

            FoldersTreeView.BeginUpdate();
            PopulateFolders(folders, FoldersTreeView.Nodes);
            FoldersTreeView.ExpandAll();
            FoldersTreeView.EndUpdate();

            if (base.ShowDialog() == DialogResult.OK)
            {
                var newPaths = new List <string>();

                void PopulatePaths(IEnumerable <TreeNode> treeNodes)
                {
                    foreach (var n in treeNodes)
                    {
                        if (n.Checked)
                        {
                            newPaths.Add((string)n.Tag);
                        }
                        if (n.Nodes.Count > 0)
                        {
                            PopulatePaths(n.Nodes.Cast <TreeNode>());
                        }
                    }
                }

                PopulatePaths(FoldersTreeView.Nodes.Cast <TreeNode>());
                return(newPaths);
            }

            return(null);
        }
Ejemplo n.º 4
0
 private void UserControl_Loaded(object sender, RoutedEventArgs e)
 {
     FoldersTreeView.AddHandler(TreeViewItem.ExpandedEvent, new RoutedEventHandler(node_Expanded));
 }
Ejemplo n.º 5
0
        public void GetWithoutBackslashFileFolderName_Test()
        {
            string path = "D:";

            FoldersTreeView.GetFileFolderName(path);
        }
Ejemplo n.º 6
0
        public void GetSimpleFileFolderName_Test()
        {
            string path = "D:\\";

            FoldersTreeView.GetFileFolderName(path);
        }
Ejemplo n.º 7
0
        public void GetNullFileFolderName_Test()
        {
            string path = null;

            FoldersTreeView.GetFileFolderName(path);
        }
Ejemplo n.º 8
0
        public void GetFullPath_Test()
        {
            FoldersTreeView foldersTreeView = new FoldersTreeView();

            var path = foldersTreeView.getFullPath();
        }
 public void SetSelectedPath(string path)
 {
     Model.SetSelectedFolder(path);
     FoldersTreeView.Focus();
 }
        public void SetCheckedFolders(List <string> paths)
        {
            Model.SetCheckedFolders(paths);

            FoldersTreeView.Focus();
        }