Esempio n. 1
0
        private void addBtn_Click(object sender, EventArgs e)
        {
            if (_persistence.Load() != null)
            {
                _folderPathList = _persistence.Load();
            }

            //extended folder browse dialog for adding a text box where you can paste the path
            var folderDialog = new FolderBrowseDialogExtended
            {
                Description           = "Select folders",
                ShowEditBox           = true,
                ShowFullPathInEditBox = true
            };

            var result = folderDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                var folderPath  = folderDialog.SelectedPath;
                var watchFolder = new ProjectRequest
                {
                    Path = folderPath
                };
                _watchFolders.Add(watchFolder);
                var folders = Directory.GetDirectories(folderPath);

                if (folders.Length != 0)
                {
                    foreach (var directory in folders)
                    {
                        var directoryInfo = new DirectoryInfo(directory);

                        if (_folderPathList != null)
                        {
                            if (directoryInfo.Name != "AcceptedRequests")
                            {
                                var selectedFolder = new ProjectRequest
                                {
                                    Name  = directoryInfo.Name,
                                    Path  = folderPath,
                                    Files = Directory.GetFiles(directory, "*", SearchOption.AllDirectories)
                                };
                                if (!_folderPathList.Contains(selectedFolder))
                                {
                                    _folderPathList.Add(selectedFolder);
                                }
                            }
                        }
                    }
                }
                else
                {
                    SetWatchFolder(folderPath);
                }
                foldersListView.SetObjects(_watchFolders);
                Save();
            }
        }
        public static FolderBrowseDialogExtended ComputerBrowser()
        {
            FolderBrowseDialogExtended x = new FolderBrowseDialogExtended();

            // avoid MBRO comppiler warning when passing _rootFolderLocation as a ref:
            x.BecomeComputerBrowser();
            return(x);
        }