Ejemplo n.º 1
0
        private void DisplayDrives()
        {
            if (!_machineAvailable)
            {
                return;
            }

            using (new WaitCursor(this, SetCursor))
            {
                List <FileSystemDrive> drives = ConnectionStore.Connections[Machine].ServiceHandler.Service
                                                .GetFileSystemDrives().Select(x => x.FromDTO())
                                                .OrderBy(x => x.Name).ToList();

                List <FileSystemTreeNode> treeNodes = drives.Select(drive =>
                                                                    new FileSystemTreeNode(MakeDriveLabel(drive))
                {
                    ImageKey         = drive.Type.ToString(),
                    SelectedImageKey = drive.Type.ToString(),
                    Entry            = drive
                }).ToList();

                foreach (FileSystemTreeNode treeNode in treeNodes)
                {
                    _entryNodes.Add(treeNode.Entry, treeNode);
                    treeNode.Nodes.Add("dummy");
                }

                _machineNode.ChildEntries = drives.Cast <IFileSystemEntry>().ToList();
                SetTreeViewNodes(_machineNode, treeNodes);
                Task.Run(() => TaskActionWrapper.Do(() => RequestFolders(drives)));
            }
        }
Ejemplo n.º 2
0
        private void TreeView_AfterExpand(object sender, TreeViewEventArgs e)
        {
            FileSystemTreeNode node = (FileSystemTreeNode)e.Node;

            if (node.Entry != null)
            {
                Task.Run(() => TaskActionWrapper.Do(() => RequestFolders(node.ChildEntries)));
            }
        }
Ejemplo n.º 3
0
        private void TreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            listView.Items.Clear();
            EnableControls();

            if (!FolderMode)
            {
                Task.Run(() => TaskActionWrapper.Do(() => DisplayFiles((FileSystemTreeNode)e.Node)));
            }
        }
Ejemplo n.º 4
0
        private bool PerformDependentWork(TreeNode node, Action work = null)
        {
            bool cancel = !NodeHasChildren(node);

            if (cancel)
            {
                _entryQueue.IncreasePriority(((FileSystemTreeNode)node).Entry);
            }

            Task.Run(() => TaskActionWrapper.Do(() =>
            {
                if (cancel)
                {
                    using (new WaitCursor(this, SetCursor))
                        Worker.WaitFor(() => NodeHasChildren(node));
                }

                work?.Invoke();
            }));

            return(cancel);
        }
Ejemplo n.º 5
0
        private void ListView_DoubleClick(object sender, EventArgs e)
        {
            if (listView.SelectedItems.Count != 1)
            {
                return;
            }

            IFileSystemEntry entry = ((FileSystemListViewItem)listView.SelectedItems[0]).Entry;

            if (entry.IsFolder)
            {
                FileSystemTreeNode treeNode = _entryNodes[entry];
                Task.Run(() => TaskActionWrapper.Do(() =>
                {
                    ExpandTreeNode(treeNode.Parent);
                    SelectTreeNode(treeNode);
                }));
            }
            else
            {
                buttonOK.PerformClick();
            }
        }
Ejemplo n.º 6
0
        private void FileSystemBrowserForm_Load(object sender, EventArgs e)
        {
            ProcessManagerServiceConnectionHandler.Instance.ServiceHandlerConnectionChanged += ServiceConnectionHandler_ServiceHandlerConnectionChanged;

            labelDescription.Text = Description;
            _machineNode          = new FileSystemTreeNode(Machine.ToString())
            {
                ImageKey         = IMAGE_LIST_KEY_MACHINE,
                SelectedImageKey = IMAGE_LIST_KEY_MACHINE
            };
            treeView.Nodes.Add(_machineNode);

            PopulateFilter();

            if (FolderMode)
            {
                splitContainer.Panel2Collapsed = true;
                Size = new Size(400, 420);
            }
            else
            {
                Size = new Size(700, 420);
            }

            EnableControls();

            if (!string.IsNullOrEmpty(SelectedPath))
            {
                PreparePathExpansion(SelectedPath);
            }

            Task.Run(() => TaskActionWrapper.Do(() =>
            {
                DisplayDrives();
                ExpandTreeNode(_machineNode);
            }));
        }